// SPDX-License-Identifier: Apache-2.0 ; specs/widgets/tc-thirds.t27 -- lesson 23 of the course "The ternary machine" (specs/course/ternary-computing.t27) ; Source of truth for public/widgets/tc-thirds/ (gHashTag/trinity): scripts/widget-pages-from-spec.mjs compiles this ; file, checks its constants, evaluates the tests below and writes the page; the page hands every constant to ; tool.js as window.T27_WIDGET. tool.js draws through ../ternary-kit.js and computes nothing: every number comes ; from public/widgets/tc-thirds/logic.js, the fn bodies of the gHashTag/t27 spec in logic.t27, compiled to wasm. ; ASCII only (L3), English only (LANG-EN). ; phi^2 + 1/phi^2 = 3 | TRINITY module widget_tc_thirds; pub const KIND : str = "widget-tool"; pub const ID : str = "tc-thirds"; pub const TITLE : str = "Twenty questions in thirds"; pub const DESCRIPTION : str = "Hide a number. Each question asks which third it lies in; the answers are its trits, top first. 243 numbers take 5 questions instead of 8."; pub const IMAGE_ALT : str = "Thirds card: the secret 23 among the 243 numbers from -121 to 121. Each answer, left, middle or right third, keeps a third of the line lit; five answers spell 23 in balanced ternary."; pub const HOOK : str = "Ask which third, not which half: the answers spell the number in balanced ternary."; pub const CATEGORY : str = "compiler"; pub const DATA_SOURCES : [1]str = ["gHashTag/t27 specs/ternary/trits.t27 (t27#8979): every value on the page is its fn bodies, compiled to wasm (logic.js), with 18 tests and 4108 runtime asserts"]; pub const READS_LOCAL_FILES : bool = false; pub const SENDS_NOTHING : bool = true; pub const K_CARD_WIDTH : u16 = 1200; pub const K_CARD_HEIGHT : u16 = 630; pub const SAY_LOADING : str = "Loading"; pub const K_TRITS : u32 = 5; pub const K_START : i32 = 23; pub const K_VALUES : u32 = 243; pub const SAY_SECRET : str = "The hidden number"; pub const SAY_ASK : str = "Ask the next question"; pub const SAY_THIRDS : [3]str = ["low third", "middle", "high third"]; pub const SAY_LINE : str = "Every value; the lit ones are still possible"; pub const SAY_LEFT : str = "{0} numbers still possible after {1} answers"; pub const SAY_FOUND : str = "found {0} in {1} questions"; pub const SAY_VS : str = "{0} numbers: {1} questions with three answers, {2} with two."; pub const SAY_SOURCE : str = "Logic: t27 spec ternary/trits.t27, compiled"; test the_card_is_the_share_size { assert K_CARD_WIDTH == 1200; assert K_CARD_HEIGHT == 630; assert K_CARD_WIDTH * 21 == K_CARD_HEIGHT * 40; } test the_widget_starts_where_its_card_says { assert K_VALUES == 243; }