Skip to content

Instantly share code, notes, and snippets.

@iconjack

iconjack/p22.hs Secret

Last active Oct 10, 2020
Embed
What would you like to do?
import Data.Bits
flaws :: [[Int]] -> [(Char,Char)]
flaws encoding = [(a,b) | (a, (primary:_)) <- tagged, (b, secondaries) <- tagged,
not (any (primary <%) secondaries)]
where
tagged = zip ['A'..'Z'] encoding -- tag each row with alphabetic label
(<%) u v = (u .&. v) == u -- code u is overpunchable by code v
main = putStrLn ("flaws = " ++ (show (flaws kens_encoding)))
where
kens_encoding = [
[0x44, 0x0D, 0x0E, 0x31, 0x32, 0x34, 0x43, 0x78], -- A
[0x50, 0x07, 0x0B, 0x13, 0x1C, 0x2C, 0x4C, 0x63], -- B
[0x24, 0x16, 0x19, 0x23, 0x38, 0x45, 0x4A, 0x70], -- C
[0x42, 0x15, 0x1A, 0x26, 0x54, 0x69], -- D
[0x60, 0x25, 0x2A, 0x56, 0x59], -- E
[0x41, 0x3D, 0x4E, 0x72], -- F
[0x48, 0x3B, 0x47, 0x74], -- G
[0x00, 0x7F], -- H
[0x06, 0x35, 0x3A, 0x49, 0x52, 0x64], -- I
[0x05, 0x1E, 0x29, 0x51, 0x62, 0x6C], -- J
[0x12, 0x1D, 0x2E, 0x46, 0x58, 0x61], -- K
[0x0A, 0x39, 0x4D, 0x76], -- L
[0x28, 0x1B, 0x5C, 0x67], -- M
[0x22, 0x2D, 0x5E, 0x71], -- N
[0x09, 0x27, 0x55, 0x5A, 0x68], -- O
[0x01, 0x0F, 0x73, 0x7C], -- P
[0x21, 0x36, 0x5D, 0x6A], -- Q
[0x02, 0x3C, 0x57, 0x6B], -- R
[0x04, 0x3E, 0x4B, 0x75], -- S
[0x11, 0x6D, 0x7E], -- T
[0x14, 0x5B, 0x6F], -- U
[0x08, 0x17, 0x6E, 0x79], -- V
[0x10, 0x1F, 0x65, 0x7A], -- W
[0x18, 0x2B, 0x5F, 0x66], -- X
[0x20, 0x33, 0x4F, 0x7D], -- Y
[0x40, 0x77, 0x7B]] -- Z
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.