Repository navigation
Expand file tree
/
Copy pathchallenge.html
More file actions
409 lines (409 loc) · 35.7 KB
/
Copy pathchallenge.html
File metadata and controls
409 lines (409 loc) · 35.7 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta name="theme-color" content="#07121d">
<title>Mean or Median? Take the Inward Mathematics Challenge</title>
<meta name="description" content="Five readings, one known target. Predict whether the mean or median gets closer, or create and embed a challenge with your own numbers.">
<link rel="canonical" href="https://aruintelligence.github.io/inward-mathematics-simulator/challenge.html">
<meta property="og:type" content="website">
<meta property="og:title" content="Mean or Median? Make Your Prediction">
<meta property="og:description" content="Five readings. One target. Can you call which estimate gets closer before you see the math?">
<meta property="og:url" content="https://aruintelligence.github.io/inward-mathematics-simulator/challenge.html">
<meta property="og:image" content="https://aruintelligence.github.io/inward-mathematics-simulator/challenge-card.png">
<meta property="og:image:width" content="1200">
<meta property="og:image:height" content="630">
<meta name="twitter:card" content="summary_large_image">
<style>
:root { color-scheme:dark; --bg:#07121d; --panel:#102b3b; --text:#eaf6f6; --muted:#b2cad0; --mint:#5af0c6; --gold:#ffcb78; --line:#31596a; --rose:#ff8f9d; }
* { box-sizing:border-box; }
body { margin:0; background:radial-gradient(circle at 50% -10%,#14534e,transparent 45%),var(--bg); color:var(--text); font:17px/1.5 system-ui,-apple-system,Segoe UI,sans-serif; }
.wrap { width:min(1080px,calc(100% - 32px)); margin:auto; }
a { color:var(--mint); }
a:focus-visible,button:focus-visible,input:focus-visible { outline:3px solid var(--gold); outline-offset:3px; }
.skip { position:absolute; top:-70px; left:16px; padding:9px 14px; background:var(--gold); color:var(--bg); border-radius:9px; }
.skip:focus { top:10px; }
header { display:flex; justify-content:space-between; flex-wrap:wrap; gap:10px; padding:26px 0; font-size:.9rem; }
header strong { letter-spacing:.05em; }
header a { color:var(--text); text-decoration:none; }
header a:hover { color:var(--mint); }
.eyebrow { color:var(--mint); font-size:.75rem; letter-spacing:.18em; text-transform:uppercase; font-weight:800; }
h1 { font-size:clamp(2.3rem,5.8vw,4.6rem); line-height:1.08; letter-spacing:-.045em; max-width:900px; margin:10px 0; }
.intro { max-width:780px; color:var(--muted); font-size:1.1rem; }
.challenge { margin:30px 0; padding:clamp(18px,3vw,30px); border:1px solid #4b857b; border-radius:23px; background:radial-gradient(circle at 85% 0%,#1a584c,transparent 34%),linear-gradient(155deg,#132d40,var(--panel)); box-shadow:0 25px 75px #0006; }
.case-head { display:flex; justify-content:space-between; flex-wrap:wrap; align-items:center; gap:12px; }
.target { color:var(--gold); border:1px solid #9c7e4e; border-radius:99px; padding:5px 13px; font-weight:800; }
h2 { font-size:clamp(1.45rem,3vw,2rem); margin:6px 0 8px; }
.values { display:grid; grid-template-columns:repeat(5,minmax(0,1fr)); gap:10px; padding:0; margin:18px 0; list-style:none; }
.values li { min-width:0; border:1px solid var(--line); border-radius:13px; background:#0b1c2c; padding:12px 10px; text-align:center; }
.values span { display:block; color:var(--muted); font-size:.75rem; text-transform:uppercase; letter-spacing:.08em; }
.values strong { display:block; overflow-wrap:anywhere; font:750 clamp(1.1rem,2.4vw,1.65rem) ui-monospace,SFMono-Regular,monospace; }
.values li:last-child { border-color:var(--rose); }
.values li:last-child strong { color:var(--rose); }
.plot { position:relative; height:105px; margin:22px 16px 14px; border-bottom:2px solid #7593a0; }
.plot .point { position:absolute; width:13px; height:13px; border-radius:50%; bottom:22px; transform:translateX(-50%); background:#73cde8; box-shadow:0 0 0 3px #0c2632; }
.plot .point:nth-child(even) { bottom:47px; }
.plot .point.fifth { background:var(--rose); width:17px; height:17px; bottom:34px; }
.axis { display:flex; justify-content:space-between; color:var(--muted); font-size:.77rem; margin:0 16px 20px; }
.question { font-size:1.17rem; font-weight:750; margin:12px 0; }
.choices { display:flex; flex-wrap:wrap; gap:10px; }
button,.button { border:1px solid #5d8685; border-radius:11px; padding:12px 18px; min-height:47px; background:#163e43; color:var(--text); cursor:pointer; font:750 1rem system-ui,-apple-system,Segoe UI,sans-serif; text-decoration:none; }
button:hover:not(:disabled),.button:hover { filter:brightness(1.15); }
.choices button { min-width:130px; }
.choices button[aria-pressed="true"] { color:#05251f; background:var(--mint); border-color:var(--mint); }
.choices button:disabled { cursor:default; opacity:.8; }
.choices button[aria-pressed="true"]:disabled { opacity:1; }
.result { margin-top:20px; border-top:1px solid var(--line); padding-top:18px; }
.result[hidden] { display:none; }
.result h3 { margin:0 0 5px; color:var(--mint); font-size:1.4rem; }
.result p { margin:7px 0; }
.numbers { display:grid; grid-template-columns:repeat(2,minmax(0,1fr)); gap:10px; margin:15px 0; }
.numbers div { padding:13px; border:1px solid var(--line); background:#0b1d2b; border-radius:11px; }
.numbers span { display:block; color:var(--muted); font-size:.83rem; }
.numbers strong { font:750 1.4rem ui-monospace,SFMono-Regular,monospace; }
.numbers div:first-child strong { color:var(--gold); }
.numbers div:last-child strong { color:var(--mint); }
.actions { display:flex; flex-wrap:wrap; align-items:center; gap:10px 15px; margin:22px 0; }
.actions .button { display:inline-flex; align-items:center; color:#05251f; background:var(--mint); border-color:var(--mint); }
.actions .share-invite { color:#05251f; background:var(--mint); border-color:var(--mint); }
.actions a:not(.button) { font-size:.91rem; }
.status { color:var(--mint); min-height:1.4em; }
.share-data-note { margin:-8px 0 20px; color:var(--rose); font-size:.9rem; }
.share-data-note[hidden] { display:none; }
.counterfactual { margin:25px 0; padding:clamp(18px,3vw,28px); border:1px solid var(--line); border-radius:17px; background:#0d2434; }
.counterfactual[hidden] { display:none; }
.counterfactual p { margin:8px 0 15px; }
.counterfactual .sweep-context,.counterfactual .sweep-scope { color:var(--muted); font-size:.9rem; }
.sweep-control { display:flex; justify-content:space-between; gap:12px; font-weight:750; }
#sweep-fifth { color:var(--rose); font:800 1.25rem ui-monospace,SFMono-Regular,monospace; }
#fifth-sweep { display:block; width:100%; margin:13px 0 22px; accent-color:var(--rose); cursor:pointer; }
.sweep-map { position:relative; height:35px; border:1px solid #afc9d0; border-radius:7px; margin:0 3px; }
.sweep-marker { position:absolute; top:-6px; bottom:-6px; width:3px; transform:translateX(-50%); background:white; box-shadow:0 0 0 2px #07121d; pointer-events:none; }
.sweep-axis { display:flex; justify-content:space-between; color:var(--muted); font-size:.78rem; margin:5px 3px 8px; }
.sweep-legend { display:flex; flex-wrap:wrap; gap:8px 18px; font-size:.86rem; }
.sweep-legend span::before { content:""; display:inline-block; width:12px; height:12px; margin-right:6px; border-radius:3px; vertical-align:-1px; background:var(--swatch); }
#sweep-reading { font-weight:750; }
.counterfactual .button { display:inline-flex; align-items:center; margin:4px 0 6px; }
.result-card-kit { margin:25px 0; padding:16px 20px; border:1px solid #4b857b; border-radius:13px; background:#0d2434; }
.result-card-kit[hidden] { display:none; }
.result-card-kit summary { cursor:pointer; color:var(--mint); font-weight:800; }
.result-card-kit summary:focus-visible { outline:3px solid var(--gold); outline-offset:3px; }
.result-card-kit p { color:var(--muted); margin:9px 0; }
.result-card-kit canvas { display:block; width:100%; max-width:800px; height:auto; margin:16px 0; border:1px solid var(--line); border-radius:12px; background:var(--bg); }
.result-card-kit button { margin:0 8px 0 0; }
.embed-kit { margin:25px 0; padding:16px 20px; border:1px solid var(--line); border-radius:13px; background:#0d2434; }
.embed-kit summary { cursor:pointer; color:var(--mint); font-weight:800; }
.embed-kit p { color:var(--muted); margin:9px 0; }
.embed-kit textarea { display:block; width:100%; min-height:92px; resize:vertical; padding:10px; border:1px solid #648a93; border-radius:9px; background:#071522; color:var(--text); font:13px/1.5 ui-monospace,SFMono-Regular,monospace; }
.embed-kit textarea:focus-visible { outline:3px solid var(--gold); outline-offset:3px; }
.embed-kit button { margin-top:10px; }
.builder { margin:25px 0; padding:16px 20px; border:1px solid var(--line); border-radius:13px; background:#0d2434; }
.builder summary { cursor:pointer; color:var(--gold); font-weight:800; }
.builder p { color:var(--muted); }
.builder label { display:block; margin:10px 0; font-weight:700; }
.builder input { display:block; width:100%; max-width:560px; min-height:44px; margin-top:5px; padding:8px 12px; border:1px solid #648a93; border-radius:9px; background:#071522; color:var(--text); font:inherit; }
.builder input:focus-visible { outline:3px solid var(--gold); outline-offset:3px; }
#builder-error { color:var(--rose); font-weight:750; }
#link-warning { color:var(--rose); font-weight:750; }
#atlas-link[hidden] { display:none; }
.embed-note,#full-challenge { display:none; }
.scope { border-left:3px solid var(--gold); background:#122938; padding:10px 16px; border-radius:0 9px 9px 0; color:#d7e8e7; }
footer { border-top:1px solid var(--line); color:var(--muted); padding:20px 0 35px; font-size:.84rem; }
@media(max-width:640px) { .values { grid-template-columns:repeat(2,minmax(0,1fr)); } .values li:last-child { grid-column:1/-1; } .numbers { grid-template-columns:1fr; } .choices button { flex:1; min-width:95px; } }
body.embedded { background:#07121d; font-size:15px; }
.embedded .wrap { width:100%; padding:0 10px; }
.embedded header,.embedded .intro,.embedded footer,.embedded .scope,.embedded .embed-kit,.embedded .builder,.embedded .counterfactual,.embedded .result-card-kit,.embedded .share-data-note,.embedded .eyebrow.intro-label { display:none; }
.embedded h1 { font-size:clamp(1.45rem,5vw,2rem); margin:12px 0 3px; }
.embedded .challenge { margin:10px 0; padding:13px; border-radius:15px; box-shadow:none; }
.embedded .case-head .eyebrow { margin:3px 0; }
.embedded .target { padding:2px 9px; font-size:.84rem; }
.embedded h2 { font-size:1.12rem; margin:4px 0; }
.embedded .values { grid-template-columns:repeat(5,minmax(0,1fr)); gap:4px; margin:9px 0; }
.embedded .values li,.embedded .values li:last-child { grid-column:auto; padding:7px 2px; border-radius:8px; }
.embedded .values span { font-size:.58rem; letter-spacing:0; }
.embedded .values strong { font-size:clamp(.68rem,2.55vw,1rem); }
.embedded .plot { height:69px; margin:10px 9px 6px; }
.embedded .plot .point { bottom:13px; }
.embedded .plot .point:nth-child(even) { bottom:33px; }
.embedded .plot .point.fifth { bottom:22px; }
.embedded .axis { margin:0 9px 9px; }
.embedded .question { font-size:1rem; margin:8px 0; }
.embedded .choices { gap:5px; }
.embedded .choices button { flex:1; min-width:0; min-height:40px; padding:7px 3px; font-size:.84rem; }
.embedded .result { margin-top:12px; padding-top:10px; }
.embedded .result h3 { font-size:1.1rem; }
.embedded .numbers { grid-template-columns:repeat(2,minmax(0,1fr)); margin:8px 0; }
.embedded .numbers div { padding:8px; }
.embedded .numbers strong { font-size:1.02rem; }
.embedded .result .button { padding:8px 11px; min-height:40px; font-size:.86rem; }
.embedded .actions { margin:8px 0; }
.embedded .actions #next,.embedded .actions #copy,.embedded .actions #share-invite,.embedded .actions #share-link { display:none; }
.embedded #full-challenge { display:inline; }
.embedded .embed-note { display:block; color:var(--muted); font-size:.78rem; margin:5px 0 12px; }
@media(prefers-reduced-motion:reduce) { *,*::before,*::after { scroll-behavior:auto!important; } }
</style>
</head>
<body>
<a class="skip" href="#challenge">Skip to challenge</a>
<div class="wrap">
<header><strong>ĀRU INTELLIGENCE / INWARD MATHEMATICS™</strong><a href="index.html">Open the full lab ↗</a></header>
<main id="challenge">
<p class="eyebrow intro-label">One-minute prediction challenge</p>
<h1>Which estimate gets closer?</h1>
<p class="intro" id="intro">Five generated readings aim at a known target of 50. Choose the mean, median, or a tie before the calculation appears. Then inspect the same inputs in the full lab.</p>
<p id="link-warning" role="alert"></p>
<section class="challenge" aria-labelledby="case-title">
<div class="case-head"><p class="eyebrow">The five readings</p><span class="target" id="target-badge">Target 50</span></div>
<h2 id="case-title">Make your call before you reveal.</h2>
<ol class="values" id="values-list" aria-label="Five generated observations">
<li><span>Reading 1</span><strong id="value-1">—</strong></li>
<li><span>Reading 2</span><strong id="value-2">—</strong></li>
<li><span>Reading 3</span><strong id="value-3">—</strong></li>
<li><span>Reading 4</span><strong id="value-4">—</strong></li>
<li><span>Reading 5</span><strong id="value-5">—</strong></li>
</ol>
<div class="plot" id="plot" role="img" aria-label="The five readings on a scale from zero to one hundred, with the target at fifty">
<span class="point" id="dot-1"></span><span class="point" id="dot-2"></span><span class="point" id="dot-3"></span><span class="point" id="dot-4"></span><span class="point fifth" id="dot-5"></span>
</div>
<div class="axis" aria-hidden="true"><span>0</span><span>100</span></div>
<p class="question">Which has the smaller absolute error?</p>
<div class="choices" role="group" aria-label="Choose the closer estimate">
<button id="guess-mean" type="button" aria-pressed="false">Mean</button>
<button id="guess-median" type="button" aria-pressed="false">Median</button>
<button id="guess-equal" type="button" aria-pressed="false">Equal error</button>
</div>
<div class="result" id="result" hidden>
<h3 id="verdict" role="status"></h3>
<p id="answer"></p>
<div class="numbers"><div><span>Mean / absolute error</span><strong id="mean-result">—</strong></div><div><span>Median / absolute error</span><strong id="median-result">—</strong></div></div>
<p id="explanation"></p>
<a class="button" id="lab-link" href="index.html#start">Inspect this exact case in the lab ↗</a> <a id="atlas-link" href="atlas.html">Find it in the 12,928-case atlas ↗</a>
</div>
</section>
<div class="actions"><button id="share-invite" class="share-invite" type="button">Invite someone to predict ↗</button><button id="next" type="button">Try another challenge ↻</button><button id="copy" type="button">Copy this challenge link</button><a id="share-link" href="challenge.html">Open/share this exact challenge</a><a id="full-challenge" href="challenge.html">Explore the full challenge ↗</a><span id="share-status" class="status" role="status"></span></div>
<p id="share-data-note" class="share-data-note" hidden>This invitation link contains all five reader-supplied values and the stated target. Share only invented or public data.</p>
<section class="counterfactual" id="counterfactual" aria-labelledby="sweep-title" hidden>
<p class="eyebrow">After the reveal · change one reading</p>
<h2 id="sweep-title">Where does the answer flip?</h2>
<p>Keep the first four readings and stated target fixed. Move only the fifth reading to compare both absolute errors. The answer above stays on the original case.</p>
<p class="sweep-context" id="sweep-context"></p>
<div class="sweep-control"><label for="fifth-sweep">Explore fifth reading</label><output id="sweep-fifth" for="fifth-sweep"></output></div>
<input id="fifth-sweep" type="range" min="0" max="100" step="1" value="40" aria-describedby="sweep-context sweep-counts">
<div class="sweep-map" id="sweep-map" role="img" aria-label="Winning estimate across fifth readings from zero to one hundred"><span class="sweep-marker" id="sweep-marker" aria-hidden="true"></span></div>
<div class="sweep-axis" aria-hidden="true"><span>0</span><span>Fifth reading</span><span>100</span></div>
<div class="sweep-legend" aria-hidden="true"><span style="--swatch:#ffcb78">Mean closer</span><span style="--swatch:#5af0c6">Median closer</span><span style="--swatch:#73cde8">Equal error</span></div>
<p id="sweep-counts"></p>
<p id="sweep-reading" role="status"></p>
<a class="button" id="sweep-link" href="challenge.html">Open this selection as a new blind challenge ↗</a>
<p class="sweep-scope">These are 101 evenly spaced whole-number positions, not probabilities. This comparison uses the same generated toy readings or reader-supplied values and target as the original case.</p>
</section>
<details class="result-card-kit" id="result-card-kit" hidden><summary>Keep a picture of your result</summary><p>This 1200 × 630 PNG shows your prediction, the five readings, stated target, and both errors. It is created in your browser. If you share it, everyone can see the numbers and answer; use only invented or public data.</p><canvas id="result-card" width="1200" height="630" role="img" aria-label="Result card preview appears after a prediction">Your prediction and result are described above.</canvas><button id="download-card" type="button">Download result PNG</button><span id="card-status" class="status" role="status"></span></details>
<details class="builder" id="builder"><summary>Create a challenge with your own numbers</summary><p>Enter exactly five readings and a known target, all from 0 to 100 with at most four decimal places. Previewing opens a new challenge with the answer hidden. These numbers become part of its URL and may appear in browser history, hosting logs, and links you share. Use invented or public data, never private information.</p><label for="builder-values">Five readings, separated by commas<input id="builder-values" type="text" value="48, 49, 50, 51, 85" spellcheck="false"></label><label for="builder-target">Known target<input id="builder-target" type="text" value="50" inputmode="decimal"></label><button id="build" type="button">Preview my challenge ↗</button><p id="builder-error" role="alert"></p></details>
<details class="embed-kit"><summary>Put this challenge on your own page</summary><p id="embed-description">Copy this iframe into a webpage or course page that accepts HTML. It embeds this exact case, asks for a prediction before revealing the answer, and links back to the full lab. The widget has no account, tracking, or backend. Test the display in your publishing platform before sharing it.</p><label for="embed-code">Embed code</label><textarea id="embed-code" readonly rows="3"></textarea><button id="copy-embed" type="button">Copy embed code</button><span id="embed-status" class="status" role="status"></span></details>
<p class="embed-note"><span id="embed-note-lead">Generated toy readings; target 50. One case does not establish a universal rule. </span><a href="index.html">Inspect the method in the lab.</a></p>
<p class="scope" id="scope">This is a deterministic toy example. The four generated values use the lab's seed rule; the fifth value is a chosen input. A closer estimate here is not a generally superior estimator, and the numbers do not measure memory, consciousness, safety, or a physical law. Displayed observations are rounded to four decimal places; calculations use their full generated precision.</p>
</main>
<footer>Developed by Daniel Jacob Read IV / ĀRU Intelligence Inc. with Shane Travis Horman. <a href="guide.html">Five-minute lesson</a> · <a href="https://github.com/aruintelligence/inward-mathematics-simulator">Source and methods</a> · MIT license.</footer>
</div>
<script>
"use strict";
const $=id=>document.getElementById(id);
const bank=[[42,40],[42,85],[58,35],[23,80],[2026,40],[7,30],[17,55],[91,70],[1,45],[123,25],[512,55],[42,75]];
function parseCustom(rawValues,rawTarget) {
if(String(rawValues??"").length>80 || String(rawTarget??"").length>16) return null;
const number=raw=>{
const text=String(raw??"").trim();
return /^\d{1,3}(?:\.\d{1,4})?$/.test(text)&&Number(text)<=100?Number(text):null;
};
const parts=String(rawValues??"").split(",");
if(parts.length!==5) return null;
const values=parts.map(number),target=number(rawTarget);
return values.every(value=>value!==null)&&target!==null?{values,target}:null;
}
function params() {
const query=new URLSearchParams(window.location.search);
const seedText=query.get("seed"),fifthText=query.get("fifth");
const valid=(raw,max)=>raw!==null && /^\d+$/.test(raw) && Number.isInteger(Number(raw)) && Number(raw)<=max;
const generated={mode:"generated",seed:valid(seedText,4294967295)?Number(seedText):42,fifth:valid(fifthText,100)?Number(fifthText):40};
if(!query.has("values")) return generated;
const custom=parseCustom(query.get("values"),query.get("target"));
return custom?{mode:"custom",...custom}:{...generated,invalidCustom:true};
}
function statsFor(values,target) {
const mean=values.reduce((sum,value)=>sum+value,0)/5;
const median=[...values].sort((a,b)=>a-b)[2];
const meanError=Math.abs(mean-target),medianError=Math.abs(median-target);
const winner=Math.abs(meanError-medianError)<1e-9?"Equal":meanError<medianError?"Mean":"Median";
return {values,target,mean,median,meanError,medianError,winner};
}
function statsAt(seed,fifth) {
let state=(seed^0x85ebca6b)>>>0;
const values=Array.from({length:4},()=>{
state=(Math.imul(1664525,state)+1013904223)>>>0;
return 42+16*state/4294967296;
});
values.push(fifth);
return {seed,fifth,...statsFor(values,50)};
}
const selected=params(),stats=selected.mode==="custom"?statsFor(selected.values,selected.target):statsAt(selected.seed,selected.fifth);
if(new URLSearchParams(window.location.search).get("embed")==="1") document.body.classList.add("embedded");
const caseQuery=()=>selected.mode==="custom"?"values="+encodeURIComponent(stats.values.join(","))+"&target="+stats.target:"seed="+selected.seed+"&fifth="+selected.fifth;
const challengeUrl=()=>window.location.href.split(/[?#]/)[0]+"?"+caseQuery();
const labUrl=()=>selected.mode==="custom"?"index.html?dataset="+encodeURIComponent(stats.values.join(","))+"&target="+stats.target+"#workbench-title":"index.html?seed="+selected.seed+"&fifth="+selected.fifth+"#start";
const embedCode=()=>'<iframe title="Mean or median prediction challenge" src="'+challengeUrl()+'&embed=1" loading="lazy" width="100%" height="800" style="max-width:680px;border:0;border-radius:16px"></iframe>';
if(selected.invalidCustom) $("link-warning").textContent="That custom link has invalid readings or target. Showing a generated example instead.";
if(selected.mode==="custom") {
$("intro").textContent="Five reader-supplied values and a reader-supplied target. Choose the mean, median, or a tie before the calculation appears. The target is supplied, not independently verified.";
$("values-list").setAttribute("aria-label","Five reader-supplied values");
$("lab-link").textContent="Inspect these values in the workbench ↗";
$("atlas-link").hidden=true;
$("scope").textContent="This challenge uses values supplied through a share link. The target is a reference supplied by its author, not verified by this page. A closer estimate in one case does not prove a universal rule. Values in the URL may appear in history, hosting logs, and shared links; do not use private data.";
$("embed-note-lead").textContent="Reader-supplied values and target "+stats.target+". One case does not establish a universal rule. ";
$("embed-description").textContent+=" Reader-supplied values are in the embed URL; use invented or public data only.";
$("builder-values").value=stats.values.join(", ");
$("builder-target").value=String(stats.target);
$("share-data-note").hidden=false;
}
$("target-badge").textContent="Target "+stats.target;
$("plot").setAttribute("aria-label","Five readings on a scale from zero to one hundred, with the stated target at "+stats.target);
$("plot").style.background="linear-gradient(to right,transparent calc("+stats.target+"% - 1px),#ffffff80 "+stats.target+"%,transparent calc("+stats.target+"% + 1px))";
for(let i=0;i<5;i++) {
$("value-"+(i+1)).textContent=selected.mode==="custom"?String(stats.values[i]):i===4?String(stats.values[i]):stats.values[i].toFixed(4);
$("dot-"+(i+1)).style.left=stats.values[i]+"%";
}
$("share-link").href=challengeUrl();
$("full-challenge").href=challengeUrl();
$("lab-link").href=labUrl();
$("atlas-link").href="atlas.html?start="+selected.seed+"&offset=0&fifth="+selected.fifth;
$("embed-code").value=embedCode();
const sweep=Array.from({length:101},(_,fifth)=>statsFor([...stats.values.slice(0,4),fifth],stats.target));
const counts={Mean:0,Median:0,Equal:0};
for(const point of sweep) counts[point.winner]++;
const colors={Mean:"#ffcb78",Median:"#5af0c6",Equal:"#73cde8"};
const stops=[];
for(let start=0;start<sweep.length;) {
let end=start+1;
while(end<sweep.length && sweep[end].winner===sweep[start].winner) end++;
const color=colors[sweep[start].winner];
stops.push(color+" "+(start/101*100).toFixed(4)+"%",color+" "+(end/101*100).toFixed(4)+"%");
start=end;
}
$("sweep-map").style.background="linear-gradient(to right,"+stops.join(",")+")";
$("sweep-map").setAttribute("aria-label","Across fifth readings 0 through 100 in whole-number steps, mean closer at "+counts.Mean+", median closer at "+counts.Median+", equal error at "+counts.Equal+" positions. The white marker shows the selected fifth reading.");
$("sweep-counts").textContent="Across 101 positions: mean closer at "+counts.Mean+", median closer at "+counts.Median+", equal error at "+counts.Equal+".";
const initialFifth=Math.round(stats.values[4]);
$("sweep-context").textContent="Original fifth reading: "+stats.values[4]+". The explorer starts at "+initialFifth+" and uses whole-number steps.";
function updateSweep(fifth) {
const point=sweep[fifth];
$("sweep-fifth").textContent=String(fifth);
$("sweep-marker").style.left=fifth+"%";
$("sweep-reading").textContent="At fifth reading "+fifth+": mean "+point.mean.toFixed(2)+" (error "+point.meanError.toFixed(2)+"); median "+point.median.toFixed(2)+" (error "+point.medianError.toFixed(2)+"). "+(point.winner==="Equal"?"Equal error.":point.winner+" is closer.");
$("sweep-link").href=selected.mode==="custom"?"challenge.html?values="+encodeURIComponent(point.values.join(","))+"&target="+stats.target:"challenge.html?seed="+selected.seed+"&fifth="+fifth;
}
$("fifth-sweep").value=String(initialFifth);
updateSweep(initialFifth);
$("fifth-sweep").addEventListener("input",()=>updateSweep(Number($("fifth-sweep").value)));
let cardReady=false;
function drawResultCard(pick) {
const canvas=$("result-card"),ctx=canvas.getContext("2d");
if(!ctx) { $("card-status").textContent="PNG preview is unavailable in this browser.";return; }
const color={Mean:"#ffcb78",Median:"#5af0c6",Equal:"#73cde8"}[stats.winner];
const label=pick==="equal"?"Equal error":pick[0].toUpperCase()+pick.slice(1);
const correct=label.toLowerCase()===stats.winner.toLowerCase() || pick==="equal"&&stats.winner==="Equal";
ctx.fillStyle="#07121d";ctx.fillRect(0,0,1200,630);
ctx.fillStyle="#102b3b";ctx.fillRect(18,18,1164,594);
ctx.fillStyle=color;ctx.fillRect(18,18,1164,9);
ctx.textAlign="left";
ctx.fillStyle="#5af0c6";ctx.font="800 22px system-ui, sans-serif";ctx.fillText("INWARD MATHEMATICS / PREDICTION CHALLENGE",64,80);
ctx.fillStyle="#eaf6f6";ctx.font="800 52px system-ui, sans-serif";ctx.fillText("I picked "+label+".",64,153);
ctx.fillStyle=color;ctx.font="800 27px system-ui, sans-serif";ctx.fillText(correct?"I called it.":"Closer: "+(stats.winner==="Equal"?"equal error":stats.winner),66,195);
ctx.textAlign="right";ctx.fillStyle="#ffcb78";ctx.font="800 27px system-ui, sans-serif";ctx.fillText("STATED TARGET "+stats.target,1136,149);
ctx.textAlign="left";ctx.fillStyle="#b2cad0";ctx.font="700 19px system-ui, sans-serif";ctx.fillText("FIVE READINGS",64,246);
for(let i=0;i<5;i++) {
const x=64+i*224;
ctx.fillStyle="#0b1c2c";ctx.fillRect(x,265,208,94);
ctx.fillStyle=i===4?"#ff8f9d":"#b2cad0";ctx.font="700 17px system-ui, sans-serif";ctx.fillText("READING "+(i+1),x+16,293);
ctx.fillStyle=i===4?"#ff8f9d":"#eaf6f6";ctx.font="750 29px ui-monospace, monospace";
ctx.fillText(selected.mode==="custom"?String(stats.values[i]):i===4?String(stats.values[i]):stats.values[i].toFixed(4),x+16,337);
}
for(const [i,kind,value,error] of [[0,"Mean",stats.mean,stats.meanError],[1,"Median",stats.median,stats.medianError]]) {
const x=64+i*560,winning=stats.winner===kind||stats.winner==="Equal";
ctx.fillStyle="#0b1c2c";ctx.fillRect(x,386,544,130);
ctx.strokeStyle=winning?color:"#31596a";ctx.lineWidth=winning?3:1;ctx.strokeRect(x+1.5,387.5,541,127);
ctx.fillStyle=winning?color:"#b2cad0";ctx.font="800 23px system-ui, sans-serif";ctx.fillText(kind.toUpperCase()+(winning?(stats.winner==="Equal"?" · TIED":" · CLOSER"):""),x+22,425);
ctx.fillStyle="#eaf6f6";ctx.font="800 39px ui-monospace, monospace";ctx.fillText(value.toFixed(2),x+22,483);
ctx.fillStyle="#b2cad0";ctx.font="700 22px system-ui, sans-serif";ctx.fillText("ABS. ERROR "+error.toFixed(2),x+264,482);
}
ctx.fillStyle="#b2cad0";ctx.font="650 19px system-ui, sans-serif";
ctx.fillText(selected.mode==="custom"?"READER-SUPPLIED VALUES + TARGET · NOT INDEPENDENTLY VERIFIED":"DETERMINISTIC TOY READINGS · SEED "+selected.seed+" · FIFTH "+selected.fifth,64,555);
ctx.font="500 17px system-ui, sans-serif";ctx.fillText("One case is not a rule. Errors use full precision; labels are rounded.",64,584);
ctx.textAlign="right";ctx.fillStyle="#5af0c6";ctx.font="700 17px system-ui, sans-serif";ctx.fillText("aruintelligence.github.io/inward-mathematics-simulator",1136,583);
canvas.setAttribute("aria-label","Result card: you picked "+label+"; "+(stats.winner==="Equal"?"the errors tie":stats.winner+" has the smaller absolute error")+". Five readings "+stats.values.join(", ")+"; stated target "+stats.target+"; mean "+stats.mean.toFixed(2)+" with error "+stats.meanError.toFixed(2)+"; median "+stats.median.toFixed(2)+" with error "+stats.medianError.toFixed(2)+". "+(selected.mode==="custom"?"Reader-supplied values and target, not independently verified.":"Deterministic toy readings."));
cardReady=true;
}
function reveal(pick) {
for(const answer of ["mean","median","equal"]) {
const button=$("guess-"+answer);
button.disabled=true;
button.setAttribute("aria-pressed",String(answer===pick));
}
$("result").hidden=false;
$("counterfactual").hidden=false;
$("result-card-kit").hidden=false;
const correct=pick.toLowerCase()===stats.winner.toLowerCase();
$("verdict").textContent=correct?"You called it.":"Surprise: "+(stats.winner==="Equal"?"the errors tie.":"the "+stats.winner.toLowerCase()+" gets closer.");
$("answer").textContent=(selected.mode==="custom"?"For the five supplied values":"For seed "+selected.seed+" and fifth reading "+selected.fifth)+", "+(stats.winner==="Equal"?"the two errors are equal.":"the "+stats.winner.toLowerCase()+" has the smaller error against "+stats.target+".");
$("mean-result").textContent=stats.mean.toFixed(2)+" / "+stats.meanError.toFixed(2);
$("median-result").textContent=stats.median.toFixed(2)+" / "+stats.medianError.toFixed(2);
$("explanation").textContent="Mean = sum of all five ÷ 5. Median = the middle sorted reading. Absolute error = distance from the stated target "+stats.target+"."+(selected.mode==="custom"?" The target was supplied by the author of this link.":" The fifth reading changes both estimates by different amounts.");
drawResultCard(pick);
}
for(const answer of ["mean","median","equal"]) $("guess-"+answer).addEventListener("click",()=>reveal(answer));
$("download-card").addEventListener("click",()=>{
if(!cardReady) return;
$("result-card").toBlob(blob=>{
if(!blob) { $("card-status").textContent="Could not create a PNG. Try again in another browser.";return; }
const url=URL.createObjectURL(blob),link=document.createElement("a");
link.href=url;link.download=selected.mode==="custom"?"inward-math-result-custom.png":"inward-math-result-seed-"+selected.seed+"-fifth-"+selected.fifth+".png";
document.body.append(link);link.click();link.remove();
setTimeout(()=>URL.revokeObjectURL(url),60000);
$("card-status").textContent="Result PNG downloaded.";
},"image/png");
});
$("build").addEventListener("click",()=>{
const custom=parseCustom($("builder-values").value,$("builder-target").value);
if(!custom) {$("builder-error").textContent="Enter exactly five comma-separated numbers and one target, each from 0 to 100 with up to four decimal places.";return;}
window.location.href=window.location.href.split(/[?#]/)[0]+"?values="+encodeURIComponent(custom.values.join(","))+"&target="+custom.target;
});
$("next").addEventListener("click",()=>{
const other=bank.filter(([seed,fifth])=>seed!==selected.seed||fifth!==selected.fifth);
const [seed,fifth]=other[Math.floor(Math.random()*other.length)];
window.location.href=window.location.href.split(/[?#]/)[0]+"?seed="+seed+"&fifth="+fifth;
});
$("copy").addEventListener("click",async()=>{
try { await navigator.clipboard.writeText(challengeUrl());$("share-status").textContent="Exact challenge link copied."; }
catch { $("share-status").textContent="Use the visible challenge link to copy or open it."; }
});
$("share-invite").addEventListener("click",async()=>{
const message="Five readings, one stated target. Which gets closer: mean, median, or equal error? Make your call before the answer appears.";
if(typeof navigator.share==="function") {
try {
await navigator.share({title:"Mean or median? Make your prediction",text:message,url:challengeUrl()});
$("share-status").textContent="Invitation shared.";
return;
} catch(error) {
if(error?.name==="AbortError") { $("share-status").textContent="Sharing canceled.";return; }
}
}
try { await navigator.clipboard.writeText(message+"\n"+challengeUrl());$("share-status").textContent="Invitation copied. Paste it into a message."; }
catch { $("share-status").textContent="Use the visible challenge link to copy or open it."; }
});
$("copy-embed").addEventListener("click",async()=>{
try { await navigator.clipboard.writeText(embedCode());$("embed-status").textContent="Embed code copied."; }
catch { $("embed-status").textContent="Select the visible embed code to copy it."; }
});
window.InwardMathChallenge=Object.freeze({statsAt,statsFor,parseCustom,challengeUrl,embedCode});
</script>
</body>
</html>