Jump to content

Twelve statements: Difference between revisions

m
(→‎{{header|Haskell}}: bug fix, change to 1/0 for easier reading, add indices of incorrect answers)
Line 24:
Shows answers with 1 for true, followed by list of indices of incorrect elements each set of 1/0s (index is 0-based).
 
<lang haskell>tfimport [x]Data.List = [[1], [0]](findIndices)
 
tf (x:xs) = map (1:) s ++ map (0:) s where s = tf xs
tf = mapM (\_ -> [1,0])
wrongness b = mapfindIndices fstid . filterzipWith snd(/=) b . map (fromEnum . ($ b))
zip [0..] . zipWith (/=) b . map (\f ->fromEnum $ f b)
statements = [ (==12) . length,
Line 43:
4 ⊂ [0..10]
] where
(s ) s x) = \b ->= s == (sum . map (b!!) . takeWhile (< length b)) x
(a ) a x) = \b ->= (b!!a == 0) || all ((==1).(b!!)) x
testall s n = [(b, w) | b <- tf s, w <- [wrongness b s], length w == n]
Anonymous user
Cookies help us deliver our services. By using our services, you agree to our use of cookies.