#! /usr/bin/python
statementList = [\
"I'm very much afraid I didn't mean anything but nonsense!",
"Just the place for a Snark!",
"Just the place for a Snark!",
"6 * 7 = 42",
"I'm very much afraid I didn't mean anything but nonsense!",
"6 * 7 = 39",
"6 * 7 = 39",
"Just the place for a Snark!",
"6 * 7 = 42",
"I'm very much afraid I didn't mean anything but nonsense!",
"6 * 7 = 39",
]
for s in (s for s in frozenset(statementList) if statementList.count(s) >= 3):
print('"' + s + '" must be true.')
(The code in the image is older than the code above the image, but looks nicer.
The background image is based on Green on Green by MJ Maccardini, 2012-26-02.)
#! /usr/bin/lua
statementlist = {
"I'm very much afraid I didn't mean anything but nonsense!",
"Just the place for a Snark!",
"Just the place for a Snark!",
"6 * 7 = 42",
"I'm very much afraid I didn't mean anything but nonsense!",
"6 * 7 = 39",
"6 * 7 = 39",
"Just the place for a Snark!",
"6 * 7 = 42",
"I'm very much afraid I didn't mean anything but nonsense!",
"6 * 7 = 39",
}
statementcount = {}
for _,statement in ipairs(statementlist) do
local count = (statementcount[statement] or 0) + 1
statementcount[statement] = count
if count == 3 then print('"'..statement..'" is true!') end
end
#! /usr/bin/haskell
import Data.List
someAssertions :: [String]
someAssertions =
[“Just the place for a Snark!”
,”1+1=2.”
,”Just the place for a Snark!”
,”Just the place for a Snark!”
,”1+1=2.”
]
atLeastThrice :: [String] -> [String]
atLeastThrice assertions =
[head grp | grp <-
group $ sort assertions, length grp >= 3]
Result (if loaded and executed in GHCi):
*Main> atLeastThrice someAssertions
[“Just the place for a Snark!”]
2018-08-10, update: 2024-06-28