├── .github └── workflows │ └── main.yml ├── .gitignore ├── 1.fut ├── 10.fut ├── 11.fut ├── 12.fut ├── 13.fut ├── 14.fut ├── 15.fut ├── 16.fut ├── 17.fut ├── 18.fut ├── 19.fut ├── 2.fut ├── 20.fut ├── 21.fut ├── 22.fut ├── 23.fut ├── 24.fut ├── 25.fut ├── 3.fut ├── 4.fut ├── 5.fut ├── 6.fut ├── 7.fut ├── 8.fut ├── 9.fut ├── Makefile ├── README.md ├── bfs.fut ├── fut2txt.py ├── futhark.pkg ├── inputs ├── 1.input ├── 10.input ├── 11.input ├── 12.input ├── 13.input ├── 14.input ├── 15.input ├── 16.input ├── 17.input ├── 18.input ├── 19.input ├── 2.input ├── 20.input ├── 21.input ├── 22.input ├── 23.input ├── 24.input ├── 25.input ├── 3.input ├── 4.input ├── 5.input ├── 6.input ├── 7.input ├── 8.input └── 9.input ├── txt2fut.py └── utils.fut /.github/workflows/main.yml: -------------------------------------------------------------------------------- 1 | name: CI 2 | 3 | on: 4 | push: 5 | branches: [ main ] 6 | 7 | jobs: 8 | test-on-nightly: 9 | runs-on: ubuntu-latest 10 | 11 | steps: 12 | - uses: actions/checkout@v2 13 | 14 | - name: Install Futhark 15 | uses: diku-dk/install-futhark@v1.1.0 16 | with: 17 | version: 'nightly' 18 | 19 | - run: futhark pkg sync 20 | - run: make -j 21 | - run: futhark test --pass-compiler-option=--Werror *.fut 22 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | /* 2 | !inputs/ 3 | !*.input 4 | !*.fut 5 | !*.py 6 | !futhark.pkg 7 | !.gitignore 8 | !README.md 9 | !Makefile 10 | !.github 11 | -------------------------------------------------------------------------------- /1.fut: -------------------------------------------------------------------------------- 1 | -- Pretty straightforward segmented reductions. Very clean. 2 | 3 | import "utils" 4 | import "lib/github.com/diku-dk/sorts/radix_sort" 5 | import "lib/github.com/diku-dk/segmented/segmented" 6 | 7 | -- Turns empty lines into zeroes 8 | def parse (s: string[]): []i32 = 9 | let (get,ls) = lines.lines s 10 | in map (\l -> atoi (get l)) ls 11 | 12 | entry part1 (s: string[]) = 13 | parse s 14 | |> (map (==0) &&& id) 15 | |> uncurry (segmented_reduce (+) 0) 16 | |> i32.maximum 17 | 18 | entry part2 (s: string[]) = 19 | parse s 20 | |> (map (==0) &&& id) 21 | |> uncurry (segmented_reduce (+) 0) 22 | |> radix_sort i32.num_bits i32.get_bit 23 | |> reverse 24 | |> take 3 25 | |> foldl (+) 0 26 | 27 | -- == 28 | -- entry: part1 29 | -- input @ data/1.input 30 | -- output { 68802 } 31 | 32 | -- == 33 | -- entry: part2 34 | -- input @ data/1.input 35 | -- output { 205370 } 36 | -------------------------------------------------------------------------------- /10.fut: -------------------------------------------------------------------------------- 1 | -- Because of how limited this virtual machine is, we can actually 2 | -- compute its intermediate states with a scan. 3 | 4 | import "utils" 5 | 6 | type op = #addx i32 | #noop 7 | 8 | def parse (s: string[]) : []op = 9 | let (get,ls) = lines.lines s 10 | let f l = let l' = get l 11 | in if l'[0] == 'a' 12 | then #addx (atoi(drop 5 l')) 13 | else #noop 14 | in map f ls 15 | 16 | type state = (i32,i32) 17 | def initial_state: state = (0,1) 18 | 19 | -- Really annoying that the start register value is 1! That means the 20 | -- initial machine state is not a neutral element for the composition 21 | -- of machine states. We try to make it work anyway, by always having 22 | -- an additional 1 in the register value; taking care to adjust when 23 | -- combining machine states. 24 | 25 | def state_combine (c1,r1) (c2,r2) : state = (c1+c2,r1+r2-1) 26 | 27 | def exec (o: op) : state = 28 | match o case #addx x -> (2, x+1) 29 | case #noop -> (1, 1) 30 | 31 | def cmp `on` get = \x y -> cmp (get x) (get y) 32 | 33 | def run s = parse s |> map exec |> scan state_combine initial_state 34 | 35 | def find_state [n] (states: [n]state) x = 36 | let i = binsearch ((<) `on` (.0)) states (x,0) 37 | in if i < 0 38 | then initial_state.1 39 | else states[i `i64.min` (n-1)].1 40 | 41 | entry part1 s = 42 | let states = run s 43 | let interesting = [20, 60, 100, 140, 180, 220] 44 | in map (find_state states) interesting |> map2 (*) interesting |> i32.sum 45 | 46 | entry part2 s = 47 | let states = run s 48 | let close x y = i32.abs (x-y) < 2 49 | let f i = let i' = i32.i64 i 50 | in close (i'%40) (find_state states (i'+1)) 51 | let char b = if b then '#' else '.' 52 | let nl s = s ++ "\n" 53 | in tabulate 240 f |> map char |> sized (6*40) |> unflatten |> map nl |> flatten 54 | 55 | -- == 56 | -- entry: part1 57 | -- input @ data/10.input 58 | -- output { 15680 } 59 | 60 | -- Not bothering testing part 2. 61 | -- == 62 | -- entry: part2 63 | -- input @ data/10.input 64 | -------------------------------------------------------------------------------- /11.fut: -------------------------------------------------------------------------------- 1 | -- This one is Death, but not as much as I immediately thought. The 2 | -- simulation can be parallelised to some extent, although it is not 3 | -- work efficient. Ths most painful part is the excessive parsing, 4 | -- which even exposed a compiler bug in my original overly complicated 5 | -- version. 6 | -- 7 | -- I wasted a lot of time on stupid things, like not realising that 8 | -- the intermediate results might not fit in 32-bit integers. That is 9 | -- unusual for an AOC problem. 10 | 11 | import "utils" 12 | import "lib/github.com/diku-dk/segmented/segmented" 13 | import "lib/github.com/diku-dk/sorts/radix_sort" 14 | 15 | let testinput = "Monkey 0:\n Starting items: 79, 98\n Operation: new = old * 19\n Test: divisible by 23\n If true: throw to monkey 2\n If false: throw to monkey 3\n\nMonkey 1:\n Starting items: 54, 65, 75, 74\n Operation: new = old + 6\n Test: divisible by 19\n If true: throw to monkey 2\n If false: throw to monkey 0\n\nMonkey 2:\n Starting items: 79, 60, 97\n Operation: new = old * old\n Test: divisible by 13\n If true: throw to monkey 1\n If false: throw to monkey 3\n\nMonkey 3:\n Starting items: 74\n Operation: new = old + 3\n Test: divisible by 17\n If true: throw to monkey 0\n If false: throw to monkey 1\n" 16 | 17 | def num_items [n] (s: string[n]) : i64 = 18 | (loop (x,i) = (0,0) while i < n do 19 | let j = i + index_of_first (is_digit >-> not) s[i:] 20 | in (x+1, j + 2)).0 21 | 22 | def get_item [n] (i: i64) (s: string[n]) : i32 = 23 | let (_, j) = 24 | loop (i,j) = (i,0) while i > 0 do 25 | (if s[j] == ' ' then i-1 else i, j + 1) 26 | in atoi s[j:] 27 | 28 | type test = #divisible_by i32 i32 i32 29 | 30 | def divisor (t: test) = 31 | match t case #divisible_by d _ _ -> d 32 | 33 | def do_test (t: test) (x: i64) : i32 = 34 | match t case #divisible_by d t f -> if x % i64.i32 d == 0 then t else f 35 | 36 | type op = #add i32 | #mul i32 | #square 37 | 38 | def do_op (op: op) (x: i64) : i64 = 39 | match op case #add y -> x + i64.i32 y 40 | case #mul y -> x * i64.i32 y 41 | case #square -> x * x 42 | 43 | #[noinline] 44 | def parse (s: string[]) 45 | : ?[num_items][num_monkeys].([num_monkeys]test,[num_monkeys]op,[num_items]i64,[num_items]i32) = 46 | let (get_l,ls) = lines.lines s 47 | let num_monkeys = (length ls + 7 - 1) / 7 48 | let monkey_lines i = ls[i*7:] 49 | let num_items' i = let f_ls = monkey_lines i 50 | in num_items (drop 18 (get_l f_ls[1])) 51 | let get_worry i j = let f_ls = monkey_lines i 52 | in i64.i32 (get_item j (drop 18 (get_l f_ls[1]))) 53 | let get_test i : test = let f_ls = monkey_lines i 54 | let d = atoi (drop 21 (get_l f_ls[3])) 55 | let t = atoi (drop 29 (get_l f_ls[4])) 56 | let f = atoi (drop 30 (get_l f_ls[5])) 57 | in #divisible_by d t f 58 | let get_op i = let f_ls = monkey_lines i 59 | let s = drop 23 (get_l f_ls[2]) 60 | in if s[0] == '*' then if s[2] == 'o' then #square 61 | else #mul (atoi s[2:]) 62 | else #add (atoi s[2:]) 63 | let [num_items] (worry: [num_items]i64) = expand num_items' get_worry (iota num_monkeys) 64 | let monkey = map i32.i64 (replicated_iota (map num_items' (iota num_monkeys))) 65 | let test = map get_test (iota num_monkeys) 66 | let op = map get_op (iota num_monkeys) 67 | in (test, op, worry, monkey :> [num_items]i32) 68 | 69 | def turn [num_monkeys][num_items] 70 | (relax: i64 -> i64) 71 | (test: [num_monkeys]test) (op: [num_monkeys]op) 72 | (i: i32) 73 | (worry: [num_items]i64) (monkey: [num_items]i32) : 74 | ([num_items]i64, [num_items]i32, i32) = 75 | let inspected = count (==i) monkey 76 | let move w m = 77 | if m != i then (w,m) 78 | else let w = relax (do_op op[m] w) 79 | in (w, do_test test[m] w) 80 | let (worry, monkey) = unzip (map2 move worry monkey) 81 | in (worry, monkey, inspected) 82 | 83 | def round [num_monkeys][num_items] 84 | (relax: i64 -> i64) 85 | (test: [num_monkeys]test) (op: [num_monkeys]op) 86 | (inspections: [num_monkeys]i32, worry: [num_items]i64, monkey: [num_items]i32) : 87 | ([num_monkeys]i32, [num_items]i64, [num_items]i32) = 88 | let inspections = copy inspections 89 | in loop (inspections,worry,monkey) for i < num_monkeys do 90 | let (worry, monkey, inspected) = turn relax test op (i32.i64 i) worry monkey 91 | in (inspections with [i] = inspections[i] + inspected, worry, monkey) 92 | 93 | def two_largest xs = 94 | xs 95 | |> radix_sort i32.num_bits i32.get_bit 96 | |> reverse 97 | |> take 2 98 | 99 | entry part1 s = 100 | let (test, op, worry, monkey) = parse s 101 | in iterate 20 (round (/3) test op) (map (const 0) test, worry, monkey) 102 | |> (.0) 103 | |> two_largest 104 | |> i32.product 105 | 106 | -- == 107 | -- entry: part1 108 | -- input @ data/11.input 109 | -- output { 54036 } 110 | 111 | entry part2 s = 112 | let (test, op, worry, monkey) = parse s 113 | let d = i64.i32 (i32.product (map divisor test)) 114 | in iterate 10000 (round (%d) test op) (map (const 0) test, worry, monkey) 115 | |> (.0) 116 | |> radix_sort i32.num_bits i32.get_bit 117 | |> map i64.i32 118 | |> reverse 119 | |> take 2 120 | |> i64.product 121 | 122 | -- == 123 | -- entry: part2 124 | -- input @ data/11.input 125 | -- output { 13237873355i64 } 126 | -------------------------------------------------------------------------------- /12.fut: -------------------------------------------------------------------------------- 1 | -- This is just breadth-first search. Somewhat clunky because I have 2 | -- to construct a graph. This could be simplified a lot by exploiting 3 | -- the structure of the input, but I really wanted to take a graph 4 | -- approach. 5 | 6 | import "utils" 7 | import "lib/github.com/diku-dk/segmented/segmented" 8 | import "lib/github.com/diku-dk/sorts/radix_sort" 9 | import "bfs" 10 | 11 | def find_index_of [n][m] (grid: [n][m]char) (c: char) : (i64,i64) = 12 | tabulate_2d n m (\i j -> ((i,j), grid[i,j] == c)) 13 | |> flatten 14 | |> find (.1) 15 | |> from_opt ((-1,-1),true) 16 | |> (.0) 17 | 18 | def movable [n][m] (grid: [n][m]char) (i:i64,j:i64) (x,y) = 19 | x >= 0 && x < n && y >= 0 && y < m && 20 | (grid[i,j] == 'S' || grid[x,y] == 'E' || grid[i,j] + 1 >= grid[x,y]) 21 | 22 | def node_num_edges [n][m] (grid: [n][m]char) (i,j) = 23 | i64.bool (movable grid (i,j) (i-1,j)) 24 | + i64.bool (movable grid (i,j) (i+1,j)) 25 | + i64.bool (movable grid (i,j) (i,j-1)) 26 | + i64.bool (movable grid (i,j) (i,j+1)) 27 | 28 | def to_flat [n][m] (_: [n][m]char) (i,j) = i * m + j 29 | 30 | def node_edge [n][m] (grid: [n][m]char) (i, j) (e: i64) = 31 | -- Very gross; really wish I came up with a way to write this as a 32 | -- closed form. 33 | let ps = [(i-1,j),(i+1,j),(i,j-1),(i,j+1)] 34 | in to_flat grid (filter (movable grid (i,j)) ps)[e] 35 | 36 | #[noinline] 37 | def parse_grid (s: string[]) = 38 | -- Special case the sizes so I don't have to get out my line 39 | -- splitter. 40 | let [n][m] (grid: [n][m]char) = 41 | copy (if length s == 45 42 | then s |> sized (5*9) |> unflatten |> map (take 8) 43 | else s |> sized (41*182) |> unflatten |> map (take 181)) 44 | let start = find_index_of grid 'S' 45 | let end = find_index_of grid 'E' 46 | let grid[start.0,start.1] = 'a' 47 | let grid[end.0,end.1] = 'z' 48 | in (start, end, grid) 49 | 50 | #[noinline] 51 | def parse1 (s: string[]) : ([]u8,i64,i64,graph[][]) = 52 | let [n][m] (start, end, grid: [n][m]char) = parse_grid s 53 | let coords = tabulate_2d n m (\i j -> (i,j)) |> flatten 54 | let nodes_n_edges = map (node_num_edges grid) coords 55 | let nodes_start_index = exscan (+) 0 nodes_n_edges 56 | let edges_dest = expand (node_num_edges grid) (node_edge grid) coords 57 | in (flatten grid |> matches coords, 58 | to_flat grid start, 59 | to_flat grid end, 60 | {nodes_n_edges, 61 | nodes_start_index, 62 | edges_dest}) 63 | 64 | entry part1 (s: string[]) = 65 | let (_,start,end,g) = parse1 s 66 | let costs = bfs g (map (==start) (node_indices g)) 67 | in costs[end] 68 | 69 | entry part2 (s: string[]) = 70 | let (grid,_,end,g) = parse1 s 71 | let g' = invert_graph g 72 | let costs = bfs g' (map (==end) (node_indices g)) 73 | in zip grid costs 74 | |> filter (\(x,y) -> x == 'a' && y > 0) 75 | |> map (.1) 76 | |> i32.minimum 77 | 78 | -- == 79 | -- entry: part1 80 | -- input @ data/12.input 81 | -- output { 528 } 82 | 83 | -- == 84 | -- entry: part2 85 | -- input @ data/12.input 86 | -- output { 522 } 87 | -------------------------------------------------------------------------------- /13.fut: -------------------------------------------------------------------------------- 1 | -- Futhark is extremely unsuited for this. I tried to come up with an 2 | -- allocation-free way of writing the comparison, but all I did was 3 | -- waste a bunch of hours. This is supremely inelegant and I am not 4 | -- proud of it at all. 5 | -- 6 | -- (Obv. it also crashed the compiler along the way.) 7 | 8 | import "utils" 9 | import "lib/github.com/diku-dk/sorts/merge_sort" 10 | 11 | def testinput = "[1,1,3,1,1]\n[1,1,5,1,1]\n\n[[1],[2,3,4]]\n[[1],4]\n\n[9]\n[[8,7,6]]\n\n[[4,4],4,4]\n[[4,4],4,4,4]\n\n[7,7,7,7]\n[7,7,7]\n\n[]\n[3]\n\n[[[]]]\n[[]]\n\n[1,[2,[3,[4,[5,6,7]]]],8,9]\n[1,[2,[3,[4,[5,6,0]]]],8,9]\n" 12 | 13 | def cmp [n][m] (a: string[n]) (b: string[m]): bool = 14 | let (ok, _, _, _) = 15 | loop (ok, done, a: string[], b: string[]) = (true,false,a,b) while !done do 16 | let end r = (r,true,[],[]) 17 | in if length a == 0 18 | then (true,true,a,b) 19 | else if is_digit a[0] && is_digit b[0] then 20 | let x = atoi a 21 | let y = atoi b 22 | in if x < y then end true 23 | else if y < x then end false 24 | else let (_,a) = span isnt_digit a 25 | let (_,b) = span isnt_digit b 26 | in (ok,false,a,b) 27 | else match (a[0], b[0]) 28 | case ('[', '[') -> (ok,false,drop 1 a,drop 1 b) 29 | case (']', ']') -> (ok,false,drop 1 a,drop 1 b) 30 | case (']', _) -> end true 31 | case (_, ']') -> end false 32 | case ('[', _) -> let (x,y) = span isnt_digit b 33 | in (ok,false,a,"[" ++ x ++ "]" ++ y) 34 | case (_, '[') -> let (x,y) = span isnt_digit a 35 | in (ok,false,"[" ++ x ++ "]" ++ y, b) 36 | case _ -> (ok,false,drop 1 a,drop 1 b) 37 | in ok 38 | 39 | entry part1 s = 40 | let (get,ls) = lines.lines s 41 | let n = (length ls + 3 - 1) / 3 42 | let relevant = tabulate n (\i -> (ls[i * 3], ls[i*3+1])) 43 | let ok (a,b) = cmp (get a) (get b) 44 | in relevant 45 | |> (id &&& indices) 46 | |> uncurry zip 47 | |> filter (ok <-< (.0)) 48 | |> map (.1) 49 | |> map (+1) 50 | |> i64.sum 51 | 52 | def streq [n][m] (a: string[n]) (b: string[m]): bool = 53 | n == m && all (uncurry (==)) (zip (exactly m a) b) 54 | 55 | entry part2 s = 56 | let (get,ls) = lines.lines (s ++ "\n[[2]]\n[[6]]\n") 57 | let n = (length ls + 3 - 1) / 3 58 | let relevant = tabulate n (\i -> [ls[i * 3], ls[i*3+1]]) |> flatten 59 | let sorted = relevant |> merge_sort (\a b -> cmp (get a) (get b)) 60 | in match (find (\(_,l) -> streq (get l) "[[2]]") (zip (indices sorted) sorted), 61 | find (\(_,l) -> streq (get l) "[[6]]") (zip (indices sorted) sorted)) 62 | case (#some (a,_), #some (b,_)) -> (a+1)*(b+1) 63 | case _ -> -1 64 | 65 | -- == 66 | -- entry: part1 67 | -- input @ data/13.input 68 | -- output { 5808i64 } 69 | 70 | -- == 71 | -- entry: part2 72 | -- input @ data/13.input 73 | -- output { 22713i64 } 74 | -------------------------------------------------------------------------------- /14.fut: -------------------------------------------------------------------------------- 1 | -- Only the input parsing is parallel here. I suspect the search 2 | -- could also be parallelised, at least when falling down, but it is 3 | -- probably not worth it. This program also uncovered a compiler bug 4 | -- (#1798). 5 | 6 | import "utils" 7 | import "lib/github.com/diku-dk/segmented/segmented" 8 | 9 | type pos = (i32,i32) 10 | 11 | def linesegs (s: string[]) : [](pos,pos) = 12 | let (get,fs) = splits.splits (=='-') s 13 | let on_f f = let fs = get f 14 | let fs = if fs[0] == '>' then drop 2 fs else fs 15 | let (x,y) = span isnt_digit fs 16 | in (atoi x, atoi (drop 1 y)) 17 | in map on_f fs |> (id &&& rotate 1) |> uncurry zip |> init 18 | 19 | def parse (s: string[]) = 20 | let (get,ls) = lines.lines s 21 | let max_segs = 100 22 | let noseg = ((-1,-1),(-1,-1)) 23 | let get_segs l = pad_to max_segs noseg (linesegs (get l)) 24 | in map get_segs ls |> flatten |> filter (!=noseg) 25 | 26 | def air: u8 = '.' 27 | def rock: u8 = '#' 28 | def sand: u8 = 'o' 29 | 30 | def drop [rows][cols] (x,y) (world: [rows][cols]u8) = 31 | let (x,y,_) = 32 | loop (x,y,continue) = (x,y,true) while continue do 33 | if x == 0 || x == cols-1 then (cols,y,false) 34 | else if y == rows-1 then (x,rows,false) 35 | else if world[y+1,x] == air then (x,y+1,true) 36 | else if world[y+1,x-1] == air then (x-1,y+1,true) 37 | else if world[y+1,x+1] == air then (x+1,y+1,true) 38 | else (x,y,false) 39 | in (x,y) 40 | 41 | def sim [rows][cols] (x,y) (world: [rows][cols]u8) : i32 = 42 | let (_,i,_) = 43 | loop (world,i,continue) = (copy world,0,true) while continue do 44 | let (x,y) = drop (x,y) world 45 | in if x == cols || y == rows then (world, i, false) 46 | else (world with [y,x] = sand, i+1, true) 47 | in i 48 | 49 | def mkworld s = 50 | let linelength ((x1,y1),(x2,y2)) = 51 | i64.i32 (if x1 == x2 52 | then i32.abs(y2 - y1)+1 53 | else i32.abs(x2 - x1)+1) 54 | let coord ((x1,y1),(x2,y2)) i = 55 | if x1 == x2 56 | then (x1,y1+i32.i64 i*(i32.sgn(y2-y1))) 57 | else (x1+i32.i64 i*(i32.sgn(x2-x1)),y1) 58 | let lines = parse s 59 | let max_x = i64.i32 (i32.maximum (map (\((x1,_),(x2,_)) -> i32.max x1 x2) lines)) 60 | let max_y = i64.i32 (i32.maximum (map (\((_,y1),(_,y2)) -> i32.max y1 y2) lines)) 61 | let flat (x,y) = i64.i32 y*(max_x+1)+i64.i32 x 62 | let rocks = expand linelength coord lines 63 | in spread ((max_y+1)*(max_x+1)) air (map flat rocks) (map (const rock) rocks) 64 | |> unflatten 65 | 66 | entry part1 s = sim (500,0) (mkworld s) 67 | 68 | def sim2 [rows][cols] (x,y) (world: [rows][cols]u8) : i32 = 69 | let (_,i,_) = 70 | loop (world,i,continue) = (copy world,0,true) while continue do 71 | let (x',y') = drop (x,y) world 72 | in if (x',y') == (x,y) then (world, i+1, false) 73 | else (world with [y',x'] = sand, i+1, true) 74 | in i 75 | 76 | entry part2 s = 77 | let [rows][cols] (world: [rows][cols]u8) = mkworld s 78 | let padding = cols -- Ugly! But probably enough. 79 | let cols' = cols + padding*2 80 | in sim2 (500+padding,0) 81 | (world 82 | |> map (\r -> replicate padding air ++ r ++ replicate padding air :> [cols']u8) 83 | |> (++[replicate cols' air, replicate cols' rock])) 84 | 85 | -- == 86 | -- entry: part1 87 | -- input @ data/14.input 88 | -- output { 892 } 89 | 90 | -- == 91 | -- entry: part2 92 | -- input @ data/14.input 93 | -- output { 27155 } 94 | -------------------------------------------------------------------------------- /15.fut: -------------------------------------------------------------------------------- 1 | -- This one is a lovely parallel implementation. Seems a bit slow, so 2 | -- I'm probably missing some algorithmic trick. Oh well. 3 | 4 | import "utils" 5 | import "lib/github.com/diku-dk/segmented/segmented" 6 | 7 | def testinput = "Sensor at x=2, y=18: closest beacon is at x=-2, y=15\nSensor at x=9, y=16: closest beacon is at x=10, y=16\nSensor at x=13, y=2: closest beacon is at x=15, y=3\nSensor at x=12, y=14: closest beacon is at x=10, y=16\nSensor at x=10, y=20: closest beacon is at x=10, y=16\nSensor at x=14, y=17: closest beacon is at x=10, y=16\nSensor at x=8, y=7: closest beacon is at x=2, y=10\nSensor at x=2, y=0: closest beacon is at x=2, y=10\nSensor at x=0, y=11: closest beacon is at x=2, y=10\nSensor at x=20, y=14: closest beacon is at x=25, y=17\nSensor at x=17, y=20: closest beacon is at x=21, y=22\nSensor at x=16, y=7: closest beacon is at x=15, y=3\nSensor at x=14, y=3: closest beacon is at x=15, y=3\nSensor at x=20, y=1: closest beacon is at x=15, y=3\n" 8 | 9 | type pos = {x:i32,y:i32} 10 | 11 | def manhattan (a:pos) (b:pos) = 12 | i32.abs (a.x-b.x) + i32.abs(a.y-b.y) 13 | 14 | #[noinline] 15 | def parse (s: string[]) = 16 | let (get_l,ls) = lines.lines s 17 | let on_line l = let (get_w, ws) = words.words (get_l l) 18 | let sensor = {x=atoi (drop 2 (get_w ws[2])), 19 | y=atoi (drop 2 (get_w ws[3]))} 20 | let beacon = {x=atoi (drop 2 (get_w ws[8])), 21 | y=atoi (drop 2 (get_w ws[9]))} 22 | in (sensor, beacon) 23 | in map on_line ls 24 | 25 | def distances haystack needle = map (manhattan needle) haystack 26 | 27 | def find_closest haystack needle = 28 | distances haystack needle |> argmin (<=) |> (\i -> (i, haystack[i])) 29 | 30 | def num_surface_points r : i32 = r * 4 31 | 32 | def surface_point (p: pos) r (i: i64) = 33 | let m = num_surface_points r 34 | let i = i32.i64 i 35 | in {x=(p.x-r) + (i+1)/2, 36 | y=p.y + if i < m/2 37 | then ((i+1)/2 * if i % 2 == 1 then -1 else 1) 38 | else ((m-i)/2 * if i % 2 == 1 then -1 else 1)} 39 | 40 | def covered sensors closest p = 41 | any (\(s,b) -> manhattan s b >= manhattan s p) (zip sensors closest) 42 | 43 | def is_beacon beacons p = 44 | i32.minimum (distances beacons p) == 0 45 | 46 | entry part1 s = 47 | let (sensors,beacons) = unzip (parse s) 48 | let closest = map (find_closest beacons) sensors 49 | let min_x = map2 (\a d -> (a.x - manhattan a d.1)) sensors closest |> i32.minimum 50 | let max_x = map2 (\a d -> (a.x + manhattan a d.1)) sensors closest |> i32.maximum 51 | let no_beacon p = covered sensors (map (.1) closest) p && not (is_beacon beacons p) 52 | in iota (i64.i32 (max_x-min_x)) 53 | |> map i32.i64 54 | |> map (+min_x) 55 | |> map (\x -> {x,y=2000000}) 56 | |> count no_beacon 57 | 58 | entry part2 s = 59 | let (sensors,beacons) = unzip (parse s) 60 | let closest = map (find_closest beacons) sensors 61 | let ok p = p.x >= 0 && p.x <= 4000000 && p.y >= 0 && p.y <= 4000000 && 62 | not (covered sensors (map (.1) closest) p) && 63 | not (is_beacon beacons p) 64 | in map2 (\s (_,b) -> (s,manhattan s b)) sensors closest 65 | |> expand (\(_,r) -> i64.i32(num_surface_points (r+1))) 66 | (\(s,r) i -> surface_point s (r+1) i) 67 | |> find ok 68 | |> from_opt {x= -1, y= -1} 69 | |> (\{x,y} -> i64.i32 x * 4000000 + i64.i32 y) 70 | 71 | -- == 72 | -- entry: part1 73 | -- input @ data/15.input 74 | -- output { 5125700 } 75 | 76 | -- == 77 | -- entry: part2 78 | -- input @ data/15.input 79 | -- output { 11379394658764i64 } 80 | 81 | -------------------------------------------------------------------------------- /16.fut: -------------------------------------------------------------------------------- 1 | -- I did not enjoy this one at all. I am considering giving up on 2 | -- AOC. I really wish these problems were calibrated to be solvable 3 | -- without too much time investment; I'm just looking for fun little 4 | -- tasks to do every day in December! I have enough real challenges 5 | -- at my job. 6 | 7 | import "utils" 8 | 9 | type valve = {flow: i32, tunnels: [5]i64} 10 | 11 | def far: i32 = 1000000 12 | 13 | def adjacency [n] (vs: [n]valve): [n][n]i32 = 14 | let on_node i v = spread n far v.tunnels (map (const 1) v.tunnels) with [i] = 0 15 | in map2 on_node (indices vs) vs 16 | 17 | def update [n] (adj: [n][n]i32) = 18 | tabulate_2d n n (\i j -> i32.minimum (map2 (+) adj[i] adj[:,j])) 19 | 20 | def find_paths [n] (adj: [n][n]i32) = 21 | (.0) <| 22 | loop (adj,go) = (adj,true) while go do 23 | let adj' = update adj 24 | in (adj', map2 (map2 (!=)) adj adj' |> flatten |> or) 25 | 26 | def shrink [n] (keep: i64) (flow: [n]i32) (adj: [n][n]i32) = 27 | let keep = map2 (\i f -> i == keep || f > 0) (indices flow) flow 28 | let n' = i64.i32 (count id keep) 29 | let shrink' l = zip keep l |> filter (.0) |> map (.1) |> exactly n' 30 | in (shrink' flow, 31 | adj |> map shrink' |> shrink') 32 | 33 | #[noinline] 34 | def parse s : (i64,[]valve) = 35 | let (get,ls) = lines.lines s 36 | let mkcode a b = i32.u8 a*256 + i32.u8 b 37 | let on_line l = 38 | let ls = get l 39 | let code = mkcode ls[6] ls[7] 40 | let flow = atoi (drop 23 ls) 41 | let tunnels = if ls[49] == ' ' then drop 50 ls else drop 49 ls 42 | let mktunnel i = let j = i * 4 43 | in if j < length tunnels then mkcode tunnels[j] tunnels[j+1] 44 | else -1 45 | in (code, {flow, tunnels=tabulate 5 mktunnel}) 46 | let (codes, valves) = unzip (map on_line ls) 47 | let start = zip codes (indices codes) 48 | |> find ((.0) >-> (==mkcode 'A' 'A')) 49 | |> from_opt (-1,-1) 50 | |> (.1) 51 | let link' x = if x == -1 then -1 else index_of_first (==x) codes 52 | let link {flow,tunnels} = {flow,tunnels=map link' tunnels} 53 | in (start,map link valves) 54 | 55 | def eval_step [n] (flow: [n]i32) (adj: [n][n]i32) 56 | (value: i32) (here: i32) (remaining: i32) 57 | (there: i32) = 58 | let t = adj[here,there] + 1 59 | let remaining = remaining - t 60 | in (value + remaining * flow[there], 61 | there, 62 | remaining) 63 | 64 | type path = {visited:u64,remaining:i32,value:i32,here:i32} 65 | 66 | def invalid (p: path) = p.remaining < 0 67 | 68 | def next_node (visited: u64) (j: i64) : i32 = 69 | (loop (i,j) = (0,j) while u64.get_bit i visited != 0 || j > 0 do 70 | (i+1,if u64.get_bit i visited==0 then j-1 else j)) 71 | |> (.0) 72 | 73 | def grow [n] (flow: [n]i32) (adj: [n][n]i32) (i: i64) (p: path) : []path = 74 | tabulate (n-i) (\j -> 75 | let next = next_node p.visited j 76 | let (value,there,remaining) = 77 | eval_step flow adj p.value p.here p.remaining next 78 | in {visited=u64.set_bit next p.visited 1, 79 | remaining, 80 | value, 81 | here=there}) 82 | 83 | def evolve [n] (flow: [n]i32) (adj: [n][n]i32) (ps: []path) : []path = 84 | (loop (done,front,i) = ([],ps,0) while i < n do 85 | let n' = n-i 86 | let new = filter (invalid >-> not) 87 | (flatten (map (\p -> grow flow adj i p |> exactly n') front)) 88 | in (done ++ front, new, i+1)) 89 | |> (\(done,front,_) -> done ++ front) 90 | 91 | #[noinline] 92 | def process s = 93 | let (start,vs) = parse s 94 | let [n] (flow : [n]i32,adj : [n][n]i32) = 95 | adjacency vs |> find_paths |> shrink start (map (.flow) vs) 96 | let start = if start == 0 then 0 else i32.i64 (n-1) 97 | in (start, flow, adj) 98 | 99 | #[noinline] 100 | def solve start flow adj remaining = 101 | let res = evolve flow adj [{visited=0, 102 | here=start, 103 | remaining, 104 | value=0}] 105 | in res 106 | 107 | entry part1 s = 108 | let (start,flow,adj) = process s 109 | let res = solve start flow adj 30 110 | in map (.value) res |> i32.maximum 111 | 112 | entry part2 s = 113 | let (start,flow,adj) = process s 114 | let p1s = solve start flow adj 26 115 | let p2s = solve start flow adj 26 116 | let compatible p1 p2 = (p1.visited & p2.visited) == 0 117 | let best_of p1 = 118 | i32.maximum (map (\p2 -> if compatible p1 p2 then p1.value + p2.value else 0) p2s) 119 | in map best_of p1s |> i32.maximum 120 | 121 | -- == 122 | -- entry: part1 123 | -- input @ data/16.input 124 | -- output { 2265i32 } 125 | 126 | -- == 127 | -- entry: part2 128 | -- input @ data/16.input 129 | -- output { 2811i32 } 130 | -------------------------------------------------------------------------------- /17.fut: -------------------------------------------------------------------------------- 1 | -- This is the one; the most sequential one of them all. Even the 2 | -- input has no parallelism to exploit! 3 | -- 4 | -- Neither me nor Futhark is suitable for this kind of programming. 5 | 6 | import "utils" 7 | 8 | def width (piece: i64) : i64 = 9 | match piece 10 | case 0 -> 4 11 | case 1 -> 3 12 | case 2 -> 3 13 | case 3 -> 1 14 | case _ -> 2 15 | 16 | def height (piece: i64) : i64 = 17 | match piece 18 | case 0 -> 1 19 | case 1 -> 3 20 | case 2 -> 3 21 | case 3 -> 4 22 | case _ -> 2 23 | 24 | def space [h] (piece: i64) ((x,y):(i64,i64)) (world: [h][7]char) = 25 | x >= 0 && x <= 7 - width piece && y - height piece + 1 >= 0 && 26 | match piece 27 | case 0 -> 28 | world[h-1-y,x+0] + world[h-1-y,x+1] + world[h-1-y,x+2] + world[h-1-y,x+3] == 0 29 | case 1 -> 30 | world[h-1-(y-0),x+1] + world[h-1-(y-1),x+0] + world[h-1-(y-1),x+1] + world[h-1-(y-1),x+2] + world[h-1-(y-2),x+1] == 0 31 | case 2 -> 32 | world[h-1-(y-0),x+2] + world[h-1-(y-1),x+2] + world[h-1-(y-2),x+0] + world[h-1-(y-2),x+1] + world[h-1-(y-2),x+2] == 0 33 | case 3 -> 34 | world[h-1-(y-0),x] + world[h-1-(y-1),x] + world[h-1-(y-2),x] + world[h-1-(y-3),x] == 0 35 | case 4 -> 36 | world[h-1-(y-0),x+0] + world[h-1-(y-1),x+0] + world[h-1-(y-0),x+1] + world[h-1-(y-1),x+1] == 0 37 | case _ -> assert false false 38 | 39 | def push piece (x,y) (dir: u8) world = 40 | let x' = if dir == '<' then x-1 else x+1 41 | in if space piece (x',y) world then (x',y) else (x,y) 42 | 43 | def fall piece (x,y) world : opt (i64,i64) = 44 | if space piece (x,y-1) world then #some (x,y-1) else #none 45 | 46 | def put_piece [h] (piece: i64) ((x,y):(i64,i64)) (world: *[h][7]char) = 47 | match piece 48 | case 0 -> world with [h-1-y,x+0] = 1 49 | with [h-1-y,x+1] = 1 50 | with [h-1-y,x+2] = 1 51 | with [h-1-y,x+3] = 1 52 | case 1 -> world with [h-1-(y-0),x+1] = 1 53 | with [h-1-(y-1),x+0] = 1 54 | with [h-1-(y-1),x+1] = 1 55 | with [h-1-(y-1),x+2] = 1 56 | with [h-1-(y-2),x+1] = 1 57 | case 2 -> world with [h-1-(y-0),x+2] = 1 58 | with [h-1-(y-1),x+2] = 1 59 | with [h-1-(y-2),x+0] = 1 60 | with [h-1-(y-2),x+1] = 1 61 | with [h-1-(y-2),x+2] = 1 62 | case 3 -> world with [h-1-(y-0),x] = 1 63 | with [h-1-(y-1),x] = 1 64 | with [h-1-(y-2),x] = 1 65 | with [h-1-(y-3),x] = 1 66 | case 4 -> world with [h-1-(y-0),x+0] = 1 67 | with [h-1-(y-1),x+0] = 1 68 | with [h-1-(y-0),x+1] = 1 69 | with [h-1-(y-1),x+1] = 1 70 | case _ -> assert false world 71 | 72 | def place [h] [j] 73 | (J: [j]u8) 74 | (T: *[h][7]u8) (jet: i64) (piece: i64) (maxy: i64) : 75 | (*[h][7]u8, i64, i64, i64) = 76 | let pos = (2, maxy + 3 + height piece) 77 | let (_, pos, jet) = 78 | loop (go,pos,jet) = (true,pos,jet) while go do 79 | let pos = push piece pos J[jet%j] T 80 | in match fall piece pos T 81 | case #some pos -> (true,pos,(jet+1)%j) 82 | case #none -> (false,pos,(jet+1)%j) 83 | in (put_piece piece pos T, jet, (piece+1)%5, i64.max maxy pos.1) 84 | 85 | def ground_shape [h] (T: [h][7]u8) (maxy: i64): opt u64 = 86 | let T' = T[h-1-maxy:] 87 | let get r i = r[i] << u8.i32 i 88 | let mask r = u64.u8 (get r 0 | get r 1 | get r 2 | get r 3 | get r 4 | get r 5 | get r 6) 89 | in if length T' >= 4 90 | then let (a,b,c,d) = (mask T'[0], mask T'[1], mask T'[2], mask T'[3]) 91 | in if a|b|c|d == 0b1111111 92 | then #some ((a << 0) | (b << 8) | (c << 16) | (d << 24)) 93 | else #none 94 | else #none 95 | 96 | type cycle = ((i64,i64,u64), (i64,i64)) 97 | 98 | def find_cycle [c] (cycles: [c]cycle) (num_cycles: i64) (key: (i64,i64,u64)) : opt (i64,i64) = 99 | match find ((.0) >-> (==key)) (take num_cycles cycles) 100 | case #none -> #none 101 | case #some (_,v) -> #some v 102 | 103 | #[noinline] 104 | def solve [j] (J: [j]u8) (count: i64) = 105 | let h = 20000 106 | let c = 20000 107 | let T = replicate h (replicate 7 0) 108 | let cycles = replicate c ((0,0,0), (0,0)) 109 | let num_cycles = 0 110 | let (jet, maxy, piece, additional) = (0,-1,0,0) 111 | let (_, _, _, _, additional, maxy, _, _) = 112 | loop (count, T, jet, piece, additional, maxy, cycles, num_cycles) while count > 0 do 113 | let (T, jet, piece, maxy) = place J T jet piece maxy 114 | let count = count - 1 115 | in match ground_shape T maxy 116 | case #some mask -> 117 | let (additional, count) = 118 | match find_cycle cycles num_cycles (jet,piece,mask) 119 | case #some (oldmaxy, oldcount) -> 120 | let additional = additional + (maxy - oldmaxy) * (count / (oldcount - count)) 121 | let count = count % (oldcount - count) 122 | in (additional, count) 123 | case #none -> (additional, count) 124 | let cycles[num_cycles] = ((jet, piece, mask), (maxy, count)) 125 | let num_cycles = num_cycles + 1 126 | in (count, T, jet, piece, additional, maxy, cycles, num_cycles) 127 | case #none -> (count, T, jet, piece, additional, maxy, cycles, num_cycles) 128 | in additional + maxy + 1 129 | 130 | entry part1 s = solve (init s) 2022 131 | 132 | entry part2 s = solve (init s) 1000000000000 133 | 134 | -- == 135 | -- entry: part1 136 | -- input @ data/17.input 137 | -- output { 3130i64 } 138 | 139 | -- == 140 | -- entry: part2 141 | -- input @ data/17.input 142 | -- output { 1556521739139i64 } 143 | -------------------------------------------------------------------------------- /18.fut: -------------------------------------------------------------------------------- 1 | -- Second part is solved with a stencil. The most efficient solution 2 | -- is probably more like a BFS, but pretty proud I made it this far 3 | -- without turning to inefficient stencils! 4 | 5 | import "utils" 6 | 7 | type cube = {x:i32,y:i32,z:i32} 8 | 9 | def parse (s: string[]) : []cube = 10 | let (get,ls) = lines.lines s 11 | let f l = let ls = get l 12 | let (x,ls) = span (==',') ls 13 | let (y,ls) = span (==',') (drop 1 ls) 14 | let z = drop 1 ls 15 | in {x=atoi x, y=atoi y, z=atoi z} 16 | in map f ls 17 | 18 | def adjacent (c1: cube) (c2: cube) = 19 | c2 == (c1 with x = c1.x + 1) || 20 | c2 == (c1 with x = c1.x - 1) || 21 | c2 == (c1 with y = c1.y + 1) || 22 | c2 == (c1 with y = c1.y - 1) || 23 | c2 == (c1 with z = c1.z + 1) || 24 | c2 == (c1 with z = c1.z - 1) 25 | 26 | entry part1 s = 27 | let cubes = parse s 28 | in map (\c -> 6-count (adjacent c) cubes) cubes |> i32.sum 29 | 30 | type cell = #air | #steam | #cube 31 | 32 | def evolve [nx][ny][nz] (grid: [nx][ny][nz]cell) = 33 | let steam (x,y,z) = grid[x,y,z] == #steam 34 | let f x y z : cell = 35 | match grid[x,y,z] 36 | case #air -> 37 | if steam (x-1,y,z)||steam (x+1,y,z)|| 38 | steam (x,y-1,z)||steam (x,y+1,z)|| 39 | steam (x,y,z-1)||steam (x,y,z+1) 40 | then #steam 41 | else #air 42 | case #cube -> #cube 43 | case #steam -> #steam 44 | in tabulate_3d nx ny nz f 45 | 46 | def put_cubes [nx][ny][nz] (grid: *[nx][ny][nz]cell) (cubes: []cube) = 47 | let flat_idx c = 48 | i64.i32 c.x * (ny*nz) + i64.i32 c.y * nz + i64.i32 c.z 49 | in scatter (flatten_3d grid) (map flat_idx cubes) (map (const #cube) cubes) 50 | |> sized (nx*ny*nz) |> unflatten_3d 51 | 52 | def find_steam nx ny nz cubes : [nx][ny][nz]bool = 53 | let grid = tabulate_3d nx ny nz 54 | (\x y z -> if x == 0 || y == 0 || z == 0 || 55 | x == nx-1 || y == ny-1 || z == nz-1 56 | then #steam else #air) 57 | let grid = put_cubes grid cubes 58 | let go = true 59 | let (grid,_) = loop (grid, go) while go do 60 | let grid' = evolve grid 61 | in (grid', or (flatten_3d (map2 (map2 (map2 (!=))) grid grid'))) 62 | let is_steam x = match x case #steam -> true 63 | case _ -> false 64 | in map (map (map is_steam)) grid 65 | 66 | entry part2 s = 67 | let cubes = parse s 68 | let nx = map (.x) cubes |> i32.maximum |> (+3) |> i64.i32 69 | let ny = map (.y) cubes |> i32.maximum |> (+3) |> i64.i32 70 | let nz = map (.z) cubes |> i32.maximum |> (+3) |> i64.i32 71 | let steam = find_steam nx ny nz cubes 72 | let at (x,y,z) = if x < 0 || y < 0 || z < 0 then 1 else i32.bool steam[x,y,z] 73 | let count_steam c = at(c.x-1,c.y,c.z) + at(c.x+1,c.y,c.z) + 74 | at(c.x,c.y-1,c.z) + at(c.x,c.y+1,c.z) + 75 | at(c.x,c.y,c.z-1) + at(c.x,c.y,c.z+1) 76 | in map count_steam cubes |> i32.sum 77 | 78 | -- == 79 | -- entry: part1 80 | -- input @ data/18.input 81 | -- output { 3466 } 82 | 83 | -- == 84 | -- entry: part2 85 | -- input @ data/18.input 86 | -- output { 2012 } 87 | -------------------------------------------------------------------------------- /19.fut: -------------------------------------------------------------------------------- 1 | -- BFS with little meaningful pruning. Not proud of this one. Takes 2 | -- a while to run and requires a lot of memory. Memory usage kept 3 | -- down by using 8-bit counters. Some crude deduplication. 4 | -- 5 | -- This one is possibly too slow to run in GitHub Actions. 6 | 7 | import "utils" 8 | 9 | def testinput = "Blueprint 1: Each ore robot costs 4 ore. Each clay robot costs 2 ore. Each obsidian robot costs 3 ore and 14 clay. Each geode robot costs 2 ore and 7 obsidian.\nBlueprint 2: Each ore robot costs 2 ore. Each clay robot costs 3 ore. Each obsidian robot costs 3 ore and 8 clay. Each geode robot costs 3 ore and 12 obsidian.\n" 10 | 11 | type blueprint = {ore:u8,clay:u8,obsidian:(u8,u8),geode:(u8,u8)} 12 | 13 | #[noinline] 14 | def parse (s: string[]) : []blueprint = 15 | let (get,ls) = lines.lines s 16 | let f l = let ls = drop 20 (get l) 17 | let (_,ls) = span is_digit ls 18 | let (a,ls) = span isnt_digit ls 19 | let (_,ls) = span is_digit ls 20 | let (b,ls) = span isnt_digit ls 21 | let (_,ls) = span is_digit ls 22 | let (c,ls) = span isnt_digit ls 23 | let (_,ls) = span is_digit ls 24 | let (d,ls) = span isnt_digit ls 25 | let (_,ls) = span is_digit ls 26 | let (e,ls) = span isnt_digit ls 27 | let (_,ls) = span is_digit ls 28 | let (f,_) = span isnt_digit ls 29 | in {ore=u8.i32 (atoi a), 30 | clay=u8.i32 (atoi b), 31 | obsidian=(u8.i32(atoi c),u8.i32(atoi d)), 32 | geode=(u8.i32(atoi e), u8.i32(atoi f))} 33 | in map f ls 34 | 35 | type res = {ore:u8,clay:u8,obsidian:u8,geode:u8} 36 | 37 | def empty_res : res = {ore=0,clay=0,obsidian=0,geode=0} 38 | 39 | def add_res (a: res) (b: res) = 40 | {ore=a.ore + b.ore, 41 | clay = a.clay + b.clay, 42 | obsidian = a.obsidian + b.obsidian, 43 | geode = a.geode + b.geode} 44 | 45 | def sub_res (a: res) (b: res) = 46 | {ore=a.ore - b.ore, 47 | clay = a.clay - b.clay, 48 | obsidian = a.obsidian - b.obsidian, 49 | geode = a.geode - b.geode} 50 | 51 | type plan = {prod:res,stash:res} 52 | 53 | def ore_cost (b: blueprint) : res = empty_res with ore = b.ore 54 | 55 | def clay_cost (b: blueprint) : res = empty_res with ore = b.clay 56 | 57 | def obsidian_cost (b: blueprint) : res = empty_res with ore = b.obsidian.0 58 | with clay = b.obsidian.1 59 | 60 | def geode_cost (b: blueprint) : res = empty_res with ore = b.geode.0 61 | with obsidian = b.geode.1 62 | 63 | def max_ore_cost (b: blueprint) = 64 | b.ore `u8.max` b.clay `u8.max` b.obsidian.0 `u8.max` b.geode.0 65 | 66 | def grow (b: blueprint) (p: plan) : [5](bool,plan) = 67 | let build_ore = b.ore <= p.stash.ore 68 | let build_clay = b.clay <= p.stash.ore 69 | let build_obsidian = b.obsidian.0 <= p.stash.ore && b.obsidian.1 <= p.stash.clay 70 | let build_geode = b.geode.0 <= p.stash.ore && b.geode.1 <= p.stash.obsidian 71 | in [(!build_geode && p.stash.ore < 2*max_ore_cost b, 72 | p with stash = add_res p.stash p.prod), 73 | (!build_geode && build_ore && p.prod.ore < max_ore_cost b, 74 | p with stash = (add_res p.stash p.prod `sub_res` ore_cost b) 75 | with prod = (p.prod with ore = p.prod.ore + 1)), 76 | (!build_geode && build_clay && p.prod.clay < b.obsidian.1, 77 | p with stash = (add_res p.stash p.prod `sub_res` clay_cost b) 78 | with prod = (p.prod with clay = p.prod.clay + 1)), 79 | (!build_geode && build_obsidian && p.prod.obsidian < b.geode.1, 80 | p with stash = (add_res p.stash p.prod `sub_res` obsidian_cost b) 81 | with prod = (p.prod with obsidian = p.prod.obsidian + 1)), 82 | (build_geode, 83 | p with stash = (add_res p.stash p.prod `sub_res` geode_cost b) 84 | with prod = (p.prod with geode = p.prod.geode + 1))] 85 | 86 | def prune (ps: []plan) : []plan = 87 | let g = u8.maximum (map (.prod.geode) ps) 88 | let min = if g > 0 then g-1 else g 89 | in filter ((.prod.geode) >-> (>=min)) ps 90 | 91 | def res_lt (a: res) (b: res) = 92 | let word x = 93 | u32.u8 x.ore | (u32.u8 x.clay<<8) | (u32.u8 x.obsidian<<16) | (u32.u8 x.geode<<24) 94 | in word a < word b 95 | 96 | def res_lte (a: res) (b: res) = 97 | res_lt a b || a == b 98 | 99 | def plan_lte (a: plan) (b: plan): bool = 100 | if a.prod `res_lt` b.prod 101 | then true 102 | else if a.prod == b.prod 103 | then a.stash `res_lte` b.stash 104 | else false 105 | 106 | def evolve (t: i32) (b: blueprint) (ps: []plan) : []plan = 107 | loop ps for _i < t do 108 | ps 109 | |> map (grow b) 110 | |> flatten 111 | |> filter (.0) 112 | |> map (.1) 113 | |> prune 114 | |> dedup (==) plan_lte 115 | 116 | entry part1 s = 117 | let bs = parse s 118 | let best i b = 119 | #[sequential] 120 | evolve 24 b [{prod=empty_res with ore = 1,stash=empty_res}] 121 | |> map (.stash.geode) |> map i32.u8 |> i32.maximum |> (*i32.i64 (i+1)) 122 | in map2 best (indices bs) bs |> i32.sum 123 | 124 | entry part2 s = 125 | let bs = parse s 126 | let best b = 127 | evolve 32 b [{prod=empty_res with ore = 1,stash=empty_res}] 128 | |> map (.stash.geode) |> map i32.u8 |> i32.maximum 129 | in map best (take 3 bs) |> foldl (*) 1 130 | 131 | -- == 132 | -- entry: part1 133 | -- input @ data/19.input 134 | -- output { 1616 } 135 | 136 | -- == 137 | -- entry: part2 138 | -- input @ data/19.input 139 | -- output { 8990 } 140 | -------------------------------------------------------------------------------- /2.fut: -------------------------------------------------------------------------------- 1 | -- A bit repetitive, but very straightforward and trivial parallelism. 2 | 3 | import "utils" 4 | 5 | def parse [n] (s: string[n]) = 6 | sized ((n/4)*4) s |> unflatten |> map (\l -> (l[0], l[2] - 'X' + 'A')) 7 | 8 | def shape_score (s: u8) : i32 = 9 | match s case 'A' -> 1 10 | case 'B' -> 2 11 | case 'C' -> 3 12 | case _ -> 0 13 | 14 | def score (c: u8, r: u8) = 15 | shape_score r + 16 | match (c,r) 17 | case ('A', 'B') -> 6 18 | case ('A', 'C') -> 0 19 | case ('B', 'C') -> 6 20 | case ('B', 'A') -> 0 21 | case ('C', 'A') -> 6 22 | case ('C', 'B') -> 0 23 | case _ -> 3 24 | 25 | def counter (c: u8, o: u8) = 26 | (c, 27 | match (c,o) 28 | case ('A', 'A') -> 'C' 29 | case ('A', 'C') -> 'B' 30 | case ('B', 'A') -> 'A' 31 | case ('B', 'C') -> 'C' 32 | case ('C', 'A') -> 'B' 33 | case ('C', 'C') -> 'A' 34 | case _ -> c) 35 | 36 | entry part1 s = s |> parse |> map score |> i32.sum 37 | entry part2 s = s |> parse |> map counter |> map score |> i32.sum 38 | 39 | -- == 40 | -- entry: part1 41 | -- input @ data/2.input 42 | -- output { 12156 } 43 | 44 | -- == 45 | -- entry: part2 46 | -- input @ data/2.input 47 | -- output { 10835 } 48 | -------------------------------------------------------------------------------- /20.fut: -------------------------------------------------------------------------------- 1 | -- Oh no, this is very inappropriate for arrays, but I am much too 2 | -- tired to implement a doubly linked list for this. 3 | -- 4 | -- I had hoped to do something parallel here, via a composition of 5 | -- permutations, but I'm not sure it would actually work. 6 | 7 | import "utils" 8 | 9 | def parse (s: string[]) = 10 | let (get,ls) = lines.lines s 11 | in map (\l -> i64.i32 (atoi (get l))) ls 12 | 13 | def shift [n] 'a (from: i64) (d: i64) (A: [n]a): [n]a = 14 | if d >= 0 && from+d < n 15 | then tabulate n (\i -> A[if i == from+d then from 16 | else if i < from then i 17 | else if i < from+d then i+1 18 | else i]) 19 | else if d > 0 && from + d >= n 20 | then tabulate n (\i -> A[if i < (from+d)%n then i 21 | else if i == (from+d+1)%n then from 22 | else if i > (from+d)%n && i <= from then i-1 23 | else i]) 24 | else if d < 0 && from + d > 0 25 | then tabulate n (\i -> A[if i == from+d then from 26 | else if i > from then i 27 | else if i > from+d then i-1 28 | else i]) 29 | else let d = n+d-1 30 | in tabulate n (\i -> A[if i == from+d then from 31 | else if i < from then i 32 | else if i < from+d then i+1 33 | else i]) 34 | 35 | def move [n] (i: i64) (A: [n](i64,i64)): [n](i64,i64) = 36 | let j = index_of_first ((.0) >-> (==i)) A 37 | in shift j (i64.i64 A[j].1 %% (n-1)) A 38 | 39 | def moves [n] (A: [n](i64,i64)) = 40 | loop A = copy A for i < n do move i A 41 | 42 | entry part1 (s: string[]) = 43 | parse s 44 | |> (indices &&& id) 45 | |> uncurry zip 46 | |> moves 47 | |> map (.1) 48 | |> (\A -> let j = index_of_first (==0) A 49 | in A[(j+1000)%length A] + A[(j+2000)%length A] + A[(j+3000)%length A]) 50 | 51 | entry part2 (s: string[]) = 52 | parse s 53 | |> map (*811589153) 54 | |> (indices &&& id) 55 | |> uncurry zip 56 | |> iterate 10 moves 57 | |> map (.1) 58 | |> (\A -> let j = index_of_first (==0) A 59 | in A[(j+1000)%length A] + A[(j+2000)%length A] + A[(j+3000)%length A]) 60 | 61 | -- == 62 | -- entry: part1 63 | -- input @ data/20.input 64 | -- output { 1591i64 } 65 | 66 | -- == 67 | -- entry: part2 68 | -- input @ data/20.input 69 | -- output { 14579387544492i64 } 70 | -------------------------------------------------------------------------------- /21.fut: -------------------------------------------------------------------------------- 1 | -- Inefficient solution (touching all nodes all the time), but I 2 | -- managed to use AD for the second part! 3 | 4 | import "utils" 5 | 6 | def testinput = "root: pppw + sjmn\ndbpl: 5\ncczh: sllz + lgvd\nzczc: 2\nptdq: humn - dvpt\ndvpt: 3\nlfqf: 4\nhumn: 5\nljgn: 2\nsjmn: drzm * dbpl\nsllz: 4\npppw: cczh / lfqf\nlgvd: ljgn * ptdq\ndrzm: hmdt - zczc\nhmdt: 32\n" 7 | 8 | type op = #add | #sub | #mul | #div 9 | type monkey = #const f64 | #op op i32 i32 10 | 11 | def do_op (op: op) x y : f64 = 12 | match op case #add -> x + y 13 | case #sub -> x - y 14 | case #mul -> x * y 15 | case #div -> x / y 16 | 17 | def name l = (i32.u8 l[0] << 24) | (i32.u8 l[1] << 16) | (i32.u8 l[2] << 8) | (i32.u8 l[3] << 0) 18 | 19 | def parse (s: string[]) : (i32,i32,*[]monkey) = 20 | let (get,ls) = lines.lines s 21 | let on_line l: (i32,monkey) = 22 | let l = get l 23 | in (name l, 24 | if length l < 11 25 | then #const (f64.i32 (atoi (drop 6 l))) 26 | else #op (match l[11] 27 | case '+' -> #add 28 | case '-' -> #sub 29 | case '*' -> #mul 30 | case _ -> #div) 31 | (name (drop 6 l)) (name (drop 13 l))) 32 | let (ids,monkeys) = unzip (map on_line ls) 33 | let idx x = i32.i64 (index_of_first (==x) ids) 34 | let link m = match m case #const x -> #const x 35 | case #op op x y -> #op op (idx x) (idx y) 36 | in (idx (name "root"), 37 | idx (name "humn"), 38 | map link monkeys) 39 | 40 | def nonconst (m: monkey) = match m case #const _ -> false 41 | case _ -> true 42 | 43 | def eval (ms: []monkey) = 44 | let on_monkey (m: monkey): monkey = 45 | match m 46 | case #const x -> #const x 47 | case #op op x y -> 48 | match (ms[x],ms[y]) 49 | case (#const x, #const y) -> #const (do_op op x y) 50 | case _ -> #op op x y 51 | in map on_monkey ms 52 | 53 | entry part1 s = 54 | let (root,_humn,ms) = parse s 55 | in match (iterate_while (any nonconst) eval ms)[root] 56 | case #const x -> x 57 | case #op _ _ _ -> assert false 0 58 | 59 | -- == 60 | -- entry: part1 61 | -- input @ data/21.input 62 | -- output { 62386792426088f64 } 63 | 64 | def cost (root: i32) (humn: i32) (ms: []monkey) (x: f64) = 65 | let ms = copy ms with [humn] = #const x 66 | in match (iterate_while (any nonconst) eval ms)[root] 67 | case #const x -> x 68 | case #op _ _ _ -> assert false 0 69 | 70 | def newton (tol: f64) (f: f64 -> f64) (x0: f64) = 71 | let iteration (_, x, i) = 72 | let (y, dy) = jvp2 f x 1 73 | let x' = x - y / dy 74 | in (f64.abs (x - x') < tol, x', i+1) 75 | let (_, x, steps) = iterate_until (.0) iteration (false, x0, 0i32) 76 | in (x, steps) 77 | 78 | entry part2 s = 79 | let (root,humn,ms) = parse s 80 | let ms = match ms[root] case #op _ x y -> ms with [root] = #op #sub x y 81 | case _ -> assert false ms 82 | in let (x, _) = newton 0.002 (cost root humn ms) 100 83 | in i64.f64 (f64.round x) 84 | 85 | -- == 86 | -- entry: part2 87 | -- input @ data/21.input 88 | -- output { 3876027196185i64 } 89 | -------------------------------------------------------------------------------- /22.fut: -------------------------------------------------------------------------------- 1 | -- Not parallel and not nice. I am very inexperienced at programming 2 | -- with coordinate space transformations, so I really hacked this one 3 | -- up. 4 | 5 | import "utils" 6 | 7 | type pos = {x:i64,y:i64} 8 | type dir = #n|#w|#e|#s 9 | type world [n][m] = {cells: [n][m]u8, xbounds: [n]((pos,dir),(pos,dir)), ybounds: [m]((pos,dir),(pos,dir))} 10 | 11 | type move = #l | #r | #go i64 12 | 13 | #[noinline] 14 | def parse s: (world[][], []u8) = 15 | let (get,ls) = lines.lines s 16 | let linelen l = length (get l) 17 | let (map_lines,ls) = span (\l -> linelen l == 0) ls 18 | let m = map linelen map_lines |> i64.maximum 19 | let on_line y l = (pad_to m ' ' (get l), 20 | (({x=linelen l-1,y},#w), ({x=index_of_first (!=' ') (get l),y},#e))) 21 | let (cells,xbounds) = unzip (imap on_line map_lines) 22 | let movs = get ls[1] 23 | let find_ybounds x l = (({x,y=length cells - index_of_first (!=' ') (reverse l) - 1},#n), 24 | ({x,y=index_of_first (!=' ') l},#s)) 25 | let ybounds = imap find_ybounds (transpose cells) 26 | in ({cells, xbounds, ybounds}, movs) 27 | 28 | def get_move (s: []u8) : (move, []u8) = 29 | match s[0] case 'L' -> (#l, s[1:]) 30 | case 'R' -> (#r, s[1:]) 31 | case _ -> (#go (i64.i32 (atoi s)), (span isnt_digit s).1) 32 | 33 | type me = {pos: pos, dir: dir} 34 | 35 | def progress [n][m] (w: world[n][m]) ({dir=dir,pos={x,y}}: me) : me = 36 | match dir case #n -> if y-1 < 0 || w.cells[y-1,x] == ' ' 37 | then {pos=(w.ybounds[x].0.0), dir=w.ybounds[x].0.1} 38 | else {pos={y=y-1,x}, dir} 39 | case #s -> if y+1 >= n || w.cells[y+1,x] == ' ' 40 | then {pos=(w.ybounds[x].1.0), dir=w.ybounds[x].1.1} 41 | else {pos={y=y+1,x}, dir} 42 | case #w -> if x-1 < 0 || w.cells[y, x-1] == ' ' 43 | then {pos=w.xbounds[y].0.0, dir=w.xbounds[y].0.1} 44 | else {pos={y,x=x-1}, dir} 45 | case #e -> if x+1 >= m || w.cells[y, x+1] == ' ' 46 | then {pos=w.xbounds[y].1.0, dir=w.xbounds[y].1.1} 47 | else {pos={y,x=x+1}, dir} 48 | 49 | def move [n][m] (world: world [n][m]) (move: move) (me: me) : me = 50 | match move case #l -> (match me.dir case #n -> me with dir = #w 51 | case #w -> me with dir = #s 52 | case #s -> me with dir = #e 53 | case #e -> me with dir = #n) 54 | case #r -> (match me.dir case #n -> me with dir = #e 55 | case #w -> me with dir = #n 56 | case #s -> me with dir = #w 57 | case #e -> me with dir = #s) 58 | case #go n -> loop me for _i < n do 59 | let me' = progress world me 60 | in if world.cells[me'.pos.y,me'.pos.x] == '#' 61 | then me 62 | else me' 63 | 64 | def dir_num (d: dir) : i64 = 65 | match d case #e -> 0 66 | case #s -> 1 67 | case #w -> 2 68 | case #n -> 3 69 | 70 | def walk world (steps: []u8) = 71 | let me = {pos=({y=0,x=index_of_first (!=' ') world.cells[0]}),dir=#e} 72 | let (_,_,me) = 73 | loop (world,steps,me) while length steps > 0 do 74 | let (mv, steps) = get_move steps 75 | in (world, steps, move world mv me) 76 | in ((me.pos.y+1) * 1000 + (me.pos.x+1) * 4 + dir_num me.dir) 77 | 78 | entry part1 s = 79 | let (world,steps) = parse s 80 | in walk world steps 81 | 82 | -- Note: does not work for example input, only real input. 83 | def fold [n][m] (world: world[n][m]) : world[n][m] = 84 | let k = n/4 85 | let on_xbound y = 86 | if y < k then (({y=3*k-1-y%k,x=0},#e), 87 | ({y=3*k-1-y%k,x=2*k-1},#w)) 88 | else if y < 2*k then (({y=k*2,x=y%k},#s), 89 | ({y=k-1,x=k*2+y%k},#n)) 90 | else if y < 3*k then (({y=k-1-y%k,x=k},#e), 91 | ({y=k-1-y%k,x=k*3-1},#w)) 92 | else (({y=0,x=k+y%k},#s), 93 | ({y=3*k-1,x=k+y%k},#n)) 94 | let on_ybound x = 95 | if x < k then (({x=k,y=k+x%k}, #e), 96 | ({x=2*k+x%k,y=0}, #s)) 97 | else if x < 2*k then (({x=0,y=3*k+x%k}, #e), 98 | ({x=k-1,y=3*k+x%k}, #w)) 99 | else (({y=4*k-1, x=x%k}, #n), 100 | ({x=k*2-1, y=k+x%k}, #w)) 101 | in world with xbounds = map on_xbound (indices world.xbounds) 102 | with ybounds = map on_ybound (indices world.ybounds) 103 | 104 | entry part2 s = 105 | let (world, steps) = parse s 106 | in walk (fold world) steps 107 | 108 | -- == 109 | -- entry: part1 110 | -- input @ data/22.input 111 | -- output { 117102i64 } 112 | 113 | -- == 114 | -- entry: part2 115 | -- input @ data/22.input 116 | -- output { 135297i64 } 117 | -------------------------------------------------------------------------------- /23.fut: -------------------------------------------------------------------------------- 1 | -- This was delightful. I wanted to solve this with a spatial data 2 | -- structure rather than a stencil, although the stencil will almost 3 | -- certainly be more efficient due to the density and locality. I 4 | -- maintain the world as an array of the elf positions, encoded as a 5 | -- u32. I perform lookups by sorting and then doing a binary 6 | -- search. I end up sorting much too often here. I was worried that 7 | -- part 2 would be something impossible to do with a stencil (also, 8 | -- stencils are boring). 9 | 10 | import "utils" 11 | import "lib/github.com/diku-dk/sorts/merge_sort" 12 | 13 | def testinput = "....#..\n..###.#\n#...#.#\n.#...##\n#.###..\n##.#.##\n.#..#..\n" 14 | def smallinput = ".....\n..##.\n..#..\n.....\n..##.\n.....\n" 15 | 16 | type pos = u32 17 | 18 | def pos_x (p: pos) = i16.u32 (p >> 16) 19 | def pos_y (p: pos) = i16.u32 p 20 | def mk_pos (x: i16) (y: i16) = (u32.i16 x << 16) | u32.i16 y 21 | 22 | def pos_nw p = mk_pos (pos_x p - 1) (pos_y p + 1) 23 | def pos_n p = mk_pos (pos_x p) (pos_y p + 1) 24 | def pos_ne p = mk_pos (pos_x p + 1) (pos_y p + 1) 25 | def pos_w p = mk_pos (pos_x p - 1) (pos_y p) 26 | def pos_e p = mk_pos (pos_x p + 1) (pos_y p) 27 | def pos_sw p = mk_pos (pos_x p - 1) (pos_y p - 1) 28 | def pos_s p = mk_pos (pos_x p) (pos_y p - 1) 29 | def pos_se p = mk_pos (pos_x p + 1) (pos_y p - 1) 30 | 31 | type dir = #n | #s | #w | #e 32 | 33 | #[noinline] 34 | def occupied [n] (world: [n]pos) (p: pos) = 35 | let i = binsearch (<=) world p 36 | in i >= 0 && i < n && world[i] == p 37 | 38 | -- This one is clever. 39 | #[noinline] 40 | def singleton [n] (world: [n]pos) (p: pos) = 41 | let i = binsearch (<=) world (p-1) 42 | in world[(i+1)%n] != world[(i+2)%n] 43 | 44 | def propose [n] (world: [n]pos) (ds: [4]dir) (from: pos) : pos = 45 | if occupied world (pos_nw from) || occupied world (pos_n from) || occupied world (pos_ne from) 46 | || occupied world (pos_w from) || occupied world (pos_e from) 47 | || occupied world (pos_sw from) || occupied world (pos_s from) || occupied world (pos_se from) 48 | then let clear a b c = !occupied world a && !occupied world b && !occupied world c 49 | in (.0) <| 50 | loop (pos,i) = (from,0) while i < 4 do 51 | match ds[i] case #n -> if clear (pos_nw from) (pos_n from) (pos_ne from) 52 | then (pos_n from,4) 53 | else (pos,i+1) 54 | case #s -> if clear (pos_sw from) (pos_s from) (pos_se from) 55 | then (pos_s from,4) 56 | else (pos,i+1) 57 | case #w -> if clear (pos_nw from) (pos_w from) (pos_sw from) 58 | then (pos_w from,4) 59 | else (pos,i+1) 60 | case #e -> if clear (pos_ne from) (pos_e from) (pos_se from) 61 | then (pos_e from,4) 62 | else (pos,i+1) 63 | else from 64 | 65 | #[noinline] 66 | def order (world: []pos) = merge_sort (<=) world 67 | 68 | def parse s = 69 | let (get,ls) = lines.lines s 70 | let m = length (get ls[0]) 71 | let on_line l = get l :> [m]u8 72 | let world = map on_line ls |> reverse 73 | let is = map (map (\(y,x) -> mk_pos (i16.i64 x) (i16.i64 y))) (indices_2d world) 74 | in map2 zip is world 75 | |> flatten 76 | |> filter (\(_,c) -> c == '#') 77 | |> map (.0) 78 | |> order 79 | 80 | def dirs: []dir = [#n, #s, #w, #e] 81 | 82 | #[noinline] 83 | def step [n] (i: i64) (world: [n]pos) : [n]pos = 84 | let proposals = map (propose world (rotate i dirs)) world 85 | let proposals_sorted = order proposals 86 | let resolve from to = if singleton proposals_sorted to then to else from 87 | in order (map2 resolve world proposals) 88 | 89 | entry part1 s = 90 | let world = parse s 91 | let world = loop world for i < 10 do step i world 92 | let min_x = world |> map pos_x |> i16.minimum 93 | let max_x = world |> map pos_x |> i16.maximum 94 | let min_y = world |> map pos_y |> i16.minimum 95 | let max_y = world |> map pos_y |> i16.maximum 96 | in (i32.i16 (max_x-min_x)+1) * (i32.i16 (max_y-min_y)+1) - i32.i64 (length world) 97 | 98 | entry part2 s = 99 | let world = parse s 100 | let go = true 101 | let i = 0 102 | let (_,_,i) = 103 | loop (world,go,i) while go do 104 | let world' = step i world 105 | in if or (map2 (!=) world world') 106 | then (world', go, i+1) 107 | else (world', false, i+1) 108 | in i 109 | 110 | -- == 111 | -- entry: part1 112 | -- input @ data/23.input 113 | -- output { 3757 } 114 | 115 | -- == 116 | -- entry: part2 117 | -- input @ data/23.input 118 | -- output { 918i64 } 119 | -------------------------------------------------------------------------------- /24.fut: -------------------------------------------------------------------------------- 1 | -- Absolutely delightful. A proper BFS might be more efficient, but 2 | -- the stencil works nicely too. 3 | 4 | import "utils" 5 | 6 | def parse s = 7 | let (get,ls) = lines.lines s 8 | let m = length (get ls[0]) - 2 9 | let on_line l = get l |> drop 1 |> take m 10 | in map on_line ls[1:length ls-1] 11 | 12 | def easts wind = map (map (u8.=='>')) wind 13 | def wests wind = map (map (u8.=='<')) wind 14 | def norths wind = map (map (u8.=='^')) wind 15 | def souths wind = map (map (u8.=='v')) wind 16 | 17 | -- Windy cells after i steps. 18 | def windy_in (i: i64) (wind: [][]u8) = 19 | map4 (map4 (\a b c d -> a||b||c||d)) 20 | (map (rotate (-i)) (easts wind)) 21 | (map (rotate i) (wests wind)) 22 | (rotate i (norths wind)) 23 | (rotate (-i) (souths wind)) 24 | 25 | #[noinline] 26 | def step [n][m] (start: (i64,i64)) (wind: [n][m]u8) (s: i64) (where: [n][m]bool): [n][m]bool = 27 | let present i j = (i,j) == start || (i >= 0 && i < n && j >= 0 && j < m && where[i,j]) 28 | let windy = windy_in s wind 29 | in tabulate_2d n m 30 | (\i j -> !windy[i,j] && 31 | (present i j || present (i-1) j || present (i+1) j 32 | || present i (j-1) || present i (j+1))) 33 | 34 | entry part1 s = 35 | let [n][m] wind : [n][m]u8 = parse s 36 | let go = true 37 | let s = 1 38 | let where = replicate n (replicate m false) 39 | let (_,s,_) = 40 | loop (go,s,where) while go do 41 | let where = step (-1,0) wind s where 42 | in (!where[n-1,m-1], s+1, where) 43 | in s 44 | 45 | entry part2 s = 46 | let [n][m] wind : [n][m]u8 = parse s 47 | let go = true 48 | let s = 1 49 | let where = replicate n (replicate m false) 50 | let (_,s,_) = 51 | loop (go,s,where) while go do 52 | let where = step (-1,0) wind s where 53 | in (!where[n-1,m-1], s+1, where) 54 | let (_,s,_) = 55 | loop (go,s,where) while go do 56 | let where = step (n,m-1) wind s where 57 | in (!where[0,0], s+1, where) 58 | let (_,s,_) = 59 | loop (go,s,where) while go do 60 | let where = step (-1,0) wind s where 61 | in (!where[n-1,m-1], s+1, where) 62 | in s 63 | 64 | 65 | -- == 66 | -- entry: part1 67 | -- input @ data/24.input 68 | -- output { 373i64 } 69 | 70 | -- == 71 | -- entry: part2 72 | -- input @ data/24.input 73 | -- output { 997i64 } 74 | -------------------------------------------------------------------------------- /25.fut: -------------------------------------------------------------------------------- 1 | import "utils" 2 | 3 | def digit (d: u8) : i64 = 4 | match d case '2' -> 2 5 | case '1' -> 1 6 | case '0' -> 0 7 | case '-' -> -1 8 | case '=' -> -2 9 | case _ -> 0 10 | 11 | def snafu_to_int (s: string[]) : i64 = 12 | loop acc = 0 for i < length s do (acc * 5 + digit s[i]) 13 | 14 | def enum (x: i64) : u8 = 15 | match x case 0 -> '0' 16 | case 1 -> '1' 17 | case 2 -> '2' 18 | case 3 -> '=' 19 | case 4 -> '-' 20 | case _ -> ' ' 21 | 22 | def int_to_snafu (x: i64) : string[] = 23 | let d i = enum (iterate (i32.i64 i) ((+2) >-> (/5)) x % 5) 24 | in tabulate 30 d |> reverse |> span (!= '0') |> (.1) 25 | 26 | entry part1 s = 27 | let (get,ls) = lines.lines s 28 | in ls 29 | |> map (\l -> snafu_to_int (get l)) 30 | |> i64.sum 31 | |> int_to_snafu 32 | 33 | 34 | -- == 35 | -- entry: part1 36 | -- input @ data/25.input 37 | -- output { [50u8, 61u8, 49u8, 50u8, 45u8, 49u8, 48u8, 48u8, 45u8, 45u8, 49u8, 48u8, 49u8, 50u8, 45u8, 48u8, 61u8, 48u8, 49u8, 50u8] } 38 | -------------------------------------------------------------------------------- /3.fut: -------------------------------------------------------------------------------- 1 | -- Nicely solved by using bitmasks to model the sets, but 2 | -- unfortunately needs irregular parallelism. 3 | 4 | import "lib/github.com/diku-dk/segmented/segmented" 5 | import "utils" 6 | 7 | def priority (c: u8) = 8 | if c <= 'Z' then 27 + (c - 'A') else 1 + (c - 'a') 9 | 10 | def mask c = 1u64 << u64.u8 (priority c) 11 | 12 | entry part1 (s: string[]) = 13 | let (get,ls) = lines.lines s 14 | let on_line l = 15 | let [n] (l: [n]u64) = map mask (get l) 16 | in u64.ctz (reduce (|) 0 (take (n/2) l) & reduce (|) 0 (drop (n/2) l)) 17 | in map on_line ls |> i32.sum 18 | 19 | entry part2 (s: string[]) = 20 | let (get,ls) = lines.lines s 21 | let on_group g = 22 | let (l1,l2,l3) = (get g[0], get g[1], get g[2]) 23 | in u64.ctz (reduce (|) 0 (map mask l1) 24 | & reduce (|) 0 (map mask l2) 25 | & reduce (|) 0 (map mask l3)) 26 | in sized ((length ls / 3)*3) ls |> unflatten |> map on_group |> i32.sum 27 | 28 | -- == 29 | -- entry: part1 30 | -- input @ data/3.input 31 | -- output { 7701 } 32 | 33 | 34 | -- == 35 | -- entry: part2 36 | -- input @ data/3.input 37 | -- output { 2644 } 38 | -------------------------------------------------------------------------------- /4.fut: -------------------------------------------------------------------------------- 1 | -- This is where parsing becomes annoying. 2 | 3 | import "utils" 4 | 5 | def parse (s: string[]) = 6 | let (get,ls) = lines.lines s 7 | in map (\l -> let (a,b) = span (==',') (get l) 8 | let (a0,a1) = span (=='-') a 9 | let (b0,b1) = span (=='-') (tail b) 10 | in ((atoi a0, atoi (tail a1)), 11 | (atoi b0, atoi (tail b1)))) ls 12 | 13 | let contains ((a:i32,b:i32),(x,y)) = (a <= x && b >= y) || (x <= a && y >= b) 14 | 15 | entry part1 s = 16 | s |> parse |> count contains 17 | 18 | let overlap ((a:i32,b:i32),(x,y)) = 19 | (a <= x && b >= x) || (a <= y && b >= y) || contains ((a,b),(x,y)) 20 | 21 | entry part2 s = 22 | s |> parse |> count overlap 23 | 24 | -- == 25 | -- entry: part1 26 | -- input @ data/4.input 27 | -- output { 542 } 28 | 29 | -- == 30 | -- entry: part2 31 | -- input @ data/4.input 32 | -- output { 900 } 33 | -------------------------------------------------------------------------------- /5.fut: -------------------------------------------------------------------------------- 1 | -- Very sequential and the input parsing is a bad experience and done 2 | -- hackily. I suspect the movement part can actually be parallelised. 3 | 4 | import "utils" 5 | 6 | def parse (s: string[]) = 7 | let header_line_len = 36 8 | let num_stack_lines = 8 9 | let stack_lines = take (num_stack_lines * header_line_len) s 10 | let (get, move_lines) = lines.lines (drop ((num_stack_lines+1) * header_line_len + 1) s) 11 | let on_stack_line l = tabulate 9 (\i -> l[1+i*4]) 12 | let on_move_line l = let l' = get l 13 | let (num,l') = span (==' ') (drop 5 l') 14 | let (from,l') = span (==' ') (drop 6 l') 15 | let (to,_) = span (==' ') (drop 4 l') 16 | in (atoi num, atoi from - 1, atoi to - 1) 17 | in (sized (num_stack_lines*header_line_len) stack_lines 18 | |> unflatten 19 | |> map on_stack_line 20 | |> (replicate 100 (replicate 9 ' ')++) 21 | |> transpose 22 | |> map reverse, 23 | map on_move_line move_lines) 24 | 25 | entry part1 s = 26 | let sim (state: [][]u8, moves) = 27 | let (counts,state) = 28 | loop (counts,state) = (map (count (!=' ')) state, copy state) 29 | for (num,from,to) in moves do 30 | loop (counts,state) for _i < num do 31 | let state[to,counts[to]] = state[from,counts[from]-1] 32 | let counts[to] = counts[to] + 1 33 | let counts[from] = counts[from] - 1 34 | in (counts, state) 35 | in (map2 (\c s -> s[c-1]) counts state) 36 | in s |> parse |> sim 37 | 38 | entry part2 s = 39 | let sim (state: [][]u8, moves) = 40 | let (counts,state) = 41 | loop (counts,state) = (map (count (!=' ')) state, copy state) 42 | for (num,from,to) in moves do 43 | loop 44 | (counts,state) = 45 | (counts with [from] = counts[from] - num, state) 46 | for i < num do 47 | let state[to,counts[to]] = state[from,counts[from]+i] 48 | let counts[to] = counts[to] + 1 49 | in (counts, state) 50 | in (map2 (\c s -> s[c-1]) counts state) 51 | in s |> parse |> sim 52 | 53 | -- == 54 | -- entry: part1 55 | -- input @ data/5.input 56 | -- output { [70u8,67u8,86u8,82u8,76u8,77u8,86u8,81u8,80u8] } 57 | 58 | -- == 59 | -- entry: part2 60 | -- input @ data/5.input 61 | -- output { [82u8,87u8,76u8,87u8,71u8,74u8,71u8,70u8,68u8] } 62 | -------------------------------------------------------------------------------- /6.fut: -------------------------------------------------------------------------------- 1 | -- This one is quite clean. Using bit vectors to detect duplicates 2 | -- doesn't seem like it should work, but it does. 3 | 4 | import "utils" 5 | 6 | entry part1 (s: string[]) = 7 | let f a b c d i = 8 | if a != b && a != c && a != d 9 | && b != c && b != d 10 | && c != d 11 | then i32.i64 i + 4 else i32.highest 12 | in map5 f s (rotate 1 s) (rotate 2 s) (rotate 3 s) (indices s) |> i32.minimum 13 | 14 | entry part2 [n] (s: string[n]) = 15 | let f (w,i) = 16 | if w |> map (\x -> u32.u8 x - 'a') |> map (1<<) |> reduce (^) 0 |> u32.popc |> (==14) 17 | then i32.i64 i + 14 else i32.highest 18 | in windows 14 s |> (id &&& indices) |> uncurry zip |> map f |> i32.minimum 19 | 20 | -- == 21 | -- entry: part1 22 | -- input @ data/6.input 23 | -- output { 1155 } 24 | 25 | -- == 26 | -- entry: part2 27 | -- input @ data/6.input 28 | -- output { 2789 } 29 | -------------------------------------------------------------------------------- /7.fut: -------------------------------------------------------------------------------- 1 | -- Oh no, this is very inappropriate for Futhark. 2 | -- 3 | -- Many thanks to Aaron Hsu whose PhD thesis contains nice expositions 4 | -- of tree processing in array languages: 5 | -- https://scholarworks.iu.edu/dspace/handle/2022/24749 6 | 7 | import "utils" 8 | 9 | type op = #ls | #cd | #dotdot | #dir | #file i32 10 | 11 | def parse_line (s: string[]) : op = 12 | if s[0] == '$' 13 | then if s[2] == 'l' then #ls else if s[5] == '.' then #dotdot else #cd 14 | else if s[0] == 'd' then #dir else #file (atoi (span (not <-< is_digit) s).0) 15 | 16 | #[noinline] 17 | def dir_sizes (s: string[]) = 18 | let (get,ls) = lines.lines s 19 | let ops = map (\l -> parse_line (get l)) ls 20 | let deepen op = match op case #cd -> 1 21 | case #dotdot -> -1 22 | case _ -> 0 23 | let depths = exscan (+) 0 (map deepen ops) 24 | let find_parent i d = 25 | loop i while i > 0 && depths[i] >= d do i - 1 26 | let max_depth = i32.maximum depths 27 | let parents = map2 find_parent (indices depths) depths 28 | let file_size op = match op case #file k -> k 29 | case _ -> 0 30 | let weights = 31 | loop acc = map file_size ops for d in reverse (1...max_depth) do 32 | reduce_by_index (copy acc) (+) 0i32 33 | (map2 (\di p -> if di == d then p else -1) depths parents) 34 | acc 35 | let is_dir op = match op case #cd -> true 36 | case _ -> false 37 | in zip ops weights |> filter ((.0) >-> is_dir) |> map (.1) 38 | 39 | entry part1 (s: string[]) = 40 | dir_sizes s 41 | |> drop 1 42 | |> filter (<= 100000) 43 | |> i32.sum 44 | 45 | entry part2 (s: string[]) = 46 | let dirs = dir_sizes s 47 | let available = 70000000 48 | let need = 30000000 49 | let unused = available - dirs[0] 50 | let to_obtain = need-unused 51 | in dirs 52 | |> filter (>=to_obtain) 53 | |> i32.minimum 54 | 55 | -- == 56 | -- entry: part1 57 | -- input @ data/7.input 58 | -- output { 1306611 } 59 | 60 | -- == 61 | -- entry: part2 62 | -- input @ data/7.input 63 | -- output { 13210366 } 64 | -------------------------------------------------------------------------------- /8.fut: -------------------------------------------------------------------------------- 1 | -- This one was lovely. The first part is a classic use of scans, and 2 | -- the second was... tolerable. I do wonder if it is possible to also 3 | -- parallelise the search. 4 | 5 | import "utils" 6 | 7 | def visible (xs: []i32) = 8 | xs |> (id &&& exscan i32.max i32.lowest) |> uncurry (map2 (>)) 9 | 10 | def parse [l] (s: string [l]) = 11 | -- Careful to cut off the newlines. 12 | let n = i64.f32 (f32.sqrt (f32.i64 l)) 13 | in sized (n*(n+1)) s 14 | |> unflatten 15 | |> map (take n) 16 | |> map (map (\x -> x - '0')) 17 | |> map (map i32.u8) 18 | 19 | entry part1 s = 20 | let grid = parse s 21 | in map4 (map4 (\a b c d -> a || b || c || d)) 22 | (map visible grid) 23 | (map reverse (map visible (map reverse grid))) 24 | (transpose (map visible (transpose grid))) 25 | (transpose (map reverse (map visible (map reverse (transpose grid))))) 26 | |> flatten |> map i32.bool |> i32.sum 27 | 28 | def search [n] (grid: [n][n]i32) (i,j) (x,y) : i32 = 29 | let me = grid[i,j] 30 | let (_,_,view) = 31 | loop (i,j,acc) = (i+x,j+y,0) while (i>=0 && i < n && j >= 0 && j < n) do 32 | let h = grid[i,j] 33 | in if h >= me then (-1,-1,acc+1) else (i+x,j+y,acc+1) 34 | in view 35 | 36 | entry part2 s = 37 | let [n] (grid: [n][n]i32) = parse s 38 | in tabulate_2d n n (\i j -> search grid (i,j) (-1,0) * 39 | search grid (i,j) (1,0) * 40 | search grid (i,j) (0,-1) * 41 | search grid (i,j) (0,1)) 42 | |> flatten |> i32.maximum 43 | 44 | -- == 45 | -- entry: part1 46 | -- input @ data/8.input 47 | -- output { 1713 } 48 | 49 | -- == 50 | -- entry: part2 51 | -- input @ data/8.input 52 | -- output { 268464 } 53 | -------------------------------------------------------------------------------- /9.fut: -------------------------------------------------------------------------------- 1 | -- This one is truly crazy, but I got it to work! The 'unmove' 2 | -- function is pretty inelegant, but it does not affect the 3 | -- parallelism. 4 | 5 | import "utils" 6 | import "lib/github.com/diku-dk/segmented/segmented" 7 | 8 | type dir = #U | #D | #L | #R | #UL | #UR | #DL | #DR | #C 9 | 10 | def dir (c: u8) : dir = 11 | match c 12 | case 'U' -> #U 13 | case 'D' -> #D 14 | case 'L' -> #L 15 | case _ -> #R 16 | 17 | def testinput = "R 4\nU 4\nL 3\nD 1\nR 4\nD 1\nL 5\nR 2\n" 18 | 19 | def parse (s: string[]) = 20 | let (get,ls) = lines.lines s 21 | in map (\l -> let l' = get l 22 | in (dir l'[0], atoi (drop 2 l'))) ls 23 | 24 | type pos = (i32,i32) 25 | 26 | def pos_add (a: pos) (b: pos) = (a.0 + b.0, a.1 + b.1) 27 | def pos_sub (a: pos) (b: pos) = (a.0 - b.0, a.1 - b.1) 28 | 29 | def coords moves = scan pos_add (0,0) moves 30 | 31 | def move (d: dir) : pos = 32 | match d case #U -> (0,1) 33 | case #D -> (0,-1) 34 | case #L -> (-1,0) 35 | case #R -> (1,0) 36 | case #UL -> (-1,1) 37 | case #DL -> (-1,-1) 38 | case #UR -> (1,1) 39 | case #DR -> (1,-1) 40 | case #C -> (0,0) 41 | 42 | def unmove (p: pos) : dir = 43 | match p case (0,1) -> #U 44 | case (0,-1) -> #D 45 | case (-1,0) -> #L 46 | case (1,0) -> #R 47 | case (-1,1) -> #UL 48 | case (-1,-1) -> #DL 49 | case (1,1) -> #UR 50 | case (1,-1) -> #DR 51 | case _ -> #C 52 | 53 | -- Representing neighbourhood with indexes 54 | -- 55 | -- 0 1 2 56 | -- 3 4 5 57 | -- 6 7 8 58 | -- 59 | -- Represented as a single 64-bit number, with 4 bits per field. 60 | type perm = u64 61 | 62 | def tovec (xs: [9]u64) : perm = 63 | let f i = xs[i32.u64 i]<<(i*4) 64 | in f 0 | f 1 | f 2 | f 3 | f 4 | f 5 | f 6 | f 7 | f 8 65 | 66 | def perm_lookup (i: u64) (x: perm) : u64 = 67 | (x >> (i * 4)) & 0b1111 68 | 69 | def perm (d: dir): perm = 70 | match d case #U -> tovec [3,4,5, 6,7,8, 7,7,7] 71 | case #D -> tovec [1,1,1, 0,1,2, 3,4,5] 72 | case #L -> tovec [1,2,5, 4,5,5, 7,8,5] 73 | case #R -> tovec [3,0,1, 3,3,4, 3,6,7] 74 | case #UL -> tovec [4,5,5, 7,8,5, 7,7,8] 75 | case #DL -> tovec [1,1,2, 1,2,5, 4,5,5] 76 | case #UR -> tovec [3,3,4, 3,6,7, 6,7,7] 77 | case #DR -> tovec [0,1,1, 3,0,1, 3,3,4] 78 | case #C -> tovec [0,1,2, 3,4,5, 6,7,8] 79 | 80 | def perm_compose (a: perm) (b: perm): perm = 81 | tovec [perm_lookup (perm_lookup 0 a) b, 82 | perm_lookup (perm_lookup 1 a) b, 83 | perm_lookup (perm_lookup 2 a) b, 84 | perm_lookup (perm_lookup 3 a) b, 85 | perm_lookup (perm_lookup 4 a) b, 86 | perm_lookup (perm_lookup 5 a) b, 87 | perm_lookup (perm_lookup 6 a) b, 88 | perm_lookup (perm_lookup 7 a) b, 89 | perm_lookup (perm_lookup 8 a) b] 90 | 91 | def idx_to_dir (x: u64) : dir = 92 | ([#UL, #U, #UR, #L, #C, #R, #DL, #D, #DR])[i32.u64 x] 93 | 94 | def move_tail dirs = 95 | map perm dirs 96 | |> scan perm_compose (perm #C) 97 | |> map (perm_lookup 4) 98 | |> map idx_to_dir 99 | 100 | def count_visits poses = 101 | let min_x = i32.minimum (map (.0) poses) 102 | let max_x = i32.maximum (map (.0) poses) 103 | let min_y = i32.minimum (map (.1) poses) 104 | let max_y = i32.maximum (map (.1) poses) 105 | let span_x = max_x - min_x + 1 106 | let span_y = max_y - min_y + 1 107 | let flat_pos (x,y) = i64.i32 ((x-min_x) * span_y + (y-min_y)) 108 | in hist (+) 0i32 (i64.i32 (span_x*span_y)) 109 | (map flat_pos poses) 110 | (map (const 1) poses) 111 | |> count (>0) 112 | 113 | def moves s = s |> parse |> expand (\(_,n) -> i64.i32 n) (\(d,_) _ -> d) 114 | 115 | let compute_tail (heads, dirs) = 116 | let tails = move_tail dirs |> map move |> map2 pos_add heads 117 | let tail_dir i prev this: dir = 118 | let prev = if i == 0 then (0,0) else prev 119 | in unmove (pos_sub this prev) 120 | in (tails, map3 tail_dir (indices tails) (rotate (-1) tails) tails) 121 | 122 | entry part1 s = 123 | let dirs = moves s 124 | let heads = coords (map move dirs) 125 | let (tails, _) = compute_tail (heads,dirs) 126 | in count_visits tails 127 | 128 | entry part2 s = 129 | let dirs = moves s 130 | let heads = coords (map move dirs) 131 | let (tails, _) = iterate 9 compute_tail (heads,dirs) 132 | in count_visits tails 133 | 134 | -- == 135 | -- entry: part1 136 | -- input @ data/9.input 137 | -- output { 5779 } 138 | 139 | -- == 140 | -- entry: part2 141 | -- input @ data/9.input 142 | -- output { 2331 } 143 | -------------------------------------------------------------------------------- /Makefile: -------------------------------------------------------------------------------- 1 | DATA=data/1.input data/2.input data/3.input data/4.input data/5.input data/6.input data/7.input data/8.input data/9.input data/10.input data/11.input data/12.input data/13.input data/14.input data/15.input data/16.input data/17.input data/18.input data/19.input data/20.input data/21.input data/22.input data/23.input data/24.input data/25.input 2 | 3 | all: $(DATA) 4 | 5 | data/%.input: inputs/%.input 6 | @mkdir -p data 7 | cat $< | ./txt2fut.py > $@ 8 | 9 | clean: 10 | rm -rf data 11 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Advent of [Futhark](https://futhark-lang.org) 2 | 3 | [See reflections here.](https://futhark-lang.org/blog/2022-12-25-reflections-on-advent-of-code.html) 4 | 5 | I also [did this in 6 | 2018](https://github.com/athas/advent_of_code_2018), but then Snektron 7 | upstaged me by doing a [much better solution in 8 | 2021](https://github.com/Snektron/aoc21), particularly by also doing 9 | the input processing in Futhark. 10 | 11 | Following his lead, I'll also try to do it all in Futhark! And I will 12 | try to abuse the type system along the way. 13 | 14 | ## Running 15 | 16 | We still need a preprocessor to convert text files to Futhark input 17 | data: 18 | 19 | ``` 20 | $ futhark c 1.fut 21 | $ cat 1.input | ./txt2fut.py | ./1 -e part1 22 | ``` 23 | -------------------------------------------------------------------------------- /bfs.fut: -------------------------------------------------------------------------------- 1 | module utils = import "utils" 2 | import "lib/github.com/diku-dk/segmented/segmented" 3 | import "lib/github.com/diku-dk/sorts/radix_sort" 4 | 5 | type graph [n][e] = {nodes_start_index: [n]i64, 6 | nodes_n_edges: [n]i64, 7 | edges_dest: [e]i64} 8 | 9 | def node_indices [n][e] (_: graph[n][e]) : [n]i64 = iota n 10 | def edge_indices [n][e] (_: graph[n][e]) : [e]i64 = iota e 11 | 12 | def invert_graph [n][e] 13 | (g: graph [n][e]) : graph [][] = 14 | let nodes_n_edges = 15 | hist (+) 0 n g.edges_dest (map (const 1) g.edges_dest) 16 | let nodes_start_index = 17 | utils.exscan (+) 0 nodes_n_edges 18 | let edges_dest = 19 | replicated_iota g.nodes_n_edges 20 | |> utils.matches g.edges_dest 21 | |> zip g.edges_dest 22 | |> radix_sort_by_key (.0) i64.num_bits i64.get_bit 23 | |> map (.1) 24 | in {nodes_n_edges, nodes_start_index, edges_dest} 25 | 26 | type^ step_fn [n][e] = 27 | (cost: *[n]i32) 28 | -> graph [n][e] 29 | -> (graph_visited: [n]bool) 30 | -> (graph_mask: *[n]bool) 31 | -> (updating_graph_mask: *[n]bool) 32 | -> (*[n]i32, *[n]bool, *[n]bool) 33 | 34 | def generic_bfs [n][e] 35 | (step: step_fn [n][e]) 36 | (graph: graph [n][e]) 37 | (is_source: []bool): [n]i32 = 38 | let (graph_mask, graph_visited, cost) = (copy is_source, 39 | copy is_source, 40 | map (\x -> if x then 0 else -1) is_source) 41 | let (cost,_,_,_,_) = 42 | loop (cost, graph_mask, graph_visited, updating_graph_mask, continue) = 43 | (cost, graph_mask, graph_visited, replicate n false, true) 44 | while continue do 45 | let (cost', graph_mask', updating_graph_mask') = 46 | step cost graph graph_visited graph_mask updating_graph_mask 47 | 48 | let step2_inds = map2 (\x i -> if x then i else -1) updating_graph_mask' (iota n) 49 | 50 | let graph_visited' = 51 | scatter graph_visited step2_inds (replicate n true) 52 | 53 | let graph_mask'' = 54 | scatter graph_mask' step2_inds (replicate n true) 55 | 56 | let updating_graph_mask'' = 57 | scatter updating_graph_mask' step2_inds (replicate n false) 58 | 59 | let continue_indices = map (\x -> if x>=0 then 0 else -1) step2_inds 60 | let continue' = 61 | scatter [false] continue_indices (replicate n true) 62 | 63 | in (cost', graph_mask'', graph_visited', updating_graph_mask'', continue'[0]) 64 | 65 | in cost 66 | 67 | def step [n][e] 68 | (cost: *[n]i32) 69 | ({nodes_start_index,nodes_n_edges,edges_dest}: graph [n][e]) 70 | (graph_visited: [n]bool) 71 | (graph_mask: *[n]bool) 72 | (updating_graph_mask: *[n]bool) : (*[n]i32, *[n]bool, *[n]bool) = 73 | let [n_indices] (active_indices : [n_indices]i64, _) = unzip (filter (.1) (zip (iota n) graph_mask)) 74 | 75 | let graph_mask' = 76 | scatter graph_mask active_indices (map (const false) active_indices) 77 | 78 | -- We calculate the maximum number of edges for a node. This is necessary, 79 | -- since the number of edges are irregular, and since we want to construct a 80 | -- nested array. 81 | let e_max = i64.maximum nodes_n_edges 82 | let active_costs = map (\tid -> #[unsafe] cost[tid]) active_indices 83 | 84 | let flat_len = e_max * n_indices 85 | let changes = tabulate flat_len 86 | (\ii -> let row = ii / e_max 87 | let col = ii % e_max 88 | let tid = #[unsafe] active_indices[row] 89 | let n_edges = #[unsafe] nodes_n_edges[tid] 90 | in #[unsafe] 91 | if col < n_edges 92 | then let start_index = #[unsafe] nodes_start_index[tid] 93 | let edge_index = col+start_index 94 | let node_id = #[unsafe] edges_dest[edge_index] 95 | in if !(#[unsafe] graph_visited[node_id]) 96 | then (node_id, active_costs[row]+1) 97 | else (-1, -1) 98 | else (-1, -1)) 99 | 100 | let (changes_node_ids, changes_costs) = unzip(changes) 101 | 102 | let cost' = 103 | scatter cost changes_node_ids changes_costs 104 | 105 | let updating_graph_mask' = 106 | scatter updating_graph_mask changes_node_ids (replicate flat_len true) 107 | 108 | in (cost', graph_mask', updating_graph_mask') 109 | 110 | def bfs = generic_bfs step 111 | -------------------------------------------------------------------------------- /fut2txt.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | 3 | import sys 4 | import struct 5 | 6 | v = sys.stdin.buffer.read() 7 | sys.stdout.buffer.write(v[7:]) 8 | -------------------------------------------------------------------------------- /futhark.pkg: -------------------------------------------------------------------------------- 1 | require { 2 | github.com/diku-dk/sorts 0.4.2 #3b2cfcc0d0256df7cd1f2548f68d85f2453007a0 3 | github.com/diku-dk/segmented 0.4.3 #3d86d79e757d68fb503c551e894c4ef4b091bdfc 4 | } 5 | -------------------------------------------------------------------------------- /inputs/10.input: -------------------------------------------------------------------------------- 1 | addx 2 2 | addx 3 3 | addx 1 4 | noop 5 | addx 4 6 | noop 7 | noop 8 | noop 9 | addx 5 10 | noop 11 | addx 1 12 | addx 4 13 | addx -2 14 | addx 3 15 | addx 5 16 | addx -1 17 | addx 5 18 | addx 3 19 | addx -2 20 | addx 4 21 | noop 22 | noop 23 | noop 24 | addx -27 25 | addx -5 26 | addx 2 27 | addx -7 28 | addx 3 29 | addx 7 30 | addx 5 31 | addx 2 32 | addx 5 33 | noop 34 | noop 35 | addx -2 36 | noop 37 | addx 3 38 | addx 2 39 | addx 5 40 | addx 2 41 | addx 3 42 | noop 43 | addx 2 44 | addx -29 45 | addx 30 46 | addx -26 47 | addx -10 48 | noop 49 | addx 5 50 | noop 51 | addx 18 52 | addx -13 53 | noop 54 | noop 55 | addx 5 56 | noop 57 | noop 58 | addx 5 59 | noop 60 | noop 61 | noop 62 | addx 1 63 | addx 2 64 | addx 7 65 | noop 66 | noop 67 | addx 3 68 | noop 69 | addx 2 70 | addx 3 71 | noop 72 | addx -37 73 | noop 74 | addx 16 75 | addx -12 76 | addx 29 77 | addx -16 78 | addx -10 79 | addx 5 80 | addx 2 81 | addx -11 82 | addx 11 83 | addx 3 84 | addx 5 85 | addx 2 86 | addx 2 87 | addx -1 88 | addx 2 89 | addx 5 90 | addx 2 91 | noop 92 | noop 93 | noop 94 | addx -37 95 | noop 96 | addx 17 97 | addx -10 98 | addx -2 99 | noop 100 | addx 7 101 | addx 3 102 | noop 103 | addx 2 104 | addx -10 105 | addx 22 106 | addx -9 107 | addx 5 108 | addx 2 109 | addx -5 110 | addx 6 111 | addx 2 112 | addx 5 113 | addx 2 114 | addx -28 115 | addx -7 116 | noop 117 | noop 118 | addx 1 119 | addx 4 120 | addx 17 121 | addx -12 122 | noop 123 | noop 124 | noop 125 | noop 126 | addx 5 127 | addx 6 128 | noop 129 | addx -1 130 | addx -17 131 | addx 18 132 | noop 133 | addx 5 134 | noop 135 | noop 136 | noop 137 | addx 5 138 | addx 4 139 | addx -2 140 | noop 141 | noop 142 | noop 143 | noop 144 | noop 145 | -------------------------------------------------------------------------------- /inputs/11.input: -------------------------------------------------------------------------------- 1 | Monkey 0: 2 | Starting items: 98, 97, 98, 55, 56, 72 3 | Operation: new = old * 13 4 | Test: divisible by 11 5 | If true: throw to monkey 4 6 | If false: throw to monkey 7 7 | 8 | Monkey 1: 9 | Starting items: 73, 99, 55, 54, 88, 50, 55 10 | Operation: new = old + 4 11 | Test: divisible by 17 12 | If true: throw to monkey 2 13 | If false: throw to monkey 6 14 | 15 | Monkey 2: 16 | Starting items: 67, 98 17 | Operation: new = old * 11 18 | Test: divisible by 5 19 | If true: throw to monkey 6 20 | If false: throw to monkey 5 21 | 22 | Monkey 3: 23 | Starting items: 82, 91, 92, 53, 99 24 | Operation: new = old + 8 25 | Test: divisible by 13 26 | If true: throw to monkey 1 27 | If false: throw to monkey 2 28 | 29 | Monkey 4: 30 | Starting items: 52, 62, 94, 96, 52, 87, 53, 60 31 | Operation: new = old * old 32 | Test: divisible by 19 33 | If true: throw to monkey 3 34 | If false: throw to monkey 1 35 | 36 | Monkey 5: 37 | Starting items: 94, 80, 84, 79 38 | Operation: new = old + 5 39 | Test: divisible by 2 40 | If true: throw to monkey 7 41 | If false: throw to monkey 0 42 | 43 | Monkey 6: 44 | Starting items: 89 45 | Operation: new = old + 1 46 | Test: divisible by 3 47 | If true: throw to monkey 0 48 | If false: throw to monkey 5 49 | 50 | Monkey 7: 51 | Starting items: 70, 59, 63 52 | Operation: new = old + 3 53 | Test: divisible by 7 54 | If true: throw to monkey 4 55 | If false: throw to monkey 3 56 | -------------------------------------------------------------------------------- /inputs/12.input: -------------------------------------------------------------------------------- 1 | abccccccccccccccccccccccccccaaaaaaaaacccccccccccaaacccccccccccccccccccccccccaaaaaaaaccccccccaaaaaaccaaccccccccccccccccccccccccaaaaacaacaaaacccccccccccccccccccccccccccccccccccccaaaaa 2 | abccaaacccccccccccccccccccccaaaaaaaaacccccccccaaaaaacccccccccccccccccccccaaaaaaaaaaaccccccccaaaaaaccaaaaaacccaacaaccccccccccccaaaaaaaacaaaaaaccccccccccccccccccccccccccccccccccaaaaaa 3 | abccaaaaccccccccccccccccccccaaaaaaaaccccccccccaaaaaaccccaaaaaccccccccccccaaaaaaaaaaacccccccccaaaaaccaaaaaccccaaaacccccccccccccccaaaaacccaaaaaccccccccccccccccccccaaccccccccccccaaaaaa 4 | abccaaaacccccccaaaccccccccccaaaaaaacccccccccccaaaaaaccccaaaaaccccccccccccacaaaaaaaaaacccccccaaaaacaaaaaaacccaaaaaccccccccccccccaaaaacccaaaaaccccccccccccccccccccaaaaccccccccccccccaaa 5 | abccaaaccccccaaaaaacccccccccaccaaaccccccccccccaaaaacccccaaaaaaccccaaaacccccaaaaaaaaaaaccccccaaaaacaaaaaaacccaaaaaacccccccccccccaacaaaccaccaacccccccccccccccaaaccaaaaccccccccccccccaaa 6 | abcccccccccccaaaaaacccccccccccccaaacccccccccccaaaaacccccaaaaaaccccaaaaccccccaaaaacaaaaccccccccccccccaaaaaaccacaaaaccccaaaaacccccccaaccccccccccccccccccccccaaaackkkaccccccccccccccccaa 7 | abcccccccccccaaaaaacccccccccccccccaaacccccccccccccccccccaaaaaaccccaaaacccccaaaaaccccaaccccccccccccccaaccaaccccaaccccccaaaaaccccccccccccccccccccccccccccccccaakkkkkkkccccccccccccccccc 8 | abaccccccccccaaaaaccccccccccccccccaaaaccccccccccccccccccccaaaccccccaaccccccccaaaccccccccccccccccccccaacccccccccccccccaaaaaacccccccccccccccccccccaaacccccccccjkkkkkkkkccccccccaacccccc 9 | abaccccccccccaaaaacccccaacccccccccaaaaccccccccccccaacccccccccccccccccccccccccaaacccccccccccccccccccccaaccccccaccaccccaaaaaaaaaccaccccccccccccccaaaaccccccccjjkkoopkkkkaccaacaaacccccc 10 | abaccccccccccccccccaaaaaacccccccccaaacccccccccccccaaaaaacccccccccccccccccccccccccccccccccccccccccccccaaaaaaccaaaaccccaaaaaaaaacaaccccccccccccccaaaacccccccjjjkoooppkkkaccaaaaaaaacccc 11 | abcccccccccccccccccaaaaaaaaccccccccccccccccaccccccaaaaaaccccccccccccccccccccccccaaccaacccccccccccccccaaaaaacaaaaacccccaaacccaaaaacccccccccccccccaaacccccjjjjjoooppppkklccaaaaaaaacccc 12 | abcccccccccccccccccaaaaaaaacccccccccccccccaaacccaaaaaaaccccaacccacccccccccccccccaaaaaaccccccccaaaccaaaaaaaccaaaaaaccccccccaaaaaacccccccccccccccccccccjjjjjjjoooouuppplllccaccaaaacccc 13 | abccccccccccccccccccaaaaaaaccccaacccccaaacaaacccaaaaaaaccccaaacaacccccccccccccccaaaaaacccccccccaaaaaaaaaaaacaaaaaaccccccccaaaaaaaaccccccccccccccccciijjjjjjooouuuupppllllcccccccccccc 14 | abccccccccccccccccccaaaaaccccccaacccccaaaaaaaaaaccaaaaaaccccaaaaaccccccccccccccaaaaaaacccccccaaaaaaaaaaaaaacccaaccccccccccaacaaaaacccccccccccccccciiiijoooooouuuuuuppplllllcccccccccc 15 | abcccccccccccccccccaaaaaacccaacaaaaacccaaaaaaaaaccaaccaaccaaaaaacccccccccccccccaaaaaaaaccccccaaaaacccaaaaaacccaccccccccccccccaacccccccccccccccccciiiinnoooooouuxuuuupppplllllcccccccc 16 | abcccccccccccccccccccccaacccaaaaaaaaccccaaaaaaccccaaccccccaaaaaaaaccaaaccccccccaaaaaaaacccccccaaaaaccaacaaaaaaaacccaaccccccccacccccccccaaaccccccciiinnnnntttuuuxxuuuppppqqllllccccccc 17 | abccccccccccccaacccccccccccccaaaaaccccccaaaaaacccccaaaccccaaaaaaaaccaaaacccccccccaaaccccccccccaaccaccccccaaaaaacccaaaaaaccccccccccccccaaaaccccaaiiinnnntttttuuxxxxuuvpqqqqqllmmcccccc 18 | abccccccccccaaaaaaccccccccccccaaaaaccccaaaaaaacccccaaacccccccaacccccaaaaccccaaccccaacccccccccccccccccccccaaaaaaccccaaaaaccccccccccccccaaaaccccaaiiinnnttttxxxxxxxyuvvvvvqqqqmmmcccccc 19 | abccaaacccccaaaaaacccccccccccaaacaaccccaaacaaacccccaaaaaaacccaccccccaaaccccaaaacccccccccccccccccccccccccaaaaaaaacaaaaaaacccccccccaaacccaaaccccaaaiinnntttxxxxxxxxyyyyvvvvqqqmmmcccccc 20 | abcaaaacccccaaaaaccccccccccccaaaccaccccccccccacccaaaaaaaaaaccccccccccccccccaaaaccccccccccccccccccccccccaaaaaaaaaaaaaaaaaaccccccccaaaaaacccccaaaaaiiinnnttxxxxxxxyyyyyyvvvqqqmmmcccccc 21 | SbcaaaaccccccaaaaacccccaaaccccccaaacccccccccaaccaaaaaaaaaaaacccccccccccccccaaaaccccccccccccccccccccccccaaaaaaaaaaaaaaaaaacccccccaaaaaaacccccaaaaaiiinnntttxxxxEzzyyyyvvvqqqmmmdddcccc 22 | abccaaaccccccaaaaacccccaaaaccccaaaaaaccccccaaaaccaaaaaaacaaacccccaaccccccccccccccccccccccccccccccccccccacaaaaacccccaaacacccccccaaaaaaaccccccaaaaaahhhnnntttxxxyyyyyyvvvvqqmmmmdddcccc 23 | abcccccccccccccccccccccaaaaccccaaaaaaccccccaaaaccccaaaaaaaaaaaaaaaacacccccccccccccccccccccccccccccccccccccaaaacccccaaccccccccccaaaaaaaccccccccaaaahhhnnnnttxxxyyyyyvvvqqqqmmmdddccccc 24 | abcccccccccccccccaacaacaaacccccaaaaaaccccccaaaacccaaaaaaaaaaaaaaaaaaacccccccccccccccccaacaaccccccccccccccccaaccccccccccccccccccccaaaaaacccccccaaccchhhmmmttxwyyyyyyvvrqqqmmmddddccccc 25 | abcccccccccccccccaaaacccccccccccaaaaacccccccccccaaaaaaaaaaaaaaccaaaaccccaacccccaacccccaaaaaccccccccccccccccccccccccccccccccaaaaccaaaaaacccccccaaccahhhmmssswwywwwyyyvvrqmmmmdddcccccc 26 | abccccccccccccccaaaaacccccccccccaacaacccccccccccaaaaaacaaaaaacccaaaaaaacaaccccaaaccccccaaaaacccccccacccccccccccccccccccccccaaaaccaacccccccccccaaaaahhhmmsswwwwwwwwywwvrrnnmdddccccccc 27 | abccccccccccccccaaaaaaccaaccccccccccccccccccccccaaaaaaaaaaaaacccacaacaaaaaccccaaacaaacaaaaaacaaacaaacccccccacccaaccccaaccccaaaacccccccccaaaccccaaaahhhmmssswwwwswwwwwwrrnnndddccccccc 28 | abaaccccccccccccacaaaacaaaaaaaccccccccccaacccccccaaaaaaaacaaaccccccccaaaaaaaaaaaaaaaacaaaacccaaaaaaacccccccaacaaaaaaaaacccccaaccccccccccaaacccaaaaahhhmmsssswsssrrwwwrrrnneddaccccccc 29 | abaaccccccccaaccccaaccccaaaaacccccccccccaacccccccaaaacccccccacccccccaaaaaaaaaaaaaaaaacccaaccccaaaaaacccccccaaaaacaaaaaaacccccccccccccaaaaaaaaaaaaaahhhmmssssssssrrrrrrrrnneedaaaacccc 30 | abacccccccccaaaaccccccaaaaaaaccccccccaaaaaaaacccccccccccccccccccccccaaaaaaaacaaaaaacccaaacccccaaaaaaaacccccaaaaaacaaaaaaaccccccccccccaaaaaaaaaaaaaahhhmmmsssssllrrrrrrrnnneeeaaaacccc 31 | abaaacccccaaaaaaccccccaaaaaaaacccaaccaaaaaaaaccccaaaaaccccccccccccccaaaaaacccaaaaaaccccaaaccaaaaaaaaaaccccaaaaaaaaaaaaaaaccccccccccccccaaaaaccccaachhgmmmmmlllllllrrrrrnnneeeaaaacccc 32 | abaaacccccaaaaaccccaccaaaaaaaacaaaaaaccaaaaccccccaaaaacccccccccccccccccaaacccaaaaaaaccaaaaaaaaaaaaaaaaccccaaaaaaaaaaaaacccccccccccccccaaaaaaccccaaccgggmmmllllllllllnnnnneeeaaaaccccc 33 | abcccccccccaaaaacccaaacaaaacaacaaaaaacaaaaaccccccaaaaaaccccccccccccccccccccccaaacaaacccaaaaaaaacaaaccccccccccaaccaaaaaacccccccccccccccaaaaaacaacccccgggggmlllfffflllnnnnneeeaaaaccccc 34 | abcccccccccaaccacccaaaaaaacccccaaaaaacaacaaacccccaaaaaaccccccccccccccccccccccaccaaccaaaaaaaaacccaaaccccccccccaaccccccaacccccaaaaccccccaccaaaaaaccccccggggggggfffffflnnneeeeeacaaacccc 35 | abaaaccccccccccccccaaaaaacccccccaaaaacacccaaaacccaaaaaacccccccccccccccccccaaacccaaccaaaaaaaaacccaaccccccccccccccccccccccccccaaaaccccaaaccaaaaaacccccccgggggggfffffffffeeeeeaacccccccc 36 | abaaaaacccccccccccaaaaaaaaccccccaaaacccccccaaacccccaacccccccaaacccccccccccaaaacaaacccaaaaaaaacccccccccccccccccccccccccccccccaaaaccccaaacccaaaaaaacccccccccgccaaaafffffeeeeccccccccccc 37 | abaaaaaccccccaaccaaaaaaaaaacccccaaacaaaaaacaaaccccccccccccaaaaaccccccccccaaaaacaaacccccaaaaaaacccccccccccccccccccccccccccccccaacccccaaaaaaaaaaaaaccccccccccccaaaacaafffecccccccccccaa 38 | abaaaacccaaacaaccaaaaaaaaaacccccaaaaaaaaaaaaaaaaacccccccccaaaaaaccccccccccaaaaaaaaaaacaaacccacccaacccccccccaaaaccccaaacccccccccccaaaaaaaaaaaaaaacccccccccccccaaaccccaaccccccccccccaaa 39 | abaaaaacccaaaaacccccaaacaaacccccaaaaaaccaaaaaaaaacccccccccaaaaaaccaaccacccaaaaaaaaaaaaaaaccccccaaacccccccccaaaaccccaaaaccccccccccaaaaaaaaaaaaaaccccccccccccccaaaccccccccccccccccccaaa 40 | abaaaaacccaaaaaaacccaaaccccccccaaaaaaaaccaaaaaaaccccccccccaaaaacccaaaaaccccaaaaaaaaaaaaacccccaaaaaaaaccccccaaaaccccaaaacccccccccccaaaaaaacccaaaccccccccccccccaaacccccccccccccccaaaaaa 41 | abcccccccaaaaaaaaccccaacccccccaaaaaaaaaaaaaaaaacccccccccccaaaaaccaaaaaacccccaaaaaaaaaaaaaccccaaaaaaaacccccccaacccccaaacccccccccccccaaaaaaacccccccccccccccccccccccccccccccccccccaaaaaa 42 | -------------------------------------------------------------------------------- /inputs/15.input: -------------------------------------------------------------------------------- 1 | Sensor at x=98246, y=1908027: closest beacon is at x=1076513, y=2000000 2 | Sensor at x=1339369, y=2083853: closest beacon is at x=1076513, y=2000000 3 | Sensor at x=679177, y=3007305: closest beacon is at x=1076513, y=2000000 4 | Sensor at x=20262, y=3978297: closest beacon is at x=13166, y=4136840 5 | Sensor at x=3260165, y=2268955: closest beacon is at x=4044141, y=2290104 6 | Sensor at x=2577675, y=3062584: closest beacon is at x=2141091, y=2828176 7 | Sensor at x=3683313, y=2729137: closest beacon is at x=4044141, y=2290104 8 | Sensor at x=1056412, y=370641: closest beacon is at x=1076513, y=2000000 9 | Sensor at x=2827280, y=1827095: closest beacon is at x=2757345, y=1800840 10 | Sensor at x=1640458, y=3954524: closest beacon is at x=2141091, y=2828176 11 | Sensor at x=2139884, y=1162189: closest beacon is at x=2757345, y=1800840 12 | Sensor at x=3777450, y=3714504: closest beacon is at x=3355953, y=3271922 13 | Sensor at x=1108884, y=2426713: closest beacon is at x=1076513, y=2000000 14 | Sensor at x=2364307, y=20668: closest beacon is at x=2972273, y=-494417 15 | Sensor at x=3226902, y=2838842: closest beacon is at x=3355953, y=3271922 16 | Sensor at x=22804, y=3803886: closest beacon is at x=13166, y=4136840 17 | Sensor at x=2216477, y=2547945: closest beacon is at x=2141091, y=2828176 18 | Sensor at x=1690953, y=2203555: closest beacon is at x=1076513, y=2000000 19 | Sensor at x=3055156, y=3386812: closest beacon is at x=3355953, y=3271922 20 | Sensor at x=3538996, y=719130: closest beacon is at x=2972273, y=-494417 21 | Sensor at x=2108918, y=2669413: closest beacon is at x=2141091, y=2828176 22 | Sensor at x=3999776, y=2044283: closest beacon is at x=4044141, y=2290104 23 | Sensor at x=2184714, y=2763072: closest beacon is at x=2141091, y=2828176 24 | Sensor at x=2615462, y=2273553: closest beacon is at x=2757345, y=1800840 25 | -------------------------------------------------------------------------------- /inputs/16.input: -------------------------------------------------------------------------------- 1 | Valve XB has flow rate=0; tunnels lead to valves WZ, LE 2 | Valve BM has flow rate=0; tunnels lead to valves PL, RI 3 | Valve GC has flow rate=0; tunnels lead to valves HN, IT 4 | Valve RM has flow rate=0; tunnels lead to valves ZQ, YL 5 | Valve ZM has flow rate=5; tunnels lead to valves SN, KE, UW, MY, GW 6 | Valve UH has flow rate=0; tunnels lead to valves HM, HN 7 | Valve GW has flow rate=0; tunnels lead to valves LE, ZM 8 | Valve HN has flow rate=19; tunnels lead to valves UW, UH, GL, WZ, GC 9 | Valve VT has flow rate=0; tunnels lead to valves ZD, PE 10 | Valve VI has flow rate=0; tunnels lead to valves JS, AA 11 | Valve YL has flow rate=12; tunnels lead to valves PM, MH, RM, CM 12 | Valve LA has flow rate=0; tunnels lead to valves SN, IY 13 | Valve CM has flow rate=0; tunnels lead to valves YL, UL 14 | Valve JI has flow rate=24; tunnels lead to valves UV, WH, XW, OJ 15 | Valve ZD has flow rate=25; tunnels lead to valves VB, XW, VT 16 | Valve VB has flow rate=0; tunnels lead to valves QX, ZD 17 | Valve FO has flow rate=0; tunnels lead to valves WH, PE 18 | Valve JS has flow rate=0; tunnels lead to valves VI, IY 19 | Valve RI has flow rate=0; tunnels lead to valves PE, BM 20 | Valve XD has flow rate=14; tunnel leads to valve CP 21 | Valve ES has flow rate=11; tunnels lead to valves GU, WU 22 | Valve WZ has flow rate=0; tunnels lead to valves XB, HN 23 | Valve HW has flow rate=0; tunnels lead to valves QY, LE 24 | Valve KE has flow rate=0; tunnels lead to valves AA, ZM 25 | Valve IY has flow rate=22; tunnels lead to valves JS, AB, LA, IT 26 | Valve XW has flow rate=0; tunnels lead to valves ZD, JI 27 | Valve BE has flow rate=0; tunnels lead to valves AB, LE 28 | Valve QY has flow rate=23; tunnels lead to valves AM, HW, MY 29 | Valve MH has flow rate=0; tunnels lead to valves YL, AM 30 | Valve IT has flow rate=0; tunnels lead to valves GC, IY 31 | Valve DA has flow rate=0; tunnels lead to valves QR, CP 32 | Valve PM has flow rate=0; tunnels lead to valves LE, YL 33 | Valve WU has flow rate=0; tunnels lead to valves SM, ES 34 | Valve UL has flow rate=0; tunnels lead to valves CM, QR 35 | Valve SM has flow rate=13; tunnel leads to valve WU 36 | Valve XC has flow rate=0; tunnels lead to valves ZJ, AA 37 | Valve OJ has flow rate=0; tunnels lead to valves GI, JI 38 | Valve SN has flow rate=0; tunnels lead to valves LA, ZM 39 | Valve WH has flow rate=0; tunnels lead to valves JI, FO 40 | Valve UW has flow rate=0; tunnels lead to valves HN, ZM 41 | Valve HM has flow rate=0; tunnels lead to valves UH, PE 42 | Valve AB has flow rate=0; tunnels lead to valves BE, IY 43 | Valve QR has flow rate=8; tunnels lead to valves WW, UL, DA 44 | Valve UV has flow rate=0; tunnels lead to valves JI, FF 45 | Valve ZQ has flow rate=20; tunnel leads to valve RM 46 | Valve ZJ has flow rate=0; tunnels lead to valves PE, XC 47 | Valve GL has flow rate=0; tunnels lead to valves HN, PL 48 | Valve CP has flow rate=0; tunnels lead to valves DA, XD 49 | Valve AM has flow rate=0; tunnels lead to valves QY, MH 50 | Valve PL has flow rate=17; tunnels lead to valves GL, YE, BM, FF, QX 51 | Valve YE has flow rate=0; tunnels lead to valves PL, AA 52 | Valve PE has flow rate=4; tunnels lead to valves FO, RI, ZJ, VT, HM 53 | Valve MY has flow rate=0; tunnels lead to valves QY, ZM 54 | Valve QX has flow rate=0; tunnels lead to valves VB, PL 55 | Valve GI has flow rate=0; tunnels lead to valves OJ, AA 56 | Valve WW has flow rate=0; tunnels lead to valves GU, QR 57 | Valve FF has flow rate=0; tunnels lead to valves UV, PL 58 | Valve LE has flow rate=6; tunnels lead to valves HW, GW, XB, BE, PM 59 | Valve GU has flow rate=0; tunnels lead to valves ES, WW 60 | Valve AA has flow rate=0; tunnels lead to valves KE, GI, VI, YE, XC 61 | -------------------------------------------------------------------------------- /inputs/17.input: -------------------------------------------------------------------------------- 1 | >><<<>>>><<<>><>>>><<>>><<<<>><<<<><<<><<<>><<>>><<<<><>>>><<<>>><<>>>><<>>>><>>>><<><<<>><>><<<<>><<<<>>><<>><<>>>><<<<>>>><<>><<<>>><<<<>><><>>><<<<><<>>>><<>>><><<>><<<<>>><<<<>>><<<<><>>><<<>>>><<>>>><<>><<<>><<<><<<>><<>><<><<<><<>>>><<<<><<<<>>>><>><<<><>><<>>><<<<>><><<>><<<>>><<>>>><>>>><<>><><<<>><<<<><<<>><<<><<<<>><<>>>><<><<<>>>><<<<>>>><<><<<<>><>>>><>><<<>>>><<<>><>>><>>><<>>>><<<<>>>><<<<>>><<>>>><<<<>>><<>>>><<<>>>><<><<><>><>><<<<><<<<>><><>><<<<><>><<<>><<<>>><>>>><<<<>>><<>>><<<>><<<><>>>><<>>><<<<>>>><><<<>><>><<><<<<><><<<><<<<>>>><>>>><><<>>>><>>>><<<<>>><<<>><<<>>><<<<>>>><<<<>>><<<>>>><<<<><<>>>><<><<<<>><<<><<>>><<<>>><<>>>><>>>><>>><><>>><>>>><>>>><><>>>><>><>>>><<<>><<<<><<><<<<><<>><<>><<>>><<>><>>><>><<<>>><<<>>>><>>><>><<<<><<<>>><>>><><<>><>><<<<>>>><><<<>><<<<>><<>>><<>>><>>>><<<<>><<><><<>>>><<<>>>><<>>><<><<><<>>><<><<<><<>><<>><<><<<<>>><<>>>><<>>><<<>><<<<>><<<>><<>><<>><<<><>><<><<<>>>><<<<>>><>><>>>><<<<><<>>>><><<<><<>><<>>>><>><<<>>><<><<>>><>>>><<>>><>>><<<<>>><<<>><<<<><<<><<<<><<<<>><<<<>>><<<<>>><<<<><>>>><<<>>><<><<>>>><<>>><>><<>><><<<>>>><<>><>>>><<<><>>><<<<>><<<<>>>><<<<>><<<<>><>><<<<>>><<<>>><<<>>>><<>><<<<>><<<<>>><<><<<><<<<>>><<<<>>><><<><<>>><<<<>><>>><>>><<<><<<>>><<<>>>><<>>><><<>>><<<>><<>><<<<><<><<<<>><<<<>><><<<>>><<>><<<<><<<>>><>>>><<>>>><>>>><<<<>><>>><>><<>><<<><<>><<><<<<>><<<<>>><<<><<<<>>><<<<>>><<<>><<>>><<<>><<<<><<<>>><<>>><<><>>>><<<><<<>>><<<<>>><<<<>><<><<<<><<<>>><<>>>><<<>>><<>>>><>>>><<><<><>>><<<>>><<<<>>><<>>><<<<><>>>><<<<><<<>><<<<>>><>>><<<>>>><<<<><>><>>><<<<>>><<<><<<>>><>><<><<<<><<>>>><<<<>>><>>>><<<>>>><<<>>>><>>><>>><<<>>>><<<>>>><<<>><<>><<>>>><<<>><<>><><>><>>>><<<><<<<>>><<<<>><<>><<>>><<<>><<<<>>>><<<<>>>><>>>><<>>>><<<<><<<>><<><>>>><>><<<>>><<<>>>><<<<>>>><<>><<<<>>>><<>>>><<<<>><<<>>>><<<><<<><<<<>>>><>><<<><<<<><<<<>>>><<>><<<<>>>><<<>>>><<<><>>>><<<>><<<><<>>>><<<<>><<>><<<>><<<>>>><<<>>><>>><<>>>><<<><>>><<<<>><<<><<<><<<<><<>>>><>>><>>>><>><<<><<<><<<>>>><><<><>>>><<<><<>>>><<<>><<<<>>>><<<>>>><>>><>><<<<>>><>><<><<<<>>>><<><><<<><>><<>>>><>>>><<<>>>><<>><<<<><<<><<><<<<>><><<<<><<<>><>><<<<><<<<>><<<>>><<>>>><<>><<<>>>><<>>><<><>>>><<<<><<><<>>>><<<>>>><<><<<>>><>><<<<><>><>><>>><<<<>><<<><<<>>>><<>>>><<>>><<<<>>>><<><<<<>>><<<><><>>><<<<>>><<<<>>>><<<<>>><><<<<><<<><<<<>>>><>>>><>>>><<<<>>><>>>><<<><<<>>><<><<<<><<<>>><<><<<>>>><<>><<><<<>>>><<<>>><<<<><<<>><<<<>>>><>>><<<<><>>><<<<>><<<<>>>><>><<<>>><>><<<<><<<><<<>>>><<<>>>><<<>>>><<<<><>><<<<><<<<><<>>><<<<>>><<<>>>><<<>>>><<>>><<<<><<<<>>>><<<>>>><<<>>>><>>><<<><<<<><>><<>>><<<>>>><<><>>><<<<><<><<>>><<>>>><>>><>>>><<>>>><<>>>><<<<>><<>>><<>>><<<><<>>>><<>>>><<<>>>><>>>><<>>><><<>>><<<>><<<>><<<><<<<>><<<><<<<><>><>>>><<>><<<>><>>><<>>>><<>>><><<<>>>><<<><>>>><<<<>><<<>>>><<<<>>><<<>>>><<>><<>><<>>>><<>>>><><<<><<<<>><<>>>><<<<>><>>>><<>>><<<>>><<>><>>>><<<>>><<<><<><<<<><><<><<<<>><<>><<>>>><><>>>><>>>><<<<>><<<>>><<<<>>>><<>><<<<>>>><<<<><<<><<<<>><>><><<<<><<<>>><<><>>><><<<<>>><<>><><<<<>>><<<<><><<<<><<<>>><><>>>><<<>><<<<>>>><<<>>>><<>>><>>>><>><>><><<<>>>><<><><>><<>><<<<>>><<<<>>><<<>>>><<<<>><<>><<<<><>>><>>><>><<>>>><>>>><<<<>><<>>><<<<><<<>>><<<<>><>>><<>>>><<<>>><>>><<>><<<>>>><<<>>><<><><<<>>>><<<>>>><<<<>>>><<<>>><<<>>>><<>>>><<>><<<>>><<<<>><<<>>>><<>><<<>>>><<<>><><<<>><<><>>>><<<<>><>>>><>><>><<>>><><<><>><<<<>><<<>><<>>>><<<<>><><<>>><<<<><<<><>>><<<>>>><<><<>><>>><<<<>>>><<><<<>><<<><<>>><<<<><<<<>><<<<>>>><><<>>>><<<>>><<<>>><>><>>><<<>>><>>><><<<<>>><<<<>>>><<><>><><<><<<<>>><<<<>>>><<<<>>>><<<<>><<<><>>><<<>><<<<>>>><>>><<<>><>>>><<<><<>>><<<<><<<>>><<>>>><<><<<>>>><<<>><>>>><<>>>><>>><<<<>><<><<<>><<<>>>><<><>><<>>>><<<<>>><<<<>>><<<<>><>>>><<<<>>><<>><<<<>>><<<>>>><>>><<>>><<<<>><<<><<<<>>>><<<><<><>>>><>>>><<<<>><<<>>><>><<<<>>><><<>>>><<>>><><<>>><><<>><<><<>><<<<><<<<>>><<>><<>>><>><>><<>>><<><<>><<>><<<>>><<>>><<>><<>>>><><<<<>><<<<>>>><<<>><>><<<><<><>>>><<<<>>>><>><<<<>><><>>><<><<<<><<<>>><<<>><<>>><>>><<>>>><<<>><<<><<>>>><<<>>><<<<>>>><<<<>>>><<<>><<<<><>>><<<<>>><>>>><<<<>>><<<>>><<<>><<>>>><<>><<<<>>><<>><<<>>><<<<>><<<><<>>>><<<>><<<<><>>><<<>>>><<>>><<>><<><<<>>>><<<>>><<>><<<>>><<<<>>><<<>><><<<<>><><<<>>>><><<<>>><<>>><<>><<>><<<<><<<<>>>><<><<<>>>><<<>><<>>><<<>>>><><<<>><<>>>><<<<><<<>><<>><<<<>><<><<>>><>>><<<><<<<>>><<<>><<<<>><>><<<>>><<<<><<<<><<<>>><<<<>>><<>>>><<>><<<<><<>><>>><<>>>><>>>><<><<<>>>><<<>>><><<>>>><<<<>><<<>>><><<>>>><<><<<>>>><<<>><<<>>>><><<<><<>>>><<<>><>>><><><<<<>><<>><>>><<<<>>><<><<><<<><<<>>><<<>><<<>><<<>><<>>><>>><<<<><<<<>>>><<><<<><<<<><<<<><<<>><>>><<<>>><<<><<<>>><>>>><<>>>><>>><<<<><<<<>>><<<>><<<>><>>>><<<>><<<<>>>><<<<><>>><>>>><<<<>>>><<<<>><<<>>>><<<>>><<<<>><<<><<<>>>><<>>><<>>><>>>><><>>><<<<>>><<<>>>><>>><<<<>><>>>><<<<>><>>>><>>><><>><<>>>><<><><<><<<>>>><<<<>>><<>>><<<<>><><<<>><>><<<><<>>><<<>>>><<>><<<>>>><<<<>><<>><<<>><<<>>>><<<<>><>><<<><<<<>>>><<>>>><<><<<<><<<><<<<><<<<>><><>>>><<<<><>>>><<<><<<><>>>><<<<>>>><>>>><<<<>>>><<<>><>>>><<>>>><<<>>><>><<>>>><<<<>><<<><<<>><<>>>><<>>><<<<>>><<><<<>>><<<>><<<<>>>><<<<>><<>><>>>><><><>>>><<>>><>>>><<>>>><<<>>>><><<>>><<><><<<><<<><<<>><><<>>><<>>><<<<>>>><>>>><<>><<<<>><<<>>>><<<<>>><<>>><<>><>>><<<<><>>>><<<>>>><<<>>><>>><<><<<>>><>>><<><<<<>><<<>>>><<<>>>><<<<>>><<<<><<<>>>><><><<<<>>>><<<>>>><<<<>>><<<>><<<<><<>><<>><>><>><>><<>><<<><<<<>>><<>>><<>>>><>>>><>>>><<<<>><<<>>>><<<>>><<<<>>><>>>><<<>>><><<><<<<>><<<>>><<>><>><<><<<>><<<<>>>><<<>>><<<<>>><>>>><<<>>><<>><<>><<<<>><<<><<<>>>><<<<>><<<><>>>><<<<>>>><>><>><<>><<<<>>><>>><<>>><<<>>>><<<<>><<<>>>><>>><<<<>>>><>>><<<><<<><<<>>>><>>>><>><<<<><<<>><<<<>><<>><<<>>><<<>>>><<<<><<<>><<>><>><<<>>>><<>>><<><<<<><<<>>>><<<<>>>><<>>>><<<<>>><<<<>><<>><<<<>>>><><<<><<><>>><<<><<<<>>>><><<><>>>><<>><>>><><<<>>><<><<>>><<<<>>><><><<<>>><>><<<><<<<><<<>>>><>>>><>>>><<<>>>><<><<<>>><><><<<<>><<<>>>><<<<>>>><<<<><<>><<<><><>>><>>>><<<>>><<<>><<>><<<>><>><<><>>>><>><<<<><<<<>>>><<<<><<<><<>><>>>><><<<><<<>><<><<>>><<<<>>>><<<>>>><>><>><<>>><<<>><<>>>><>>><<>><<>>>><<>>>><<>>><<<><<<<>>>><>><>>>><<>>><><<<>><>><>>>><<<<>>><<><<<><>><><>>>><<>>><<>>>><<>>><<>>><<<><<<>><<<>><<<><<<>>><><<<>>>><<>><<<><<<<>><<<><>>>><>>><<<><<<<><>>>><<<>>><>>>><<<>>>><<<<>>><>>><<<>>>><<>><><<><<<<>>>><<>><<<<>>>><><>>>><>>><><<<<>>><<><<<<>>><<<<>>>><<<<>><<<<>>>><>><<<<><>>><><<<<>>><<>><>>><<<>><<<<>>><<<<><<>><<>><>>>><<<<>><<<<><<>><>>>><<<>><<<<>>><<>>><<<<>>><<<<><<<<><>>>><<<<>>><<>><<<<>>>><<<<>>>><<<<>>>><<<>>>><<<>>><<<>>>><<<><>><><<<<><<<>>>><>>><<<<><<<<>>><<<<>>>><<<<>><>><<>>><>>>><<>>>><<<><<<>>>><<<>>>><<><>>>><<>><>>>><<>>><<<>>>><<<>><<><>>>><<<<>>>><><<>><<><<<<>>><<<<>>><<<<>>><>>>><<<>><<><<>><<><<<>>><<<<><<<<><<<<><>><<<<>>>><<>>>><<<<><<<>><<>>><><<>><<<>>>><<<<>>><<>>>><>>><<<<><<<<>>>><<>>>><>><><<<<>>><>><<<<>><<<<>><<<>><<>>>><<<>><<<>><<<><<>><<<<>>>><<<<>><<<<><<<<><<>>><<>>><<<<>>>><><>>>><<<><<<>>><>><<<<>>>><<>>>><<>>>><<>><<<><>><<<><<>>>><>><<<<>><>>>><<>><<>>>><>><>>>><><<<<>>><<>>>><<<<>>><>><<>>>><>>><<<><>>><<<><>>>><>>>><<<>><<>>><>><<<<><<<<>><<<>>><<<<>>><<<>><<<>><>><<<<>><<>>>><<>>><<<>>><<<><>>>><<>><>>><<<>>>><<<<>><<<>>>><<<>>>><><<><<<>>><<<<><<>><>>><<>>><<<>>><<>><<<><<<<>><<<<><<>>>><<<<>>>><<<<>>><<<><>>><<>><>><<<><<<>>>><<<>>><<>><<>><<<>>><>>><<<>>>><<<>>><<<>><<<>><>>><<>>><<>>>><<<><<<>>>><<>>><<<<>>>><<<>><>><<<<>>>><<<<>>><<<>><<<><<<>>>><>>><<<>><><<>><<<<>>>><<<><<<><<<>>>><><>>>><<<>><<<>>><<>>>><<><<<>>>><<<<><<>>><<<<>>>><<><>>><<<>>><<<>>>><<<<><<>>><<<<>>>><>>>><<<>><<<<><>>>><<>><<>><<<<><>>><<<><<<<><<<>>>><<<<>>><<>>><>><><>>><<<<><<><<<<>>>><<<<>>><<<><<<><<<><><<>><<<>><<>><>>><<>>><<>><<<>><<<<>>>><<<<>><>>>><<<<><<>>>><>><<<>>><<<>>>><>>><<<><<<<><<<>><<<>><<<<>>>><<>>><<<>>>><<>>>><<<<>>>><<>>>><<>><<<>>>><<<<>>><<<<><<<<>>><<>>>><<<>>>><<>>>><>>><<>>><<<<>><<<<>>><>>><<<<>>><><<<<>>><<<<>>><><><<>>>><<<<>>><<<<>>><>><<<<>><<>>><<<<>><>><<>><<<>>>><<<<>>>><><<>>>><<<<>>><<<>>><>>>><<<<>>><<<>>><<>><<<<>>>><>><>><<<>>><<<>>>><<><<>><<<<><>>><><<<><>>>><>>>><<<>>><<<>>>><<>>>><<<>>><<<>><<><>>>><<<>>>><<><<><>>><<<<><>><<>><><<>>>><<<<>>><>>><>>><<>>><<<<><>>><>>><>><<<<>><><<<<>>>><<<>>><<>>>><<>>><<<<><<><<<><<<>>>><<<>>>><<<<>>><<<>>><<<<>><>>><<>><>>>><<<<><>><<>>>><<>>>><<<>>><<<<>>>><<>>>><<><<<><<<<>>>><<>>>><<<><<<>>>><<<>>><<<<>><<<>>><<<>><<>><<<<>><<<>>>><<>>>><<<<>>>><<><>>><<>><<<>>><<<>>>><<<<>><<><<<<>><>>>><<>>>><>><<><<>>><><<>><<<<>>><<>>>><<<>>><<>><<>><>><><<><<<><<<<>>><<>>><<><<>>>><<<>><<>><<<>><<>><<<<>><<>>><<>><>>><<>><<>>>><<<<>>>><>><><>>>><>><<>>>><>>><>>>><<<><<<<>><>><>>>><<>>><<<<>>>><<<<>>><<<<>><<>>>><<<<>>><<<>><<<>>>><>>>><<>>><<>>>><>><<<<>>><><<<>>>><<<>><>>><<<<><><<>><<>>>><>>>><<>><><<<>>><>>><<<<>><<>><<<<>><>>><<>>>><<<<>>>><<<<><<<<>>><><<<>>><>><<<>><<<<>><<>>><<<<><<<>>>><<>>><<<<>><>>>><<>>>><<<<>><<<<>><<<>><<<<>>><>>>><<>><<><>><>>><<>>>><<<>>><<<>>><>>><>>><<<>><<<><<><<<<>><<><>>><>>><<<>>><<<>>><>>><<<<>>><<>><<<>>>><<<>>><<<<>>>><<<<>>><><<<>><>>><<<>>>><<>>>><<><>><<>><<<>>><><<<>><<>>><<<<>>><>><<<<><><>>><>><>>><>>><<>>>><<<><<<<>>><>>>><<>><>><<<<>><<<>>><<>>>><<>>>><><<>>><<<><<<<>><<>>>><>>>><<<>>><<>>><<>><<>>>><<<>>>><<<<>><<<><<<>>>><<<<>>>><<<<>>><><<>>><>><><<<<>>>><<<<><<>>>><>>>><<<<>><<<>><<<>>><><<<<><<<<><<<<><<<>>><<<<><<<<>>>><<><<><<<>>>><>>>><>><<<<>>><>>><<<<>>>><>>><<<<>><<><<<<>>>><<<<><<<<>>>><<<>>><><<<<>>>><<<<><<><<<<>><><<><>>><>><<<<>>><<<<>>><<<<><>>>><<>>>><<<<>>>><<<>><<><<>><<>>><<>>>><<<>><>>><<><<<<><<<><<<>><<><>>><>>><<<>>>><<<<>>><>>><<>>><>><<<<><<<>>><<>>>><<<>><<<>>>><<<<>>>><<<<>>>><<<>><>>><<<>><<><<<<>><<>><<>><<>>><><<<>><<<<>>>><<>>><<>>>><<><<>>>><>>><<<><><<>>>><>>><>>><><<><<><<<>><<<>><<<<>><><<<<>>>><<>><<>>><<>>><>>><>><<<<>>><>><>><<<><<<>>>><<<<>><<<>>><<<><<<><<<<>>><>>><>>>><<><<<<>><<><<>><>>><<<>><<>>>><<<<>>><<>>>><<><<<<>><>>>><<<<>><>>>><<<<><<>>><<<>>>><<<><<<>>>><<><<<>><<>><<>><<<>><<<>><>>>><<<>>>><>>><<<<>>>><<><><<>><<<<><>>><<<<>><<<><>>>><><<<<>>><<<><<<>>>><<<<>>><<<<>>><<<>>><<<<>><><<<>>><<>>><><<<<>>><<>>><<<<><<<<>><<>>><>>>><<<><<>><<<<>>>><<<<>>><<<<>><><<>>><<<<>>>><<>>><<<<><<><>>>><<<<>>>> 2 | -------------------------------------------------------------------------------- /inputs/19.input: -------------------------------------------------------------------------------- 1 | Blueprint 1: Each ore robot costs 4 ore. Each clay robot costs 4 ore. Each obsidian robot costs 4 ore and 5 clay. Each geode robot costs 3 ore and 15 obsidian. 2 | Blueprint 2: Each ore robot costs 4 ore. Each clay robot costs 4 ore. Each obsidian robot costs 4 ore and 17 clay. Each geode robot costs 2 ore and 13 obsidian. 3 | Blueprint 3: Each ore robot costs 4 ore. Each clay robot costs 4 ore. Each obsidian robot costs 3 ore and 6 clay. Each geode robot costs 2 ore and 14 obsidian. 4 | Blueprint 4: Each ore robot costs 2 ore. Each clay robot costs 2 ore. Each obsidian robot costs 2 ore and 20 clay. Each geode robot costs 2 ore and 14 obsidian. 5 | Blueprint 5: Each ore robot costs 3 ore. Each clay robot costs 3 ore. Each obsidian robot costs 2 ore and 12 clay. Each geode robot costs 2 ore and 10 obsidian. 6 | Blueprint 6: Each ore robot costs 4 ore. Each clay robot costs 4 ore. Each obsidian robot costs 3 ore and 7 clay. Each geode robot costs 4 ore and 11 obsidian. 7 | Blueprint 7: Each ore robot costs 4 ore. Each clay robot costs 4 ore. Each obsidian robot costs 2 ore and 9 clay. Each geode robot costs 3 ore and 15 obsidian. 8 | Blueprint 8: Each ore robot costs 4 ore. Each clay robot costs 4 ore. Each obsidian robot costs 4 ore and 10 clay. Each geode robot costs 2 ore and 7 obsidian. 9 | Blueprint 9: Each ore robot costs 4 ore. Each clay robot costs 3 ore. Each obsidian robot costs 4 ore and 15 clay. Each geode robot costs 4 ore and 9 obsidian. 10 | Blueprint 10: Each ore robot costs 2 ore. Each clay robot costs 4 ore. Each obsidian robot costs 4 ore and 19 clay. Each geode robot costs 2 ore and 18 obsidian. 11 | Blueprint 11: Each ore robot costs 2 ore. Each clay robot costs 3 ore. Each obsidian robot costs 3 ore and 17 clay. Each geode robot costs 3 ore and 10 obsidian. 12 | Blueprint 12: Each ore robot costs 4 ore. Each clay robot costs 3 ore. Each obsidian robot costs 2 ore and 10 clay. Each geode robot costs 4 ore and 10 obsidian. 13 | Blueprint 13: Each ore robot costs 3 ore. Each clay robot costs 3 ore. Each obsidian robot costs 2 ore and 16 clay. Each geode robot costs 3 ore and 14 obsidian. 14 | Blueprint 14: Each ore robot costs 4 ore. Each clay robot costs 4 ore. Each obsidian robot costs 2 ore and 7 clay. Each geode robot costs 4 ore and 13 obsidian. 15 | Blueprint 15: Each ore robot costs 3 ore. Each clay robot costs 4 ore. Each obsidian robot costs 4 ore and 18 clay. Each geode robot costs 3 ore and 8 obsidian. 16 | Blueprint 16: Each ore robot costs 2 ore. Each clay robot costs 4 ore. Each obsidian robot costs 4 ore and 11 clay. Each geode robot costs 3 ore and 8 obsidian. 17 | Blueprint 17: Each ore robot costs 3 ore. Each clay robot costs 3 ore. Each obsidian robot costs 3 ore and 17 clay. Each geode robot costs 4 ore and 8 obsidian. 18 | Blueprint 18: Each ore robot costs 4 ore. Each clay robot costs 3 ore. Each obsidian robot costs 4 ore and 6 clay. Each geode robot costs 3 ore and 11 obsidian. 19 | Blueprint 19: Each ore robot costs 3 ore. Each clay robot costs 3 ore. Each obsidian robot costs 2 ore and 20 clay. Each geode robot costs 3 ore and 18 obsidian. 20 | Blueprint 20: Each ore robot costs 4 ore. Each clay robot costs 3 ore. Each obsidian robot costs 2 ore and 14 clay. Each geode robot costs 4 ore and 11 obsidian. 21 | Blueprint 21: Each ore robot costs 4 ore. Each clay robot costs 3 ore. Each obsidian robot costs 3 ore and 20 clay. Each geode robot costs 2 ore and 19 obsidian. 22 | Blueprint 22: Each ore robot costs 3 ore. Each clay robot costs 3 ore. Each obsidian robot costs 2 ore and 19 clay. Each geode robot costs 2 ore and 12 obsidian. 23 | Blueprint 23: Each ore robot costs 4 ore. Each clay robot costs 3 ore. Each obsidian robot costs 3 ore and 17 clay. Each geode robot costs 3 ore and 13 obsidian. 24 | Blueprint 24: Each ore robot costs 4 ore. Each clay robot costs 2 ore. Each obsidian robot costs 2 ore and 16 clay. Each geode robot costs 2 ore and 8 obsidian. 25 | Blueprint 25: Each ore robot costs 3 ore. Each clay robot costs 3 ore. Each obsidian robot costs 3 ore and 19 clay. Each geode robot costs 2 ore and 9 obsidian. 26 | Blueprint 26: Each ore robot costs 2 ore. Each clay robot costs 2 ore. Each obsidian robot costs 2 ore and 7 clay. Each geode robot costs 2 ore and 14 obsidian. 27 | Blueprint 27: Each ore robot costs 4 ore. Each clay robot costs 3 ore. Each obsidian robot costs 4 ore and 5 clay. Each geode robot costs 3 ore and 10 obsidian. 28 | Blueprint 28: Each ore robot costs 4 ore. Each clay robot costs 4 ore. Each obsidian robot costs 2 ore and 15 clay. Each geode robot costs 3 ore and 16 obsidian. 29 | Blueprint 29: Each ore robot costs 3 ore. Each clay robot costs 3 ore. Each obsidian robot costs 2 ore and 14 clay. Each geode robot costs 3 ore and 17 obsidian. 30 | Blueprint 30: Each ore robot costs 4 ore. Each clay robot costs 4 ore. Each obsidian robot costs 4 ore and 15 clay. Each geode robot costs 4 ore and 20 obsidian. 31 | -------------------------------------------------------------------------------- /inputs/23.input: -------------------------------------------------------------------------------- 1 | ######.##.#.###.#..##.#....#..###...#...##.#.#..##.#...#..##.#..#####. 2 | .#.#....#.###.#....###......#..#.########.##.##..##...##.###.#.##.###. 3 | #...###.##.#.##.#.##.#..##.#.....##.#.....#.#.#.#####.#####.#.#.....## 4 | .###.#..##...#.#.#..#...###...#.#..###.#####..#.##....#.##.#..#...##.# 5 | ...####.#####.##..#.#...#.###..#######..###.#.#.#####.#.#..##........# 6 | ......##.##...##..#..########.....#######..#.####.#..##..##.#####..##. 7 | ##..#####..#.#..#.##..#..#..#..#####.####.#....#...##....##.###..#.#.. 8 | ...#.#.####.##.###.#...#.##......###..#.####..##.#..#.#.##.#..#...###. 9 | .#...#######.#.####.##..###....#.....#..###.#..#..#.#..####.#.#.###### 10 | ......#.###.#####...........##.#..####..##.##.....###.######..##..#... 11 | ###...#.##....#.##...#.###....##.......#.#.##..#......###...###.####.. 12 | ####.#.......####.####.#.########..#.#..#.#.###.######...##..##....##. 13 | #.#.#..#...#.#...##.#####..###...........###..##..####..#.#.#######.## 14 | ###...#..#..#..#.####.###.#..####...#.#....#.....########...##...###.# 15 | #.#...##.#.###..##..##.##....##..#.####.#.##.#.##..#.#.###.#.#.#.#.### 16 | ..#.######.##.#.#...##.###.##.#.####.##..#...#.#.##.####.#..###....#.. 17 | .##########...###....###.#.##..#.#.#..#.##..#.#...##..#.##.#..#..##.#. 18 | ..######.###..##.##.....#.#...#####.##..#.#.##....###.#.....#...#.#..# 19 | .....###.#..##...##...#.#.#.#####....##.##.#.#....#...######.###.#.... 20 | #....#..###.#.##.##...###.#####.#....#....###.#..#.##..#.#...#.####### 21 | ##...#..###....#..#...#..###.#.##.#.##.#..###..##...##....##..##.#.#.# 22 | #..####..#.###..#.#.#.##...#..####.#.....#..######......#########.#... 23 | .##.###..#....###.##..#####.###.....##..#.........#......#.#..#.#.###. 24 | ##..######.###.###.#....#..##.#.#...#..##...##...##.##...#..##.#...### 25 | .....#..#..##..#.##..#.#.#.#.##.#.#.#.###...##.#.#.#.#..#.#......####. 26 | .#.#....#...#.##.####..#.###..#.###...#...#......###.####.###.##...#.. 27 | .#####.###.#.#..#.##..#.##..##..##....#.#.###....#.#....#..##...#.##.# 28 | ..##.##....#..#......###.###...###.#####.#...##..#####.###.##.##.#...# 29 | ##..###..#.###.###.####.##..#...##..##.#......#.##..##.#....#.#..#.#.# 30 | ##......#..#.#...#.#.##.....####...#.#...##.##....##.#.#.#.###.######. 31 | #..##.....#.##..#.......#.#.#.##.#####..#..##.#....#....####..##.###.# 32 | #.#.#.##.#..##.#..#.##..#........#..##.##.#..#..###.#.##..#.##.###.#.. 33 | ..#.#.###...#....#.....#....#..##.#...##.##..##.##..#..#..#.#..##.#### 34 | ####.#####.##.#..#...####.#..#.#...##...#..#..#.##...#.####..#####.##. 35 | ##..####..##.####.#####...###....####...##..##.#.....#.#..##.#...#..#. 36 | #....##.###.######...#..#..##.#.#.#.#.#.#...#..#.###..#.#.##....##..## 37 | .#.#.##.#.##...#...#.##.###.....#.#.#.#.#.#...#.#..##..#.####.#..#.### 38 | ####..##.#.#.....#.#..##.#####......#..#........######.###.######.#.## 39 | .###.#.#..##...#.##...####.#......#..#.###..################.#.#..##.# 40 | ##.........#######...###.......#..##..#.#..#...##.#..#.###..#.###.##.. 41 | ...#..#.##...######....#.#...#####...###.##.##..#..#.###.#...###.#...# 42 | .#..#.##....#...###.###...###..###.##......#.##...#.#...##.######.#..# 43 | ##.#.##.###...#.##..#.###.....#.#..##.#.##..##...#.#######.#.######..# 44 | ##.#.###.##.#..#..##.##.##.....#.#.###...###..##....#......#.#.##..#.. 45 | #.#..#.##...#...##.##.#.#.##..##.##...#.######.##....#####.##.#.#.#... 46 | ...####....#.#.#.#.####.##.######.#####.##.###.##..###..#.###.#.#.#### 47 | #.#########...#.######.###....#.###..#....#.###.##..#...#..##...#..##. 48 | #..####...#.#.##..#.#....##.#...###.#..##.#....#..##...#.##.##.###.##. 49 | ..##.....###......##.###...#.#..##.#.####.###.###.##....#####.###.#.#. 50 | ##.#....#.#..#.##.....#.###...#..###.####.###..#.##..#..#...#......#.. 51 | #...##..####.###...#...#...#.#.#.#.#...#.###...#.##..##.#.####...#.... 52 | #...#.#.##.##.#.##.##.##..#.#.#...#..#..####.#.####..#....##..#.#.##.. 53 | ######.....#...#.##...#.###..######.#.###.#.....##...####...#.#.##..#. 54 | ####.#.##.#..###...##..###.##.##.#.####.###.##.##.##.###..##.###..#..# 55 | .#.#...###..#.##.##...####...#....#..#.#.###..###.##.#...#..#..##..##. 56 | .###.#.#..#.#..###..###....##.....##..#...###..##.#..#.#.#####.#....#. 57 | .#....##...#.###.......#....#..#.#.##.###.#.#......#.##.#....###.#.#.# 58 | ######.#..######.#####...#.#.###..##..##...###.###.#.##....#...#.##..# 59 | #.....##.#.####....###.###..##...##..#.#.##.#.#..#..###.###.###.##.... 60 | .#####..#.###.....##.##...##..#.##..##.#.##.##....#.##.#.########.#### 61 | .###..##.####..#.#..###.#...#######.###.#...##..##.....#..#.###.##...# 62 | #.#...#.#####..#..#...##.##.#.##.###.###..#.##.#.#..#..####.##..####.# 63 | .#..##.#..###...###.####.....#...#.#.##..##.#...###..####.#.##.##.#.## 64 | .#.#...###......##.##..##.#.#..###..#.##....##..##..#.#...#.#####...#. 65 | #.####.....#.#.#...#..#.#.#.###...#.#.#....#.....#.##.##.#.#.#..#..##. 66 | #....####...###..####.#.....#######.#######.#....##.#######...#..###.. 67 | ##....##..###...#.#.#.#..##....####.###.....##.##..#....##.#..#.#.##.. 68 | .......#..#.##...#.###..###..#..#..##.###.#...#..##....#.#..##.####.#. 69 | ..#.#..#.##..#..##...#....#...##.###.###...###....##....######..####.# 70 | ####.##....#.....##.#.#..####.#.###.#..####.#..##...#.#..#..#..##.###. 71 | -------------------------------------------------------------------------------- /inputs/24.input: -------------------------------------------------------------------------------- 1 | #.###################################################################################################################################################### 2 | #>>>v.<>v>.<<^v.>.<<>v>^v^>vv<<>>v^<>^vv>vv.v^.v<vv>.>^<^^<<>^^.^>v<>v^<.v.^>^.>>^^<^^vv.<<^v.>^^^.<^v><.>>^.<^^<>^.# 3 | #>^<>>>^.^>v^<^v<^v^<>>v>^>>..v<<<^>vv>.>v>><<.v>v.<^>.v^v^>vv^^>v^><>^^>>>v.<^>v.^^><v^v.^v<.v><.^<<<>^.^>>>.^>.<.<.<>v^v^<<^<<v<<<><.<<<v^v^>^v<^.<>vvv<^^>.><>^>..vvvvv^v>..<^vv.<>v^><>^^v<>v^..^^v>>..<>>vv^<^v>vv<^.<<^>>.>>>v>><># 5 | #>>>^<^.>^^><^^>^>.^><^>^^^<<^^>>>.<^vv.<<>v><..^<^<>v<<^vv>>^v<^^>^.^^<^^^v>>>>><^v^^>^>v>^v.^.v.# 6 | #>^>>v^^.>v>>>>^^>vvv>><^v<>v>><<>>^^^v<<..<^^>v>>.<>>>^><<>^>^>v<>v<^^vv.^<>>v<>v.^<>^^vv^^<^v.>>>^^.<<# 7 | #>v.<>vv^.^><>v>^<<.^<^v<^><.^<.^<>^...^<<<.>v>v^v^>v^><^<^v>>^.^^<<><^>^v>>^>>>>^>vv.v<^<.^>.v><<<><.><>^^<># 8 | #<<^^^>vv<^<..v.<>^^^>.^v.vv^><><.v^^^>^^>^v^.^v^v>.<<>v><>^^>v^<<<>^>..<^.^vv>^.^^>>vv<..^<^.vv.^<<.>>.<<^v>v^<>>^^v><^v>>^vv^>v^>v.<^<<>.^v^v^^v.v>^<^.^<<>^^>^vv>..v<^^>^.>^v^<<^<><>^>>.^>.^<.vv^.^.^<<>>>^^.v^<<^.^<># 10 | #>v^><<<>^<>v<<^^><v>^^^v^v>.v<^^<<<>v^^^>>^vv.^v>v^>.>v><.>.>^>^^v.v<^<>><<>v<^v>^^^>v><<<..<^.>.^>v.^><.vv># 11 | #>><>.vvv^vv^>^><<>vv<^>.>><>.>.<^v>>>v^^<>^>^>^>v^vvv<<v^v>^v^>v>>v^v^v>.>v<^><><<^v>v.>>..<^v>v><^.vvv.^v>>>># 12 | #.<<>^.<<<>vv^>^>>>v^.><<<.v<vv<<<<>^<^>>v>>^v>.v.<>v<<^^>>><vvvv^v>^^vv^^^^^^<<^><>vv.vv>vvv.<^v^>>^<^v^><# 13 | #>^.v^>>^^vvv>>^>^.>v.^>>><>^v^.>^<<^v.<^^v>><<>.^>>^.<^^>^v>>^<<<>><^v<<^^v.^>vv^v<<.^>^>.<<^.<^vv^vv^.>>.vv<<^vv>v># 14 | #vv<>v^>><>>v^v<^<..>vvv.v^<>><.^v.^^.<>>^<<>.v^vv^>v>v^v>>>.>^.><<<>^.<^v<^.^^v>vv>v>v^>..v>.^v>vv^><>^>^v^v^.vv^><>.v<>^># 15 | #<^<><<>.v<<^.v<^v><<^><>^.v^^^<>>^^^v.^v<v<^>>v>>.v^^>vvvvv^<^>^.>^<><<>..^<>v>v># 16 | #>.^^v.^.>v>>v.v>>>^<^<<<>v>vv.^v^>vv<^>>v^>^>^<>.>v<<^<^v^^<<><>.>v.^>^<.v<<^<^<<^^<^vv^<.vv<<><<^v.^vv.v^>^# 17 | #<>^^^<<<<^>>vvv>^>>vv^v^v.><^>.>.>>v^<>v<.>^vv<^<^<><><.<^v^>v<.v^<^^^v<^v<<^v>^>v>>^^^v^v>^vvvvv.vv>>^^>>^v<^v>^^^><# 18 | #<.v><.v<<^^>>v><^>.^<>^>vv<<v>v^^v^^^>v<>.^^^v><^<^<<^.^><.vvv.v^<^>vv^<<^>.><<^v<^^<>>v<^>v.v^># 19 | #>v.<<<^>v^^v<.><^^v.>^vv>^v>>^><^.><>^.>v<>>>.>^.>>^.<^>v^>.vv.>^>^.<>>>vv^>.v>.vv>>v><>v^^^>v>>^<.<<v^<>>>v><^v.^^^># 20 | #>^>.v>>^>.>>v>^<<^<>>.^>^^^vv>..v^^^v^>.^^.v.v><>v>v^>..<v^^vv>.>>^>.v..<.vv>.<^^>.>># 21 | #<>vv.>v<^<^<>>^..v>v>v^^>vv<.<.^^><<.vv.<.<^.<>.v^.^<>vv^vv.<^^>v><>v<>^v<^^<^v<>^>>^<<>^><># 22 | ######################################################################################################################################################.# 23 | -------------------------------------------------------------------------------- /inputs/25.input: -------------------------------------------------------------------------------- 1 | 12-1 2 | 1=-20 3 | 1=112011= 4 | 1=212=01 5 | 2--2-= 6 | 11-2-0201-1 7 | 1--=1-110=00===- 8 | 1=2==221011==22 9 | 22=0= 10 | 20--- 11 | 1==00-121= 12 | 2-2=--00 13 | 1110=22-10=1=12 14 | 1-1===22-1-=2 15 | 1010-22-2-121-1 16 | 111 17 | 1121102 18 | 1=-11 19 | 102=0-=-2-2=--1-2 20 | 2- 21 | 22-=000=1=-== 22 | 2011-=1221 23 | 211=02 24 | 1=-002 25 | 10---21102 26 | 1-00=2-1==-0 27 | 1012=22-22- 28 | 10-01====-010 29 | 22120020121=20 30 | 1-01=002=1=-122= 31 | 1-101-==1 32 | 1=01=1-===-- 33 | 21122 34 | 120=2=1102=1 35 | 10=20=2==20 36 | 1111200=221-1=--2 37 | 1==2-=1 38 | 11=1=2-1-21-=1 39 | 2-02=0==-1--- 40 | 120 41 | 12 42 | 10-0=-=2==2120=- 43 | 1-=0 44 | 2==-=202-11110=020 45 | 1-=212=0212--02---=0 46 | 2-=1-2=22= 47 | 1=-2-1===200-0=1 48 | 10-110 49 | 200=-2 50 | 210=-21=021-=-12- 51 | 2=-2122-20-11= 52 | 2=1-1 53 | 202=1-20=0--11 54 | 12200202 55 | 1-2-21- 56 | 100=-2 57 | 2101010-022 58 | 1=-===010=1--1-2 59 | 10-=2020===0021 60 | 11=10=0=22-10=2= 61 | 12-221-2==21=-1 62 | 1=-01--00- 63 | 21100==-0=120-=0--2 64 | 122=1-220-010-0= 65 | 120-=-0==--01222-1 66 | 1=220=1==122-1-=22 67 | 112=1-2=001- 68 | 21-012 69 | 1=21=10=1==2 70 | 2=-=--112=1--- 71 | 2-= 72 | 12020-022-210 73 | 1=122==-20-12220- 74 | 20=-021-22 75 | 1=2-020 76 | 101- 77 | 2==-010=20-120 78 | 10-2=110= 79 | 2=22 80 | 1=2=0112=22-1-=2 81 | 20=0-22---0012=2- 82 | 10121-=0=1 83 | 1--2= 84 | 1=--10222-1-2-1-2- 85 | 212-01220=-= 86 | 1-=-0==0=0 87 | 10102- 88 | 20-2-1=-120212-1 89 | 2=01= 90 | 10101-100-1-=10 91 | 210=0----00=21- 92 | 1-- 93 | 111-2=2=22--= 94 | 12-22-102==1-21-= 95 | 21-2==11 96 | 1-=-2 97 | 22=1=22-0=-20 98 | 120-= 99 | 1=20=20 100 | 2=12-12-=- 101 | 1=2--0-012= 102 | 1-2=221102 103 | 1=211=-===11-11 104 | 21-==-01=0210-- 105 | 1110-=02001 106 | 2=12 107 | 1===11=1-1-2= 108 | 212=11=11=12000 109 | 20=12-02=-=201==- 110 | 2==-=21-2=01=01-2 111 | 1-==1=0-02= 112 | 211==--22 113 | 1-2-02=0=12=1-=1211 114 | 12122-021== 115 | 1-==2110021 116 | 11210211==11= 117 | 1=- 118 | 112=12- 119 | 1- 120 | 1==-1=-110 121 | 2-2100210 122 | 2-=1---1-02220201 123 | 1201-0 124 | 1---02=-2--=-2 125 | -------------------------------------------------------------------------------- /inputs/3.input: -------------------------------------------------------------------------------- 1 | MVWpzTTrTFNNLtssjV 2 | hRJncnJCnhPCnBSbCQRhhQRPFHmsbHLzbLNHsjNNFmGGGsGF 3 | lSBQJBBBBcnccnQvBnPQznfrgwlrTZfDwTfWqrrpgMpw 4 | sRPgrzSgrSbfTrgspBPsDWWTmdnvdZWZwTmwvdmd 5 | tVGpCGqCGjlHcNGVNHZDmnZMWdWMWCdZDvnZ 6 | HqpQptLlclLGtlpcjHNhQqfRhrSBrrbfbrSRrsPfBSgg 7 | JpjLbQbFPBjDBBJLWltglfBfhhlcctht 8 | vNFmsdFsnmzGtWvgzhzc 9 | rqwRCCqmCTqHCnqRNTNFsJVMQSjLRbbVVbjQVLbLSV 10 | mLNNCNDwBwDnmCwnJwLRvdlqZclRccsgvcZndc 11 | QWMtVWbpVlgHHcgMHs 12 | VsTVWhThsVQWzjtQPpVWjWbpwJNCJDCzSNNCCCSfmfBCSGLL 13 | NbSfHnwDvwwfHwwQsHbWPgrsZsZjRPLRgLWhWP 14 | lmMlTGFzVmzqjGLLZWWGhrCh 15 | qFclMprqmrvbcnwDQtNQ 16 | tWQZFvvtWQWbqQQggZZLvpLrpzDrmGDmmDHPzPzHrfnHTG 17 | NMlhlTMccTCVBlRNHzJnzDDmnJmnGGBf 18 | NMMSSSSSlNVMdjdNSNNhFwTbvbLqjbtLwWQwZqgg 19 | jPwcJwRmmhJpbhNJVgDbrHzzzQzzBQHg 20 | tdZqlCnnnlvZCqlnlCSqZdFCHGDBgzsDzssBtHGLQtrHsssL 21 | TZZFSdrdlZMFZRMwMPmNcwNmwm 22 | nsdhzmDBGQWQPvJPjbbW 23 | gCgBqCNpMHTwgwqMPRJJTtWjbFRJFJvP 24 | ZlCwBrwgmzhGzDrd 25 | sTBHfcnBTnqHRvqPgFFbLtrQTPLjjm 26 | GWzpwSJSpbwbNNGJPQrrtrrrrgzLtjzm 27 | NNSlCCdplWwplCwSndnssdZfqVbHvfqc 28 | rrfHgqnlllRrDgrCbQfszMPtmzPQzFsFMQ 29 | JJLGVGjcwVcPQNNNtRPmLM 30 | WThVJJWJBdGwBpBTqDrSRCCggShqbSCb 31 | TbCqzqzmbCffzDbHRddLbdRFRS 32 | ZmvZJPjPwwWNZJGtWSDRRDFWSLhhhMVVWL 33 | ZwplGwmptNjZnjvnGGPjJlZppTrTsCczfggBgfgfggCsBrqr 34 | gMBBbfBbBMfnMsvRvWJhDsQW 35 | ZZqHLzczjjsLzlpjqTprNJvhQpRvtRJJQrtQtJ 36 | llZlzZZzPZZqsTZscHczfnSwSPSwwgSBwwSnPwnf 37 | chMtcPPgQtthqgvczhMTcCSBLBlGpsFnBnnsGvLplSFG 38 | bhRmJWDRmHSmFGBnGBps 39 | jdDZWbrDdDbbdbDrRRWwRjZRVqztCzqtcThcTQtgqVMMVzjq 40 | flNmNHgcZwTzRLzMLRPlzz 41 | nntqBJtFbbCbBVCnBtFjJjhVhLzLvRLvgRRvPvpMpvpp 42 | CgJWjJQDjgBtnGNGfcssNfcwNW 43 | MrMpMrGBznjPMGCmCrrjdwndfJLQNfdLQNdNggdL 44 | sJVcZqvhZtVqhDFFsDJslcdwgwvwQwwQNbbTbwfLLTgL 45 | RDDRcsSsstJstVDDqctszzmRmGjpjBRHPmmGHGrj 46 | tdplZtlrBGwTlLQQ 47 | sfsPPvNhWLQBhGQG 48 | zPVfzVbbMcscvVfzzNgcJHnJZgtrrndJqjJqndrL 49 | nglLjRCCHLLCnNCLHQnFNQmmVMbVmwMwlMwMMMWwBTsT 50 | cqtfcqZpzhSvvBfWwbvrbT 51 | PPqpDSqcSJPdPhtPtqZcpPtGjFRFFFNLJFGRgjFbGRNbHn 52 | gjtRSLMqLdSgLMCltTSDQcQQqhDcfcfrWDhWrr 53 | GwFZCwNzFJsPmFFmZmPPNhvDDfDWWmpvQWWfVDQppW 54 | swNGZbPBGwnCgBBlBljl 55 | BsrDsnQGwFFQQtfNTBNSffBgBt 56 | VJlhWVLlRppLQZTCbtZTttgJ 57 | ppLqqRhQdRPhqPVhdPjhljqHFnGnzFrjFFDznHFHrmwwnH 58 | CJMmmJLmlshCCdmzjHjPWztgdnjttt 59 | GwZvGwrgTcFpzHWjnT 60 | GbqrvrRwbrbGbwwZBbgfhmJMmsDJhNRfLChhCh 61 | CfgfjCLCgfgFgBhBsccswQwtsQHvBBtc 62 | SbSMGbnmDMGJWmRmDmvzwtcscWtQzsrPsvHc 63 | DbJdNpJSnMSJmpSSNVqgqgTTFVQTFqdZLq 64 | MBMCmlllPSSlmmPPjCMpPgggJcnZgntJsDvHsDZt 65 | hrNzhrRNbrhbGRbfpVLRGNqqngvnttngJctgDZJGcZvHvZnc 66 | LTTzVqppSmwdTmQW 67 | mmlBQmLbsbmRnFnwlqqprF 68 | dZScZSZSdHcNMDcJwLqRfppzpzfTpHfF 69 | JLWJLJJJdMmGtgCWjQjt 70 | PPMzpVDblwGVMMzDLLjrcrjdzjdTzLjd 71 | RRcCJRcNQRBqtCFBRJJsZWBWrjLWLHZZWndBLWjh 72 | qQQtttNqsqqtJRgqQfcpcgDcbggplGbfMp 73 | QmmSTQPmLSmjpczMJtwPzg 74 | BHHHdwdvDpllvctjZv 75 | HdrDHNfrrBDGGBhBNfHNsLFqmbRQSwqmGTLnTbSF 76 | gcMmgRQPqqPPsgjFSvctCHvHllSSHcvd 77 | JTWfZwhTwzbWwTFTrZnTrDDlDSVtVHLVShtvSHvlHL 78 | bWbWBfzTfwrWJNbTrnzfTwJFpmMQgqsFRsQGqRMggPmPBG 79 | GqCWpGGLpmpWjbSDGjGGmwCzZlvMBTrCvsrlwwswCl 80 | FPFHFVdJgQHJZnslrgvsTrwMlNgw 81 | hQVchcdcZZpZqcDG 82 | JbBRgBsRffgPPFQttQvQQMvG 83 | dmNZgmZVtGTNtNGC 84 | ZqqndLZnccqRbsrgpggsBc 85 | DDvMVmTjwFWPBBTzBF 86 | cqnggcbNNCqbQQqbZbpfQpqgRWlFhLRBhRzRPLFJhlJBfPLh 87 | dpscpcncbbqcpMVSvSrPDMsrjr 88 | hGCGZmVRRcMVsGMtmZWssmFLzbFblnnzfmqbfnzNNb 89 | wjrSPBJdSjjDrggpSJpdrSnlFNlzLTnqNLqqpbqqfMln 90 | dMwPBHPPJHDdvrBBhshWCGcsQRcHRZGV 91 | vdHwhqdtLdVnHBZbFBFzbBPS 92 | TmNCLNDpWfCNmpCgTWNTDMMZlzSggBMzlZlMBlBbZZ 93 | NQfWcscDNQrhqvGLrdhVjh 94 | lZLqzzqvgrCRcQcCLD 95 | HSVVwNTJzwVNTDQrRrrdrBwdhd 96 | TpNTzsfSTVsSpHVppzFpgvvlqZWZPMvMjPPGGsgP 97 | BCMLshLdLDDCgwFRwHHqqRqRWd 98 | QnSqQlGSfpQzTQJNTPNwNPFRFcccHc 99 | mfJJmztnQpGpvnSzGrsqgrhrBBhqjBrthL 100 | BSlmzmlvdNnlQlQQJnJHRVFVFVVqMtqRMfSfCw 101 | WBPsDPBBjfssFHMRRq 102 | DLWpGhbPjbhZrhZDnBQgdNZmQNgmvdzg 103 | WWvgBFgHWChBzgBFbjbtPtnPrsHlsRMrwRrMRR 104 | SGfNpfdGfVpVSGGppSDdwRwclMlfPMwccsntPqPw 105 | TVdpQDSpQZJpVpDQQFBbthvmWzmgvhbjzJ 106 | VVCCbzqdbzhFHvbdhZFPmhCPSNRNGSrPJfTNRSGJfGwPST 107 | LngtBnlcnDvLcTTRfTTwRtGNTG 108 | DpnBjMpLlLDQWDgvpLvbqzmbjzVjVHqbFFqbFq 109 | SbzMbNQQSDdmvqqzdSlWFpwZnvpFWWllpFww 110 | CjLPTPjjLCPtBCLJjBLPLBTFsFFgfwwpZgplpgFnWWRl 111 | nPncrBHGnmrbdmdmNN 112 | FnlblGlTTbNVLVtRvQQvgqRQBCvgNr 113 | DPMDMpMHmnzjPqDhQWvvQvhghq 114 | zMMcddznsjFTldVGlFGT 115 | cLSNGLhmRRVmlVCq 116 | HvzbQBzBMQMpQDpCSlSVZRSCqV 117 | QwWznWnTbQSMMJQHnvwbWjrhNhLFgsGNNrFLNnFNhd 118 | dBrWNQWWcTNqqnNN 119 | bPlmgRgRghlCVlbhwZccCZjZqvmqvmTTvGqmJTvqnGTGvLLJ 120 | DCDZhjllcpDMrSQS 121 | ddtNNTFTwRzGRGCwqnBMjlqMHMfqnB 122 | hDpPsQLLSprhnHVhqhVfHM 123 | QWLWDQZpgpWbQgfspGGRdcGcCcCcztTGZC 124 | GGHFdGwFlswcFtnvTfjMjBFfNBjNBZ 125 | JWmSJLPSRprWWPWVMMVQpZfBvvfQtj 126 | RzPSPDbDDhbhPDLRhCgGHHccsqGCqqtHzG 127 | dbSdptWddDMNtdFvttFclqMTZJlJTlMZqJTJTqjC 128 | BzfwRzrwPzfzLNGmZZCZBTGBqqlH 129 | hVNVQPNQQQVLPwhRrQwgWWvFdDsFWSbdWgdFSFDb 130 | hhSnmhtZSFSqZBJSSqqmJJRHPPLgHtPcGGGcWGtvvHwgvG 131 | fCMpfTQjTrzrzCQMsQdHGHvPGPwLppPRvWPLLc 132 | MdTzCsCMzNzDCTjlmNhRmRnZBllRVh 133 | RrFglccgBVVvFNvCvWlgmDbbDfQDtCdjjDbDwmZD 134 | STnMqSLHJhHHnqLqtnBndbBdfQQZDtZD 135 | GHJPTBsTSsMMSpSBHJFNlWzcvFlzsVzvzgsv 136 | lplNdrVrVrWMMVcJfcDDzbqCCpDL 137 | SSSgvBRSjggPgzvTTRHTvFnfJLbcLsCDLnCLDCcJBsJq 138 | GmHjjRwvHSjHTRjrlZrNMzVMhVrmVW 139 | gdtFtgStSbHCbHMPZrFLPLrVlrVZrP 140 | hQnjMGfDqTvzvpBjVVjPRLRRjJ 141 | QmsQmhvvMtssHtWw 142 | RNjTGSCLJCGdRqMRFvMrfzMvzz 143 | ZpcWcVDpWBmWQMZZpZDpwBcznrshtntvfvhfFtzmvnzvhf 144 | WHHHcVWgQVCbCllbgMLN 145 | ZjjdJHSdSzvcZFMhhhDqDHtthw 146 | rNTlNqVWTmRPlshsDPDlph 147 | WbTNGNmQBRQbRNQgNGmCLdvvjzcCSBqLcLnScL 148 | bZwpSpBvSHCBqNzpdFffqQft 149 | nWRnGRnVnljmlDnzdPfQfdcQPWWfNq 150 | dmRDGMMlDmnVjgMlhBSwCbCgwHbBHhvv 151 | NwqLgLBLgnwNNBGpgsQsddhhpQQg 152 | JcztcZnzVtZvnVcJMTvTJtWtppsQHGdQhhHHQsPhWdPS 153 | fJTJnMmvZvMvRDqFblNBNNjlBf 154 | drZVzZzzNWWzwwTWTZrjWcLCqnRqNnLNLqCqnsPPRL 155 | JhlBgvHBBLnwMBqDwC 156 | GmGFSHmhJSGJwgFJmwJhJhgQVWVdbSWZQzZTrWtZzjzjTz 157 | wPGRPpnzgwwGgLddFBFrnrnJdc 158 | jCsVclQWmCTrJJddrdFs 159 | lWjlCqfmlWccpGPPSgcf 160 | hCThCzTdPcPhzqTzMfVfHrhMMmhVHgVM 161 | lJSJNqwJsZBSsSBFsMprDmFmFDfDDHgHDf 162 | JNGQsSSNGsbZZZSBwZLPtdLjttnqPCbtPbjC 163 | vnlWNpbrNrpShhQDLRLB 164 | MzCjPgffVTVgCJSRQhBdRdJS 165 | VPHcfcBfTzVMTttMzMfgzMfHvrllWvlnvNvlmGwWNwwNmw 166 | BwwsqPJqwBssLlFqLRCDzWwzDGRGGWfSRG 167 | vTtmmthvpphpnNgNvvpvRrDCddDQrCQCzCDrCfnf 168 | pppccNpTVVlqssHHVzBH 169 | HWHphZWVWvMZNvpMtfJZgssffsjJgBlslJ 170 | RLmrFFnGFrFFrrFCRwCrLNPwqfjSJjqJSJBbsqjbbsblfq 171 | LnFLPPGLrGNRQPmndLzPmPmpcDcMHhcMhVHvczcpHHchcV 172 | zwqqvNDVggwqVfNQRlszFBsCCJFtFlFPsz 173 | MSrrGTZPGSSMSjPbTmtlHBBFrFHFsHlsJsct 174 | MnmMPMSZZGSZWmSjnWgfqdgVQDvnqvRDggDV 175 | SQCSBShsQnSsSJswsNpVppPPMVpGpnDVgg 176 | WWjHvmtWZrwvtzzjTTRPrRRrMVNVVGgVGpGR 177 | lTvWjWLfWwbJCQqBSlbB 178 | cjPChhswrNVtMZJjVM 179 | pfvTFvTzLBFndGTlJmVJZmNlCMGtCJ 180 | nfvFTfpbBFdSFpTLswsWDbchwHCWHrbw 181 | lNdNPLJJLHHHlpPJcvtVcsBBrrBvBqrVrC 182 | wDTbwTQRZTMWsVWtmWhhTr 183 | nzRMbSZtMQDnpzzJHLHNflHP 184 | HrwwmwcRbmwcbrrTbwwcrTJWLlPshllhLccqLhnnlljhZhjZ 185 | GMFMSNSpCBSFSdGpNFpBznLlzzhzshlGhhqPhGGL 186 | nFFSCCSSfttBdddDQNDBQpSSrbrmWJwrHfJHWJrbVwWHrgVr 187 | SdddNNCmpNNDhMswhsmbhvHM 188 | frtzqqqFjgrWfgfqtthsnvRHZRRvFlhnvRZb 189 | rtrgqzzrbWtqLGLLtBWzfGcTNCCVGpSNDppTJJVddNpPSG 190 | WWJvJvBgpHSHScQRQSVQLzqL 191 | ddZTlZGZVfQhZRLLMqsR 192 | rPfwrGGrFjjNTGNCCVBggDJHmNDvbmmpmNJJ 193 | bbGrJPRVPtfsVfFlMjBV 194 | WQzhQQQNZQCWNnQDhzWdNjFZggmlHjjmMmMFjFHpMs 195 | CzQCSWDTWhNhzWhTGJwtRRqTblwcclvP 196 | HLDvZgZldDTnLLsswMpVLn 197 | FNVQzQSPznCMmpBwCF 198 | SqfJPfttqffjJPVlhvhZZtvdVDRZ 199 | jVsLvHvvdrSjpJFsGzmnmltnml 200 | nTNTRCTBTmmmFPMJ 201 | CQnCggWQDgBrrSqHjDDfSS 202 | ZpNlrZNcmctZbcZlmcmZhhpPvPHvwBMHJPMTMHBTFJvJ 203 | zmdCnGzGRnLDjQnzPvMFVHMVMLTVwMJv 204 | GGjqssqgzCnCzQsshcffmrbNrrNZtW 205 | DNpTwhpLlWMDWNMhbJjGttJFHgDcjtjG 206 | wqQrdCdqbFtCtJtJ 207 | vffdrwfPrsmqVBBWRVlRRlTSTWSTlR 208 | ZqTCTQQTFvsDSsBDvWBd 209 | hfBLzRLtHHLDDWRRWWDNbd 210 | pHhhnPzLfJcJhzHLzZjcmwCTqTQgwBqqwg 211 | WJHgqgFqrVrqgqCHwsJHHVFZzppZFGGfTtpcfbdpzzpd 212 | RvNMQlMBhwMdMfcpbM 213 | LLRQNBDSSNSwmDDBQRBRBCHsgrgHLVnJVqLsJsnCPJ 214 | BFhGsDsDsBtsPGtQDrrMdbdrffrffbJbRt 215 | cVVqScVSWWvVWgVZjnrHJgLfdrLrnrLLLQ 216 | WmvqNZzzzZSvVzqvcccSzSmqFGCDTGBPQGDhwCDhNDCwPBQp 217 | RqTlHHTTrQqHlTqsrVDqHbrZFZwhpBhphZBFhZpDpLLLfB 218 | nSzGCGdvzdGNPBQQBfhLZfFwFN 219 | WPPPCJMtJSQMJQCCWMJslRrrRgrMRbRqVqqTRR 220 | BMtfLsLZfTPmCtGWZrZqJNJqvpZdWr 221 | bRwgHhhRhbbSRbjSglcgwHHJWPcJdPrnNWrnqnWVVqpdnq 222 | bgjlSgDljHhjgwMPCLPFDMFPGGBC 223 | zJWjczcWjSWghZgzgSSSZflTqwlfqTTbnQwhdTnMdl 224 | NrGVCmNpHFPsrJFbFQMJbJdQTn 225 | JvrtpHHmrCGJCJmNvNpVCsHVgzWgWDDcjjgjDRStWWDLSgzz 226 | HzdFsBBVsfnTfsPmPtDcZqtMhDDz 227 | wrjjRQLlwwwrJQLQbCrbwlJDSlcSDtPZmPSDclWDtcDqWh 228 | RwgprLbNLrLbCCpRCrJLRLFfsGTNNZHBZnnBvvfffnvd 229 | MlqqlWZclnPtZtDSSvwQQjgQpNQSRM 230 | rLJTsBrsJBhshTNNwSQBWNvNgNSg 231 | JbbbChCHsJzHzbWdGHThlFnnPqlPlGPPGncPtFlD 232 | WcMVvwNNvjRcwTQwVcpNRcspPCFtbPztbCTFmtPtCJtbCzmz 233 | grrgDhrnDLnLrdfdLZlLZhmCqzlCbtJlSSStFmttqsJJ 234 | GHHDdgnLDDhrrrgZrZgLNVVVVcRNvcwjWvpWGcRs 235 | qhGhPSJtGhGtJtvNjnJjnvmNQQmj 236 | sRBFlbZsrdBRRGbVGBDwDMDQwQwMNDjjjVNV 237 | CzCflffbBszdBCbdbrtLcfhhgHLGgPccLSPh 238 | zShhHFzgJWFVFFHFHhRPNjwqPLPtLbtrbwVjjr 239 | ssnvTmvCDfpCZTnsfCqwNLNPwbJqNJPwrjZw 240 | vDvpmcnmnBDnsnJTJmQWMHMWzScFggRFRFSW 241 | nnVHHPLrnpssLnrpLRnHtHrjJcCdzCjcDzMzdqwRdjdDcJ 242 | WWTGQQzSGWlTmBbDJJjwMJjcvvlDjw 243 | TGTWBTWmTbgzghZhgzBgpVNrZPPfntfNrVLNNnZP 244 | TqhQnqqLnnqddttNqQWdtqQmppSSFFClRmzmFZFLSmSlFF 245 | BcHjGclVPPBrVrcjrGGDrMgcmmRJbRCFzpZmSDRpRZJJmRzz 246 | ccGjMgvPvsHMgvBHWlhQdqwtllwNdThs 247 | WjddwRGgHRRdMbrwHRwWjHDtDZplslnJnZrsDvCprJPJ 248 | QSLLFqQBffCFststlFnn 249 | CSSmSqzmVVjWMdMjVWgT 250 | lTfQRhVpRzjThpRQTTTlvHrvBvHnPMHgHqHJvn 251 | cGDctCwCdDCGSFcJsFJsFBvgnMBrHvvrqngHgmgssg 252 | SCbSDSFScNpfbRVVJf 253 | RrwmdwMVjMjMTghDWNTJDpWfWG 254 | SbPvNbvbSsPbSvZsPJtJWhHpGGGgJWgJ 255 | lSFvsLNcqzqLrwnFQMnVdmnn 256 | FgCJFTWntWTFtPLmJmmQJmCMMpljWZBwlGMljjjlwvwBvZ 257 | SDSbVbdScSDzbLZMBrjlZpVrZp 258 | ccsSDhSDffzbLNscfcfDcgqhPgTntqmnQmCgtgQCTJ 259 | VnCnrHnPPrCwHmVWtqfMQQqzCqffCZ 260 | DDbDcJJJbpJDGppFpqGZRWfGfddzMWtfWM 261 | tTTglDcgFjwNPHPPwHlH 262 | bMGbqqgPqqVVMGnbVqSMmRfPcJmCTPDDLJDTCmDm 263 | FFjjZvFRsFCctmtvtJWD 264 | wwFhHjQjwQhZrFjQbngglGbRMnSzgbRH 265 | GPTTJSgTPrPPmcTPpdJsGGGjqbRvqlztqlRqMzGjRv 266 | LwnfWLNwwHHQwHnjbbMMjWttqtMmMj 267 | mhwfBDhnQTpJBcBJps 268 | HQQHwMfwlltzMlVljQhVjjHPPPFGPFcCGprPTPPfDrDcGf 269 | pRLdvRvJgqLRBSJCcvFnCDTPTcTGnT 270 | LBLSJbRSLSqbSdBdgJRRqRbwjHHblQttlwtwhzpjMlwhpw 271 | NWLNSNSDtgSgghgdcwccmwGntwclnT 272 | FRCQzJRsvfVVjvzFJfQnffwCcmdwmHmmHmTwmCmdGBcq 273 | sjfJvjfzPRPzvPPVFMssvSLhSSWrMZnSDNrDDhSLZZ 274 | FvLpSLtCfPCWhRSZZMZJSW 275 | jbbjwbHjQmHjHsQrQFMnwTnJznwRzhJRnNTM 276 | gVrjqGqjgrgsFGLDtDBLLfLB 277 | cgTvRWWLVScRWflNJJDfVJmVlG 278 | nPPnnmqjmZHCHBHFdfwNsDhzzfJznhsfhw 279 | bddmQqQjpdFCQWtLQMMSvMMQRS 280 | wjnmPwCgjPnRlwnmvmvvPnTwbSSLLvsLDWdbbWzvsLzWbzbz 281 | NqrGqFHqJlfhhJGbszdWQzzLNtQDzz 282 | FfHFpphrJqJrpGBffcTnBjCnVTMjMRCnVljT 283 | SrfSJGJpSgMprMHdhBGhsdsshdGsmm 284 | nRTRPvQllQlblwvCjTwLTnvBqdhmHDPVsmDmdqshDVhNsP 285 | lbRFHvRwlnlLbnbjLbLjLCzggSpWfMFzSZpzZFJJWpJr 286 | vNLlFldlvPtHFPHQRt 287 | jcpRsScDgshzjqzfVStntBTPMTnmWttntMpp 288 | fSssgVjDsbqSVbCJClLRJLCZRZZb 289 | wnHmCJccDDcrNnrNMRDtTzpTlMpTzpBp 290 | PjSPPGjWjLzTjjMtzzMj 291 | hWvLLFWvHvczVcVn 292 | jgtngnnhMthcnLjMgCZvChDsmdNCvNNZDN 293 | bWqFPbFbLzRFfZBNDNNPZsNd 294 | RbJzGpzVLLLWHHQgTMwcTptQ 295 | sJBhsMWQnhhrFBsFhlQQMfrDCDpLlVCddjTdDDpqDLTLdj 296 | tZHHSRmNHcgmNzpDPJtttqjLqdpL 297 | HbNbZmcHQJbsFWvs 298 | VgPNWGbgSjGjfhRRFfzThtmtzF 299 | qLCQJBqqcPPmLHhHFz 300 | CcJvplQswNgZlNPSbS 301 | -------------------------------------------------------------------------------- /inputs/4.input: -------------------------------------------------------------------------------- 1 | 1-2,2-96 2 | 17-75,14-75 3 | 33-92,93-93 4 | 18-18,18-83 5 | 14-30,15-30 6 | 6-92,6-6 7 | 15-16,15-90 8 | 32-66,66-77 9 | 90-90,89-89 10 | 24-71,25-50 11 | 31-48,41-42 12 | 28-98,28-99 13 | 17-44,18-43 14 | 5-95,5-45 15 | 29-30,30-78 16 | 26-71,10-70 17 | 62-71,39-71 18 | 23-60,24-59 19 | 85-93,39-84 20 | 3-4,3-58 21 | 8-96,8-95 22 | 62-79,61-61 23 | 15-42,16-41 24 | 96-97,68-97 25 | 60-72,29-71 26 | 22-38,29-37 27 | 15-15,15-85 28 | 61-85,84-86 29 | 22-23,22-40 30 | 5-94,35-99 31 | 44-98,45-92 32 | 12-69,60-67 33 | 6-39,7-78 34 | 3-28,4-29 35 | 26-74,65-72 36 | 35-69,34-82 37 | 27-97,8-98 38 | 3-98,99-99 39 | 86-88,9-87 40 | 3-18,18-18 41 | 12-75,32-74 42 | 3-85,4-84 43 | 11-92,12-91 44 | 7-33,6-34 45 | 37-37,38-38 46 | 12-54,13-53 47 | 18-50,9-17 48 | 3-50,38-50 49 | 46-48,10-47 50 | 3-89,78-88 51 | 14-14,13-15 52 | 18-60,17-60 53 | 40-52,45-53 54 | 20-46,18-45 55 | 22-23,23-95 56 | 6-22,1-13 57 | 7-94,7-8 58 | 6-38,24-38 59 | 1-98,1-99 60 | 26-55,26-27 61 | 16-36,15-17 62 | 5-93,92-94 63 | 46-98,97-99 64 | 29-48,30-86 65 | 10-86,85-86 66 | 6-87,6-65 67 | 77-77,76-78 68 | 2-95,3-96 69 | 95-95,6-94 70 | 77-78,77-82 71 | 86-99,3-87 72 | 25-91,25-92 73 | 23-97,23-43 74 | 94-96,21-95 75 | 6-94,98-99 76 | 8-38,22-38 77 | 54-96,53-55 78 | 16-71,70-70 79 | 4-68,3-4 80 | 39-60,23-60 81 | 43-87,17-86 82 | 32-77,32-76 83 | 8-94,8-9 84 | 1-72,37-73 85 | 20-83,84-84 86 | 41-54,41-53 87 | 68-85,84-86 88 | 7-20,21-31 89 | 1-99,98-98 90 | 28-57,58-64 91 | 29-67,17-68 92 | 36-92,61-92 93 | 54-56,8-55 94 | 14-79,15-80 95 | 32-87,12-86 96 | 3-98,99-99 97 | 93-94,16-93 98 | 11-85,84-86 99 | 64-89,59-64 100 | 2-89,14-89 101 | 70-82,71-83 102 | 10-10,9-96 103 | 9-24,9-72 104 | 85-85,18-86 105 | 23-91,3-90 106 | 56-91,55-57 107 | 4-98,97-98 108 | 18-76,16-43 109 | 3-80,4-79 110 | 75-76,49-75 111 | 62-64,61-65 112 | 21-34,21-35 113 | 6-61,60-85 114 | 12-96,12-95 115 | 22-98,9-23 116 | 27-87,78-86 117 | 28-95,87-99 118 | 3-96,95-98 119 | 1-94,95-95 120 | 35-85,36-84 121 | 45-51,33-50 122 | 39-70,22-70 123 | 61-88,3-62 124 | 57-85,56-97 125 | 25-74,25-73 126 | 44-51,4-83 127 | 67-77,57-77 128 | 15-82,16-56 129 | 21-22,20-22 130 | 1-29,13-28 131 | 36-80,4-80 132 | 15-19,14-61 133 | 4-12,5-11 134 | 36-71,70-72 135 | 67-67,35-66 136 | 13-29,13-28 137 | 7-7,7-67 138 | 44-69,43-70 139 | 34-97,2-98 140 | 49-95,50-94 141 | 29-85,20-70 142 | 16-71,15-92 143 | 1-77,16-78 144 | 27-27,28-83 145 | 81-96,2-95 146 | 88-95,12-88 147 | 8-9,8-88 148 | 68-74,68-68 149 | 52-89,88-90 150 | 21-91,90-90 151 | 39-95,40-94 152 | 58-98,1-97 153 | 3-82,5-81 154 | 22-54,26-82 155 | 47-86,46-86 156 | 26-40,25-26 157 | 66-83,66-82 158 | 28-59,3-28 159 | 47-93,4-93 160 | 2-4,3-97 161 | 22-98,22-99 162 | 30-89,34-90 163 | 25-76,59-77 164 | 25-96,96-97 165 | 14-77,15-78 166 | 15-97,16-96 167 | 5-81,80-94 168 | 22-87,23-38 169 | 10-23,10-22 170 | 7-74,7-7 171 | 13-27,26-27 172 | 8-95,7-98 173 | 63-78,62-77 174 | 2-99,3-87 175 | 10-78,10-11 176 | 76-76,63-75 177 | 74-77,52-79 178 | 27-63,33-47 179 | 85-94,91-94 180 | 65-76,51-94 181 | 46-88,12-61 182 | 79-79,27-78 183 | 85-95,21-95 184 | 5-40,4-41 185 | 35-45,21-45 186 | 69-70,70-86 187 | 58-78,12-82 188 | 84-90,85-90 189 | 40-80,41-81 190 | 3-5,4-97 191 | 69-94,69-93 192 | 43-50,50-78 193 | 36-76,69-77 194 | 1-99,2-98 195 | 8-96,8-95 196 | 3-36,36-79 197 | 73-73,43-72 198 | 64-84,67-93 199 | 3-11,17-84 200 | 85-87,14-86 201 | 11-13,12-71 202 | 81-81,17-80 203 | 16-75,27-75 204 | 11-33,11-34 205 | 3-10,3-3 206 | 38-42,38-47 207 | 12-92,11-93 208 | 3-93,4-94 209 | 45-75,95-99 210 | 11-79,95-98 211 | 17-75,16-76 212 | 75-77,12-76 213 | 64-70,32-90 214 | 6-82,6-47 215 | 11-16,16-96 216 | 1-99,5-99 217 | 49-58,49-57 218 | 11-41,95-98 219 | 1-11,5-10 220 | 2-4,3-99 221 | 56-73,57-77 222 | 34-96,33-35 223 | 4-80,4-93 224 | 62-67,66-88 225 | 89-90,28-90 226 | 10-85,16-85 227 | 93-95,41-95 228 | 60-84,60-61 229 | 28-57,57-58 230 | 11-78,59-79 231 | 12-68,69-69 232 | 50-77,49-50 233 | 58-81,80-82 234 | 3-21,2-21 235 | 46-64,29-56 236 | 44-51,37-50 237 | 59-91,90-92 238 | 46-46,41-47 239 | 58-76,68-74 240 | 1-4,4-97 241 | 23-24,24-31 242 | 38-92,37-39 243 | 84-86,35-92 244 | 15-37,14-16 245 | 18-18,18-26 246 | 66-78,62-65 247 | 11-85,11-12 248 | 4-68,3-3 249 | 95-99,3-96 250 | 93-94,75-87 251 | 3-5,4-61 252 | 81-81,36-81 253 | 93-97,95-96 254 | 18-19,18-97 255 | 53-96,71-96 256 | 2-62,25-46 257 | 40-72,71-83 258 | 7-97,6-96 259 | 19-98,19-99 260 | 1-48,2-41 261 | 45-66,63-81 262 | 41-42,41-49 263 | 52-88,4-87 264 | 27-27,51-96 265 | 7-62,45-83 266 | 76-80,10-84 267 | 51-94,50-52 268 | 9-84,1-83 269 | 30-46,45-93 270 | 7-12,11-90 271 | 18-78,17-78 272 | 61-94,60-95 273 | 13-20,3-16 274 | 68-93,88-95 275 | 8-93,8-8 276 | 70-71,1-70 277 | 66-81,41-81 278 | 10-95,78-96 279 | 3-10,11-26 280 | 29-89,28-90 281 | 22-53,22-54 282 | 42-67,42-47 283 | 7-94,7-31 284 | 9-72,10-71 285 | 61-63,28-62 286 | 22-61,47-61 287 | 68-98,58-69 288 | 20-72,71-76 289 | 24-37,12-23 290 | 3-86,3-87 291 | 42-81,82-93 292 | 2-98,3-3 293 | 57-70,58-71 294 | 85-88,34-86 295 | 93-94,4-93 296 | 36-73,36-37 297 | 67-92,91-96 298 | 9-13,9-15 299 | 32-34,33-64 300 | 5-31,5-47 301 | 39-84,38-59 302 | 63-86,14-87 303 | 31-50,41-66 304 | 74-80,43-79 305 | 21-31,18-31 306 | 72-84,73-84 307 | 13-71,5-71 308 | 10-71,39-61 309 | 30-34,27-34 310 | 4-55,6-56 311 | 8-53,15-16 312 | 61-72,47-71 313 | 8-60,9-9 314 | 41-55,38-54 315 | 19-99,9-40 316 | 86-87,6-87 317 | 7-82,3-8 318 | 24-75,24-36 319 | 11-19,2-11 320 | 77-89,63-78 321 | 31-43,2-47 322 | 21-70,20-70 323 | 50-51,51-63 324 | 19-43,20-42 325 | 53-88,87-94 326 | 51-95,52-82 327 | 93-95,1-94 328 | 18-26,18-27 329 | 26-50,40-50 330 | 63-90,29-64 331 | 68-69,23-68 332 | 9-12,4-12 333 | 20-68,20-20 334 | 79-80,61-79 335 | 15-81,30-82 336 | 39-97,40-98 337 | 27-35,3-34 338 | 36-92,35-37 339 | 35-59,31-75 340 | 60-61,60-72 341 | 70-91,70-77 342 | 75-80,11-76 343 | 11-94,9-9 344 | 1-94,2-2 345 | 9-86,85-85 346 | 19-36,18-53 347 | 13-86,53-87 348 | 4-62,4-63 349 | 32-96,31-97 350 | 33-46,33-34 351 | 22-47,45-48 352 | 5-60,11-61 353 | 96-98,89-97 354 | 1-99,3-99 355 | 6-52,12-52 356 | 9-13,12-36 357 | 47-96,47-96 358 | 4-7,2-7 359 | 6-45,5-46 360 | 22-92,93-93 361 | 14-63,13-96 362 | 15-85,15-16 363 | 23-93,23-52 364 | 2-44,2-97 365 | 12-92,94-96 366 | 29-64,28-42 367 | 4-98,4-99 368 | 3-35,1-3 369 | 2-97,2-83 370 | 46-87,46-86 371 | 23-45,24-57 372 | 25-91,5-54 373 | 63-64,63-94 374 | 3-30,2-4 375 | 75-98,61-86 376 | 45-82,65-68 377 | 95-95,94-97 378 | 76-85,26-77 379 | 66-96,51-67 380 | 5-81,2-4 381 | 42-70,42-73 382 | 12-84,14-85 383 | 22-84,16-31 384 | 7-86,8-85 385 | 2-97,1-96 386 | 70-89,97-98 387 | 10-67,44-67 388 | 61-96,61-61 389 | 7-72,71-71 390 | 34-56,49-58 391 | 2-4,3-73 392 | 53-65,52-53 393 | 83-97,51-84 394 | 38-73,37-79 395 | 68-68,68-80 396 | 18-94,28-95 397 | 11-25,23-23 398 | 30-71,70-72 399 | 2-58,46-59 400 | 46-46,25-48 401 | 23-82,11-73 402 | 4-71,2-72 403 | 10-86,9-86 404 | 80-88,10-88 405 | 87-88,86-93 406 | 19-78,77-79 407 | 9-91,90-94 408 | 38-39,14-42 409 | 12-57,31-32 410 | 8-8,9-90 411 | 96-96,96-97 412 | 15-86,24-85 413 | 43-91,88-97 414 | 13-72,5-12 415 | 1-3,3-65 416 | 66-95,4-95 417 | 36-66,35-36 418 | 40-95,94-98 419 | 13-88,12-89 420 | 10-99,19-99 421 | 10-57,57-70 422 | 32-57,32-56 423 | 52-95,97-99 424 | 1-41,19-43 425 | 36-49,36-66 426 | 15-16,16-89 427 | 39-77,76-78 428 | 43-83,43-44 429 | 14-95,13-71 430 | 38-41,37-39 431 | 54-89,52-88 432 | 34-59,18-58 433 | 75-75,54-74 434 | 37-69,68-70 435 | 9-96,16-95 436 | 2-4,3-76 437 | 14-91,92-95 438 | 1-51,1-97 439 | 3-17,10-17 440 | 54-80,81-81 441 | 73-93,73-86 442 | 48-62,49-61 443 | 25-44,26-44 444 | 69-70,62-70 445 | 11-12,33-99 446 | 54-64,54-59 447 | 33-42,36-88 448 | 6-57,5-58 449 | 84-85,29-84 450 | 21-22,21-49 451 | 62-92,62-93 452 | 9-29,4-28 453 | 28-77,27-72 454 | 24-31,30-53 455 | 8-63,6-12 456 | 17-21,21-22 457 | 14-15,1-15 458 | 6-89,5-89 459 | 87-99,87-98 460 | 59-63,33-60 461 | 71-95,9-72 462 | 5-92,4-6 463 | 3-81,3-80 464 | 19-71,72-77 465 | 83-87,30-82 466 | 19-52,19-53 467 | 58-73,58-74 468 | 12-95,6-12 469 | 52-80,79-81 470 | 4-87,34-88 471 | 55-90,11-89 472 | 6-99,1-99 473 | 93-98,91-93 474 | 13-13,16-70 475 | 92-96,91-91 476 | 1-1,5-93 477 | 61-97,10-98 478 | 22-68,21-69 479 | 16-93,80-80 480 | 5-46,2-46 481 | 44-69,68-70 482 | 30-55,30-56 483 | 8-68,8-8 484 | 52-81,67-81 485 | 12-58,12-35 486 | 7-39,7-7 487 | 10-42,42-43 488 | 81-87,81-86 489 | 15-90,14-22 490 | 5-91,5-92 491 | 41-44,40-45 492 | 27-85,27-84 493 | 19-26,18-22 494 | 15-33,38-93 495 | 7-9,9-83 496 | 9-77,36-77 497 | 29-68,8-30 498 | 20-98,19-97 499 | 11-75,1-74 500 | 56-89,65-88 501 | 50-67,51-67 502 | 15-97,20-97 503 | 6-98,7-98 504 | 36-90,89-91 505 | 6-70,4-6 506 | 23-55,24-54 507 | 7-79,6-8 508 | 13-83,14-82 509 | 9-77,34-77 510 | 27-85,86-98 511 | 61-91,61-72 512 | 40-87,17-95 513 | 12-78,23-79 514 | 11-14,13-54 515 | 1-94,1-95 516 | 1-98,2-19 517 | 24-48,21-49 518 | 86-94,2-86 519 | 22-98,33-98 520 | 89-89,37-90 521 | 10-57,26-56 522 | 11-97,10-11 523 | 53-63,17-63 524 | 13-99,14-98 525 | 69-89,27-99 526 | 64-64,19-65 527 | 46-97,47-80 528 | 23-39,23-64 529 | 70-85,69-89 530 | 11-96,9-9 531 | 57-62,35-63 532 | 51-64,50-52 533 | 32-43,40-56 534 | 36-99,98-99 535 | 22-48,61-88 536 | 4-91,4-50 537 | 20-69,7-70 538 | 82-96,83-95 539 | 9-87,8-86 540 | 4-90,33-90 541 | 23-83,24-82 542 | 7-83,83-84 543 | 7-28,7-30 544 | 84-90,89-91 545 | 48-50,49-99 546 | 25-79,24-78 547 | 52-94,52-62 548 | 10-94,11-11 549 | 48-88,89-93 550 | 20-35,5-19 551 | 1-98,98-99 552 | 19-72,11-19 553 | 25-96,24-96 554 | 81-83,71-83 555 | 76-84,76-97 556 | 1-14,14-73 557 | 12-12,11-71 558 | 63-89,90-90 559 | 36-64,36-52 560 | 37-84,37-66 561 | 15-79,14-79 562 | 6-61,5-62 563 | 29-68,28-69 564 | 30-31,31-73 565 | 46-60,15-90 566 | 1-52,1-2 567 | 14-73,14-74 568 | 20-70,25-53 569 | 73-81,72-82 570 | 4-5,5-70 571 | 60-75,59-74 572 | 2-3,2-74 573 | 3-89,3-88 574 | 15-32,15-16 575 | 81-81,31-80 576 | 3-52,5-13 577 | 97-98,34-97 578 | 33-34,48-62 579 | 96-97,64-91 580 | 6-77,4-76 581 | 9-39,10-10 582 | 3-25,4-24 583 | 43-64,44-63 584 | 2-92,1-3 585 | 30-98,30-76 586 | 9-10,9-27 587 | 8-25,26-26 588 | 53-93,92-94 589 | 36-36,36-74 590 | 7-8,7-44 591 | 13-78,14-14 592 | 79-85,80-85 593 | 6-93,6-54 594 | 17-81,17-23 595 | 14-15,2-15 596 | 8-13,18-91 597 | 2-53,2-96 598 | 11-98,10-12 599 | 5-9,4-99 600 | 3-94,3-85 601 | 9-83,82-82 602 | 61-77,56-94 603 | 81-81,15-82 604 | 30-92,15-91 605 | 31-95,32-96 606 | 21-91,27-92 607 | 58-88,58-89 608 | 10-92,91-95 609 | 16-92,91-98 610 | 70-71,44-70 611 | 1-68,2-54 612 | 59-89,58-90 613 | 33-44,44-68 614 | 8-38,1-8 615 | 20-37,21-94 616 | 94-95,11-94 617 | 1-2,2-28 618 | 11-94,72-87 619 | 49-70,48-70 620 | 69-78,70-77 621 | 37-73,37-93 622 | 33-98,32-98 623 | 34-91,92-92 624 | 14-39,14-25 625 | 33-60,33-59 626 | 73-93,83-94 627 | 70-76,70-81 628 | 15-95,16-88 629 | 16-69,17-68 630 | 5-98,5-99 631 | 67-91,90-91 632 | 31-98,11-93 633 | 2-92,91-91 634 | 72-86,72-85 635 | 4-11,11-56 636 | 46-47,16-46 637 | 24-88,87-89 638 | 65-69,9-64 639 | 25-78,25-77 640 | 67-73,47-88 641 | 52-52,52-53 642 | 2-98,3-99 643 | 25-92,25-91 644 | 29-87,28-94 645 | 3-99,2-33 646 | 7-90,66-90 647 | 43-85,65-85 648 | 42-94,65-97 649 | 58-60,59-59 650 | 26-67,20-66 651 | 46-75,46-74 652 | 39-86,79-87 653 | 62-91,28-63 654 | 41-95,42-96 655 | 9-57,10-57 656 | 1-94,1-95 657 | 33-87,16-87 658 | 14-43,13-15 659 | 25-33,26-34 660 | 34-52,35-53 661 | 23-30,22-31 662 | 14-87,13-97 663 | 2-48,2-3 664 | 46-97,98-98 665 | 61-74,61-62 666 | 64-96,74-97 667 | 3-25,3-15 668 | 31-50,31-31 669 | 91-92,79-91 670 | 41-91,1-90 671 | 5-99,6-98 672 | 4-10,9-16 673 | 11-11,11-96 674 | 5-40,31-41 675 | 15-97,15-96 676 | 20-39,38-40 677 | 28-57,10-29 678 | 97-99,83-96 679 | 29-62,61-62 680 | 29-81,28-81 681 | 6-99,6-98 682 | 70-78,78-79 683 | 6-27,7-13 684 | 52-53,52-84 685 | 8-73,21-73 686 | 75-85,39-80 687 | 18-48,47-49 688 | 4-88,89-89 689 | 32-68,31-33 690 | 26-97,25-98 691 | 64-64,12-64 692 | 20-36,2-21 693 | 48-48,47-91 694 | 8-84,36-83 695 | 50-76,49-76 696 | 12-66,7-66 697 | 1-64,1-63 698 | 41-86,41-86 699 | 5-86,3-85 700 | 4-82,4-83 701 | 15-78,13-79 702 | 1-94,74-83 703 | 90-91,46-90 704 | 60-72,49-71 705 | 24-69,25-25 706 | 15-92,15-15 707 | 47-96,48-48 708 | 1-20,19-86 709 | 15-93,93-93 710 | 17-20,24-68 711 | 9-98,23-98 712 | 34-43,42-44 713 | 77-99,74-83 714 | 86-86,23-85 715 | 14-15,15-98 716 | 39-98,39-40 717 | 62-97,96-99 718 | 11-94,6-10 719 | 27-50,51-60 720 | 50-84,84-85 721 | 79-92,3-91 722 | 69-71,25-70 723 | 20-70,1-83 724 | 10-88,7-89 725 | 19-65,1-66 726 | 22-67,52-65 727 | 90-91,54-90 728 | 12-42,6-11 729 | 27-98,26-27 730 | 31-34,31-33 731 | 95-95,1-94 732 | 20-93,86-94 733 | 6-25,11-92 734 | 26-97,77-96 735 | 9-88,9-87 736 | 71-93,11-72 737 | 5-93,94-94 738 | 29-35,28-57 739 | 6-86,85-97 740 | 40-86,22-82 741 | 36-79,1-78 742 | 11-11,10-96 743 | 1-59,1-5 744 | 1-5,4-90 745 | 9-13,8-63 746 | 25-72,51-73 747 | 62-65,62-82 748 | 4-92,2-5 749 | 8-96,61-95 750 | 31-64,32-84 751 | 84-94,42-85 752 | 11-87,12-87 753 | 96-99,4-97 754 | 89-90,45-89 755 | 63-84,63-83 756 | 36-36,8-37 757 | 17-57,18-50 758 | 8-90,9-89 759 | 59-62,17-62 760 | 9-86,9-85 761 | 75-96,76-76 762 | 50-61,60-62 763 | 93-99,95-96 764 | 73-77,73-90 765 | 26-59,25-27 766 | 20-21,20-54 767 | 8-95,8-96 768 | 6-92,25-93 769 | 36-71,41-72 770 | 67-73,68-73 771 | 25-64,63-92 772 | 51-51,18-50 773 | 69-69,65-69 774 | 26-85,26-86 775 | 49-66,14-49 776 | 42-86,42-48 777 | 13-98,97-99 778 | 67-82,60-82 779 | 47-93,19-46 780 | 67-89,21-46 781 | 25-62,24-63 782 | 1-85,5-85 783 | 2-99,2-98 784 | 49-78,10-78 785 | 65-65,11-64 786 | 96-96,7-97 787 | 5-95,76-96 788 | 29-85,11-29 789 | 17-92,42-93 790 | 12-48,12-59 791 | 26-27,26-76 792 | 2-43,39-51 793 | 2-68,67-67 794 | 71-72,73-85 795 | 47-96,24-95 796 | 16-32,32-72 797 | 3-64,30-64 798 | 2-91,2-90 799 | 61-96,62-95 800 | 58-98,22-96 801 | 21-22,21-95 802 | 46-98,39-47 803 | 1-90,25-91 804 | 4-68,18-68 805 | 36-55,37-54 806 | 91-95,15-92 807 | 54-75,65-67 808 | 47-89,70-95 809 | 84-86,13-85 810 | 80-80,80-80 811 | 7-76,7-76 812 | 56-98,51-57 813 | 32-59,58-60 814 | 4-81,3-89 815 | 7-15,5-15 816 | 1-91,2-91 817 | 54-64,53-65 818 | 2-5,5-99 819 | 13-29,12-29 820 | 24-25,24-99 821 | 52-67,2-67 822 | 2-79,3-79 823 | 13-70,65-69 824 | 3-93,92-92 825 | 38-38,10-37 826 | 2-52,51-53 827 | 1-29,6-29 828 | 2-85,1-15 829 | 41-82,81-83 830 | 12-60,13-60 831 | 5-84,3-84 832 | 47-47,47-75 833 | 84-84,17-84 834 | 2-86,1-86 835 | 49-52,43-50 836 | 42-81,80-80 837 | 12-91,13-92 838 | 30-33,30-53 839 | 31-53,15-48 840 | 72-84,55-73 841 | 86-87,86-90 842 | 38-93,35-39 843 | 8-78,6-8 844 | 10-92,10-20 845 | 17-88,16-16 846 | 4-4,4-92 847 | 14-63,15-64 848 | 12-97,12-50 849 | 2-40,1-44 850 | 5-94,1-94 851 | 24-75,23-75 852 | 31-60,12-60 853 | 79-82,74-81 854 | 94-94,9-95 855 | 2-25,24-26 856 | 7-77,8-76 857 | 41-95,32-47 858 | 5-75,4-80 859 | 16-43,16-23 860 | 79-92,20-80 861 | 21-63,20-64 862 | 5-69,6-69 863 | 5-5,5-99 864 | 2-91,3-92 865 | 44-94,93-96 866 | 20-92,20-93 867 | 18-78,18-79 868 | 13-99,12-95 869 | 20-85,20-86 870 | 68-92,2-92 871 | 1-6,6-57 872 | 4-82,81-87 873 | 95-96,2-95 874 | 10-98,10-10 875 | 8-87,8-94 876 | 15-95,16-94 877 | 5-95,1-3 878 | 20-37,37-98 879 | 82-98,82-96 880 | 52-54,30-98 881 | 75-88,52-74 882 | 79-95,79-82 883 | 11-57,10-74 884 | 39-73,39-93 885 | 66-67,1-67 886 | 10-79,5-37 887 | 13-96,34-80 888 | 28-61,28-62 889 | 48-83,30-59 890 | 61-83,21-60 891 | 44-50,36-50 892 | 68-78,37-78 893 | 27-91,26-27 894 | 57-66,57-57 895 | 8-65,7-70 896 | 92-95,24-86 897 | 20-80,19-99 898 | 21-43,21-21 899 | 27-99,21-26 900 | 88-93,87-94 901 | 29-61,78-89 902 | 77-96,76-97 903 | 24-89,19-90 904 | 12-28,27-37 905 | 49-96,10-95 906 | 89-90,49-89 907 | 31-95,72-95 908 | 1-99,1-1 909 | 15-47,47-93 910 | 19-81,4-96 911 | 48-62,48-61 912 | 52-92,51-53 913 | 28-48,28-49 914 | 46-83,12-82 915 | 11-69,70-70 916 | 60-92,46-92 917 | 12-53,35-52 918 | 1-88,89-97 919 | 10-93,9-94 920 | 7-93,7-7 921 | 20-97,21-91 922 | 6-82,6-83 923 | 19-72,72-89 924 | 22-35,34-36 925 | 3-70,10-59 926 | 28-30,29-96 927 | 9-15,11-14 928 | 77-82,52-77 929 | 34-34,33-88 930 | 3-4,3-88 931 | 4-97,4-99 932 | 17-65,14-65 933 | 44-81,44-82 934 | 1-87,3-87 935 | 9-75,10-75 936 | 21-41,12-18 937 | 47-54,53-70 938 | 20-67,7-67 939 | 70-70,53-69 940 | 97-98,69-98 941 | 8-56,9-57 942 | 22-54,23-53 943 | 1-16,10-14 944 | 57-67,11-66 945 | 2-99,3-34 946 | 11-37,36-38 947 | 30-83,52-88 948 | 61-94,20-60 949 | 24-81,23-69 950 | 7-44,43-45 951 | 54-77,55-76 952 | 57-91,57-92 953 | 1-30,9-30 954 | 20-20,19-58 955 | 9-83,8-94 956 | 6-89,6-90 957 | 98-98,16-97 958 | 52-52,51-64 959 | 29-62,29-63 960 | 64-91,92-94 961 | 46-90,47-86 962 | 95-99,10-96 963 | 84-84,17-83 964 | 11-37,2-10 965 | 14-85,13-85 966 | 37-58,11-57 967 | 32-85,33-86 968 | 14-92,3-9 969 | 14-33,13-32 970 | 36-84,66-84 971 | 19-99,20-73 972 | 10-30,2-31 973 | 49-72,23-71 974 | 2-83,7-84 975 | 53-69,26-72 976 | 11-24,25-56 977 | 85-87,86-87 978 | 18-97,12-97 979 | 61-80,61-62 980 | 2-59,2-12 981 | 27-93,57-93 982 | 29-83,29-84 983 | 45-57,55-58 984 | 80-92,81-86 985 | 48-51,31-36 986 | 7-96,97-98 987 | 62-62,63-80 988 | 16-39,17-39 989 | 17-36,17-37 990 | 59-59,59-88 991 | 42-88,27-88 992 | 42-72,43-73 993 | 5-6,5-89 994 | 80-81,80-91 995 | 41-56,41-42 996 | 20-42,21-42 997 | 23-91,22-23 998 | 5-88,5-5 999 | 78-96,79-81 1000 | 8-9,7-8 1001 | -------------------------------------------------------------------------------- /inputs/5.input: -------------------------------------------------------------------------------- 1 | [M] [Z] [V] 2 | [Z] [P] [L] [Z] [J] 3 | [S] [D] [W] [W] [H] [Q] 4 | [P] [V] [N] [D] [P] [C] [V] 5 | [H] [B] [J] [V] [B] [M] [N] [P] 6 | [V] [F] [L] [Z] [C] [S] [P] [S] [G] 7 | [F] [J] [M] [G] [R] [R] [H] [R] [L] 8 | [G] [G] [G] [N] [V] [V] [T] [Q] [F] 9 | 1 2 3 4 5 6 7 8 9 10 | 11 | move 6 from 9 to 3 12 | move 2 from 2 to 1 13 | move 1 from 8 to 2 14 | move 3 from 7 to 2 15 | move 7 from 6 to 9 16 | move 1 from 9 to 5 17 | move 3 from 5 to 7 18 | move 6 from 8 to 6 19 | move 1 from 7 to 8 20 | move 6 from 6 to 5 21 | move 4 from 5 to 8 22 | move 9 from 2 to 9 23 | move 1 from 2 to 3 24 | move 3 from 1 to 3 25 | move 3 from 5 to 1 26 | move 10 from 3 to 5 27 | move 4 from 4 to 6 28 | move 2 from 7 to 6 29 | move 2 from 6 to 9 30 | move 6 from 8 to 6 31 | move 1 from 4 to 3 32 | move 1 from 4 to 5 33 | move 1 from 4 to 1 34 | move 2 from 3 to 1 35 | move 1 from 3 to 7 36 | move 8 from 1 to 9 37 | move 1 from 1 to 2 38 | move 1 from 2 to 7 39 | move 6 from 6 to 3 40 | move 7 from 3 to 5 41 | move 14 from 5 to 6 42 | move 2 from 1 to 3 43 | move 5 from 5 to 8 44 | move 5 from 8 to 1 45 | move 2 from 7 to 1 46 | move 5 from 6 to 9 47 | move 8 from 9 to 3 48 | move 13 from 9 to 3 49 | move 7 from 1 to 4 50 | move 6 from 4 to 1 51 | move 22 from 3 to 1 52 | move 1 from 9 to 3 53 | move 2 from 6 to 1 54 | move 1 from 3 to 4 55 | move 7 from 9 to 8 56 | move 2 from 1 to 7 57 | move 2 from 3 to 2 58 | move 2 from 6 to 9 59 | move 2 from 7 to 8 60 | move 1 from 3 to 6 61 | move 9 from 8 to 6 62 | move 1 from 2 to 4 63 | move 8 from 1 to 2 64 | move 1 from 9 to 4 65 | move 3 from 4 to 1 66 | move 1 from 4 to 6 67 | move 10 from 6 to 5 68 | move 5 from 2 to 9 69 | move 6 from 9 to 3 70 | move 2 from 5 to 3 71 | move 2 from 9 to 7 72 | move 7 from 5 to 8 73 | move 5 from 6 to 2 74 | move 3 from 3 to 7 75 | move 3 from 3 to 5 76 | move 4 from 5 to 8 77 | move 1 from 3 to 5 78 | move 6 from 6 to 8 79 | move 1 from 5 to 7 80 | move 9 from 8 to 9 81 | move 1 from 3 to 1 82 | move 7 from 2 to 7 83 | move 9 from 7 to 6 84 | move 2 from 2 to 3 85 | move 7 from 9 to 3 86 | move 9 from 6 to 8 87 | move 7 from 3 to 4 88 | move 2 from 7 to 6 89 | move 4 from 4 to 5 90 | move 3 from 5 to 6 91 | move 2 from 7 to 4 92 | move 5 from 4 to 7 93 | move 13 from 8 to 4 94 | move 2 from 9 to 4 95 | move 2 from 8 to 7 96 | move 6 from 7 to 5 97 | move 6 from 4 to 2 98 | move 1 from 7 to 5 99 | move 3 from 2 to 7 100 | move 1 from 7 to 8 101 | move 3 from 2 to 4 102 | move 2 from 3 to 9 103 | move 2 from 7 to 2 104 | move 6 from 5 to 4 105 | move 3 from 6 to 2 106 | move 2 from 6 to 9 107 | move 5 from 2 to 9 108 | move 12 from 4 to 8 109 | move 3 from 9 to 2 110 | move 12 from 1 to 5 111 | move 4 from 4 to 6 112 | move 12 from 8 to 9 113 | move 2 from 6 to 5 114 | move 1 from 4 to 8 115 | move 1 from 4 to 1 116 | move 3 from 2 to 1 117 | move 2 from 6 to 7 118 | move 1 from 5 to 9 119 | move 2 from 1 to 4 120 | move 10 from 5 to 1 121 | move 2 from 7 to 3 122 | move 18 from 9 to 7 123 | move 8 from 7 to 2 124 | move 1 from 9 to 6 125 | move 1 from 6 to 7 126 | move 10 from 7 to 9 127 | move 1 from 4 to 2 128 | move 19 from 1 to 5 129 | move 8 from 5 to 9 130 | move 3 from 8 to 4 131 | move 2 from 5 to 2 132 | move 2 from 3 to 6 133 | move 10 from 5 to 2 134 | move 4 from 1 to 2 135 | move 2 from 9 to 2 136 | move 1 from 1 to 6 137 | move 2 from 5 to 6 138 | move 1 from 8 to 7 139 | move 1 from 5 to 8 140 | move 1 from 5 to 6 141 | move 18 from 2 to 5 142 | move 5 from 2 to 1 143 | move 6 from 5 to 8 144 | move 1 from 8 to 9 145 | move 2 from 2 to 4 146 | move 1 from 2 to 6 147 | move 2 from 7 to 6 148 | move 1 from 4 to 1 149 | move 4 from 8 to 5 150 | move 1 from 2 to 9 151 | move 2 from 8 to 3 152 | move 1 from 3 to 6 153 | move 1 from 4 to 8 154 | move 1 from 8 to 9 155 | move 10 from 5 to 7 156 | move 5 from 5 to 1 157 | move 2 from 4 to 1 158 | move 3 from 7 to 6 159 | move 12 from 1 to 4 160 | move 8 from 9 to 5 161 | move 6 from 7 to 4 162 | move 1 from 7 to 9 163 | move 4 from 4 to 3 164 | move 1 from 1 to 7 165 | move 3 from 9 to 5 166 | move 2 from 3 to 1 167 | move 1 from 7 to 6 168 | move 8 from 4 to 7 169 | move 1 from 7 to 6 170 | move 7 from 6 to 4 171 | move 2 from 1 to 3 172 | move 1 from 7 to 1 173 | move 1 from 3 to 7 174 | move 1 from 1 to 6 175 | move 4 from 9 to 3 176 | move 5 from 4 to 6 177 | move 12 from 6 to 2 178 | move 3 from 9 to 4 179 | move 8 from 2 to 6 180 | move 2 from 9 to 6 181 | move 8 from 5 to 6 182 | move 4 from 5 to 8 183 | move 14 from 6 to 3 184 | move 11 from 4 to 9 185 | move 2 from 2 to 7 186 | move 8 from 3 to 9 187 | move 11 from 3 to 6 188 | move 14 from 9 to 1 189 | move 7 from 1 to 3 190 | move 2 from 9 to 5 191 | move 2 from 2 to 8 192 | move 6 from 7 to 5 193 | move 1 from 9 to 8 194 | move 13 from 6 to 3 195 | move 4 from 6 to 8 196 | move 3 from 1 to 6 197 | move 5 from 5 to 8 198 | move 7 from 8 to 7 199 | move 2 from 1 to 8 200 | move 1 from 4 to 1 201 | move 4 from 8 to 9 202 | move 8 from 7 to 5 203 | move 1 from 8 to 1 204 | move 4 from 9 to 3 205 | move 1 from 4 to 5 206 | move 5 from 5 to 2 207 | move 1 from 8 to 9 208 | move 1 from 8 to 6 209 | move 2 from 6 to 2 210 | move 4 from 8 to 6 211 | move 4 from 1 to 8 212 | move 4 from 8 to 5 213 | move 1 from 9 to 8 214 | move 1 from 2 to 3 215 | move 4 from 6 to 1 216 | move 1 from 8 to 2 217 | move 3 from 5 to 4 218 | move 4 from 2 to 5 219 | move 1 from 7 to 9 220 | move 1 from 2 to 6 221 | move 3 from 1 to 8 222 | move 2 from 4 to 5 223 | move 2 from 6 to 1 224 | move 3 from 8 to 9 225 | move 4 from 9 to 2 226 | move 1 from 7 to 1 227 | move 1 from 6 to 7 228 | move 4 from 1 to 6 229 | move 1 from 7 to 4 230 | move 6 from 2 to 8 231 | move 2 from 4 to 8 232 | move 1 from 9 to 5 233 | move 3 from 6 to 2 234 | move 1 from 6 to 4 235 | move 7 from 3 to 5 236 | move 2 from 8 to 1 237 | move 3 from 2 to 8 238 | move 6 from 8 to 5 239 | move 17 from 5 to 3 240 | move 2 from 1 to 6 241 | move 3 from 8 to 3 242 | move 1 from 9 to 5 243 | move 11 from 5 to 2 244 | move 40 from 3 to 5 245 | move 11 from 2 to 7 246 | move 4 from 7 to 8 247 | move 1 from 8 to 9 248 | move 1 from 3 to 5 249 | move 1 from 4 to 8 250 | move 19 from 5 to 8 251 | move 7 from 7 to 8 252 | move 16 from 5 to 2 253 | move 6 from 5 to 8 254 | move 1 from 5 to 8 255 | move 1 from 9 to 4 256 | move 1 from 6 to 1 257 | move 1 from 4 to 7 258 | move 1 from 6 to 9 259 | move 1 from 1 to 7 260 | move 1 from 7 to 3 261 | move 1 from 7 to 2 262 | move 1 from 9 to 8 263 | move 1 from 3 to 4 264 | move 1 from 4 to 6 265 | move 14 from 2 to 9 266 | move 24 from 8 to 4 267 | move 8 from 8 to 3 268 | move 1 from 6 to 3 269 | move 16 from 4 to 1 270 | move 3 from 8 to 4 271 | move 3 from 3 to 8 272 | move 4 from 3 to 4 273 | move 1 from 3 to 9 274 | move 13 from 9 to 4 275 | move 16 from 1 to 8 276 | move 8 from 8 to 1 277 | move 3 from 1 to 7 278 | move 1 from 8 to 6 279 | move 1 from 3 to 8 280 | move 10 from 8 to 5 281 | move 5 from 5 to 2 282 | move 3 from 8 to 9 283 | move 1 from 8 to 9 284 | move 1 from 4 to 5 285 | move 5 from 2 to 6 286 | move 3 from 5 to 2 287 | move 1 from 6 to 1 288 | move 5 from 1 to 5 289 | move 1 from 1 to 5 290 | move 2 from 7 to 3 291 | move 2 from 3 to 2 292 | move 1 from 5 to 7 293 | move 7 from 5 to 3 294 | move 5 from 9 to 5 295 | move 2 from 7 to 9 296 | move 4 from 5 to 6 297 | move 2 from 9 to 8 298 | move 2 from 2 to 4 299 | move 5 from 3 to 5 300 | move 1 from 3 to 2 301 | move 7 from 4 to 9 302 | move 1 from 8 to 1 303 | move 1 from 2 to 1 304 | move 9 from 4 to 6 305 | move 2 from 1 to 8 306 | move 1 from 3 to 9 307 | move 2 from 8 to 6 308 | move 13 from 4 to 6 309 | move 1 from 8 to 7 310 | move 2 from 9 to 6 311 | move 3 from 5 to 7 312 | move 3 from 2 to 5 313 | move 3 from 2 to 6 314 | move 5 from 6 to 2 315 | move 4 from 2 to 5 316 | move 4 from 5 to 7 317 | move 5 from 5 to 7 318 | move 7 from 9 to 6 319 | move 6 from 7 to 2 320 | move 22 from 6 to 5 321 | move 10 from 5 to 8 322 | move 7 from 5 to 4 323 | move 8 from 8 to 5 324 | move 18 from 6 to 2 325 | move 5 from 7 to 5 326 | move 1 from 8 to 2 327 | move 6 from 5 to 1 328 | move 7 from 4 to 2 329 | move 4 from 1 to 5 330 | move 1 from 7 to 9 331 | move 1 from 8 to 6 332 | move 1 from 7 to 8 333 | move 10 from 5 to 9 334 | move 12 from 2 to 1 335 | move 8 from 5 to 2 336 | move 19 from 2 to 9 337 | move 1 from 6 to 8 338 | move 13 from 9 to 3 339 | move 8 from 1 to 2 340 | move 5 from 1 to 3 341 | move 10 from 2 to 1 342 | move 7 from 2 to 5 343 | move 3 from 5 to 7 344 | move 4 from 1 to 3 345 | move 1 from 2 to 3 346 | move 3 from 1 to 2 347 | move 1 from 8 to 6 348 | move 2 from 7 to 5 349 | move 4 from 1 to 3 350 | move 6 from 5 to 4 351 | move 2 from 2 to 1 352 | move 1 from 2 to 9 353 | move 6 from 4 to 5 354 | move 5 from 5 to 9 355 | move 1 from 6 to 8 356 | move 1 from 5 to 1 357 | move 6 from 9 to 2 358 | move 5 from 2 to 4 359 | move 3 from 1 to 6 360 | move 2 from 4 to 7 361 | move 22 from 3 to 9 362 | move 1 from 8 to 4 363 | move 2 from 4 to 3 364 | move 2 from 6 to 1 365 | move 2 from 1 to 5 366 | move 1 from 6 to 7 367 | move 1 from 7 to 4 368 | move 6 from 3 to 7 369 | move 1 from 2 to 4 370 | move 8 from 7 to 3 371 | move 1 from 4 to 5 372 | move 1 from 7 to 9 373 | move 5 from 3 to 6 374 | move 1 from 8 to 4 375 | move 4 from 3 to 2 376 | move 32 from 9 to 3 377 | move 3 from 6 to 7 378 | move 5 from 9 to 3 379 | move 1 from 9 to 7 380 | move 2 from 9 to 2 381 | move 2 from 4 to 3 382 | move 2 from 5 to 4 383 | move 5 from 3 to 2 384 | move 3 from 7 to 8 385 | move 1 from 7 to 2 386 | move 1 from 8 to 5 387 | move 1 from 3 to 4 388 | move 5 from 4 to 5 389 | move 4 from 5 to 2 390 | move 3 from 5 to 7 391 | move 1 from 7 to 5 392 | move 1 from 6 to 5 393 | move 2 from 8 to 5 394 | move 15 from 2 to 4 395 | move 3 from 5 to 6 396 | move 4 from 6 to 5 397 | move 2 from 5 to 2 398 | move 1 from 2 to 4 399 | move 25 from 3 to 9 400 | move 2 from 5 to 2 401 | move 11 from 9 to 2 402 | move 13 from 2 to 1 403 | move 4 from 4 to 7 404 | move 12 from 9 to 8 405 | move 6 from 7 to 8 406 | move 7 from 4 to 7 407 | move 7 from 7 to 8 408 | move 1 from 5 to 1 409 | move 5 from 4 to 3 410 | move 2 from 2 to 1 411 | move 2 from 9 to 5 412 | move 7 from 1 to 7 413 | move 1 from 1 to 4 414 | move 12 from 3 to 2 415 | move 1 from 3 to 9 416 | move 1 from 1 to 3 417 | move 1 from 9 to 1 418 | move 7 from 7 to 2 419 | move 1 from 4 to 7 420 | move 2 from 8 to 7 421 | move 7 from 1 to 2 422 | move 1 from 3 to 4 423 | move 26 from 2 to 1 424 | move 4 from 8 to 1 425 | move 3 from 1 to 6 426 | move 1 from 6 to 3 427 | move 1 from 6 to 9 428 | move 1 from 3 to 8 429 | move 20 from 1 to 3 430 | move 1 from 9 to 7 431 | move 4 from 7 to 1 432 | move 1 from 5 to 3 433 | move 4 from 3 to 5 434 | move 1 from 6 to 2 435 | move 6 from 3 to 2 436 | move 8 from 1 to 4 437 | move 1 from 1 to 5 438 | move 3 from 1 to 4 439 | move 7 from 2 to 4 440 | move 10 from 3 to 8 441 | move 4 from 4 to 3 442 | move 12 from 4 to 7 443 | move 3 from 3 to 1 444 | move 2 from 4 to 3 445 | move 2 from 8 to 1 446 | move 6 from 8 to 9 447 | move 5 from 9 to 6 448 | move 1 from 9 to 3 449 | move 3 from 8 to 7 450 | move 10 from 8 to 5 451 | move 4 from 8 to 7 452 | move 9 from 7 to 9 453 | move 4 from 8 to 4 454 | move 2 from 4 to 3 455 | move 3 from 1 to 7 456 | move 11 from 7 to 4 457 | move 6 from 4 to 8 458 | move 1 from 7 to 3 459 | move 4 from 5 to 1 460 | move 5 from 3 to 6 461 | move 5 from 9 to 4 462 | move 1 from 9 to 8 463 | move 10 from 4 to 8 464 | move 5 from 1 to 2 465 | move 1 from 7 to 6 466 | move 9 from 6 to 3 467 | move 7 from 8 to 7 468 | move 3 from 4 to 1 469 | move 2 from 2 to 1 470 | move 9 from 8 to 3 471 | move 10 from 5 to 8 472 | move 18 from 3 to 9 473 | move 1 from 7 to 8 474 | move 1 from 5 to 3 475 | move 4 from 8 to 3 476 | move 2 from 6 to 3 477 | move 6 from 7 to 2 478 | move 1 from 5 to 3 479 | move 1 from 1 to 9 480 | move 10 from 3 to 9 481 | move 4 from 1 to 8 482 | move 13 from 8 to 1 483 | move 3 from 1 to 8 484 | move 3 from 2 to 4 485 | move 5 from 2 to 6 486 | move 5 from 6 to 4 487 | move 28 from 9 to 2 488 | move 2 from 9 to 5 489 | move 2 from 5 to 2 490 | move 1 from 3 to 7 491 | move 2 from 1 to 4 492 | move 3 from 8 to 3 493 | move 1 from 9 to 4 494 | move 3 from 4 to 6 495 | move 2 from 3 to 7 496 | move 8 from 1 to 5 497 | move 3 from 7 to 6 498 | move 14 from 2 to 8 499 | move 1 from 9 to 1 500 | move 6 from 5 to 6 501 | move 4 from 2 to 5 502 | move 9 from 8 to 2 503 | move 4 from 8 to 4 504 | move 7 from 2 to 4 505 | move 12 from 4 to 3 506 | move 5 from 4 to 7 507 | move 5 from 7 to 4 508 | move 1 from 8 to 7 509 | move 1 from 4 to 5 510 | move 2 from 5 to 4 511 | move 1 from 5 to 8 512 | move 1 from 5 to 9 513 | -------------------------------------------------------------------------------- /inputs/6.input: -------------------------------------------------------------------------------- 1 | hrbbjllllspssblslvvrdrbbpbbmcccfppvbbwvbbmrmjrjrfrgfgbffgfqfqlltlwttscsncscchssrppffvwwvvpnnwwwpvwvhhnvhhbttvzzdlzdlzzwmmjhhznnjdnnnqddbtdbdbsdsmdsdrrdpdwpdppgcgqgcctftsfszslljbljbjwbwbnwnqqrnnztntmtrmmzwzdwzwgwwwjhjsjgjtjjhpjhhppqzqdqffrvrtvvsmmgwmgwgbbclltctptzpzhpzptzppcfpcfftflfzftztddzgzmmfsmsrmmsstttvbvmbvvsmsqmqlldjdtthwtwbwggrzzjrzrcctffsshqshhpthhlnhlhqhdqqrwrmmcttpfttzfzgzdgdzzwrrtsrrsnrnccrbbsssbpbjjvzzwlwtwjwsjwjggzqgzzrsszzjnzjzwjzzcrzczncnqqztzfzhfhvvtjvjdvjjmrjrppvzppczpczcggshghvhnhhsrsnsdszzdpzpzlpzzhwwmnwmwmcwwfnwfwjjcbcncllcsllqdqzzhqhmqmbbjvjjwwcjjpnpllzfzddtmtccqrcrtrwrpphpmpplslmltthnnvhhvrvbblhhrrdqqmbqqgtqggdgcdcvvsbsswvvpggbbtftlflglzlmlbbfhhrshswhshffhhdnnrfrvrmrnrprrmfmpmnpnfnggvvcncdcrczrzccpmmssrbbdjdtdrdwrrwhrrvrtvvszvvwvzzmhhjhhwlhlqlvlttzftztdtstftrfrdddmtmzzsqzqvvpdpdcpcncnrrtntznzrzgznztnznhhsqqnrqrhhlzhzthhfddrzdrrqmqggcmmllnjjvwwjccfjfqfcfzccwvcwvcvjcjtjtnnqsqmqrmrzrszrszzfwfggnmmcdmdjmmhwwgfwfnwnlwwcffsrffvnvbvnvwnwgnwnmmbzbmbpplmplpspzpmzpzdzgzrzrtrjrbbppwvwgwmggqwgghqqshhcwcqwcqcfcbbnsnrrtztzrtrvtvhthzhmmrqqrwqqsjqjcctgtwthhqmmnffmgmdgdlgljjhwjwggrqqfrqqjvqvhqqgsqsgsttmrrbprbppmjppslpsllvlfvlvrvhvtqmrjcdzwsbzfmgmwmwqwhztqrsdzhqjqvbjbntnbndflthljcczdmmhszfgsplrtlqnfzbrlqngwdqtfwcmrdjrsmdpmjmqwrbwfjzwnvqhfmlqtvvnlfzbfccwslqpbzzjccbvrzhghqwtvqgwrmsfzqnmnqqjsjtpcmngpqgllfsnpqtjjbqcdppnsmtwrslnrbqtwvnbctzvwfmgctscmzjbqqgqdwbpzmrdwgfcjzftzgmfcjhchbnmnqnrgtqngwrmncjvptqqdtjtgtpzzdrfsdgmwlwrjnqldbwrqjrhwcczlzvlhpgrnwzhbwjnpthggczfgtrjnzvnlfdfbwcnzfbwlwlmgnnjnpvhbhqgnzhqsnmvbcftsmrcgpvnnnmgnrvpbzlpwnbwpzmwpgqvbfgjwfrjqnvvgmqwwcfddqmdznmfhpjcfgptqdqwmplrglbwlmsqzjshrlhflcjvptgrcfhjfgqmlfzrtphpbvcqzwpcnwljjdlmqzhcctqshdngrgtlfsrfccdtlvmqcdgnpcvphdsrpzfzwclvsqcpzqlfvvqzggdhpfzdvhshglvfzfmcllrdfjfsjtngjgddcpqnlmrnplwtlvwdvzftltnsnspcdztgqhlhvvbnwvnmhscfnqbngpvprzfrjcmfpfzfftrlnwgllhnjndpjdrwcgqpcgcqngnbfzlvzvhnqdjthflmwvppmbdssddmgsbgrqnpjzrjpzdddqgsdlmwnhhpjbthclvqhgrsnrbqgtnsjhncnzbhrdgftvbptrqssvsqfpqnddhmgwcrfqndqjsqgffmhdvqhjrdlmrlcqctqccprwlbqgqrwmtfhwmfjfqzdqbsdsjbtsvfvgbsrvqwnqqqqthpsqgcfslsqtnjwtsrcdcctggdghrjwpbfccrtwgszwbrsjswmjmjbcqrsgbcfsdjzsbjnnssnddnnvwgftlrqvphnqcgjszscrlhhjnljlqcjqtqfwbmdmrgdlcqqwmbsmsdhpplvlfglqwspbfptlbzqjwhqmfvzvsvpjclcdzsbvntmhdqdvhghcmmflpjbglsghbswdshtsbdrgpsrsclrmfwwqbrgdjsqztgttqpwhnfhszlgbfpzhczsnwqflmshlgbrpmdzgpqwtsbssgfjbtrwbmztlwwfmsdgpgfgdjfdccwlfgztbcbqjvjtvslmddjplrswwcszspgplsrhrnwnmrrfbcgdmntcrlvnfqtwwcczsglrhtrfqnmhvgzjpmlplqvqhmnfgvzqcmzhqszgslvndqtqhvrbvbmclbcbjdswvcjrzgfdmdwnnlzlzqcffsrqdfmmpzfnmdsnqlpcrhzsdnsflblcjsfsgcnsspftjrlmdjsmfpqtmlgfvnlfnjscsgwzwvpjrvvclhsbqldlnmtglhbjfwlzmvrbvgtprfjbjhhnlqnbrswwlqtcgrjrltdrnfrjhrntllptlsbhqrwvdsfrlghtfcndznzjwcgmtdvffltgrdmljlqhdtmdvnfsfsrvdpmhlrrsttvqlwfptddwbpfrbclwwzmfpttmrmmqzjnbbnnfvzwmmcfshvrlbdbjzprftbqvdsghnnzwbjccpthdsvsdlgvphsgjdqjwsgmzqnqpqvgqjvwgjtzpmqqwnlwrwhqqjjclcbhjgpwhqdclwmqfmwbwmwwvcbhfznfhcfbprfcdqlbcttnvgnjwswcmpbrghtzgdbppbprffzjgvddzpwmdctrhnrfzdfhtmnfrsfdqvzcnrtncflhvldcndwqtvbggmwlzhchlcwtcbqcvlfhdwljgddwpvcfczvfqmphgtdsnsqwdpvvmwnwqjbrjwbdhhgtffphsdrvspsbgmfrmwmhnrgqdfppzgfpgmqjcsnglczgwhjthfhztzrlpgzjhcfrjpjvtjptptbvflftjtcfhmbwlhlbhvnjnbfmwjrgbvvhmdlncdgncgfjcnnpdljfcjsmsfscqpwsgcmlhhqmldsnjfrrqpghwncmgwgnjsdtvbhrbbnmpqjrrctqqnqzztmbqmdsgdvmmlwmbvprllzgntnmttrlzrttmjjlrwpwmtfznmwnsjmjhjdnsppfhcrjpzhjqzdtdbsjshfzzvrwvjbjbgtsfpgggbdztczwlhpmthfjdgsbrvlwmlrvgdrpjzccwmgpcnqqzmqdjqmwsrzwsmtmdjdhmjrwfwnzlmfnqtcgtslwtlnwhvmqntmglhntnsjlnmzfvfdztcfwmpchsrsdmqvqcwljzrmmssjvbmvvnmqlbsdwnrbmqctdtmfzlgfzpmjcnftgftvjpfbwwmzfdrrwjwcfwfcfmzbbnppgjrmbcvmvnjpdrzmvndvddtvshlnjjwgtsvnwtwnhcbfpnthpjlrhgrqccdgppjvdqjwqrfrrgnvhfwvjhnwhntnpmghphrtgqhwtbrqhqljfdjbgnlgmqqgfcqpqfhcpgspdbvlbfjvlrgmtjztwdzlrhqwwtcpdvsqgssjbjjgqlwbcctzzqvvmdzpfrmspmqhtzwgcfsslpnhpjfwqrrfbwbndrvhnnsjnlvlvqdsgwzjsrprhgtvsfbhbcpljdczbtdwzcnhzntrwcrjctmhtjfdlthznzmqblppzcqgpjhlzjrmcvpptfjjzltdhmvwphwlccscwrwfcqpqwwrzcmnltzdcfvtjrcvsqwtchrmdfzjmzjfhppjzbhglwqggzqqnspfmzrfwrqdqdrsdbsdhcgdqrrnjlwrqhfhpzjhrvjndqphndnnnbwhrjvqrrbvlhhbljjcwmfpvnhcszfshlsnczgtcfhjslbhzczdqdmdnvqdzhbmbpcnbntwgllfscrcwhfrgtfvftmwhbgfhjzjrbvvwc -------------------------------------------------------------------------------- /inputs/7.input: -------------------------------------------------------------------------------- 1 | $ cd / 2 | $ ls 3 | dir btsgrbd 4 | 3868 cprq.fmm 5 | dir gcbpcf 6 | dir hfm 7 | 324644 lthcng.gnf 8 | 133181 nblfzrb.mrr 9 | 140568 sfrbjmmh.jnj 10 | dir tfsh 11 | dir vlsqgrw 12 | 202279 vmpgqbcd 13 | $ cd btsgrbd 14 | $ ls 15 | dir cmfdm 16 | dir cqd 17 | dir gvwvs 18 | dir nblfzrb 19 | dir nfm 20 | 293979 qwnml.bqn 21 | 159220 sdwnsgwv.mjm 22 | 327978 vzgwwjq.zbp 23 | 155479 zvspnvfr.zbc 24 | $ cd cmfdm 25 | $ ls 26 | dir gldnjj 27 | dir vhf 28 | $ cd gldnjj 29 | $ ls 30 | dir dvght 31 | 93750 lwvtzd.pws 32 | 176529 sdwnsgwv.mjm 33 | 100111 vmpgqbcd 34 | $ cd dvght 35 | $ ls 36 | dir tfbzq 37 | $ cd tfbzq 38 | $ ls 39 | 276592 tcghw.srg 40 | $ cd .. 41 | $ cd .. 42 | $ cd .. 43 | $ cd vhf 44 | $ ls 45 | 240217 hfm.rfp 46 | dir nblfzrb 47 | $ cd nblfzrb 48 | $ ls 49 | 160378 jhc 50 | $ cd .. 51 | $ cd .. 52 | $ cd .. 53 | $ cd cqd 54 | $ ls 55 | 305358 bnddfgrb 56 | dir dwqncqp 57 | dir hnnfdtbh 58 | dir jhc 59 | dir nblfzrb 60 | 327762 scnm.qbf 61 | 165080 vmpgqbcd 62 | 190041 vzgwwjq.zbp 63 | dir zwv 64 | $ cd dwqncqp 65 | $ ls 66 | 122570 slpgmhv 67 | 278461 zlnbcwr 68 | $ cd .. 69 | $ cd hnnfdtbh 70 | $ ls 71 | 334830 gfprhn.rjj 72 | $ cd .. 73 | $ cd jhc 74 | $ ls 75 | 179593 fgb.btb 76 | $ cd .. 77 | $ cd nblfzrb 78 | $ ls 79 | dir clbcgvhc 80 | dir jhc 81 | dir lsrnz 82 | dir mctd 83 | $ cd clbcgvhc 84 | $ ls 85 | 285825 hnn 86 | 238272 nblfzrb.wvr 87 | $ cd .. 88 | $ cd jhc 89 | $ ls 90 | 99731 nblfzrb.svz 91 | $ cd .. 92 | $ cd lsrnz 93 | $ ls 94 | 257843 fsthnpmd 95 | $ cd .. 96 | $ cd mctd 97 | $ ls 98 | 278117 zlnbcwr 99 | $ cd .. 100 | $ cd .. 101 | $ cd zwv 102 | $ ls 103 | 40349 jhc 104 | dir pqwml 105 | 173804 sdwnsgwv.mjm 106 | $ cd pqwml 107 | $ ls 108 | 193573 hbzvzwpr 109 | $ cd .. 110 | $ cd .. 111 | $ cd .. 112 | $ cd gvwvs 113 | $ ls 114 | dir gjslw 115 | dir gwz 116 | dir ljvrjp 117 | dir sltlpb 118 | dir vbsnq 119 | $ cd gjslw 120 | $ ls 121 | dir gzbm 122 | $ cd gzbm 123 | $ ls 124 | dir fst 125 | dir gpjz 126 | dir gzd 127 | dir hfm 128 | $ cd fst 129 | $ ls 130 | 99806 mqpg 131 | $ cd .. 132 | $ cd gpjz 133 | $ ls 134 | dir dnsvsp 135 | 218828 jhc.dfd 136 | $ cd dnsvsp 137 | $ ls 138 | dir vmdbpwj 139 | dir zvspnvfr 140 | $ cd vmdbpwj 141 | $ ls 142 | 258373 jhc 143 | $ cd .. 144 | $ cd zvspnvfr 145 | $ ls 146 | 18241 vzgwwjq.zbp 147 | $ cd .. 148 | $ cd .. 149 | $ cd .. 150 | $ cd gzd 151 | $ ls 152 | 20383 chdfwj 153 | 63309 prrlv.rvn 154 | $ cd .. 155 | $ cd hfm 156 | $ ls 157 | 291753 qhh 158 | $ cd .. 159 | $ cd .. 160 | $ cd .. 161 | $ cd gwz 162 | $ ls 163 | 29042 hfm.hpn 164 | 184043 mpc 165 | 230539 sdwnsgwv.mjm 166 | 803 zlnbcwr 167 | $ cd .. 168 | $ cd ljvrjp 169 | $ ls 170 | 44312 pfltqw.zvc 171 | $ cd .. 172 | $ cd sltlpb 173 | $ ls 174 | 321945 sdwnsgwv.mjm 175 | $ cd .. 176 | $ cd vbsnq 177 | $ ls 178 | 7774 twbbg.ftq 179 | 109546 zpqbp.cts 180 | $ cd .. 181 | $ cd .. 182 | $ cd nblfzrb 183 | $ ls 184 | 89034 fst 185 | 338143 sdwnsgwv.mjm 186 | 130661 vmpgqbcd 187 | 130071 vrj.zlb 188 | $ cd .. 189 | $ cd nfm 190 | $ ls 191 | 327853 fwmfmtt.hdg 192 | 151272 vdjs 193 | dir wznwjfw 194 | 75692 zlnbcwr 195 | $ cd wznwjfw 196 | $ ls 197 | dir nblfzrb 198 | dir zvspnvfr 199 | $ cd nblfzrb 200 | $ ls 201 | 271817 fpqfgs.gdl 202 | $ cd .. 203 | $ cd zvspnvfr 204 | $ ls 205 | dir hfm 206 | dir mdftsf 207 | $ cd hfm 208 | $ ls 209 | dir fsgdq 210 | dir grj 211 | $ cd fsgdq 212 | $ ls 213 | 244565 sdwnsgwv.mjm 214 | $ cd .. 215 | $ cd grj 216 | $ ls 217 | 200989 rdvvrjf.fwz 218 | $ cd .. 219 | $ cd .. 220 | $ cd mdftsf 221 | $ ls 222 | dir fnzztppm 223 | 21425 jhc.mtl 224 | $ cd fnzztppm 225 | $ ls 226 | 159263 bvf 227 | $ cd .. 228 | $ cd .. 229 | $ cd .. 230 | $ cd .. 231 | $ cd .. 232 | $ cd .. 233 | $ cd gcbpcf 234 | $ ls 235 | 295086 gfprhn.rjj 236 | dir ldwwls 237 | dir nblfzrb 238 | dir zvspnvfr 239 | dir zwv 240 | $ cd ldwwls 241 | $ ls 242 | 175977 sdwnsgwv.mjm 243 | $ cd .. 244 | $ cd nblfzrb 245 | $ ls 246 | dir mzshzw 247 | $ cd mzshzw 248 | $ ls 249 | dir mllqf 250 | $ cd mllqf 251 | $ ls 252 | 113563 hfm.svt 253 | $ cd .. 254 | $ cd .. 255 | $ cd .. 256 | $ cd zvspnvfr 257 | $ ls 258 | 84524 fst 259 | dir jhc 260 | dir llnqc 261 | 126979 nnrwp.shv 262 | dir npjd 263 | dir nptwgdbn 264 | 133618 qtn 265 | dir rddftb 266 | dir thfhbhz 267 | 129882 vmpgqbcd 268 | 170834 zlnbcwr 269 | $ cd jhc 270 | $ ls 271 | dir pjlj 272 | dir tfljr 273 | $ cd pjlj 274 | $ ls 275 | dir jhc 276 | $ cd jhc 277 | $ ls 278 | dir hqzm 279 | $ cd hqzm 280 | $ ls 281 | 159505 zlnbcwr 282 | $ cd .. 283 | $ cd .. 284 | $ cd .. 285 | $ cd tfljr 286 | $ ls 287 | dir dwhjmg 288 | $ cd dwhjmg 289 | $ ls 290 | dir nblfzrb 291 | $ cd nblfzrb 292 | $ ls 293 | 194723 ppptz 294 | $ cd .. 295 | $ cd .. 296 | $ cd .. 297 | $ cd .. 298 | $ cd llnqc 299 | $ ls 300 | 194898 vzgwwjq.zbp 301 | $ cd .. 302 | $ cd npjd 303 | $ ls 304 | dir blvfljfn 305 | dir dzpplzl 306 | 101118 gfprhn.rjj 307 | 116164 hbbnl.nvz 308 | 211685 hfm 309 | dir jhc 310 | dir mcnftw 311 | dir nblfzrb 312 | dir ncpchrj 313 | dir qrdczsdf 314 | 165190 ttbj 315 | 190954 vzgwwjq.zbp 316 | $ cd blvfljfn 317 | $ ls 318 | 283460 gfprhn.rjj 319 | 148100 sqljld 320 | $ cd .. 321 | $ cd dzpplzl 322 | $ ls 323 | 62592 jjlvdvq.mqp 324 | $ cd .. 325 | $ cd jhc 326 | $ ls 327 | 90578 dvd.wvl 328 | 165955 zqplggf 329 | $ cd .. 330 | $ cd mcnftw 331 | $ ls 332 | 157908 gbqpdt 333 | dir jsnrcfbv 334 | dir nblfzrb 335 | 322169 qlmd.dbq 336 | dir zvspnvfr 337 | $ cd jsnrcfbv 338 | $ ls 339 | dir gffj 340 | 75682 hfm 341 | dir pmfwlzn 342 | 160494 vzgwwjq.zbp 343 | $ cd gffj 344 | $ ls 345 | dir nblfzrb 346 | 9340 pcqs 347 | $ cd nblfzrb 348 | $ ls 349 | 216547 sdwnsgwv.mjm 350 | 135235 zvspnvfr.nvs 351 | $ cd .. 352 | $ cd .. 353 | $ cd pmfwlzn 354 | $ ls 355 | 137069 jbsmwm 356 | $ cd .. 357 | $ cd .. 358 | $ cd nblfzrb 359 | $ ls 360 | dir hflnbmcd 361 | 11899 vzgwwjq.zbp 362 | 334607 whmq.ftc 363 | 347595 zlnbcwr 364 | $ cd hflnbmcd 365 | $ ls 366 | 275968 sdwnsgwv.mjm 367 | $ cd .. 368 | $ cd .. 369 | $ cd zvspnvfr 370 | $ ls 371 | 75213 vmpgqbcd 372 | $ cd .. 373 | $ cd .. 374 | $ cd nblfzrb 375 | $ ls 376 | dir jhc 377 | $ cd jhc 378 | $ ls 379 | dir jhc 380 | $ cd jhc 381 | $ ls 382 | 218236 nblfzrb.mbc 383 | $ cd .. 384 | $ cd .. 385 | $ cd .. 386 | $ cd ncpchrj 387 | $ ls 388 | dir cnswqjjd 389 | dir gvmlgjnj 390 | $ cd cnswqjjd 391 | $ ls 392 | 134879 qpzfr 393 | 30171 zvspnvfr 394 | $ cd .. 395 | $ cd gvmlgjnj 396 | $ ls 397 | 209285 fst 398 | $ cd .. 399 | $ cd .. 400 | $ cd qrdczsdf 401 | $ ls 402 | 201094 zlnbcwr 403 | $ cd .. 404 | $ cd .. 405 | $ cd nptwgdbn 406 | $ ls 407 | 217555 gfprhn.rjj 408 | 66582 mrhhpr.gdg 409 | $ cd .. 410 | $ cd rddftb 411 | $ ls 412 | 205347 sdwnsgwv.mjm 413 | 195976 vzgwwjq.zbp 414 | $ cd .. 415 | $ cd thfhbhz 416 | $ ls 417 | 321628 zlnbcwr 418 | $ cd .. 419 | $ cd .. 420 | $ cd zwv 421 | $ ls 422 | dir lnqb 423 | 311249 mtv 424 | dir tnrtjrlz 425 | $ cd lnqb 426 | $ ls 427 | dir vjtnjt 428 | $ cd vjtnjt 429 | $ ls 430 | 66715 hfm 431 | $ cd .. 432 | $ cd .. 433 | $ cd tnrtjrlz 434 | $ ls 435 | 270833 jhc.vpj 436 | $ cd .. 437 | $ cd .. 438 | $ cd .. 439 | $ cd hfm 440 | $ ls 441 | 220753 fst.tfn 442 | dir hfm 443 | 154659 mnzlvc.jzw 444 | dir nblfzrb 445 | dir nrqhstc 446 | dir vwc 447 | dir wlpdphhg 448 | dir zpbh 449 | dir zvspnvfr 450 | 160091 zvspnvfr.zqt 451 | $ cd hfm 452 | $ ls 453 | dir fst 454 | dir mfmcqhbz 455 | dir pdblpszb 456 | $ cd fst 457 | $ ls 458 | dir cpll 459 | dir fst 460 | dir nblfzrb 461 | dir sbnplvz 462 | dir vsd 463 | 307662 wlzbsdh 464 | 194873 zlnbcwr 465 | $ cd cpll 466 | $ ls 467 | 13452 pwcmhcf.lwz 468 | $ cd .. 469 | $ cd fst 470 | $ ls 471 | dir nblfzrb 472 | dir rqssg 473 | $ cd nblfzrb 474 | $ ls 475 | dir ltrc 476 | dir nblfzrb 477 | 326613 vhwnz 478 | 244908 vzgwwjq.zbp 479 | $ cd ltrc 480 | $ ls 481 | 163670 zlnbcwr 482 | $ cd .. 483 | $ cd nblfzrb 484 | $ ls 485 | dir brpzhf 486 | 61846 fst 487 | 66356 vccrmc.jbd 488 | 72767 vmpgqbcd 489 | $ cd brpzhf 490 | $ ls 491 | 224488 mttr.szf 492 | $ cd .. 493 | $ cd .. 494 | $ cd .. 495 | $ cd rqssg 496 | $ ls 497 | 131534 bfmhl.cwj 498 | 261143 hhznnd 499 | dir nmb 500 | 74816 vnmwgflj.rhp 501 | 251308 wdzfzcss.fdc 502 | $ cd nmb 503 | $ ls 504 | 264421 fst.twf 505 | dir jng 506 | 81009 rnt.dlp 507 | 288053 sftvd 508 | dir vfc 509 | $ cd jng 510 | $ ls 511 | 8014 gfprhn.rjj 512 | 168688 ppn.qbv 513 | $ cd .. 514 | $ cd vfc 515 | $ ls 516 | dir bhgstrdl 517 | 138108 dggwnqp.fpl 518 | 303194 gfprhn.rjj 519 | $ cd bhgstrdl 520 | $ ls 521 | 102559 fst.nrv 522 | 269697 trqrlrw.jmc 523 | $ cd .. 524 | $ cd .. 525 | $ cd .. 526 | $ cd .. 527 | $ cd .. 528 | $ cd nblfzrb 529 | $ ls 530 | dir bcj 531 | dir cqjmmr 532 | 256392 fst.tjf 533 | 7079 gfprhn.rjj 534 | dir gqm 535 | dir hbqfms 536 | dir nmgbfhmq 537 | 57962 pvdtbdj 538 | 117035 sdwnsgwv.mjm 539 | 64208 zlnbcwr 540 | $ cd bcj 541 | $ ls 542 | dir nblfzrb 543 | $ cd nblfzrb 544 | $ ls 545 | 149417 zvspnvfr.dqv 546 | $ cd .. 547 | $ cd .. 548 | $ cd cqjmmr 549 | $ ls 550 | 147054 fcq.mmz 551 | dir fst 552 | dir hfm 553 | 110840 jcsjjj.mvg 554 | 75746 vzgwwjq.zbp 555 | 333085 zlnbcwr 556 | $ cd fst 557 | $ ls 558 | 114747 vmpgqbcd 559 | $ cd .. 560 | $ cd hfm 561 | $ ls 562 | dir nvvppmls 563 | dir phpq 564 | dir rld 565 | $ cd nvvppmls 566 | $ ls 567 | dir cdsmgjdb 568 | $ cd cdsmgjdb 569 | $ ls 570 | 158739 hfm.nmw 571 | $ cd .. 572 | $ cd .. 573 | $ cd phpq 574 | $ ls 575 | 274026 hfm.hjj 576 | $ cd .. 577 | $ cd rld 578 | $ ls 579 | 237915 hsnngd.tqw 580 | $ cd .. 581 | $ cd .. 582 | $ cd .. 583 | $ cd gqm 584 | $ ls 585 | 188469 vzgwwjq.zbp 586 | $ cd .. 587 | $ cd hbqfms 588 | $ ls 589 | 127163 fst 590 | $ cd .. 591 | $ cd nmgbfhmq 592 | $ ls 593 | 257647 gczqzbbd 594 | dir hfm 595 | dir zvspnvfr 596 | $ cd hfm 597 | $ ls 598 | 267774 gbtwdctn.drw 599 | $ cd .. 600 | $ cd zvspnvfr 601 | $ ls 602 | 189769 gfprhn.rjj 603 | $ cd .. 604 | $ cd .. 605 | $ cd .. 606 | $ cd sbnplvz 607 | $ ls 608 | dir bln 609 | dir fst 610 | dir hdv 611 | dir jhc 612 | 31790 jhc.zvm 613 | 102276 mmmjpp 614 | dir zdwzgnb 615 | $ cd bln 616 | $ ls 617 | 161029 zlnbcwr 618 | $ cd .. 619 | $ cd fst 620 | $ ls 621 | 333565 fst 622 | $ cd .. 623 | $ cd hdv 624 | $ ls 625 | dir zvpp 626 | $ cd zvpp 627 | $ ls 628 | 143723 gfprhn.rjj 629 | $ cd .. 630 | $ cd .. 631 | $ cd jhc 632 | $ ls 633 | dir hfm 634 | dir hnqpwnfb 635 | dir jqgfcmjn 636 | dir mqj 637 | 312345 psdd.ftf 638 | dir slsq 639 | 319904 thvhdmm.rpq 640 | 317429 vzgwwjq.zbp 641 | $ cd hfm 642 | $ ls 643 | 249321 bwzrcghg.zwq 644 | 38324 zlnbcwr 645 | 149647 zvspnvfr.jwn 646 | $ cd .. 647 | $ cd hnqpwnfb 648 | $ ls 649 | 113118 bdmtgt 650 | 299110 bthznc.bjt 651 | $ cd .. 652 | $ cd jqgfcmjn 653 | $ ls 654 | 176495 hfm.wnw 655 | 333817 mqds 656 | 208755 vqsmz.cbd 657 | 298875 zltfds 658 | $ cd .. 659 | $ cd mqj 660 | $ ls 661 | 186649 brfmpbwn 662 | 43322 cgdhzzl.bvg 663 | 56230 zlnbcwr 664 | $ cd .. 665 | $ cd slsq 666 | $ ls 667 | dir dtsg 668 | 343453 rjgvt.sgc 669 | 313784 vmpgqbcd 670 | $ cd dtsg 671 | $ ls 672 | 308070 zvspnvfr.dqq 673 | $ cd .. 674 | $ cd .. 675 | $ cd .. 676 | $ cd zdwzgnb 677 | $ ls 678 | dir zvspnvfr 679 | $ cd zvspnvfr 680 | $ ls 681 | 278754 glqszhnp 682 | 199713 sdwnsgwv.mjm 683 | $ cd .. 684 | $ cd .. 685 | $ cd .. 686 | $ cd vsd 687 | $ ls 688 | 17978 fdrg.cft 689 | 320284 sdwnsgwv.mjm 690 | 230059 tpfmtww.jbs 691 | 168301 vmpgqbcd 692 | $ cd .. 693 | $ cd .. 694 | $ cd mfmcqhbz 695 | $ ls 696 | dir fst 697 | dir lwlsnt 698 | dir mqqdst 699 | $ cd fst 700 | $ ls 701 | dir cln 702 | 235621 hfm.mhr 703 | 4347 qwfwj 704 | 226297 zlnbcwr 705 | $ cd cln 706 | $ ls 707 | dir cfz 708 | dir njptzz 709 | dir rcbps 710 | 161994 rjl.pfg 711 | dir tcqttb 712 | 22809 vmpgqbcd 713 | 225782 zvspnvfr.gbw 714 | $ cd cfz 715 | $ ls 716 | 168184 zvspnvfr 717 | $ cd .. 718 | $ cd njptzz 719 | $ ls 720 | 286155 hfm.mjh 721 | $ cd .. 722 | $ cd rcbps 723 | $ ls 724 | 256675 vzgwwjq.zbp 725 | $ cd .. 726 | $ cd tcqttb 727 | $ ls 728 | 91505 flmgglv.gjw 729 | 270377 ftbjzt.lcm 730 | $ cd .. 731 | $ cd .. 732 | $ cd .. 733 | $ cd lwlsnt 734 | $ ls 735 | dir ztrcwjw 736 | $ cd ztrcwjw 737 | $ ls 738 | 342059 vjcldgfj.twb 739 | $ cd .. 740 | $ cd .. 741 | $ cd mqqdst 742 | $ ls 743 | 326143 dhlhzzj.sbh 744 | dir lmsbg 745 | 13108 nblfzrb.nnr 746 | 256325 vzgwwjq.zbp 747 | 146133 zlnbcwr 748 | $ cd lmsbg 749 | $ ls 750 | 282223 zvspnvfr.zwq 751 | $ cd .. 752 | $ cd .. 753 | $ cd .. 754 | $ cd pdblpszb 755 | $ ls 756 | 167164 sdwnsgwv.mjm 757 | $ cd .. 758 | $ cd .. 759 | $ cd nblfzrb 760 | $ ls 761 | 161555 zlnbcwr 762 | $ cd .. 763 | $ cd nrqhstc 764 | $ ls 765 | 316797 gfprhn.rjj 766 | 263838 nblfzrb.cjr 767 | dir pppmp 768 | dir shcwlggz 769 | $ cd pppmp 770 | $ ls 771 | dir fst 772 | 328237 gfprhn.rjj 773 | 288094 hzv.prf 774 | 260275 pcnhmmw 775 | 214496 pptjlrn.pls 776 | dir tqjgrc 777 | 315647 vmbvl.zvh 778 | $ cd fst 779 | $ ls 780 | 4441 dtt 781 | 115073 jhdqj.tpt 782 | 337681 zlnbcwr 783 | $ cd .. 784 | $ cd tqjgrc 785 | $ ls 786 | 6491 zlnbcwr 787 | $ cd .. 788 | $ cd .. 789 | $ cd shcwlggz 790 | $ ls 791 | 251509 gfprhn.rjj 792 | 331578 slsnbzm 793 | 158534 wlchqtzj.ljz 794 | 341686 wmdvjs.tjb 795 | $ cd .. 796 | $ cd .. 797 | $ cd vwc 798 | $ ls 799 | 94599 gfprhn.rjj 800 | 298110 hql.hss 801 | dir rsrfc 802 | 230201 vmpgqbcd 803 | dir zcsqst 804 | dir zrz 805 | 58810 zvspnvfr 806 | $ cd rsrfc 807 | $ ls 808 | dir fst 809 | $ cd fst 810 | $ ls 811 | 259462 bflpjwd.wbj 812 | 177686 cvh.fnr 813 | $ cd .. 814 | $ cd .. 815 | $ cd zcsqst 816 | $ ls 817 | 344114 bbbd.ncl 818 | 282111 gfprhn.rjj 819 | 327171 jhc 820 | 43867 qwzwmffq.chl 821 | $ cd .. 822 | $ cd zrz 823 | $ ls 824 | dir zvspnvfr 825 | $ cd zvspnvfr 826 | $ ls 827 | dir fst 828 | $ cd fst 829 | $ ls 830 | 218902 fst.jmg 831 | $ cd .. 832 | $ cd .. 833 | $ cd .. 834 | $ cd .. 835 | $ cd wlpdphhg 836 | $ ls 837 | dir lllph 838 | 41390 wmn 839 | $ cd lllph 840 | $ ls 841 | 167740 bbfqftlg.pll 842 | $ cd .. 843 | $ cd .. 844 | $ cd zpbh 845 | $ ls 846 | 63568 jhc.tfs 847 | dir nblfzrb 848 | dir rlsvrfrb 849 | 29977 vzgwwjq.zbp 850 | dir zvspnvfr 851 | $ cd nblfzrb 852 | $ ls 853 | 154990 gbvpw.bpm 854 | dir hfm 855 | 148488 jhc 856 | 301795 jhc.zlg 857 | dir nblfzrb 858 | 115285 rvhcfsrw.crj 859 | 320034 wsqdt 860 | $ cd hfm 861 | $ ls 862 | 141530 vmpgqbcd 863 | $ cd .. 864 | $ cd nblfzrb 865 | $ ls 866 | dir rnhn 867 | $ cd rnhn 868 | $ ls 869 | 46251 sdwnsgwv.mjm 870 | $ cd .. 871 | $ cd .. 872 | $ cd .. 873 | $ cd rlsvrfrb 874 | $ ls 875 | 140923 hfm 876 | 228981 zvspnvfr.mvl 877 | $ cd .. 878 | $ cd zvspnvfr 879 | $ ls 880 | 182280 gnhh.hpw 881 | 95206 vvlt.pgf 882 | $ cd .. 883 | $ cd .. 884 | $ cd zvspnvfr 885 | $ ls 886 | 234551 wsfjhlqc.zsj 887 | $ cd .. 888 | $ cd .. 889 | $ cd tfsh 890 | $ ls 891 | dir fbrqvwgr 892 | $ cd fbrqvwgr 893 | $ ls 894 | 244821 nrhm 895 | $ cd .. 896 | $ cd .. 897 | $ cd vlsqgrw 898 | $ ls 899 | dir dzdd 900 | 18805 fst.rjm 901 | 50694 gfprhn.rjj 902 | 55025 jlnrm 903 | dir pnsbfz 904 | dir qjjjgd 905 | dir whrtnh 906 | 28406 zggjjcct.fsz 907 | $ cd dzdd 908 | $ ls 909 | dir hjmv 910 | $ cd hjmv 911 | $ ls 912 | 91558 hfm.qcd 913 | $ cd .. 914 | $ cd .. 915 | $ cd pnsbfz 916 | $ ls 917 | dir bmgmh 918 | dir nblfzrb 919 | dir zvfg 920 | $ cd bmgmh 921 | $ ls 922 | dir dvh 923 | dir mwfbthpj 924 | dir swqbph 925 | $ cd dvh 926 | $ ls 927 | dir jhc 928 | dir jtp 929 | 85638 rzlt.llb 930 | $ cd jhc 931 | $ ls 932 | dir dltqbnpq 933 | $ cd dltqbnpq 934 | $ ls 935 | 133426 zlnbcwr 936 | $ cd .. 937 | $ cd .. 938 | $ cd jtp 939 | $ ls 940 | dir clh 941 | $ cd clh 942 | $ ls 943 | 54117 sdwnsgwv.mjm 944 | $ cd .. 945 | $ cd .. 946 | $ cd .. 947 | $ cd mwfbthpj 948 | $ ls 949 | 75900 zwslwbr.chm 950 | $ cd .. 951 | $ cd swqbph 952 | $ ls 953 | 307258 jrlljc.ntl 954 | $ cd .. 955 | $ cd .. 956 | $ cd nblfzrb 957 | $ ls 958 | 106071 zdjg.qsj 959 | $ cd .. 960 | $ cd zvfg 961 | $ ls 962 | 311338 zvspnvfr.dqj 963 | $ cd .. 964 | $ cd .. 965 | $ cd qjjjgd 966 | $ ls 967 | dir cdmwgn 968 | dir fqmln 969 | 285733 gfprhn.rjj 970 | dir gswsc 971 | dir htpzdb 972 | 261929 jwc 973 | dir lvzpqqv 974 | dir mlc 975 | dir mzbpmhf 976 | 329303 sdwnsgwv.mjm 977 | 76120 vmpgqbcd 978 | $ cd cdmwgn 979 | $ ls 980 | dir bttff 981 | $ cd bttff 982 | $ ls 983 | dir nblfzrb 984 | $ cd nblfzrb 985 | $ ls 986 | 346048 jhc.hzf 987 | dir nccq 988 | dir rwtddj 989 | 149890 sdwnsgwv.mjm 990 | $ cd nccq 991 | $ ls 992 | 141144 gfprhn.rjj 993 | 65628 hfm 994 | $ cd .. 995 | $ cd rwtddj 996 | $ ls 997 | dir jctw 998 | $ cd jctw 999 | $ ls 1000 | 141075 thcfz.frn 1001 | $ cd .. 1002 | $ cd .. 1003 | $ cd .. 1004 | $ cd .. 1005 | $ cd .. 1006 | $ cd fqmln 1007 | $ ls 1008 | 282233 cjgh 1009 | $ cd .. 1010 | $ cd gswsc 1011 | $ ls 1012 | 153758 ccjg.zml 1013 | dir cllgt 1014 | 257967 ctqdpq.clq 1015 | 117673 jhc 1016 | 258604 wqcz.tww 1017 | 122135 zvspnvfr.grb 1018 | $ cd cllgt 1019 | $ ls 1020 | 132862 vmpgqbcd 1021 | $ cd .. 1022 | $ cd .. 1023 | $ cd htpzdb 1024 | $ ls 1025 | dir hfm 1026 | dir mlplp 1027 | 231759 nblfzrb 1028 | 159823 pqpbjbqp 1029 | 25382 vzgwwjq.zbp 1030 | $ cd hfm 1031 | $ ls 1032 | 155413 bbbsd 1033 | 288638 jhhmwq 1034 | dir lnss 1035 | $ cd lnss 1036 | $ ls 1037 | 341786 zvspnvfr 1038 | $ cd .. 1039 | $ cd .. 1040 | $ cd mlplp 1041 | $ ls 1042 | 256802 zhcq.gzj 1043 | $ cd .. 1044 | $ cd .. 1045 | $ cd lvzpqqv 1046 | $ ls 1047 | dir cgj 1048 | dir mdb 1049 | dir shpdtb 1050 | $ cd cgj 1051 | $ ls 1052 | 74595 nblfzrb.lcc 1053 | $ cd .. 1054 | $ cd mdb 1055 | $ ls 1056 | 167891 zvspnvfr.ldc 1057 | $ cd .. 1058 | $ cd shpdtb 1059 | $ ls 1060 | 45889 bvff.hsf 1061 | 92447 sdwnsgwv.mjm 1062 | $ cd .. 1063 | $ cd .. 1064 | $ cd mlc 1065 | $ ls 1066 | 7978 mrblf 1067 | $ cd .. 1068 | $ cd mzbpmhf 1069 | $ ls 1070 | 38713 jhbs 1071 | $ cd .. 1072 | $ cd .. 1073 | $ cd whrtnh 1074 | $ ls 1075 | dir jbbwzd 1076 | dir nblfzrb 1077 | $ cd jbbwzd 1078 | $ ls 1079 | 88613 jhc.qqw 1080 | $ cd .. 1081 | $ cd nblfzrb 1082 | $ ls 1083 | 164792 zlnbcwr 1084 | -------------------------------------------------------------------------------- /inputs/8.input: -------------------------------------------------------------------------------- 1 | 301201331333030024002151134115545441525510053410321024643223304253251423014345311431413433341211111 2 | 210313031411030140245452501003514242514125366210551353634546632015232323540022212401412031113310333 3 | 201223331222432221305443412445304401201165033624245311620346242360420521343514132520204104244200322 4 | 210003034413133345421153101053132524226234460546142402452466345321440520524311212410303224012242000 5 | 002232200024321241105051144044530503201446133504652500410463241436361361002024122340512441243222203 6 | 102023303032432341105353554225663326563653250523350302104003635340436625240235531151145343032212033 7 | 011432423042054254520503506222252050256315142254016650105015643542660231044302233035322122100032212 8 | 034421243321311550201305666136554451350322354144633556333022003664006612152610511132354312443134400 9 | 302214114340201552153246320504242003513464536535521715125521314654606653312124014223422135000032024 10 | 022203301311105514431426025115566414166144753435463146324664616502342356626446124204455213422314241 11 | 133202031100242023236362026113243573426315617627527543647213541517440126016042624554125530550304004 12 | 412414223443004100621020255403316757326244275247134627215636656313472021156626214003511121524211201 13 | 100020113553530111635403433310123371416566464531664371236763762654672716453255155611041431321301000 14 | 040442015403322353635250250156757514552341246114755653427321572644373333764015356451022003122252214 15 | 131335400000330152046666616363523347474566725475326875713565751313316433363251655012415235210153134 16 | 212205354412516232346215667365363413636143322285687428338237666271455444277511521334662020135104441 17 | 400134535100103465544240377332663352346366464426356585587388572154627365567576126334445412551245044 18 | 313125111102350042411627156361342341273445272266422466584446423554731131743433165124231111435223052 19 | 414211350002631116406722423146474385423846752263457355267246283862347153516722261451645234034250125 20 | 142350115212334322146515331713325337468443588225285768685574226644533724475335124115505531225141432 21 | 221420101060222256363211452511352288853828648746647256668823328327287747564123275261621500245133411 22 | 453113024555202631573132336658242736347325874252333535256677587837657678625214457745232452150220123 23 | 555034246226545644223655121622358344733858586769673974337826765554468355524344661464661052120504131 24 | 101440210460332606657775163743688753344448398636494466664973768385765272752651367426304666101123130 25 | 532232304344031236635141354227547676887398783998657559945898897482268637355733664642700640525354230 26 | 254425530336536647234251648333783825963356648666958849583777336977537428866623134526176025236412301 27 | 052420045556125743544677352453853565968669799673389736356646485675748435258353372737571166544644253 28 | 144212521432144457427473545763356688633446594997933764479494846866798222377556235341461400160564305 29 | 414546463341545336547365484645276357553584336774496855639397587938638557263543347554553131065014354 30 | 213110564326373147676363536832594994448537796457645847754798668996863976763583886251625241215423451 31 | 402441605154657151126587562648764444548399868584444984666447398399475652866688642677426256050111044 32 | 030505222044142675156675655568358889949479978645448697784665774359755689243645735162215642560304321 33 | 002364341155613641588426677659986477446964688986679878477959859546863555528383865312255533510006644 34 | 315603002442216142126278638843367593346876468657757444768587498693659647788784456647117426311553113 35 | 534026231247517653336254847934574378679647999777747989757856888763437583487626885465121722135401110 36 | 152663134317453637627862365337774534996567697946779555455989744649937645994653657567156245462533302 37 | 415120400426463528567443378965654344948544677795568678979865564545598768643876476547177613642314014 38 | 212134106151643463482274255887744459499685657799867587677998674896776889393348337484463153571460162 39 | 123265543627354585248835586978887467585449979975988897979955857994455783796697728544256417663200436 40 | 253156122444754335226888665898754494695989955588988885866899669459797535776733282376417141555433640 41 | 105125666421254638626347936375599547788669998799766755958796875664688687698846364536875113743306636 42 | 543154323554211424234263689757375946445859555669888666959896575566688549986398632678217421361116016 43 | 534446627674264324833537896437597864966965789556679958788689859997595593943745863828822163463613245 44 | 456422412772232364425647578537895646785958867897868976696886585987468565967685553265682333333642602 45 | 155305566576114247342276876599654498977865685987867897688785559595497686574858683675725765634063131 46 | 350133405277354723553294549397478955987876557987698878889985757654986568886863447837277147741536410 47 | 013062547146413742675348465764876557565879576696666889866579778749764578444847765768252647361443506 48 | 312465621677151875655585995745694878655956799697796697686885558978975449756474748887586542411256255 49 | 423204362353178745852254637935464664778869968879677697777878575777556878634856584473864213312622015 50 | 534661567344614365768387877864878845767598869677978779767787858784584759476648665773358427645311651 51 | 430011475352152575755679953749774454789788589769698678798856669687965675695986644657485514217351666 52 | 542102111432167877663467859536777594767895986867898886766676976869846495867599543374583332731266033 53 | 625000474732136887874855736749589476996659798967789898789776587976889996948384763734447643736220025 54 | 315666062115612845335864885945654758789765698688877769667668867576798855583978955268844425122514014 55 | 152600463716132562642488647595685976468985656996977998778955585795596495844759888838286175352560414 56 | 006166514645376457676454676698858546456775687876679968965697579748769964686887987774361312361623112 57 | 630201542341341448626638885984646765658869666987886976795798598788495887683399383777375346636211550 58 | 036646423755734847267336476354564466955596575589776859595968578788654499546534758266652277357366530 59 | 453243636357156364866489789657955759776966959655868798956766987954989947943863354645777345476202531 60 | 530105612477445332537878834449565659485976667656597697775688857778754844458355277846316112626121162 61 | 055455363734131537735589765579697845958456556556686566965687745949576967556763233558753142411453220 62 | 106052304147675524263254984449336844955757978879668668576768676787755787574533445667862426312335351 63 | 133545504422337378456858864594449878578885567885775668878958786485657683335482267532317234560541422 64 | 200255566345515714753376495455776859698895897588685996587586745857468367437854554745116413532363200 65 | 350510465672221255867873257334876685756745545667796896497688464848948768947422782828661471761064122 66 | 525006435255273146277854349566333878494888868995668459955986944485699959837552728523754132365504644 67 | 455465632474322677526353348496893746878784677485547847847759558643378358396575444475242721722332551 68 | 341264465466426473255828826967974346556896576764466849697759555548879644597626468762475471232114332 69 | 143015600661254143155723453874645479598897489897887869959899767545558694586565824554175726556330040 70 | 133114601616545361237744836629659733553959758846995589848895753645437876746537567247223752042644353 71 | 434245136445331567724385257642784846854365449776854954774496353883589792252488545733673623365531411 72 | 242355400240614257475587442835547333788435758749676988545464355973893552465258322436517445530103424 73 | 150522445522362651727687768785836854563533374767758439957544655684349342343244731321332645111541021 74 | 552400436500115714126552863645543555378537389683366874478896898884353658447572421457611323114255212 75 | 304202302265264467247666485428778363698453577569497785947535758344375242826567265416457044433163541 76 | 233353455013125235351275368356247267348486886475363374634485474876565735683724532261524142510630102 77 | 440535161152151631635373575637235623878689436669334497565478939626735535482665761716504623034023120 78 | 530315220006363246522576534738725655632837547375957696853688457354338383534653311344113001640515414 79 | 204313020634510554536253474458753547425233336944493739858844757374686252224513224773652513353305442 80 | 303341052510105201513731753724282223364752725537642288866686622588863837445543126664241453441235310 81 | 020424153032624323671363111463422353477742627478683844868633432636588536274451572264610340614104555 82 | 234413051424523314161146731763467724436346548732688655832363463687352214147256367321403115315443500 83 | 012242303516512442500774532142266284382765822428622346384737664242643615627661273552155526054233342 84 | 414111403514124460666037555342627216676675426728525487642273658483463277637667635142640425425132342 85 | 030230422403061322643446763675767367778368767234652457668385774272636771211474352411225452213412310 86 | 032113014010425161346051473351752565267374786865733735338367253243133431751566100563025504520403342 87 | 412304104125143243301236345151712624614211575411475821376435722564217622616521260005512052222004343 88 | 220120030303233310444012046257231472762352112415164732622531735165124331120326541545011444410002400 89 | 014433054545451316643032015010316146277161216552272145522146562717437536450604320052302441034404241 90 | 343434423453055414653253445655564632771244123251647272745743671776331230215004615545255055050133340 91 | 201000210435340452132116022411356245227731333555165752717373435156310453501204235431002250524221113 92 | 132100434242305201202434465065260455543457427521464157317741755225245256645305422324552252031144120 93 | 202441110432420500412256514006155406431013256445476676323751251451145064255351541053031130431201234 94 | 020212022220112430245130010061216066220264013366625475240550163452521001005224125240541123033121143 95 | 132244304123021525001211154544140012602120125510011436101445405650606625263223310430540142302200433 96 | 103142142201203130045124150512613540504163320002045004044613203062515015344450101154534004044231012 97 | 221234114210331020511522535110011636160005413424224560604634052506210501451443521502544433404042033 98 | 001233231400214434040102054514026055053336624361305231213331535242260044242320014551114014133012203 99 | 013221201313013142535111451534205341402225520043535003305340330410530234344250234251433044340323003 100 | -------------------------------------------------------------------------------- /inputs/9.input: -------------------------------------------------------------------------------- 1 | U 1 2 | R 1 3 | D 2 4 | L 1 5 | R 2 6 | U 1 7 | L 1 8 | U 1 9 | L 2 10 | R 1 11 | D 2 12 | U 1 13 | R 2 14 | L 2 15 | U 2 16 | R 2 17 | D 2 18 | R 1 19 | D 2 20 | L 2 21 | R 2 22 | U 1 23 | D 2 24 | L 1 25 | U 2 26 | D 2 27 | L 1 28 | D 2 29 | R 1 30 | D 1 31 | R 2 32 | L 2 33 | D 1 34 | R 2 35 | U 1 36 | L 1 37 | D 2 38 | R 2 39 | U 2 40 | L 2 41 | D 2 42 | R 1 43 | L 1 44 | U 1 45 | R 2 46 | U 1 47 | L 2 48 | R 1 49 | U 1 50 | R 2 51 | D 1 52 | R 1 53 | D 1 54 | L 2 55 | U 2 56 | L 2 57 | U 2 58 | L 1 59 | R 2 60 | L 2 61 | R 2 62 | L 1 63 | D 2 64 | U 1 65 | R 2 66 | D 1 67 | R 2 68 | D 1 69 | R 2 70 | D 2 71 | U 1 72 | L 1 73 | D 2 74 | R 2 75 | L 2 76 | R 2 77 | L 2 78 | U 1 79 | L 2 80 | R 2 81 | D 2 82 | L 1 83 | D 1 84 | L 1 85 | U 1 86 | D 1 87 | U 2 88 | L 1 89 | D 2 90 | L 2 91 | U 1 92 | R 1 93 | L 2 94 | U 1 95 | R 2 96 | U 2 97 | R 2 98 | D 2 99 | U 1 100 | L 2 101 | D 2 102 | U 2 103 | D 1 104 | U 2 105 | L 2 106 | U 1 107 | L 2 108 | R 1 109 | U 1 110 | L 1 111 | R 2 112 | U 1 113 | R 3 114 | D 3 115 | L 2 116 | D 2 117 | R 1 118 | D 3 119 | R 3 120 | D 1 121 | U 2 122 | R 1 123 | D 3 124 | R 1 125 | L 3 126 | D 1 127 | R 3 128 | L 3 129 | R 2 130 | L 2 131 | U 3 132 | R 2 133 | D 2 134 | L 2 135 | D 1 136 | R 2 137 | L 3 138 | D 1 139 | R 1 140 | U 1 141 | D 3 142 | U 2 143 | L 2 144 | R 3 145 | U 3 146 | L 2 147 | D 1 148 | L 2 149 | R 1 150 | L 2 151 | R 2 152 | D 2 153 | R 3 154 | L 3 155 | D 2 156 | L 3 157 | D 2 158 | L 3 159 | D 2 160 | R 1 161 | L 3 162 | U 3 163 | R 1 164 | L 2 165 | D 3 166 | U 1 167 | D 2 168 | L 3 169 | D 3 170 | R 1 171 | D 1 172 | U 3 173 | L 3 174 | U 2 175 | R 1 176 | D 2 177 | L 1 178 | R 3 179 | L 1 180 | D 2 181 | U 1 182 | R 3 183 | L 3 184 | D 3 185 | U 1 186 | L 3 187 | R 1 188 | L 3 189 | D 3 190 | U 2 191 | R 3 192 | D 1 193 | L 1 194 | D 2 195 | L 1 196 | U 1 197 | D 2 198 | L 2 199 | D 1 200 | U 3 201 | D 1 202 | U 2 203 | L 2 204 | D 1 205 | U 2 206 | L 2 207 | U 3 208 | R 2 209 | L 1 210 | U 1 211 | D 1 212 | L 2 213 | D 1 214 | U 2 215 | D 3 216 | U 3 217 | R 1 218 | L 3 219 | R 3 220 | L 2 221 | U 3 222 | R 3 223 | U 3 224 | R 2 225 | U 1 226 | R 3 227 | U 3 228 | R 1 229 | U 4 230 | D 3 231 | R 2 232 | L 3 233 | R 3 234 | L 4 235 | R 2 236 | L 1 237 | U 2 238 | D 4 239 | U 4 240 | D 3 241 | L 2 242 | U 3 243 | R 3 244 | U 4 245 | R 4 246 | D 3 247 | U 4 248 | R 3 249 | U 4 250 | L 4 251 | D 4 252 | R 4 253 | U 2 254 | L 3 255 | D 4 256 | L 1 257 | U 2 258 | R 1 259 | D 3 260 | U 1 261 | R 1 262 | U 3 263 | D 2 264 | L 3 265 | D 2 266 | U 4 267 | D 4 268 | L 3 269 | U 4 270 | R 1 271 | D 3 272 | L 3 273 | D 2 274 | L 1 275 | R 1 276 | U 1 277 | D 2 278 | L 2 279 | U 4 280 | D 1 281 | R 3 282 | L 2 283 | R 2 284 | L 3 285 | U 4 286 | D 1 287 | R 4 288 | L 1 289 | U 4 290 | D 2 291 | U 3 292 | R 2 293 | U 1 294 | D 2 295 | U 2 296 | R 1 297 | L 1 298 | U 4 299 | L 1 300 | R 4 301 | U 2 302 | L 2 303 | D 3 304 | R 2 305 | U 1 306 | D 4 307 | L 3 308 | D 2 309 | U 3 310 | D 3 311 | L 1 312 | U 4 313 | L 3 314 | R 2 315 | L 4 316 | R 3 317 | D 2 318 | U 3 319 | R 1 320 | D 4 321 | L 2 322 | D 3 323 | R 2 324 | U 3 325 | R 2 326 | U 2 327 | L 3 328 | D 1 329 | R 4 330 | L 1 331 | R 1 332 | D 2 333 | R 1 334 | D 5 335 | L 4 336 | U 2 337 | D 5 338 | R 4 339 | L 2 340 | U 4 341 | D 5 342 | L 3 343 | U 1 344 | R 2 345 | D 1 346 | R 4 347 | U 5 348 | L 2 349 | D 2 350 | R 4 351 | D 2 352 | R 5 353 | L 5 354 | D 3 355 | U 1 356 | R 2 357 | D 1 358 | U 1 359 | D 2 360 | U 5 361 | D 2 362 | U 5 363 | R 4 364 | L 2 365 | U 4 366 | D 1 367 | U 1 368 | L 4 369 | U 4 370 | D 1 371 | U 5 372 | D 4 373 | L 3 374 | D 2 375 | U 3 376 | R 4 377 | D 2 378 | L 3 379 | R 4 380 | D 1 381 | U 2 382 | L 2 383 | R 1 384 | D 3 385 | R 5 386 | U 1 387 | R 4 388 | U 1 389 | R 3 390 | U 5 391 | L 5 392 | D 4 393 | L 5 394 | R 2 395 | D 3 396 | R 4 397 | D 2 398 | U 4 399 | D 3 400 | U 1 401 | L 2 402 | U 3 403 | L 2 404 | R 1 405 | U 5 406 | D 2 407 | R 1 408 | D 3 409 | R 1 410 | U 2 411 | R 1 412 | U 2 413 | L 3 414 | R 1 415 | L 3 416 | U 1 417 | D 4 418 | R 5 419 | L 3 420 | D 1 421 | U 4 422 | D 1 423 | U 1 424 | R 3 425 | D 5 426 | R 3 427 | D 3 428 | U 2 429 | L 4 430 | R 3 431 | L 5 432 | U 3 433 | L 2 434 | D 1 435 | U 5 436 | R 3 437 | U 5 438 | R 3 439 | L 1 440 | U 3 441 | L 4 442 | R 1 443 | D 2 444 | L 2 445 | U 5 446 | D 3 447 | L 3 448 | U 6 449 | R 3 450 | L 4 451 | D 4 452 | R 3 453 | D 5 454 | R 3 455 | U 6 456 | D 1 457 | L 5 458 | D 5 459 | L 2 460 | U 1 461 | R 2 462 | L 4 463 | U 5 464 | R 4 465 | L 6 466 | U 2 467 | D 3 468 | L 5 469 | D 2 470 | R 3 471 | L 5 472 | R 4 473 | D 6 474 | R 6 475 | L 3 476 | U 5 477 | R 3 478 | L 2 479 | R 1 480 | D 6 481 | R 1 482 | L 1 483 | R 1 484 | U 5 485 | R 1 486 | D 1 487 | R 5 488 | L 1 489 | R 6 490 | L 1 491 | R 3 492 | U 2 493 | D 3 494 | U 4 495 | D 4 496 | R 5 497 | U 4 498 | D 2 499 | R 1 500 | D 6 501 | R 3 502 | D 1 503 | R 3 504 | U 2 505 | R 3 506 | U 2 507 | D 3 508 | U 2 509 | R 1 510 | L 4 511 | D 4 512 | L 3 513 | D 2 514 | U 3 515 | L 6 516 | D 6 517 | R 5 518 | U 3 519 | L 4 520 | R 6 521 | D 3 522 | R 1 523 | U 4 524 | D 1 525 | L 3 526 | U 5 527 | D 2 528 | L 2 529 | U 5 530 | L 3 531 | U 6 532 | D 5 533 | L 1 534 | U 4 535 | L 6 536 | D 6 537 | U 3 538 | D 2 539 | R 6 540 | D 4 541 | R 1 542 | U 5 543 | R 5 544 | U 2 545 | R 5 546 | D 4 547 | R 2 548 | U 2 549 | L 3 550 | D 3 551 | R 5 552 | D 3 553 | U 1 554 | L 1 555 | U 6 556 | D 5 557 | R 2 558 | L 4 559 | D 1 560 | R 6 561 | L 4 562 | D 2 563 | L 7 564 | U 7 565 | L 1 566 | D 4 567 | U 3 568 | D 7 569 | L 6 570 | R 5 571 | D 7 572 | R 4 573 | L 6 574 | U 3 575 | D 7 576 | U 6 577 | D 2 578 | U 2 579 | L 5 580 | D 3 581 | U 1 582 | L 1 583 | U 7 584 | D 7 585 | L 1 586 | R 1 587 | D 6 588 | R 7 589 | L 7 590 | D 3 591 | L 6 592 | R 7 593 | U 4 594 | D 7 595 | R 6 596 | L 2 597 | R 1 598 | U 1 599 | D 1 600 | R 3 601 | U 1 602 | L 5 603 | R 7 604 | L 4 605 | R 5 606 | L 2 607 | R 3 608 | L 7 609 | D 5 610 | L 3 611 | R 4 612 | U 1 613 | R 7 614 | D 4 615 | R 3 616 | U 1 617 | D 1 618 | L 1 619 | D 4 620 | R 4 621 | L 2 622 | D 3 623 | U 4 624 | R 5 625 | D 6 626 | U 4 627 | L 7 628 | R 6 629 | L 7 630 | U 3 631 | D 7 632 | R 4 633 | U 7 634 | R 5 635 | U 2 636 | L 5 637 | R 7 638 | L 5 639 | U 3 640 | L 7 641 | U 6 642 | D 7 643 | R 7 644 | D 6 645 | U 1 646 | R 1 647 | D 6 648 | U 3 649 | L 7 650 | D 1 651 | R 1 652 | D 2 653 | L 2 654 | R 2 655 | U 5 656 | L 2 657 | U 1 658 | R 5 659 | U 5 660 | L 3 661 | R 6 662 | D 1 663 | L 7 664 | D 7 665 | R 1 666 | L 1 667 | R 1 668 | U 5 669 | R 1 670 | L 8 671 | D 6 672 | R 6 673 | U 2 674 | L 7 675 | U 3 676 | L 4 677 | R 3 678 | D 3 679 | R 8 680 | U 6 681 | R 3 682 | D 4 683 | U 8 684 | R 5 685 | U 3 686 | R 3 687 | D 2 688 | R 4 689 | U 6 690 | R 2 691 | D 2 692 | L 2 693 | D 7 694 | U 4 695 | L 3 696 | R 4 697 | L 8 698 | R 1 699 | U 2 700 | D 1 701 | L 8 702 | U 8 703 | R 6 704 | U 1 705 | L 8 706 | D 6 707 | L 7 708 | U 5 709 | L 3 710 | D 1 711 | R 2 712 | L 8 713 | R 7 714 | D 7 715 | R 7 716 | D 7 717 | R 8 718 | U 5 719 | R 4 720 | U 3 721 | D 5 722 | U 3 723 | L 8 724 | D 2 725 | L 2 726 | D 4 727 | R 2 728 | D 7 729 | R 4 730 | U 8 731 | R 1 732 | L 2 733 | D 7 734 | U 1 735 | L 3 736 | R 1 737 | L 8 738 | D 1 739 | R 7 740 | U 2 741 | L 2 742 | R 8 743 | D 8 744 | U 7 745 | R 1 746 | U 7 747 | L 1 748 | R 1 749 | L 3 750 | U 7 751 | R 3 752 | D 4 753 | R 3 754 | D 4 755 | R 3 756 | U 7 757 | L 4 758 | R 7 759 | L 1 760 | D 8 761 | R 7 762 | U 6 763 | R 4 764 | D 2 765 | R 7 766 | L 8 767 | D 6 768 | R 1 769 | U 8 770 | L 6 771 | D 4 772 | L 4 773 | U 8 774 | R 3 775 | D 4 776 | U 4 777 | L 5 778 | U 9 779 | L 5 780 | R 1 781 | L 1 782 | U 7 783 | L 7 784 | U 3 785 | D 4 786 | L 4 787 | U 3 788 | D 7 789 | R 3 790 | D 6 791 | R 2 792 | U 8 793 | D 7 794 | U 1 795 | D 1 796 | L 8 797 | R 6 798 | L 4 799 | D 2 800 | L 7 801 | D 9 802 | R 6 803 | D 8 804 | R 4 805 | D 9 806 | L 4 807 | D 3 808 | L 4 809 | U 6 810 | L 2 811 | U 3 812 | D 4 813 | R 9 814 | D 5 815 | L 5 816 | U 3 817 | R 9 818 | U 9 819 | D 3 820 | R 1 821 | D 7 822 | R 1 823 | D 8 824 | R 1 825 | D 3 826 | R 6 827 | L 5 828 | D 1 829 | L 3 830 | R 3 831 | U 1 832 | D 4 833 | U 6 834 | D 9 835 | U 9 836 | L 6 837 | D 6 838 | R 1 839 | U 4 840 | D 6 841 | L 7 842 | R 1 843 | L 8 844 | R 8 845 | D 1 846 | R 6 847 | L 7 848 | D 3 849 | U 8 850 | R 8 851 | L 9 852 | R 8 853 | L 7 854 | U 5 855 | L 2 856 | R 4 857 | D 8 858 | U 9 859 | D 3 860 | L 6 861 | U 3 862 | L 2 863 | R 1 864 | D 3 865 | U 9 866 | D 9 867 | U 6 868 | R 8 869 | L 1 870 | U 8 871 | L 5 872 | R 2 873 | L 4 874 | R 6 875 | L 6 876 | D 4 877 | R 6 878 | L 9 879 | R 8 880 | U 1 881 | D 8 882 | R 7 883 | D 1 884 | L 9 885 | D 6 886 | L 1 887 | R 7 888 | D 9 889 | R 8 890 | L 6 891 | U 7 892 | R 1 893 | D 7 894 | U 9 895 | R 10 896 | D 10 897 | U 7 898 | D 5 899 | R 9 900 | U 6 901 | L 8 902 | R 4 903 | D 5 904 | R 10 905 | U 7 906 | D 10 907 | R 5 908 | L 9 909 | R 3 910 | U 9 911 | R 9 912 | D 4 913 | L 2 914 | R 4 915 | D 1 916 | L 6 917 | R 9 918 | L 1 919 | D 2 920 | R 8 921 | D 1 922 | R 10 923 | D 4 924 | L 2 925 | D 5 926 | L 3 927 | U 5 928 | L 8 929 | R 2 930 | L 6 931 | U 5 932 | D 3 933 | L 2 934 | R 2 935 | L 9 936 | R 1 937 | L 9 938 | U 10 939 | D 7 940 | U 6 941 | R 3 942 | L 9 943 | U 7 944 | L 9 945 | U 2 946 | L 3 947 | D 10 948 | U 1 949 | L 9 950 | U 8 951 | D 5 952 | U 5 953 | D 1 954 | L 9 955 | D 3 956 | U 9 957 | L 3 958 | R 3 959 | D 2 960 | R 5 961 | D 7 962 | U 4 963 | R 3 964 | U 1 965 | R 8 966 | U 1 967 | D 2 968 | R 3 969 | D 4 970 | U 5 971 | R 10 972 | U 6 973 | D 1 974 | L 7 975 | D 4 976 | L 6 977 | R 6 978 | U 2 979 | L 3 980 | D 2 981 | L 3 982 | D 7 983 | R 1 984 | D 4 985 | L 9 986 | R 9 987 | D 1 988 | L 9 989 | U 3 990 | R 9 991 | L 6 992 | U 6 993 | D 1 994 | U 10 995 | L 2 996 | D 4 997 | R 8 998 | U 2 999 | R 4 1000 | D 2 1001 | R 4 1002 | L 9 1003 | R 7 1004 | D 10 1005 | R 10 1006 | L 8 1007 | D 11 1008 | U 6 1009 | L 8 1010 | D 7 1011 | U 8 1012 | L 5 1013 | R 9 1014 | L 1 1015 | U 1 1016 | D 6 1017 | R 10 1018 | U 11 1019 | L 9 1020 | U 4 1021 | L 5 1022 | R 6 1023 | D 11 1024 | U 9 1025 | R 4 1026 | D 11 1027 | R 4 1028 | D 3 1029 | L 7 1030 | R 9 1031 | D 1 1032 | R 3 1033 | U 11 1034 | L 5 1035 | D 1 1036 | U 7 1037 | R 8 1038 | U 4 1039 | D 10 1040 | U 4 1041 | R 9 1042 | U 7 1043 | L 6 1044 | U 8 1045 | L 6 1046 | U 2 1047 | R 7 1048 | L 3 1049 | U 5 1050 | D 9 1051 | R 3 1052 | D 6 1053 | U 6 1054 | L 7 1055 | D 11 1056 | U 1 1057 | D 11 1058 | U 9 1059 | R 10 1060 | L 11 1061 | R 4 1062 | D 10 1063 | R 6 1064 | L 4 1065 | D 11 1066 | L 7 1067 | R 2 1068 | L 6 1069 | U 9 1070 | D 2 1071 | R 4 1072 | D 11 1073 | L 4 1074 | D 9 1075 | U 11 1076 | L 7 1077 | R 2 1078 | D 2 1079 | U 6 1080 | L 4 1081 | R 4 1082 | U 10 1083 | L 3 1084 | R 7 1085 | U 10 1086 | L 3 1087 | U 3 1088 | D 6 1089 | U 11 1090 | D 1 1091 | R 6 1092 | U 7 1093 | L 3 1094 | D 6 1095 | L 3 1096 | D 7 1097 | R 8 1098 | U 4 1099 | R 5 1100 | D 8 1101 | L 11 1102 | D 11 1103 | R 8 1104 | D 5 1105 | L 1 1106 | U 4 1107 | D 1 1108 | R 6 1109 | D 9 1110 | L 9 1111 | D 9 1112 | U 6 1113 | D 6 1114 | R 6 1115 | D 6 1116 | U 1 1117 | L 5 1118 | D 10 1119 | U 4 1120 | L 6 1121 | D 3 1122 | L 12 1123 | R 11 1124 | D 7 1125 | R 12 1126 | U 9 1127 | R 8 1128 | D 1 1129 | U 9 1130 | D 2 1131 | L 4 1132 | U 10 1133 | D 7 1134 | L 8 1135 | U 5 1136 | D 7 1137 | R 4 1138 | U 4 1139 | R 11 1140 | U 11 1141 | D 1 1142 | L 5 1143 | R 2 1144 | L 9 1145 | D 11 1146 | L 9 1147 | R 9 1148 | U 1 1149 | R 4 1150 | U 4 1151 | L 10 1152 | R 1 1153 | D 8 1154 | U 1 1155 | D 2 1156 | U 6 1157 | D 1 1158 | R 6 1159 | L 10 1160 | U 5 1161 | D 11 1162 | U 11 1163 | L 9 1164 | D 1 1165 | R 5 1166 | D 3 1167 | L 2 1168 | R 8 1169 | U 8 1170 | R 5 1171 | L 2 1172 | U 12 1173 | L 9 1174 | R 9 1175 | D 1 1176 | U 3 1177 | D 4 1178 | R 1 1179 | D 11 1180 | L 4 1181 | U 7 1182 | D 11 1183 | U 6 1184 | L 2 1185 | R 3 1186 | U 8 1187 | L 9 1188 | D 9 1189 | L 12 1190 | R 1 1191 | L 3 1192 | R 2 1193 | L 3 1194 | D 5 1195 | R 9 1196 | U 9 1197 | R 8 1198 | D 10 1199 | U 9 1200 | R 6 1201 | L 9 1202 | D 8 1203 | U 11 1204 | R 3 1205 | L 7 1206 | D 10 1207 | R 9 1208 | D 7 1209 | R 11 1210 | D 5 1211 | U 2 1212 | L 10 1213 | R 1 1214 | U 10 1215 | D 5 1216 | R 5 1217 | L 4 1218 | R 9 1219 | D 4 1220 | R 3 1221 | L 9 1222 | D 9 1223 | L 5 1224 | R 4 1225 | L 12 1226 | R 7 1227 | U 13 1228 | D 6 1229 | U 9 1230 | D 13 1231 | U 5 1232 | R 11 1233 | D 6 1234 | R 13 1235 | U 2 1236 | R 10 1237 | D 2 1238 | L 11 1239 | R 9 1240 | D 12 1241 | L 4 1242 | D 11 1243 | L 1 1244 | D 5 1245 | L 3 1246 | D 5 1247 | U 11 1248 | R 8 1249 | L 2 1250 | D 13 1251 | L 1 1252 | R 6 1253 | D 4 1254 | U 8 1255 | D 8 1256 | R 5 1257 | D 1 1258 | U 7 1259 | R 13 1260 | U 13 1261 | D 2 1262 | L 4 1263 | U 1 1264 | R 5 1265 | L 13 1266 | U 2 1267 | L 7 1268 | D 12 1269 | U 10 1270 | D 13 1271 | L 8 1272 | R 5 1273 | L 13 1274 | U 5 1275 | D 6 1276 | L 11 1277 | D 10 1278 | R 1 1279 | U 7 1280 | R 6 1281 | D 12 1282 | L 6 1283 | D 2 1284 | U 9 1285 | D 10 1286 | L 7 1287 | D 2 1288 | U 3 1289 | R 3 1290 | L 9 1291 | D 1 1292 | R 5 1293 | U 10 1294 | L 3 1295 | R 3 1296 | U 4 1297 | L 13 1298 | R 4 1299 | D 13 1300 | R 8 1301 | L 10 1302 | U 7 1303 | R 9 1304 | L 4 1305 | U 5 1306 | R 4 1307 | D 2 1308 | L 12 1309 | R 11 1310 | L 10 1311 | U 13 1312 | L 2 1313 | U 11 1314 | L 11 1315 | R 6 1316 | D 4 1317 | L 7 1318 | R 11 1319 | L 12 1320 | D 13 1321 | U 4 1322 | L 11 1323 | R 7 1324 | D 12 1325 | L 7 1326 | R 7 1327 | D 10 1328 | U 11 1329 | L 12 1330 | U 5 1331 | R 8 1332 | U 7 1333 | L 9 1334 | R 2 1335 | U 7 1336 | L 12 1337 | D 6 1338 | U 4 1339 | R 12 1340 | D 2 1341 | R 8 1342 | U 14 1343 | L 2 1344 | R 1 1345 | U 2 1346 | R 8 1347 | U 4 1348 | D 14 1349 | U 13 1350 | R 7 1351 | D 5 1352 | R 6 1353 | U 9 1354 | L 12 1355 | U 11 1356 | L 7 1357 | R 1 1358 | U 2 1359 | D 8 1360 | R 4 1361 | D 2 1362 | R 11 1363 | L 8 1364 | R 6 1365 | D 10 1366 | L 3 1367 | R 12 1368 | D 6 1369 | R 10 1370 | L 4 1371 | D 14 1372 | U 9 1373 | L 3 1374 | D 3 1375 | L 12 1376 | D 14 1377 | R 14 1378 | D 12 1379 | U 4 1380 | L 10 1381 | R 13 1382 | U 4 1383 | D 9 1384 | L 11 1385 | R 1 1386 | U 13 1387 | D 5 1388 | U 2 1389 | D 6 1390 | U 8 1391 | R 12 1392 | U 3 1393 | D 4 1394 | L 8 1395 | D 7 1396 | R 9 1397 | L 6 1398 | D 13 1399 | L 10 1400 | D 4 1401 | R 13 1402 | D 14 1403 | U 5 1404 | D 7 1405 | U 14 1406 | L 14 1407 | R 7 1408 | L 2 1409 | D 6 1410 | R 9 1411 | U 14 1412 | L 10 1413 | D 14 1414 | L 10 1415 | D 8 1416 | R 5 1417 | L 3 1418 | U 3 1419 | D 9 1420 | R 1 1421 | L 8 1422 | R 9 1423 | D 9 1424 | R 12 1425 | U 10 1426 | R 14 1427 | L 9 1428 | U 9 1429 | R 14 1430 | L 14 1431 | R 6 1432 | D 5 1433 | R 6 1434 | U 11 1435 | D 8 1436 | U 8 1437 | D 5 1438 | L 7 1439 | D 2 1440 | U 14 1441 | R 1 1442 | L 9 1443 | R 6 1444 | U 13 1445 | R 15 1446 | U 15 1447 | D 8 1448 | U 7 1449 | D 3 1450 | L 10 1451 | U 11 1452 | D 9 1453 | R 14 1454 | D 1 1455 | L 2 1456 | U 3 1457 | R 7 1458 | L 4 1459 | D 2 1460 | L 12 1461 | D 11 1462 | L 6 1463 | U 9 1464 | D 9 1465 | L 3 1466 | R 1 1467 | D 12 1468 | L 8 1469 | U 4 1470 | L 2 1471 | U 9 1472 | R 12 1473 | L 14 1474 | U 6 1475 | D 4 1476 | U 10 1477 | R 4 1478 | U 7 1479 | D 4 1480 | R 10 1481 | U 11 1482 | R 11 1483 | L 4 1484 | U 3 1485 | D 2 1486 | L 9 1487 | D 1 1488 | L 15 1489 | R 2 1490 | D 3 1491 | R 5 1492 | U 6 1493 | D 12 1494 | R 2 1495 | U 6 1496 | D 6 1497 | L 9 1498 | U 8 1499 | R 10 1500 | U 10 1501 | R 3 1502 | U 1 1503 | R 14 1504 | U 2 1505 | L 13 1506 | D 10 1507 | U 2 1508 | D 6 1509 | U 5 1510 | L 15 1511 | R 4 1512 | U 6 1513 | R 9 1514 | U 10 1515 | L 9 1516 | R 13 1517 | L 9 1518 | R 13 1519 | D 8 1520 | U 15 1521 | L 11 1522 | R 2 1523 | U 2 1524 | D 15 1525 | R 14 1526 | D 2 1527 | L 15 1528 | D 14 1529 | R 4 1530 | D 13 1531 | R 9 1532 | L 5 1533 | D 1 1534 | U 4 1535 | D 13 1536 | L 9 1537 | D 14 1538 | U 2 1539 | D 8 1540 | L 13 1541 | U 2 1542 | D 10 1543 | U 5 1544 | L 3 1545 | R 2 1546 | L 1 1547 | U 5 1548 | L 3 1549 | D 7 1550 | U 3 1551 | D 7 1552 | R 2 1553 | L 1 1554 | D 5 1555 | U 8 1556 | D 11 1557 | L 10 1558 | U 12 1559 | D 9 1560 | U 5 1561 | D 9 1562 | U 15 1563 | R 9 1564 | D 13 1565 | R 2 1566 | D 5 1567 | U 4 1568 | L 8 1569 | R 2 1570 | U 1 1571 | R 6 1572 | U 6 1573 | D 9 1574 | U 8 1575 | L 8 1576 | D 7 1577 | U 14 1578 | D 3 1579 | R 8 1580 | D 3 1581 | U 10 1582 | D 2 1583 | R 15 1584 | U 8 1585 | L 8 1586 | D 10 1587 | L 7 1588 | D 7 1589 | L 2 1590 | U 7 1591 | D 13 1592 | L 11 1593 | D 16 1594 | L 15 1595 | U 16 1596 | L 12 1597 | U 14 1598 | R 4 1599 | U 1 1600 | R 10 1601 | U 5 1602 | L 2 1603 | U 6 1604 | L 9 1605 | R 8 1606 | L 16 1607 | D 11 1608 | R 1 1609 | L 7 1610 | D 10 1611 | U 9 1612 | R 3 1613 | D 13 1614 | R 15 1615 | L 9 1616 | D 13 1617 | R 11 1618 | L 1 1619 | D 16 1620 | L 2 1621 | R 9 1622 | L 4 1623 | R 14 1624 | L 1 1625 | D 14 1626 | R 5 1627 | L 1 1628 | D 11 1629 | U 8 1630 | D 12 1631 | R 13 1632 | U 8 1633 | L 4 1634 | U 11 1635 | R 7 1636 | D 4 1637 | R 15 1638 | U 6 1639 | L 2 1640 | D 11 1641 | L 13 1642 | R 16 1643 | U 13 1644 | D 16 1645 | U 4 1646 | R 10 1647 | D 2 1648 | R 8 1649 | D 3 1650 | R 15 1651 | U 9 1652 | L 1 1653 | U 10 1654 | L 13 1655 | D 5 1656 | L 1 1657 | D 14 1658 | U 6 1659 | L 14 1660 | D 8 1661 | U 10 1662 | R 5 1663 | L 8 1664 | U 9 1665 | D 2 1666 | R 6 1667 | U 17 1668 | L 6 1669 | U 9 1670 | L 4 1671 | R 14 1672 | D 1 1673 | L 7 1674 | U 1 1675 | R 11 1676 | D 3 1677 | R 8 1678 | D 5 1679 | R 11 1680 | U 3 1681 | L 12 1682 | U 5 1683 | R 12 1684 | D 7 1685 | R 12 1686 | L 7 1687 | U 11 1688 | D 17 1689 | L 12 1690 | R 15 1691 | D 16 1692 | R 6 1693 | D 16 1694 | L 3 1695 | U 17 1696 | L 3 1697 | D 4 1698 | L 12 1699 | R 10 1700 | L 3 1701 | D 14 1702 | L 5 1703 | R 2 1704 | U 1 1705 | D 8 1706 | R 4 1707 | D 9 1708 | L 8 1709 | R 15 1710 | L 16 1711 | U 5 1712 | R 3 1713 | U 3 1714 | D 15 1715 | R 2 1716 | D 8 1717 | R 17 1718 | D 11 1719 | U 8 1720 | R 1 1721 | L 7 1722 | D 14 1723 | U 14 1724 | L 9 1725 | R 8 1726 | D 2 1727 | L 14 1728 | D 5 1729 | R 10 1730 | L 12 1731 | U 5 1732 | L 7 1733 | U 11 1734 | L 14 1735 | R 17 1736 | D 14 1737 | R 1 1738 | L 1 1739 | U 15 1740 | D 13 1741 | R 15 1742 | L 17 1743 | D 3 1744 | R 1 1745 | L 2 1746 | R 3 1747 | U 16 1748 | D 8 1749 | U 9 1750 | R 8 1751 | L 7 1752 | R 11 1753 | U 9 1754 | D 6 1755 | U 11 1756 | D 4 1757 | U 11 1758 | D 16 1759 | R 6 1760 | D 15 1761 | U 11 1762 | L 3 1763 | U 12 1764 | D 10 1765 | U 14 1766 | R 4 1767 | D 9 1768 | R 6 1769 | U 2 1770 | R 10 1771 | L 1 1772 | R 3 1773 | D 5 1774 | L 5 1775 | D 17 1776 | U 11 1777 | L 17 1778 | R 4 1779 | U 3 1780 | L 15 1781 | R 3 1782 | L 3 1783 | R 16 1784 | L 12 1785 | R 6 1786 | L 2 1787 | D 5 1788 | L 17 1789 | U 17 1790 | R 1 1791 | D 6 1792 | L 9 1793 | D 6 1794 | R 15 1795 | D 9 1796 | R 4 1797 | L 6 1798 | U 15 1799 | L 16 1800 | R 10 1801 | D 11 1802 | U 8 1803 | D 7 1804 | U 1 1805 | R 7 1806 | L 16 1807 | U 5 1808 | D 14 1809 | R 16 1810 | D 6 1811 | R 2 1812 | L 2 1813 | R 3 1814 | L 8 1815 | D 4 1816 | U 11 1817 | R 9 1818 | U 5 1819 | D 11 1820 | U 3 1821 | R 9 1822 | L 5 1823 | D 14 1824 | U 1 1825 | D 11 1826 | L 6 1827 | U 16 1828 | L 17 1829 | U 7 1830 | L 13 1831 | R 13 1832 | U 11 1833 | L 10 1834 | D 2 1835 | R 7 1836 | D 16 1837 | R 9 1838 | U 17 1839 | L 13 1840 | U 17 1841 | L 4 1842 | D 7 1843 | U 16 1844 | D 8 1845 | L 7 1846 | R 16 1847 | L 11 1848 | D 9 1849 | R 18 1850 | U 1 1851 | D 12 1852 | R 16 1853 | L 8 1854 | D 7 1855 | U 10 1856 | L 9 1857 | U 6 1858 | R 5 1859 | D 5 1860 | R 8 1861 | D 7 1862 | L 9 1863 | R 8 1864 | L 11 1865 | R 3 1866 | D 6 1867 | L 6 1868 | D 18 1869 | U 14 1870 | D 11 1871 | U 13 1872 | R 10 1873 | L 2 1874 | R 6 1875 | L 13 1876 | R 1 1877 | U 6 1878 | R 8 1879 | D 10 1880 | L 8 1881 | R 15 1882 | U 4 1883 | L 7 1884 | R 17 1885 | L 8 1886 | R 3 1887 | D 6 1888 | L 13 1889 | R 10 1890 | D 1 1891 | R 5 1892 | D 11 1893 | U 10 1894 | D 4 1895 | L 5 1896 | R 13 1897 | D 2 1898 | L 14 1899 | D 8 1900 | U 5 1901 | R 10 1902 | L 17 1903 | D 2 1904 | U 4 1905 | R 1 1906 | L 10 1907 | R 2 1908 | L 9 1909 | D 2 1910 | L 4 1911 | R 4 1912 | U 9 1913 | L 7 1914 | U 3 1915 | D 1 1916 | L 9 1917 | U 1 1918 | D 18 1919 | U 14 1920 | L 7 1921 | R 3 1922 | D 12 1923 | L 19 1924 | R 13 1925 | D 16 1926 | U 18 1927 | D 16 1928 | R 2 1929 | D 11 1930 | U 16 1931 | R 1 1932 | D 17 1933 | U 8 1934 | D 1 1935 | U 17 1936 | L 4 1937 | D 16 1938 | L 8 1939 | U 3 1940 | R 13 1941 | U 1 1942 | D 1 1943 | U 1 1944 | R 17 1945 | U 14 1946 | R 17 1947 | D 16 1948 | U 8 1949 | L 6 1950 | D 9 1951 | R 1 1952 | D 9 1953 | L 2 1954 | D 14 1955 | R 1 1956 | L 9 1957 | U 5 1958 | D 1 1959 | R 15 1960 | L 14 1961 | U 4 1962 | R 15 1963 | U 9 1964 | D 10 1965 | L 5 1966 | R 1 1967 | L 14 1968 | U 7 1969 | R 8 1970 | L 8 1971 | R 14 1972 | L 7 1973 | D 14 1974 | L 17 1975 | R 2 1976 | U 13 1977 | R 13 1978 | L 3 1979 | R 18 1980 | L 6 1981 | D 9 1982 | U 5 1983 | R 14 1984 | U 11 1985 | D 13 1986 | L 15 1987 | D 1 1988 | U 10 1989 | R 13 1990 | D 6 1991 | U 15 1992 | D 15 1993 | R 5 1994 | U 15 1995 | D 2 1996 | U 2 1997 | D 10 1998 | L 19 1999 | R 8 2000 | D 3 2001 | -------------------------------------------------------------------------------- /txt2fut.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | 3 | import sys 4 | import struct 5 | 6 | v = sys.stdin.buffer.read() 7 | sys.stdout.buffer.write(b'b') 8 | sys.stdout.buffer.write(b'\2') 9 | sys.stdout.buffer.write(b'\1') 10 | sys.stdout.buffer.write(b' u8') 11 | sys.stdout.buffer.write(struct.pack('= '0' && c <= '9' 10 | 11 | def isnt_digit = not <-< is_digit 12 | 13 | def atoi [n] (s: string[n]): i32 = 14 | let (sign,s) = if n > 0 && s[0] == '-' then (-1,drop 1 s) else (1,s) 15 | in sign * (loop (acc,i) = (0,0) while i < length s do 16 | if is_digit s[i] 17 | then (acc * 10 + dtoi s[i], i+1) 18 | else (acc, n)).0 19 | 20 | def f &&& g = \x -> (f x, g x) 21 | 22 | module words : { 23 | type word [p] 24 | val words [n] : [n]char -> ?[p].(word [p] -> ?[m].[m]char, ?[k].[k](word [p])) 25 | } = { 26 | def is_space (x: char) = x == ' ' 27 | def isnt_space x = !(is_space x) 28 | 29 | type word [p] = ([p](), i64, i64) 30 | 31 | def words [n] (s: [n]char) = 32 | (\(_, i, k) -> #[unsafe] s[i:i+k], 33 | segmented_scan (+) 0 (map is_space s) (map (isnt_space >-> i64.bool) s) 34 | |> (id &&& rotate 1) 35 | |> uncurry zip 36 | |> zip (indices s) 37 | |> filter (\(_,(x,y)) -> x > y) 38 | |> map (\(i,(x,_)) -> ([],i-x+1,x))) 39 | } 40 | 41 | module splits : { 42 | type split [p] 43 | val splits [n] 'a : (a -> bool) -> [n]a -> ?[p].(split [p] -> ?[m].[m]a, ?[k].[k](split [p])) 44 | } = { 45 | type split [p] = ([p](), i64, i64) 46 | 47 | def splits [n] 'a (p: a -> bool) (s: [n]a) = 48 | (\(_, i, k) -> #[unsafe] s[i:i+k], 49 | s 50 | |> rotate (-1) 51 | |> map2 (\i x -> (i,i == 0 || p x)) (indices s) 52 | |> filter (.1) 53 | |> map (.0) 54 | |> (id &&& rotate 1) 55 | |> uncurry zip 56 | |> map (\(i, j) -> ([],i, if j < i -- Last element is special. 57 | then if p (last s) then n-i-1 else n-i 58 | else j-i-1))) 59 | } 60 | 61 | module lines : { 62 | type line [p] 63 | val lines [n] : [n]char -> ?[p].(line [p] -> ?[m].[m]char, ?[k].[k](line [p])) 64 | } = { 65 | def is_word (x: char) = x == '\n' 66 | def isnt_word x = !(is_word x) 67 | 68 | type line [p] = ([p](), i64, i64) 69 | 70 | -- Assumes last line is terminated by newline. 71 | def lines [n] (s: [n]char) = 72 | (\(_, i, k) -> #[unsafe] s[i:i+k], 73 | map (\prev -> prev == '\n') (rotate (-1) s) 74 | |> zip (indices s) 75 | |> filter (.1) 76 | |> map (.0) 77 | |> (id &&& rotate 1) 78 | |> uncurry zip 79 | |> map (\(i, j) -> ([],i, if j < i then n-i-1 else j-i-1))) 80 | } 81 | 82 | def count 'a (p: a -> bool) (xs: []a): i32 = 83 | xs |> map p |> map i32.bool |> i32.sum 84 | 85 | def index_of_first p xs = 86 | loop i = 0 while i < length xs && !p xs[i] do i + 1 87 | 88 | def span p xs = let i = index_of_first p xs in (take i xs, drop i xs) 89 | 90 | def windows k s = 91 | map (\i -> take k (drop i s)) (take (length s - k) (indices s)) 92 | 93 | def exscan 'a [n] (op: a -> a -> a) (ne: a) (as: [n]a) : *[n]a = 94 | scan op ne (map2 (\i a -> if i == 0 then ne else a) (indices as) (rotate (-1) as)) 95 | 96 | -- Finds smallest element greater than x. 97 | def binsearch [n] 't (lte: t -> t -> bool) (xs: [n]t) (x: t) : i64 = 98 | let (_, end) = 99 | loop (start,end) = (0,n-1) while start <= end do 100 | let mid = (start+end)/2 101 | in if xs[mid] `lte` x 102 | then (mid+1,end) 103 | else (start,mid-1) 104 | in end 105 | 106 | def exactly [n] 't (m: i64) (arr: [n]t) : [m]t = arr :> [m]t 107 | 108 | def matches [n][m] 'a 'b (_: [m]b) (as: [n]a) : [m]a = as :> [m]a 109 | 110 | type opt 'a = #some a | #none 111 | 112 | def from_opt 'a x (y: opt a) = 113 | match y case #some y' -> y' 114 | case #none -> x 115 | 116 | def find 'a (p: a->bool) (xs:[]a) : opt a = 117 | let op a b = 118 | match (a,b) 119 | case (#none, b) -> b 120 | case (a, #none) -> a 121 | case _ -> a 122 | in xs 123 | |> map (\x -> if p x then #some x else #none) 124 | |> reduce op #none 125 | 126 | def pad_to k x xs = sized k (xs ++ replicate (k - length xs) x) 127 | 128 | def argmin 'a (lte: a -> a -> bool) (as: []a) : i64 = 129 | let cmp i j = match (i,j) 130 | case (-1, _) -> j 131 | case (_, -1) -> i 132 | case _ -> if as[i] `lte` as[j] then i else j 133 | in reduce cmp (-1) (indices as) 134 | 135 | def dedup eq lte ps = 136 | let ps = merge_sort lte ps 137 | let ok i x y = (i == 0 || not (eq x y),x) 138 | in map3 ok (indices ps) ps (rotate 1 ps) 139 | |> filter (.0) 140 | |> map (.1) 141 | 142 | def imap f xs = map2 f (indices xs) xs 143 | 144 | def indices_2d [n][m] 't (_: [n][m]t) = tabulate_2d n m (\i j -> (i,j)) 145 | 146 | def hist_2d 'a [k] (op: a -> a -> a) (ne: a) (n: i64) (m: i64) (is: [k](i64,i64)) (as: [k]a) : *[n][m]a = 147 | reduce_by_index_2d (replicate n (replicate m ne)) op ne is as 148 | 149 | --------------------------------------------------------------------------------