import Data.Packed import Data.Maybe data Car = Car { airparts :: Int, chambers :: [Chamber] } data Chamber = MainChamber { upperPipe, lowerPipe :: Pipe } | AuxChamber { upperPipe, lowerPipe :: Pipe } data Pipe = Pipe { sections :: [Section] } data Section = Section { tank :: Int } data Fuel = Matrix Int -- Cars -- 2211 220 0 0 1 0 2210 0 1 0 0 2200 1 1 0 2210 0 1 0 1 1 2210 0 1 0 1 1 1 0 2211 0 1 0 1 0 1 1 2210 1 0 1 0 0 1 0 220 0 1 0 -- 22 111001101111010 22 010010111 22 011010 22 1001011 -- 2211 1 0 0 220 1 0 1 1 220 0 1 0 1 0 220 1 0 0 220 0 1 1 1 0 220 1 1 0 220 1 21110 220 1 20 -- 2210 220 0 0 0 220 1 0 1 1 220 1 0 1 0 0 220 0 1 1 220 1 1 1 1 0 220 0 1 0 -- 220 220 0 0 0 1 1 0 220 1 0 1 0 0 1 0 -- [ ([0,0],0,[1]), ([1,1],0,[0]) ] -- 1 220 0 0 0 1 0 : 1 chamber, 1 tank -- [([0,0],0,[0])] -- 1 220 0 0 0 1 1 0: In the car, tank 1 is not properly connected to tank 0 -- [([0,0],0,[1])] -- 1 220 0 0 0 1 1 1: In the car, tank 2 is not properly connected to tank 0 -- 1 220 0 0 0 1 1 2: In the car, tank 3 is not properly connected to tank 0 -- 1 220 0 0 0 1 22000: In the car, tank 4 is not properly connected to tank 0 -- correct fuels: -- 1 1 1 220: for 1 tanks, using 1 ingredients of air, checking reaction chamber 0 -- 220 1 1 1 1 1 1 1: for 2 tanks, using 1 ingredients of air, checking reaction chamber 0, checking reaction chamber 1, surplus of ingredient 1 in lower pipe when air consists of ingredient 1 only -- [[2],[1]] -- 1111: for 1 tanks, using 1 ingredients of air, checking reaction chamber 0, first fuel component must increase -- 1110: for 1 tanks, using 1 ingredients of air, check fuel for tank 0, c_{1,1} must be >= 1 -- 220111011: for 2 tanks, using 1 ingredients of air, check fuel for tank 1, c_{1,1} must be >= 1 -- 220111111: for 2 tanks, using 1 ingredients of air, check fuel for tank 1, c_{1,1} must be >= 1 -- 2201 1111: for 2 tanks, using 1 ingredients of air, dimension mismatch -- 10: for 1 tanks, using 0 ingredients of air, dimension mismatch -- 11: for 1 tanks, using 1 ingredients of air, dimension mismatch -- 11011000000: for 1 tanks, using 1 ingredients of air, dimension mismatch -- 111220000: for 1 tanks, using 1 ingredients of air, fuel coefficients missing for tank 1 -- 1111220000: for 1 tanks, using 1 ingredients of air, fuel coefficients missing for tank 1 -- 1220: for 1 tanks, using 2 ingredients of air, dimension mismatch -- 12210: for 1 tanks, using 3 ingredients of air, dimension mismatch -- 12211: for 1 tanks, using 4 ingredients of air, dimension mismatch -- 12222000: for 1 tanks, using 6 ingredients of air, dimension mismatch -- 12222001: for 1 tanks, using 7 ingredients of air, dimension mismatch -- 1222201: for 1 tanks, using 9 ingredients of air, dimension mismatch -- 122221: for 1 tanks, using 15 ingredients of air, dimension mismatch -- 2200: for 2 tanks, using 0 ingredients of air, dimension mismatch -- 2201: for 2 tanks, using 1 ingredients of air, dimension mismatch -- 220220: for 2 tanks, using 2 ingredients of air, dimension mismatch -- 2202222022: for 2 tanks, using 14 ingredients of air, dimension mismatch -- 22100: for 3 tanks, using 0 ingredients of air, dimension mismatch -- 22101: for 3 tanks, using 1 ingredients of air, dimension mismatch -- 2210220: for 3 tanks, using 2 ingredients of air, dimension mismatch -- 22102210: for 3 tanks, using 3 ingredients of air, dimension mismatch -- 22110: for 4 tanks, using 0 ingredients of air, dimension mismatch -- 22111: for 4 tanks, using 1 ingredients of air, dimension mismatch -- 22120: for 5 tanks, using 0 ingredients of air, dimension mismatch -- 22121: for 5 tanks, using 1 ingredients of air, dimension mismatch -- 22220001: for 6 tanks, using 1 ingredients of air, dimension mismatch -- 22220011: for 7 tanks, using 1 ingredients of air, dimension mismatch -- 22220101: for 9 tanks, using 1 ingredients of air, dimension mismatch -- 22220111: for 10 tanks, using 1 ingredients of air, dimension mismatch -- 222210001: for 16 tanks, using 0 ingredients of air, dimension mismatch -- 2222100011: for 16 tanks, using 1 ingredients of air, dimension mismatch -- 222210010: for 18 tanks, using 0 ingredients of air, dimension mismatch -- 2222100101: for 18 tanks, using 1 ingredients of air, dimension mismatch -- 222210011: for 19 tanks, using 0 ingredients of air, dimension mismatch -- 2222100111: for 19 tanks, using 1 ingredients of air, dimension mismatch -- Numbers -- 0: 0 -- 1: 10 -- 2: 11 -- 3: 12 -- 4: 22000 -- 5: 22001 -- 6: 22002 -- 7: 22010 -- 8: 22011 -- 9: 22012 -- 10: 22020 -- 11: 22021 -- 12: 22022 -- List Lengths: -- 0: 0 -- 1: 1 -- 2: 220 -- 3: 2210 -- 4: 2211 -- 5: 2212 -- 6: 2222000 -- 7: 2222001 -- 8: 2222002 -- 9: 2222010 -- 10: 2222011 -- 11: 2222012 -- 12: 2222020 -- 13: 2222021 -- 14: 2222022 -- 15: 222210000 -- 16: 222210001 -- 17: 222210002 -- 18: 222210010 -- 19: 222210011 -- 20: 222210012 -- 21: 222210020 -- 22: 222210021 -- 23: 222210022 -- 24: 222210100 -- 25: 222210101 -- 26: 222210102 -- 27: 222210110 -- 28: 222210111 -- 29: 222210112 -- 30: 222210120 -- 31: 222210121 -- 32: 222210122 -- 33: 222210200 -- 34: 222210201 -- 35: 222210202 -- 36: 222210210 -- 37: 222210211 -- 38: 222210212 -- 39: 222210220 -- 40: 222210221 -- 41: 222210222