From 6b4580607efa698abdc07718f00c6cbdb425c210 Mon Sep 17 00:00:00 2001 From: eunhhu Date: Mon, 5 Oct 2026 13:24:59 +0100 Subject: Research 124's suite: seven kinds of work in one event each (roots, knapsack, sort, join, words, matmul, BFS), each against the C one would write, in one process with the same inputs and answers; PURE_AHEAD=0 to measure the code without reading ahead --- research/experiments/040-against-c/words.aup | 33 ++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 research/experiments/040-against-c/words.aup (limited to 'research/experiments/040-against-c/words.aup') diff --git a/research/experiments/040-against-c/words.aup b/research/experiments/040-against-c/words.aup new file mode 100644 index 0000000..af24130 --- /dev/null +++ b/research/experiments/040-against-c/words.aup @@ -0,0 +1,33 @@ +# Text (research 124's suite): n words "w0" .. "w{vocabulary - 1}", each +# drawn by MINSTD from seed 1, counted in a list kept by the word: how many +# distinct, and the most any one is seen. A let holds no text (aup), so the +# word is written where it is used. +record Count { + word: text + n = 0 +} +state distinct = 0 +state most = 0 +input go = message { + n: u32 + vocabulary: u32 +} +on go { + let counts: list of Count by word + let x = 1 + for i in 0 .. go.n { + x = x * 48271 - floor(x * 48271 / 2147483647) * 2147483647 + let n = x - floor(x / go.vocabulary) * go.vocabulary + if counts.has("w{n}") { + counts["w{n}"].n = counts["w{n}"].n + 1 + } else { + counts.add(Count { word: "w{n}", n: 1 }) + } + } + distinct = counts.count + let m = 0 + for c in counts { + m = max(m, c.n) + } + most = m +} -- cgit v1.2.3