Permalink
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
65 lines (56 sloc) 23.6 KB
val input = "Sue 1: goldfish: 9, cars: 0, samoyeds: 9\nSue 2: perfumes: 5, trees: 8, goldfish: 8\nSue 3: pomeranians: 2, akitas: 1, trees: 5\nSue 4: goldfish: 10, akitas: 2, perfumes: 9\nSue 5: cars: 5, perfumes: 6, akitas: 9\nSue 6: goldfish: 10, cats: 9, cars: 8\nSue 7: trees: 2, samoyeds: 7, goldfish: 10\nSue 8: cars: 8, perfumes: 6, goldfish: 1\nSue 9: cats: 4, pomeranians: 0, trees: 0\nSue 10: trees: 2, children: 10, samoyeds: 10\nSue 11: akitas: 10, perfumes: 4, vizslas: 1\nSue 12: akitas: 1, trees: 0, goldfish: 3\nSue 13: perfumes: 6, goldfish: 10, cars: 8\nSue 14: cats: 8, akitas: 5, vizslas: 0\nSue 15: cars: 8, trees: 3, samoyeds: 5\nSue 16: vizslas: 6, cats: 6, pomeranians: 10\nSue 17: akitas: 6, cats: 2, perfumes: 9\nSue 18: children: 9, goldfish: 2, akitas: 10\nSue 19: trees: 3, perfumes: 0, goldfish: 6\nSue 20: vizslas: 3, akitas: 0, trees: 1\nSue 21: vizslas: 3, cars: 7, akitas: 3\nSue 22: perfumes: 7, children: 1, pomeranians: 7\nSue 23: trees: 10, cars: 9, akitas: 10\nSue 24: akitas: 5, goldfish: 6, vizslas: 6\nSue 25: samoyeds: 3, trees: 8, vizslas: 5\nSue 26: vizslas: 4, pomeranians: 2, trees: 1\nSue 27: cars: 9, goldfish: 2, trees: 4\nSue 28: vizslas: 6, goldfish: 10, perfumes: 7\nSue 29: vizslas: 6, pomeranians: 3, akitas: 6\nSue 30: trees: 0, samoyeds: 5, akitas: 9\nSue 31: vizslas: 1, perfumes: 0, trees: 6\nSue 32: cars: 7, vizslas: 1, children: 10\nSue 33: vizslas: 1, cars: 1, perfumes: 7\nSue 34: vizslas: 9, trees: 10, akitas: 9\nSue 35: akitas: 3, vizslas: 5, cars: 10\nSue 36: cats: 3, children: 9, samoyeds: 3\nSue 37: vizslas: 5, pomeranians: 7, cars: 6\nSue 38: cars: 10, akitas: 5, vizslas: 8\nSue 39: akitas: 5, trees: 9, children: 2\nSue 40: vizslas: 0, cats: 7, akitas: 0\nSue 41: cars: 9, trees: 10, perfumes: 8\nSue 42: akitas: 4, trees: 2, goldfish: 3\nSue 43: goldfish: 1, cats: 1, akitas: 8\nSue 44: goldfish: 8, akitas: 9, vizslas: 4\nSue 45: perfumes: 3, goldfish: 4, trees: 0\nSue 46: trees: 7, perfumes: 1, goldfish: 8\nSue 47: pomeranians: 10, cars: 7, trees: 2\nSue 48: trees: 2, akitas: 1, cars: 4\nSue 49: goldfish: 5, perfumes: 7, akitas: 8\nSue 50: akitas: 9, vizslas: 9, trees: 2\nSue 51: cars: 0, samoyeds: 0, vizslas: 8\nSue 52: trees: 0, perfumes: 6, pomeranians: 4\nSue 53: vizslas: 1, cats: 6, akitas: 3\nSue 54: samoyeds: 8, akitas: 1, vizslas: 4\nSue 55: goldfish: 10, perfumes: 2, pomeranians: 10\nSue 56: trees: 9, perfumes: 3, goldfish: 5\nSue 57: akitas: 3, perfumes: 0, cats: 2\nSue 58: perfumes: 4, vizslas: 4, cars: 8\nSue 59: goldfish: 7, children: 5, pomeranians: 8\nSue 60: cars: 1, trees: 1, perfumes: 10\nSue 61: trees: 4, samoyeds: 4, cars: 6\nSue 62: akitas: 10, trees: 2, vizslas: 6\nSue 63: goldfish: 3, perfumes: 7, vizslas: 10\nSue 64: pomeranians: 5, children: 10, cars: 0\nSue 65: vizslas: 10, cars: 8, perfumes: 3\nSue 66: children: 5, vizslas: 4, akitas: 10\nSue 67: children: 6, perfumes: 7, cars: 3\nSue 68: goldfish: 8, cars: 6, children: 1\nSue 69: vizslas: 5, perfumes: 3, cars: 9\nSue 70: goldfish: 0, cats: 6, perfumes: 0\nSue 71: trees: 2, samoyeds: 3, cars: 1\nSue 72: cats: 3, akitas: 8, vizslas: 7\nSue 73: akitas: 3, vizslas: 2, goldfish: 6\nSue 74: pomeranians: 10, samoyeds: 9, cats: 8\nSue 75: vizslas: 7, cars: 7, akitas: 10\nSue 76: children: 3, cats: 6, vizslas: 3\nSue 77: goldfish: 7, pomeranians: 10, trees: 0\nSue 78: vizslas: 9, children: 7, trees: 10\nSue 79: trees: 6, pomeranians: 8, samoyeds: 1\nSue 80: vizslas: 5, children: 6, pomeranians: 5\nSue 81: cars: 9, vizslas: 9, akitas: 9\nSue 82: vizslas: 3, cars: 8, akitas: 1\nSue 83: vizslas: 4, trees: 2, cats: 1\nSue 84: children: 3, akitas: 0, vizslas: 1\nSue 85: cats: 6, vizslas: 5, akitas: 2\nSue 86: cars: 3, akitas: 7, goldfish: 8\nSue 87: samoyeds: 8, vizslas: 3, goldfish: 8\nSue 88: vizslas: 4, children: 0, cats: 7\nSue 89: goldfish: 9, pomeranians: 10, samoyeds: 0\nSue 90: trees: 6, akitas: 3, cars: 7\nSue 91: samoyeds: 3, akitas: 7, perfumes: 10\nSue 92: cars: 7, pomeranians: 10, trees: 2\nSue 93: samoyeds: 1, children: 3, cars: 3\nSue 94: samoyeds: 8, akitas: 7, vizslas: 0\nSue 95: goldfish: 7, children: 2, cars: 6\nSue 96: cars: 3, perfumes: 9, akitas: 10\nSue 97: akitas: 9, cars: 10, vizslas: 10\nSue 98: trees: 4, goldfish: 8, pomeranians: 7\nSue 99: samoyeds: 6, pomeranians: 0, vizslas: 7\nSue 100: akitas: 7, perfumes: 8, vizslas: 3\nSue 101: cars: 5, perfumes: 1, trees: 0\nSue 102: akitas: 6, pomeranians: 10, trees: 0\nSue 103: trees: 3, perfumes: 5, cats: 9\nSue 104: goldfish: 10, perfumes: 8, akitas: 0\nSue 105: goldfish: 6, vizslas: 5, trees: 2\nSue 106: pomeranians: 9, samoyeds: 10, perfumes: 10\nSue 107: cars: 8, vizslas: 4, akitas: 2\nSue 108: cats: 0, goldfish: 7, trees: 0\nSue 109: cars: 3, pomeranians: 6, trees: 2\nSue 110: perfumes: 4, goldfish: 5, akitas: 10\nSue 111: cars: 3, perfumes: 4, pomeranians: 4\nSue 112: cats: 2, goldfish: 10, akitas: 0\nSue 113: cats: 10, children: 0, trees: 1\nSue 114: akitas: 10, vizslas: 3, goldfish: 0\nSue 115: samoyeds: 3, goldfish: 6, vizslas: 1\nSue 116: cars: 3, perfumes: 5, trees: 6\nSue 117: akitas: 9, samoyeds: 8, goldfish: 8\nSue 118: pomeranians: 5, perfumes: 10, trees: 1\nSue 119: goldfish: 6, perfumes: 3, children: 1\nSue 120: trees: 1, children: 3, pomeranians: 6\nSue 121: akitas: 7, cars: 10, vizslas: 9\nSue 122: trees: 4, akitas: 8, samoyeds: 10\nSue 123: cats: 4, cars: 8, vizslas: 9\nSue 124: cars: 10, children: 1, trees: 0\nSue 125: goldfish: 5, pomeranians: 5, trees: 2\nSue 126: goldfish: 1, vizslas: 8, akitas: 10\nSue 127: vizslas: 4, cars: 9, akitas: 1\nSue 128: goldfish: 8, perfumes: 3, cars: 9\nSue 129: goldfish: 9, pomeranians: 9, perfumes: 1\nSue 130: trees: 1, vizslas: 9, perfumes: 3\nSue 131: children: 6, trees: 8, vizslas: 8\nSue 132: cars: 1, vizslas: 3, children: 7\nSue 133: cars: 7, children: 1, perfumes: 6\nSue 134: trees: 8, vizslas: 3, samoyeds: 2\nSue 135: cats: 9, perfumes: 4, pomeranians: 7\nSue 136: perfumes: 0, akitas: 8, vizslas: 6\nSue 137: goldfish: 5, trees: 0, vizslas: 7\nSue 138: trees: 1, perfumes: 2, cars: 10\nSue 139: samoyeds: 8, goldfish: 8, trees: 0\nSue 140: vizslas: 10, perfumes: 9, goldfish: 0\nSue 141: perfumes: 7, cars: 9, cats: 5\nSue 142: trees: 2, samoyeds: 2, cars: 0\nSue 143: cars: 1, perfumes: 1, akitas: 1\nSue 144: vizslas: 9, cars: 7, pomeranians: 10\nSue 145: pomeranians: 2, samoyeds: 7, children: 7\nSue 146: vizslas: 6, cars: 9, goldfish: 7\nSue 147: trees: 2, vizslas: 1, cats: 9\nSue 148: perfumes: 9, trees: 4, pomeranians: 5\nSue 149: samoyeds: 8, children: 1, vizslas: 9\nSue 150: cats: 3, trees: 2, vizslas: 4\nSue 151: goldfish: 7, akitas: 10, trees: 3\nSue 152: perfumes: 4, vizslas: 7, cars: 4\nSue 153: pomeranians: 4, akitas: 0, vizslas: 3\nSue 154: samoyeds: 8, trees: 2, vizslas: 10\nSue 155: vizslas: 7, cats: 7, pomeranians: 5\nSue 156: goldfish: 10, pomeranians: 1, vizslas: 1\nSue 157: cars: 6, perfumes: 7, trees: 9\nSue 158: trees: 5, samoyeds: 9, goldfish: 3\nSue 159: pomeranians: 4, akitas: 6, vizslas: 8\nSue 160: goldfish: 7, children: 0, cats: 0\nSue 161: vizslas: 5, akitas: 0, samoyeds: 2\nSue 162: akitas: 4, children: 0, vizslas: 3\nSue 163: samoyeds: 2, perfumes: 0, goldfish: 9\nSue 164: cars: 9, vizslas: 8, akitas: 6\nSue 165: samoyeds: 9, vizslas: 9, perfumes: 5\nSue 166: cars: 5, pomeranians: 4, samoyeds: 8\nSue 167: cars: 10, perfumes: 3, samoyeds: 6\nSue 168: pomeranians: 8, goldfish: 9, trees: 9\nSue 169: vizslas: 7, akitas: 3, samoyeds: 4\nSue 170: cats: 2, goldfish: 0, vizslas: 4\nSue 171: perfumes: 3, goldfish: 10, cats: 3\nSue 172: goldfish: 7, akitas: 6, cars: 0\nSue 173: cars: 9, goldfish: 7, akitas: 5\nSue 174: goldfish: 6, cats: 0, vizslas: 8\nSue 175: perfumes: 7, cats: 10, cars: 10\nSue 176: samoyeds: 9, vizslas: 4, pomeranians: 10\nSue 177: perfumes: 0, trees: 0, cars: 10\nSue 178: vizslas: 6, children: 7, samoyeds: 1\nSue 179: vizslas: 8, children: 6, trees: 0\nSue 180: cars: 1, vizslas: 6, trees: 1\nSue 181: vizslas: 10, perfumes: 3, cars: 1\nSue 182: trees: 8, samoyeds: 9, cars: 7\nSue 183: cars: 6, vizslas: 2, perfumes: 7\nSue 184: trees: 5, samoyeds: 9, akitas: 0\nSue 185: cars: 8, goldfish: 8, trees: 4\nSue 186: samoyeds: 6, goldfish: 1, trees: 2\nSue 187: perfumes: 1, trees: 2, akitas: 7\nSue 188: samoyeds: 5, cars: 6, perfumes: 2\nSue 189: samoyeds: 8, goldfish: 3, perfumes: 5\nSue 190: akitas: 2, cats: 1, samoyeds: 1\nSue 191: trees: 5, akitas: 1, goldfish: 7\nSue 192: vizslas: 3, trees: 0, perfumes: 4\nSue 193: cars: 3, perfumes: 4, akitas: 3\nSue 194: perfumes: 4, vizslas: 8, children: 4\nSue 195: vizslas: 1, samoyeds: 3, cars: 6\nSue 196: cars: 5, perfumes: 6, vizslas: 2\nSue 197: vizslas: 8, akitas: 8, cats: 6\nSue 198: cars: 9, akitas: 2, pomeranians: 7\nSue 199: cats: 9, akitas: 6, cars: 10\nSue 200: vizslas: 10, pomeranians: 2, goldfish: 9\nSue 201: vizslas: 9, samoyeds: 4, akitas: 3\nSue 202: akitas: 5, cats: 2, vizslas: 0\nSue 203: perfumes: 1, children: 3, akitas: 10\nSue 204: trees: 4, vizslas: 7, akitas: 9\nSue 205: trees: 8, perfumes: 9, cars: 1\nSue 206: goldfish: 6, trees: 5, cars: 8\nSue 207: akitas: 3, vizslas: 8, trees: 8\nSue 208: vizslas: 4, perfumes: 7, akitas: 10\nSue 209: cars: 9, perfumes: 7, goldfish: 9\nSue 210: vizslas: 2, cats: 2, akitas: 10\nSue 211: akitas: 1, trees: 3, cars: 2\nSue 212: goldfish: 5, trees: 0, vizslas: 7\nSue 213: akitas: 3, perfumes: 1, vizslas: 5\nSue 214: perfumes: 3, pomeranians: 6, cars: 0\nSue 215: goldfish: 1, cats: 9, cars: 3\nSue 216: goldfish: 9, pomeranians: 6, samoyeds: 0\nSue 217: cars: 6, trees: 2, perfumes: 2\nSue 218: vizslas: 3, goldfish: 8, akitas: 5\nSue 219: cats: 9, perfumes: 7, cars: 5\nSue 220: pomeranians: 5, vizslas: 4, cats: 5\nSue 221: trees: 0, akitas: 7, goldfish: 10\nSue 222: akitas: 2, cars: 3, vizslas: 5\nSue 223: goldfish: 3, perfumes: 7, akitas: 4\nSue 224: samoyeds: 2, cars: 4, vizslas: 7\nSue 225: trees: 5, cars: 0, perfumes: 0\nSue 226: trees: 2, goldfish: 10, perfumes: 6\nSue 227: cars: 8, trees: 9, akitas: 6\nSue 228: goldfish: 10, trees: 10, perfumes: 0\nSue 229: children: 7, samoyeds: 4, goldfish: 6\nSue 230: vizslas: 9, perfumes: 1, children: 10\nSue 231: vizslas: 8, trees: 5, akitas: 9\nSue 232: akitas: 5, goldfish: 9, trees: 1\nSue 233: vizslas: 3, trees: 2, children: 9\nSue 234: samoyeds: 8, perfumes: 0, cats: 0\nSue 235: perfumes: 4, vizslas: 3, akitas: 5\nSue 236: pomeranians: 5, vizslas: 3, akitas: 9\nSue 237: cats: 1, trees: 7, vizslas: 5\nSue 238: children: 5, cats: 4, samoyeds: 5\nSue 239: trees: 3, akitas: 2, goldfish: 6\nSue 240: goldfish: 9, trees: 1, perfumes: 1\nSue 241: cars: 2, pomeranians: 1, samoyeds: 2\nSue 242: akitas: 2, trees: 3, cars: 4\nSue 243: vizslas: 6, akitas: 2, samoyeds: 7\nSue 244: trees: 0, perfumes: 5, cars: 7\nSue 245: goldfish: 10, perfumes: 5, vizslas: 8\nSue 246: akitas: 0, perfumes: 0, cars: 1\nSue 247: samoyeds: 8, goldfish: 0, cars: 6\nSue 248: perfumes: 0, children: 10, trees: 10\nSue 249: perfumes: 6, akitas: 5, cats: 5\nSue 250: vizslas: 7, akitas: 4, cats: 5\nSue 251: samoyeds: 4, akitas: 1, trees: 8\nSue 252: perfumes: 8, pomeranians: 5, cars: 1\nSue 253: akitas: 10, trees: 4, cats: 3\nSue 254: perfumes: 2, cats: 2, goldfish: 9\nSue 255: cars: 4, trees: 1, akitas: 4\nSue 256: samoyeds: 9, goldfish: 0, akitas: 9\nSue 257: vizslas: 9, perfumes: 2, goldfish: 2\nSue 258: perfumes: 1, cars: 9, samoyeds: 1\nSue 259: trees: 0, goldfish: 0, samoyeds: 3\nSue 260: perfumes: 7, cars: 1, goldfish: 0\nSue 261: cars: 0, trees: 5, goldfish: 6\nSue 262: akitas: 7, vizslas: 3, pomeranians: 5\nSue 263: trees: 1, vizslas: 3, goldfish: 3\nSue 264: akitas: 7, vizslas: 4, children: 0\nSue 265: samoyeds: 5, trees: 0, akitas: 4\nSue 266: perfumes: 9, goldfish: 9, cars: 8\nSue 267: cars: 7, perfumes: 10, pomeranians: 8\nSue 268: cars: 0, akitas: 7, perfumes: 4\nSue 269: pomeranians: 0, cars: 9, perfumes: 10\nSue 270: samoyeds: 10, perfumes: 10, cars: 9\nSue 271: akitas: 2, vizslas: 8, cats: 5\nSue 272: akitas: 3, children: 9, samoyeds: 10\nSue 273: perfumes: 2, cars: 10, goldfish: 8\nSue 274: cars: 3, children: 10, perfumes: 10\nSue 275: cats: 9, akitas: 5, trees: 0\nSue 276: akitas: 6, children: 2, vizslas: 1\nSue 277: pomeranians: 6, trees: 10, samoyeds: 3\nSue 278: cars: 7, perfumes: 10, trees: 1\nSue 279: cars: 6, pomeranians: 8, trees: 2\nSue 280: pomeranians: 9, cats: 0, perfumes: 7\nSue 281: vizslas: 10, goldfish: 9, pomeranians: 5\nSue 282: perfumes: 4, samoyeds: 7, cars: 9\nSue 283: cars: 9, vizslas: 6, trees: 5\nSue 284: cars: 7, trees: 1, vizslas: 4\nSue 285: samoyeds: 4, goldfish: 10, cats: 4\nSue 286: samoyeds: 0, akitas: 4, children: 5\nSue 287: trees: 1, perfumes: 3, goldfish: 10\nSue 288: pomeranians: 10, akitas: 3, cars: 2\nSue 289: trees: 7, pomeranians: 4, goldfish: 10\nSue 290: samoyeds: 10, perfumes: 0, cars: 9\nSue 291: akitas: 0, pomeranians: 7, vizslas: 4\nSue 292: cats: 2, vizslas: 8, goldfish: 5\nSue 293: vizslas: 6, pomeranians: 9, perfumes: 0\nSue 294: akitas: 6, cars: 7, vizslas: 5\nSue 295: goldfish: 0, akitas: 9, cats: 0\nSue 296: goldfish: 1, trees: 0, cars: 6\nSue 297: perfumes: 6, cats: 8, pomeranians: 6\nSue 298: cats: 0, goldfish: 6, perfumes: 2\nSue 299: cars: 4, akitas: 1, samoyeds: 10\nSue 300: goldfish: 9, samoyeds: 6, cats: 5\nSue 301: cars: 0, vizslas: 7, trees: 0\nSue 302: goldfish: 9, samoyeds: 1, children: 6\nSue 303: cars: 6, perfumes: 7, samoyeds: 8\nSue 304: trees: 8, goldfish: 9, children: 9\nSue 305: perfumes: 0, cars: 5, goldfish: 4\nSue 306: cats: 3, cars: 7, vizslas: 7\nSue 307: pomeranians: 4, perfumes: 6, cars: 2\nSue 308: cars: 9, akitas: 6, goldfish: 4\nSue 309: pomeranians: 2, vizslas: 10, goldfish: 10\nSue 310: children: 0, cats: 4, akitas: 7\nSue 311: children: 10, akitas: 8, vizslas: 2\nSue 312: children: 5, cars: 0, vizslas: 4\nSue 313: perfumes: 10, trees: 3, pomeranians: 9\nSue 314: samoyeds: 3, goldfish: 2, trees: 9\nSue 315: cars: 2, cats: 5, pomeranians: 10\nSue 316: cats: 6, pomeranians: 6, children: 9\nSue 317: cats: 2, vizslas: 3, perfumes: 1\nSue 318: akitas: 1, perfumes: 3, vizslas: 10\nSue 319: cars: 7, perfumes: 0, trees: 0\nSue 320: goldfish: 6, samoyeds: 6, pomeranians: 4\nSue 321: trees: 2, goldfish: 6, children: 0\nSue 322: goldfish: 0, trees: 2, akitas: 8\nSue 323: pomeranians: 2, samoyeds: 9, vizslas: 1\nSue 324: trees: 4, goldfish: 6, pomeranians: 6\nSue 325: trees: 2, pomeranians: 3, goldfish: 1\nSue 326: perfumes: 4, goldfish: 6, trees: 5\nSue 327: akitas: 3, cars: 8, cats: 2\nSue 328: cats: 6, vizslas: 0, akitas: 2\nSue 329: perfumes: 3, goldfish: 10, akitas: 3\nSue 330: goldfish: 3, vizslas: 1, akitas: 6\nSue 331: perfumes: 4, trees: 1, goldfish: 5\nSue 332: goldfish: 7, vizslas: 9, akitas: 1\nSue 333: children: 8, cars: 8, trees: 4\nSue 334: cars: 1, vizslas: 6, trees: 0\nSue 335: goldfish: 2, cars: 2, akitas: 1\nSue 336: goldfish: 5, akitas: 5, trees: 9\nSue 337: cars: 5, vizslas: 6, goldfish: 6\nSue 338: cats: 9, akitas: 3, goldfish: 9\nSue 339: akitas: 3, cats: 2, children: 7\nSue 340: goldfish: 0, pomeranians: 8, perfumes: 9\nSue 341: trees: 0, pomeranians: 1, goldfish: 5\nSue 342: goldfish: 10, trees: 3, vizslas: 4\nSue 343: cats: 3, samoyeds: 1, children: 6\nSue 344: perfumes: 3, children: 4, samoyeds: 2\nSue 345: children: 6, trees: 2, goldfish: 1\nSue 346: trees: 2, pomeranians: 3, goldfish: 5\nSue 347: akitas: 10, vizslas: 7, trees: 1\nSue 348: perfumes: 4, akitas: 2, vizslas: 7\nSue 349: perfumes: 8, goldfish: 3, vizslas: 5\nSue 350: trees: 4, pomeranians: 5, akitas: 10\nSue 351: perfumes: 5, cars: 9, trees: 0\nSue 352: akitas: 6, children: 8, trees: 10\nSue 353: samoyeds: 7, akitas: 6, vizslas: 4\nSue 354: children: 9, goldfish: 7, perfumes: 5\nSue 355: trees: 1, perfumes: 4, cars: 1\nSue 356: samoyeds: 1, perfumes: 4, pomeranians: 8\nSue 357: trees: 7, goldfish: 10, akitas: 0\nSue 358: akitas: 1, vizslas: 6, cars: 7\nSue 359: vizslas: 3, goldfish: 8, trees: 4\nSue 360: akitas: 10, vizslas: 2, trees: 3\nSue 361: samoyeds: 6, pomeranians: 1, perfumes: 0\nSue 362: samoyeds: 3, cars: 1, trees: 0\nSue 363: vizslas: 0, pomeranians: 9, akitas: 4\nSue 364: perfumes: 9, pomeranians: 8, vizslas: 9\nSue 365: vizslas: 7, cars: 4, perfumes: 10\nSue 366: cars: 0, samoyeds: 5, goldfish: 10\nSue 367: children: 4, vizslas: 5, akitas: 4\nSue 368: samoyeds: 9, perfumes: 4, vizslas: 6\nSue 369: perfumes: 5, cars: 4, samoyeds: 5\nSue 370: akitas: 3, vizslas: 2, perfumes: 1\nSue 371: cars: 8, cats: 7, children: 5\nSue 372: vizslas: 9, perfumes: 2, akitas: 10\nSue 373: trees: 10, pomeranians: 9, goldfish: 3\nSue 374: children: 4, cars: 10, perfumes: 2\nSue 375: children: 7, samoyeds: 5, cats: 0\nSue 376: akitas: 10, samoyeds: 5, vizslas: 5\nSue 377: goldfish: 8, trees: 3, perfumes: 3\nSue 378: goldfish: 10, vizslas: 0, perfumes: 2\nSue 379: trees: 1, vizslas: 7, pomeranians: 4\nSue 380: samoyeds: 8, vizslas: 3, trees: 2\nSue 381: goldfish: 2, perfumes: 5, samoyeds: 9\nSue 382: cats: 3, vizslas: 10, akitas: 5\nSue 383: cars: 7, goldfish: 5, akitas: 8\nSue 384: children: 6, goldfish: 10, trees: 1\nSue 385: cats: 2, akitas: 6, samoyeds: 7\nSue 386: cars: 10, children: 4, goldfish: 2\nSue 387: cats: 0, perfumes: 5, akitas: 9\nSue 388: pomeranians: 7, akitas: 0, samoyeds: 9\nSue 389: trees: 0, akitas: 9, vizslas: 8\nSue 390: cars: 0, trees: 10, perfumes: 9\nSue 391: cats: 9, goldfish: 10, perfumes: 10\nSue 392: cars: 3, vizslas: 6, cats: 3\nSue 393: vizslas: 10, perfumes: 4, goldfish: 5\nSue 394: perfumes: 4, akitas: 10, trees: 2\nSue 395: pomeranians: 5, cars: 4, perfumes: 3\nSue 396: pomeranians: 9, vizslas: 5, akitas: 2\nSue 397: cars: 10, goldfish: 8, trees: 2\nSue 398: perfumes: 7, children: 9, goldfish: 9\nSue 399: akitas: 6, cats: 2, goldfish: 7\nSue 400: goldfish: 9, perfumes: 0, cars: 2\nSue 401: children: 4, vizslas: 0, trees: 2\nSue 402: akitas: 4, cars: 8, pomeranians: 4\nSue 403: vizslas: 8, perfumes: 7, goldfish: 1\nSue 404: goldfish: 10, samoyeds: 7, vizslas: 3\nSue 405: akitas: 1, vizslas: 6, perfumes: 6\nSue 406: pomeranians: 8, goldfish: 6, cats: 3\nSue 407: goldfish: 2, vizslas: 4, akitas: 7\nSue 408: cars: 10, perfumes: 10, vizslas: 3\nSue 409: vizslas: 7, pomeranians: 4, perfumes: 4\nSue 410: goldfish: 4, vizslas: 7, trees: 5\nSue 411: cars: 8, trees: 0, goldfish: 4\nSue 412: cars: 8, perfumes: 5, vizslas: 4\nSue 413: vizslas: 3, akitas: 7, samoyeds: 6\nSue 414: trees: 0, perfumes: 6, cars: 10\nSue 415: pomeranians: 4, trees: 1, perfumes: 6\nSue 416: cars: 10, perfumes: 6, akitas: 2\nSue 417: perfumes: 6, samoyeds: 0, akitas: 0\nSue 418: children: 1, perfumes: 9, vizslas: 3\nSue 419: goldfish: 9, samoyeds: 3, perfumes: 8\nSue 420: goldfish: 4, cars: 10, vizslas: 7\nSue 421: samoyeds: 7, vizslas: 7, cats: 2\nSue 422: trees: 1, goldfish: 8, perfumes: 0\nSue 423: cars: 3, perfumes: 2, trees: 3\nSue 424: samoyeds: 6, vizslas: 0, akitas: 6\nSue 425: trees: 3, akitas: 7, goldfish: 1\nSue 426: cars: 9, trees: 1, perfumes: 0\nSue 427: pomeranians: 0, children: 5, perfumes: 8\nSue 428: cars: 0, perfumes: 6, children: 4\nSue 429: akitas: 7, pomeranians: 9, cats: 6\nSue 430: cats: 6, trees: 1, cars: 0\nSue 431: children: 8, akitas: 5, perfumes: 9\nSue 432: perfumes: 5, akitas: 10, trees: 9\nSue 433: akitas: 4, perfumes: 10, vizslas: 7\nSue 434: trees: 3, children: 10, samoyeds: 4\nSue 435: vizslas: 5, goldfish: 2, akitas: 2\nSue 436: samoyeds: 3, trees: 2, cars: 6\nSue 437: children: 9, akitas: 0, pomeranians: 3\nSue 438: perfumes: 10, akitas: 2, cars: 7\nSue 439: perfumes: 10, samoyeds: 6, akitas: 10\nSue 440: vizslas: 10, trees: 2, akitas: 8\nSue 441: perfumes: 8, akitas: 2, pomeranians: 7\nSue 442: cars: 8, trees: 3, goldfish: 6\nSue 443: cars: 1, goldfish: 5, vizslas: 5\nSue 444: vizslas: 2, akitas: 10, samoyeds: 4\nSue 445: vizslas: 2, akitas: 10, perfumes: 9\nSue 446: akitas: 3, vizslas: 8, goldfish: 1\nSue 447: vizslas: 7, pomeranians: 5, trees: 10\nSue 448: cats: 6, perfumes: 10, children: 6\nSue 449: trees: 2, cars: 5, goldfish: 8\nSue 450: trees: 0, goldfish: 6, samoyeds: 3\nSue 451: perfumes: 0, cars: 8, trees: 1\nSue 452: akitas: 4, trees: 8, perfumes: 9\nSue 453: goldfish: 1, perfumes: 7, akitas: 6\nSue 454: vizslas: 3, cars: 1, perfumes: 6\nSue 455: trees: 1, akitas: 7, goldfish: 10\nSue 456: samoyeds: 4, vizslas: 2, cars: 9\nSue 457: perfumes: 10, children: 1, trees: 8\nSue 458: perfumes: 0, vizslas: 9, cars: 8\nSue 459: cats: 0, children: 7, trees: 3\nSue 460: vizslas: 4, cats: 6, perfumes: 2\nSue 461: trees: 3, children: 5, cars: 8\nSue 462: goldfish: 7, vizslas: 7, children: 5\nSue 463: cars: 5, akitas: 3, goldfish: 5\nSue 464: vizslas: 0, pomeranians: 5, cars: 0\nSue 465: goldfish: 4, akitas: 0, cats: 5\nSue 466: cars: 5, trees: 1, goldfish: 6\nSue 467: perfumes: 10, trees: 8, cars: 1\nSue 468: perfumes: 4, akitas: 3, cars: 0\nSue 469: vizslas: 3, cars: 7, pomeranians: 1\nSue 470: perfumes: 1, vizslas: 7, akitas: 8\nSue 471: goldfish: 10, samoyeds: 10, pomeranians: 5\nSue 472: goldfish: 6, trees: 0, perfumes: 0\nSue 473: goldfish: 5, vizslas: 0, children: 5\nSue 474: cars: 3, vizslas: 7, perfumes: 10\nSue 475: vizslas: 5, trees: 9, goldfish: 8\nSue 476: akitas: 2, goldfish: 6, children: 7\nSue 477: samoyeds: 0, perfumes: 1, pomeranians: 5\nSue 478: trees: 2, goldfish: 9, vizslas: 0\nSue 479: perfumes: 1, cars: 6, goldfish: 9\nSue 480: pomeranians: 3, perfumes: 5, trees: 9\nSue 481: cats: 3, akitas: 0, vizslas: 8\nSue 482: pomeranians: 10, akitas: 8, trees: 5\nSue 483: goldfish: 6, akitas: 10, perfumes: 2\nSue 484: cats: 0, goldfish: 0, children: 9\nSue 485: children: 4, akitas: 10, vizslas: 8\nSue 486: vizslas: 3, goldfish: 9, children: 10\nSue 487: children: 8, cats: 6, vizslas: 10\nSue 488: cars: 7, akitas: 10, samoyeds: 5\nSue 489: vizslas: 9, akitas: 6, trees: 2\nSue 490: vizslas: 5, akitas: 1, children: 5\nSue 491: vizslas: 8, goldfish: 3, perfumes: 6\nSue 492: trees: 3, samoyeds: 1, pomeranians: 6\nSue 493: akitas: 1, vizslas: 5, cars: 8\nSue 494: akitas: 4, cars: 4, vizslas: 9\nSue 495: vizslas: 1, akitas: 2, cats: 2\nSue 496: trees: 7, vizslas: 5, akitas: 6\nSue 497: akitas: 8, trees: 2, perfumes: 6\nSue 498: akitas: 1, trees: 1, samoyeds: 4\nSue 499: cars: 0, akitas: 5, vizslas: 3\nSue 500: cats: 2, goldfish: 9, children: 8"
// Input parsing.
val pattern = """Sue ([0-9]+): ([a-z]+): ([0-9]+), ([a-z]+): ([0-9]+), ([a-z]+): ([0-9]+)""".r
case class Sue( id: Int, ps: Map[String, Int])
val sues = input
.split("\n")
.map {
case pattern(id, p1, v1, p2, v2, p3, v3) => Sue(id.toInt, Map( p1 -> v1.toInt, p2 -> v2.toInt, p3 -> v3.toInt))
}
// First puzzle.
val p0: Map[String, Int] = Map(
"children" -> 3,
"cats" -> 7,
"samoyeds" -> 2,
"pomeranians" -> 3,
"akitas" -> 0,
"vizslas" -> 0,
"goldfish" -> 5,
"trees" -> 3,
"cars" -> 2,
"perfumes" -> 1
)
def dist( o: Map[String, Int])( p: Map[String,Int]) = {
p.map( s => ( s._2, o(s._1)))
.forall( p => p._1 == p._2)
}
val theSue = sues
.map {
case s => (s.id, dist(p0)(s.ps))
}
.filter( _._2 )
.head
._1 // 40
// Second puzzle.
def dist2( o: Map[String, Int])( p: Map[String,Int]) =
p.map( s => ( s._1, o(s._1), s._2))
.map {
case ( "children", oo, pp) => pp == oo
case ( "cats", oo, pp) => pp > oo
case ( "samoyeds", oo, pp) => pp == oo
case ( "pomeranians", oo, pp) => pp < oo
case ( "akitas", oo, pp) => pp == oo
case ( "vizslas", oo, pp) => pp == oo
case ( "goldfish", oo, pp) => pp < oo
case ( "trees", oo, pp) => pp > oo
case ( "cars", oo, pp) => pp == oo
case ( "perfumes", oo, pp) => pp == oo
}
.reduce( _ && _)
val theSue2 = sues
.map {
case s => (s.id, dist2(p0)(s.ps))
}
.filter( _._2 )
.head
._1 // 241