diff options
author | Botond Hende <nettingman@gmail.com> | 2024-12-03 21:21:47 +0100 |
---|---|---|
committer | Botond Hende <nettingman@gmail.com> | 2024-12-03 21:21:47 +0100 |
commit | 755d3322abe7d94ae87e5624bb1aed85bfb30bc3 (patch) | |
tree | ea8a7afe1071167a17e3d63f574dad662abcedf1 /2024 | |
parent | 873d769509c56ddbe84616d9411efc51ef0b4fd3 (diff) |
2024 day2-3, 2023 day3 2nd
Diffstat (limited to '2024')
-rw-r--r-- | 2024/day2/input | 1000 | ||||
-rw-r--r-- | 2024/day2/input_test | 6 | ||||
-rw-r--r-- | 2024/day2/solve.py | 31 | ||||
-rw-r--r-- | 2024/day2/solve2.py | 42 | ||||
-rw-r--r-- | 2024/day3/input | 6 | ||||
-rw-r--r-- | 2024/day3/input_test | 1 | ||||
-rw-r--r-- | 2024/day3/input_test2 | 1 | ||||
-rw-r--r-- | 2024/day3/solve.py | 12 | ||||
-rw-r--r-- | 2024/day3/solve2.py | 38 |
9 files changed, 1137 insertions, 0 deletions
diff --git a/2024/day2/input b/2024/day2/input new file mode 100644 index 0000000..0501d5f --- /dev/null +++ b/2024/day2/input @@ -0,0 +1,1000 @@ +24 25 28 31 28
+41 44 45 48 49 50 50
+5 8 10 13 15 16 17 21
+11 13 16 17 19 26
+79 81 78 79 82 84
+16 19 20 18 20 22 25 22
+84 87 90 92 94 97 96 96
+86 87 88 91 88 91 95
+40 43 41 44 49
+8 10 10 11 13
+91 94 95 95 92
+18 19 20 20 21 23 25 25
+15 17 19 19 23
+35 37 37 39 40 43 50
+2 5 6 10 12
+82 85 87 88 91 93 97 94
+30 32 35 38 42 43 43
+64 66 68 72 76
+73 74 77 80 84 86 91
+64 67 72 73 74 76
+72 73 75 81 82 81
+24 25 32 35 37 38 38
+59 60 62 64 65 70 74
+44 46 47 48 50 52 58 63
+54 52 53 56 57 58
+77 76 77 80 82 81
+48 45 48 49 52 54 54
+74 71 74 76 78 81 85
+20 18 19 21 27
+88 86 88 91 92 89 92
+17 16 14 17 18 15
+95 92 91 93 95 96 96
+7 5 6 9 8 11 14 18
+15 12 9 12 14 16 21
+3 2 2 5 6
+58 55 55 57 58 57
+36 35 36 36 36
+73 72 72 75 79
+80 77 78 78 79 82 87
+20 19 23 25 27 28 31 32
+92 90 91 95 97 96
+86 84 86 90 93 96 98 98
+36 33 34 38 41 45
+82 81 85 88 89 92 99
+70 69 71 77 78 81
+51 49 50 57 60 58
+28 27 30 33 35 40 40
+40 37 38 45 49
+53 52 54 55 56 61 67
+27 27 29 31 34
+82 82 84 86 89 92 89
+91 91 93 96 96
+55 55 58 60 64
+80 80 81 82 83 85 88 95
+84 84 87 84 85
+81 81 80 82 79
+25 25 22 24 24
+71 71 74 76 77 74 78
+86 86 87 86 87 88 93
+41 41 43 43 46
+70 70 70 72 71
+12 12 13 13 14 15 15
+23 23 23 26 28 31 35
+84 84 86 88 88 89 91 98
+4 4 5 7 8 9 13 14
+31 31 35 36 37 36
+19 19 23 26 26
+80 80 84 85 88 90 94
+51 51 53 54 58 60 61 66
+35 35 36 42 43
+9 9 12 15 18 24 21
+2 2 8 11 14 15 15
+25 25 30 33 36 38 39 43
+13 13 18 19 26
+10 14 15 17 19
+35 39 40 43 45 46 48 45
+41 45 47 50 50
+16 20 23 25 28 31 34 38
+10 14 15 18 20 25
+42 46 49 46 48
+25 29 32 31 34 31
+7 11 14 11 14 14
+90 94 92 94 98
+27 31 34 32 35 37 44
+50 54 54 56 59 61 63
+48 52 52 53 50
+84 88 89 90 91 91 91
+48 52 54 54 56 60
+85 89 89 91 98
+9 13 15 17 21 23
+43 47 49 52 53 57 55
+76 80 82 83 86 90 93 93
+5 9 11 15 16 20
+53 57 61 62 65 66 73
+65 69 70 73 76 81 82 83
+15 19 21 27 24
+51 55 57 63 65 65
+15 19 22 25 27 33 37
+1 5 6 7 9 11 16 22
+50 56 58 60 63 65 68 70
+36 42 43 44 41
+36 42 44 47 50 52 54 54
+79 84 87 88 90 92 94 98
+35 42 45 46 47 49 52 58
+74 80 83 80 81 82 84 85
+60 67 69 72 73 71 72 71
+85 92 94 97 96 98 98
+17 22 25 27 25 28 32
+22 28 26 28 31 33 40
+51 57 60 61 61 62 63
+7 13 16 16 19 18
+80 87 87 89 89
+70 76 79 81 84 84 88
+39 45 46 49 49 51 52 58
+38 43 45 48 52 55 57 58
+79 84 86 89 93 94 92
+39 45 48 52 52
+58 63 67 69 70 74
+76 83 86 90 97
+13 18 25 27 29 31
+60 66 69 72 75 80 82 81
+21 26 29 31 33 38 38
+31 37 42 45 46 50
+15 21 23 24 30 32 38
+51 48 45 43 44
+45 43 41 40 38 37 36 36
+66 64 61 60 57 53
+89 86 83 81 76
+36 33 30 33 30 29 28 27
+91 88 91 89 86 85 83 85
+12 10 12 11 11
+31 30 27 30 28 27 23
+35 32 31 34 32 26
+11 10 10 9 6 5 4 3
+44 41 38 38 37 35 34 36
+80 78 76 73 72 71 71 71
+45 43 40 37 37 33
+97 94 91 88 87 86 86 80
+58 56 53 51 47 44
+66 63 62 60 58 56 52 53
+73 72 71 68 65 61 61
+95 92 88 86 82
+19 17 16 12 11 10 5
+80 77 74 71 66 64 62 61
+64 62 59 56 51 52
+47 46 43 42 39 38 33 33
+45 44 41 39 34 30
+95 92 89 87 82 81 80 74
+94 96 94 91 88
+89 91 90 88 89
+40 41 38 36 36
+70 72 70 68 67 63
+22 25 24 21 19 18 13
+41 42 39 40 38 37
+35 36 35 32 31 29 32 35
+31 34 31 34 34
+88 90 89 91 90 88 85 81
+54 57 60 59 56 50
+83 85 82 82 80
+66 68 68 65 62 61 62
+35 36 36 34 32 30 30
+79 80 80 78 76 74 70
+44 45 45 43 37
+37 40 37 33 31
+63 65 63 59 56 55 54 56
+19 22 21 17 15 13 11 11
+94 95 91 90 88 84
+22 23 19 18 16 14 7
+29 32 30 23 22
+64 67 64 58 56 57
+29 30 27 24 18 18
+33 36 34 27 24 22 20 16
+50 52 49 48 46 39 37 31
+31 31 28 25 22 21 19 16
+47 47 44 43 40 37 38
+88 88 85 84 84
+41 41 38 36 32
+73 73 70 69 67 66 60
+80 80 81 80 79 77 76 75
+36 36 34 32 34 35
+59 59 57 60 59 58 56 56
+30 30 27 28 25 23 19
+9 9 7 6 5 8 3
+89 89 87 86 85 85 82
+52 52 49 46 46 47
+60 60 59 59 59
+21 21 19 19 15
+17 17 17 16 13 12 10 4
+33 33 29 28 26 25
+67 67 63 61 58 60
+27 27 25 24 20 20
+78 78 76 74 72 68 64
+62 62 59 55 49
+47 47 44 38 36 33 31
+31 31 28 21 23
+81 81 80 79 78 72 72
+75 75 69 66 62
+97 97 91 89 87 85 78
+35 31 28 27 26 25
+35 31 28 27 25 22 21 23
+37 33 32 31 28 28
+73 69 67 65 62 59 55
+67 63 60 58 53
+52 48 47 44 47 46 43
+73 69 70 68 69
+18 14 13 16 16
+91 87 84 81 82 79 77 73
+96 92 90 92 91 88 81
+40 36 35 35 34 33 31
+93 89 86 83 82 82 80 81
+86 82 79 79 78 77 77
+20 16 13 13 12 8
+30 26 23 23 21 19 17 10
+76 72 69 66 62 60 57 54
+57 53 49 46 48
+64 60 58 54 54
+20 16 15 12 8 5 1
+40 36 34 31 27 25 19
+25 21 20 18 16 14 9 6
+48 44 43 40 38 36 29 31
+96 92 90 89 83 81 80 80
+45 41 34 32 28
+35 31 28 27 21 19 14
+35 30 27 26 23
+73 66 63 61 64
+60 55 53 51 50 50
+68 62 61 60 56
+55 50 49 46 43 42 37
+29 23 22 25 22 20 18 16
+96 90 88 85 84 86 83 85
+47 41 39 36 37 37
+72 66 69 68 66 62
+52 47 49 46 43 36
+77 71 68 68 67 66
+99 94 94 93 96
+45 38 35 33 31 31 31
+23 16 13 10 10 6
+33 26 25 25 23 20 18 11
+44 37 33 30 28 27
+90 85 81 79 80
+91 85 82 79 77 73 70 70
+98 91 88 86 82 78
+68 63 61 58 54 52 45
+64 58 57 50 49
+66 59 56 49 52
+89 82 77 76 73 70 70
+80 73 72 67 63
+73 66 60 59 57 50
+11 14 15 17 20 23 21
+47 50 52 55 56 56
+16 17 18 19 20 23 27
+82 83 85 88 90 91 94 99
+59 61 59 61 64 67 70 73
+32 33 36 37 38 36 39 38
+86 89 90 91 89 92 94 94
+67 68 71 68 71 73 76 80
+28 30 31 33 34 32 39
+3 4 6 6 7 10 12 13
+61 64 64 66 69 71 68
+49 50 52 52 53 55 55
+8 11 14 16 16 20
+59 62 62 63 70
+43 45 49 52 55 57
+80 82 86 88 89 92 93 91
+81 82 86 87 88 91 94 94
+38 41 45 48 51 53 57
+35 38 40 41 45 47 54
+6 9 12 14 15 17 22 23
+81 82 83 85 91 90
+74 76 83 84 87 87
+24 27 28 35 37 41
+69 71 72 77 80 85
+12 9 12 13 15 17 20 23
+77 75 76 77 78 81 78
+60 57 59 61 61
+13 10 11 14 16 20
+81 80 81 84 85 90
+6 5 6 7 5 7 10 13
+54 51 54 52 54 55 54
+72 71 70 73 73
+89 86 88 90 91 88 90 94
+8 6 3 5 10
+10 7 8 10 12 12 15 16
+14 11 12 14 16 16 19 18
+39 37 38 38 39 42 44 44
+13 11 12 13 15 15 16 20
+10 8 8 11 14 20
+42 40 42 45 49 50
+67 66 70 73 76 78 77
+32 30 34 35 37 37
+47 44 45 49 51 55
+36 35 39 40 43 45 47 53
+68 66 67 68 73 74
+40 37 38 39 40 46 47 45
+28 26 27 30 35 35
+45 42 48 50 54
+44 43 45 48 54 59
+61 61 62 63 64 66 67
+57 57 58 61 59
+66 66 69 71 73 75 78 78
+59 59 61 64 67 71
+28 28 29 30 31 33 36 41
+41 41 42 41 44 45
+11 11 10 13 15 12
+37 37 40 38 41 41
+41 41 40 42 46
+68 68 69 72 69 71 78
+95 95 95 97 98 99
+9 9 9 10 13 14 17 16
+81 81 82 85 88 88 88
+86 86 86 89 92 96
+58 58 59 62 62 67
+80 80 81 85 87
+84 84 87 91 88
+3 3 7 10 11 12 12
+74 74 75 79 81 82 85 89
+26 26 28 29 31 35 37 44
+38 38 39 46 49
+77 77 80 81 87 88 85
+75 75 78 81 87 90 92 92
+28 28 31 37 40 43 47
+11 11 12 18 20 27
+15 19 21 22 23 26
+58 62 64 65 66 69 71 69
+56 60 61 63 63
+46 50 53 56 58 62
+67 71 73 76 81
+52 56 58 56 58 60
+6 10 11 8 7
+81 85 86 89 87 88 88
+72 76 79 76 79 82 86
+39 43 44 46 43 49
+38 42 45 45 46
+41 45 48 51 51 48
+79 83 86 86 86
+24 28 29 31 33 33 34 38
+55 59 59 61 62 65 67 74
+73 77 80 82 86 87 90
+45 49 50 53 57 54
+80 84 88 90 92 92
+14 18 20 22 24 28 32
+61 65 69 70 73 76 82
+50 54 57 59 62 63 69 70
+75 79 81 82 83 89 92 89
+45 49 52 59 61 63 63
+38 42 44 45 48 55 57 61
+62 66 69 71 74 80 86
+28 35 37 40 41 43
+25 30 32 33 34 37 35
+14 19 20 21 22 22
+8 14 17 20 23 27
+23 28 29 31 38
+68 74 77 78 76 79 80
+14 21 18 20 22 23 25 22
+18 23 20 22 22
+65 72 71 74 76 80
+8 14 15 17 14 17 20 25
+59 65 68 70 70 73
+59 65 68 68 71 74 71
+34 41 43 43 43
+20 25 25 28 32
+43 48 50 50 53 56 58 64
+38 45 49 52 55 58
+23 30 34 35 33
+4 9 11 14 18 20 21 21
+51 57 61 63 67
+67 74 78 81 82 88
+20 26 29 36 37
+9 14 15 18 20 26 29 28
+73 79 82 87 90 90
+9 16 18 24 28
+8 14 19 22 29
+80 77 75 73 76
+93 90 88 85 84 81 78 78
+25 22 20 18 15 12 11 7
+51 48 47 44 42 40 37 31
+77 74 77 75 73 72
+94 91 92 90 88 89
+28 27 26 24 21 22 20 20
+94 91 88 87 86 89 85
+91 90 87 85 82 80 81 74
+59 56 56 54 52 50
+89 88 88 87 84 82 85
+96 95 93 90 89 86 86 86
+25 22 22 19 15
+39 36 34 34 33 31 24
+53 52 49 47 43 40
+93 92 88 85 87
+82 80 76 75 72 69 66 66
+57 55 52 49 47 43 39
+43 40 36 33 26
+33 30 28 21 18
+72 70 67 66 59 61
+26 23 22 19 14 12 10 10
+25 22 20 18 13 10 9 5
+33 30 27 21 19 16 13 6
+96 98 97 95 93 90 89
+47 48 46 45 47
+10 12 9 8 7 5 3 3
+48 49 48 47 43
+25 28 26 25 22 15
+2 4 1 4 3
+59 62 65 64 65
+24 25 22 19 20 17 17
+53 54 52 54 51 48 46 42
+21 23 21 18 19 18 12
+48 49 46 46 43 41 40
+58 61 59 57 57 59
+84 85 83 80 79 78 78 78
+20 22 22 19 17 15 11
+87 89 87 86 86 81
+97 99 95 94 91
+15 18 16 15 11 13
+54 55 53 49 49
+28 30 26 25 23 21 17
+34 37 34 32 28 21
+33 36 33 31 28 21 18 15
+66 69 68 63 61 58 55 58
+93 94 93 87 85 85
+17 18 13 12 8
+81 83 80 78 71 68 63
+68 68 66 65 63
+65 65 62 61 58 57 60
+28 28 26 23 23
+48 48 46 45 44 43 39
+16 16 13 11 6
+30 30 29 26 29 28
+23 23 20 22 20 17 20
+41 41 43 41 41
+39 39 36 39 36 32
+34 34 36 35 30
+88 88 87 85 85 84
+6 6 4 3 3 5
+41 41 38 38 38
+14 14 11 8 8 7 5 1
+75 75 72 72 70 64
+59 59 55 52 51
+91 91 88 84 81 79 80
+95 95 92 88 85 85
+62 62 60 59 55 51
+17 17 13 11 4
+67 67 66 65 63 58 56
+63 63 56 55 57
+46 46 45 39 39
+42 42 39 38 32 28
+91 91 86 84 78
+30 26 24 22 21 20 19
+58 54 53 50 53
+10 6 5 4 4
+93 89 88 86 85 83 81 77
+52 48 46 43 38
+89 85 84 81 83 82 79
+46 42 41 39 42 44
+48 44 41 44 43 42 39 39
+61 57 56 53 54 51 47
+55 51 54 52 50 43
+23 19 16 16 15 13 11 8
+23 19 17 16 14 14 13 14
+23 19 19 17 14 11 9 9
+24 20 19 16 14 14 10
+94 90 88 85 85 84 77
+47 43 41 39 36 32 30
+54 50 46 45 42 43
+88 84 81 77 77
+29 25 21 20 18 15 12 8
+67 63 59 58 51
+16 12 6 3 1
+68 64 61 59 53 51 50 53
+70 66 60 58 58
+84 80 75 73 70 66
+92 88 86 85 78 77 71
+93 86 83 82 79 77 74 73
+56 50 48 46 48
+25 20 19 16 13 13
+79 74 73 72 70 69 67 63
+77 71 70 67 64 62 56
+80 74 71 68 67 69 68 65
+36 29 27 26 28 31
+88 82 83 82 82
+13 6 5 7 3
+17 11 12 9 6 1
+87 82 81 80 80 78 75
+23 17 14 11 11 12
+70 64 61 58 58 58
+96 91 90 87 87 85 81
+92 85 85 83 80 74
+23 17 13 12 11
+70 63 59 56 55 53 54
+85 80 79 76 73 70 66 66
+81 75 74 73 72 68 64
+69 62 59 55 54 49
+68 62 60 58 52 49
+81 75 74 71 69 64 66
+71 65 58 55 55
+39 32 31 26 24 22 19 15
+53 47 42 40 33
+39 40 43 44 46 48 55 61
+41 37 35 31 29 25
+33 28 26 23 23 24
+53 49 48 45 43 39
+45 45 46 47 49 49 50 57
+55 52 51 50 47 46 46 42
+43 40 39 33 27
+31 37 42 44 46 46
+38 36 34 33 30 29 27 30
+25 31 33 35 32 38
+74 74 80 82 83 87
+34 40 40 41 44 45 50
+75 68 66 63 61
+72 69 67 64 61 54 54
+23 27 27 29 34
+53 57 58 60 60
+47 40 35 34 35
+28 24 22 20 18 16 16
+55 58 56 52 52
+9 9 11 14 15 12 16
+38 33 29 27 26 21
+19 18 19 19 20 24
+59 59 55 54 53 52 46
+9 13 16 18 20 21 22 26
+36 32 25 24 21 15
+40 41 44 45 47 46 49 53
+2 4 7 7 9 11 18
+16 21 20 22 23 25
+90 84 82 79 75 72 68
+74 74 78 79 81 81
+59 61 64 63 61 59 52
+76 76 75 68 67 64 65
+85 85 85 86 85
+34 37 35 32 29 25 24
+86 84 84 83 80 77 75 68
+15 16 20 21 23 26 29
+65 71 75 76 73
+95 95 94 91 88 90
+81 87 88 91 94 96 97 97
+4 8 11 13 14 12 15
+34 40 42 44 47 45 43
+34 36 38 41 48 51 55
+44 46 44 44 41 40 38 38
+95 98 97 96 93 93
+54 53 50 48 44 38
+25 25 23 20 17 15 11
+82 82 81 81 81
+52 56 58 62 64 68
+39 39 36 35 34
+83 86 88 85 87
+46 39 41 40 34
+18 24 27 34 37
+34 30 28 26 24 23 24
+65 67 70 72 74 77 76
+18 23 24 27 34 36 37 36
+10 10 11 14 16 21
+2 6 9 12 13 13 15 14
+46 51 52 56 57 59 63
+69 75 80 81 85
+60 61 64 61 58 57 60
+84 87 86 80 79 79
+76 73 75 73 73
+72 66 65 62 65 63 60
+10 14 16 17 18 25 27 31
+15 16 17 17 18
+94 94 91 86 82
+39 46 47 49 52 56 58
+1 1 2 2 2
+3 7 8 10 17 20 20
+26 26 24 19 17 14 12
+43 43 42 44 42 37
+62 62 59 60 59 58 55 55
+19 23 27 28 30 36
+41 44 42 44 41 41
+12 10 10 12 13 15 17 22
+52 53 54 55 62 65 67 67
+21 22 21 20 20 19 16 17
+50 46 45 43 41 40 40 40
+69 70 74 77 77
+83 87 89 89 90 94
+14 11 9 11 15
+86 83 84 88 89 92 93 97
+47 44 44 47 47
+83 87 89 89 92
+65 61 57 55 57
+65 69 71 75 78 81 81
+72 72 73 80 81 84 82
+31 28 30 34 35 36 39 41
+94 89 83 82 81 80 79
+55 55 52 48 45 45
+64 66 64 61 59 54 50
+7 6 11 14 17 21
+83 79 75 73 72 71 70 70
+37 36 36 33 31 29 28 31
+92 94 93 92 91 86
+71 70 69 68 63
+80 83 82 83 82 79 77
+51 55 57 61 58
+53 50 47 46 42 42
+89 89 90 96 99
+34 33 36 39 40 44 42
+77 73 69 68 66
+10 10 13 14 16 13
+76 77 74 74 69
+91 92 93 95 96 99 99 99
+17 15 11 10 9 6 5
+47 47 44 41 39 40 41
+21 25 28 30 28 35
+52 55 52 48 49
+44 44 42 45 43 39
+36 36 37 41 42 44 46 44
+43 43 40 40 37 40
+19 22 19 15 10
+61 62 59 56 55 51
+31 37 38 41 45 45
+1 5 8 9 10 15
+42 38 40 38 37 30
+60 61 59 57 55
+36 34 36 33 30
+38 40 41 42 40 42 44 43
+58 55 53 52 51 49 46 42
+91 88 91 89 88 89
+53 53 51 50 50
+89 91 92 95 92 99
+18 13 15 13 11 11
+64 65 66 68 69 70
+71 74 77 80 83 84 86
+40 42 45 48 51 52 54 57
+29 31 32 34 37 39 42
+13 14 15 18 19 22 25 27
+20 18 16 13 12
+21 19 16 13 12 10 7
+88 91 94 95 97
+25 22 21 18 15 13
+55 53 51 48 45 42 40 38
+63 62 61 58 55 52 50 48
+61 58 56 55 54 52 49
+59 60 62 65 67 69
+68 69 72 74 76 77
+73 70 68 65 63 61
+88 89 92 95 96
+37 36 34 33 30
+50 51 52 55 56 59 62 63
+67 70 71 73 76 78
+90 92 93 95 96
+41 42 43 45 46
+60 59 56 54 52 50 47
+39 38 36 35 32 31 28 27
+14 17 19 20 21 24 25
+60 58 56 55 53 51
+11 10 7 6 5
+10 11 14 15 17 19
+14 11 8 5 4 3
+64 62 61 58 55 52 51
+17 14 13 12 11 10 7
+72 70 69 68 66 64 61
+74 77 80 82 85 86 88 89
+26 29 32 35 36 38
+62 60 59 57 56 53 50
+26 25 23 22 20 19 16 13
+7 10 13 16 17 20 21
+71 70 69 67 65 62 61
+11 13 14 15 18 21
+22 20 17 14 11 9 6 5
+3 4 6 8 11 12 14 15
+2 4 6 9 12
+81 84 86 88 91 94 97 98
+32 33 36 37 38 41
+78 77 76 74 73
+71 72 74 76 78
+44 45 48 49 51 53 54
+78 75 74 73 70 69 66 64
+75 74 71 69 66 63
+84 82 79 78 75 74 71 69
+62 61 58 56 54 52 51 48
+98 95 92 89 88 87 85
+3 5 7 9 10 12 14
+89 87 85 83 82
+80 79 77 75 73 71 68
+61 62 64 66 69 72 74 76
+51 49 46 44 43 40 39 38
+70 67 64 63 62
+35 34 33 31 29 27 24 23
+42 44 47 50 51 52
+52 55 58 59 62 64 65
+67 69 72 74 77 80
+14 12 11 9 8
+53 51 48 45 43
+57 58 60 63 65 68 70
+30 32 35 36 38 41 43
+99 97 96 94 91 89 88
+68 65 63 61 59 57 56
+92 90 88 86 85
+44 46 47 49 52
+49 52 53 54 56 57 59
+28 27 25 22 21 20 17 16
+48 46 43 41 40
+79 80 82 85 87 88 89
+58 56 54 53 52 51 49 47
+54 57 60 61 62 64 65
+40 39 38 36 35 33
+32 30 29 27 24 23 22
+17 14 11 9 7 5
+91 89 88 87 86 83
+19 16 14 11 9 8
+40 41 42 45 46 49 51 52
+86 84 81 80 77 74 71 68
+42 41 39 37 36 34
+36 33 32 29 26 23 20
+24 21 20 17 16
+12 9 8 5 4
+76 79 82 85 88 91 92
+64 66 69 72 75
+35 37 38 41 44 46 49 51
+94 92 89 87 86 85
+66 68 71 74 76
+81 80 79 77 75 74 72 71
+83 86 89 92 94
+43 40 37 34 31
+36 37 38 41 43
+31 28 25 23 20 18
+45 44 42 41 38 36
+86 85 84 82 80 77 74
+58 57 55 54 53 50 49 47
+70 71 73 75 78
+73 76 79 80 82
+85 83 81 78 75 72
+37 38 39 42 45 48 50
+64 67 68 71 72
+66 63 61 58 56
+61 64 65 67 68 69 72 74
+95 94 91 90 89 87 85 84
+84 87 89 91 94
+63 65 68 71 72 73
+40 39 38 37 35 34 32
+88 87 86 83 82 81 80
+71 70 68 65 63 62
+92 90 88 85 82 81 80
+76 74 71 68 65 64
+9 11 12 14 17
+74 75 77 78 80 82
+30 33 36 38 39 42 44 45
+59 62 63 65 67 69
+83 86 88 91 94 95
+29 28 26 23 21
+70 71 74 77 78 80 82
+70 72 74 75 76
+6 9 12 15 18 21 24 25
+32 31 29 26 23 22
+76 75 74 72 70 68
+93 92 91 90 89
+56 58 59 60 63 64
+72 73 74 76 78 80 83 85
+96 95 92 89 86 84
+98 95 94 93 90
+27 29 31 33 36 37 39 40
+48 47 44 41 39 38 37 36
+20 19 16 14 13
+98 97 96 95 92
+71 72 74 75 78 80
+49 51 53 55 57
+63 60 59 56 53
+78 80 82 83 84
+80 79 77 75 73 71 69 66
+24 25 27 30 33 34 36
+81 82 84 86 89
+35 36 39 42 43 44 46
+14 15 16 18 21 23 25 28
+83 84 86 89 92 93
+82 81 78 76 73
+19 21 24 27 28 30 32
+61 60 58 56 53
+7 8 10 12 14
+69 67 66 64 61 59
+29 28 25 23 21
+44 46 49 52 54 55 57 60
+6 7 9 10 12 14 15
+27 25 22 19 18 17 14
+50 52 54 56 59 60 63 65
+40 39 36 33 32
+10 11 12 14 16
+30 27 26 24 23 21 19 18
+24 22 20 19 18 16 14
+89 91 93 95 97 98 99
+60 57 54 53 51 48 47
+1 3 6 7 8 10 13
+14 13 11 10 8
+57 55 53 51 50
+48 46 45 42 40 39 36 35
+42 43 45 47 50
+92 90 88 86 85 82
+94 91 90 88 87 85 84 82
+45 46 48 50 53
+24 21 20 17 14 11 9 7
+65 64 62 60 59 56 55 53
+54 51 50 48 47 44 43
+49 47 45 42 39 38 37 34
+37 34 32 30 27 26 25
+87 88 91 92 94 97
+86 84 81 79 76 73 71 70
+59 60 63 64 65
+39 42 43 44 46
+14 16 17 18 21 23 24 27
+5 6 7 9 12 14 16 19
+64 65 67 70 73
+90 89 88 85 84 81 78
+83 85 88 90 92 93 96 97
+83 81 79 76 74 73
+68 71 74 77 78 80 83 86
+41 40 38 35 34
+34 31 28 27 24
+87 88 90 92 93 94 96
+52 55 56 57 60 62
+17 20 23 24 25 27
+30 28 27 24 21 18 15 12
+28 27 26 25 22 19
+72 69 68 67 66 64
+59 56 55 54 52 49 47 45
+26 28 31 32 35 36 38
+52 49 46 45 42 41 39
+9 10 11 12 14 15 17
+35 36 37 39 40 42 44 47
+59 58 55 54 53 52
+11 10 9 8 6 4 3
+18 20 22 23 24 27
+10 8 7 6 5 4 3
+68 71 72 74 76 77
+64 63 62 59 56 54 51
+37 36 35 33 31 28
+98 97 96 95 93 92 90 87
+18 19 21 24 27
+23 24 26 29 30 33 36 39
+52 51 49 47 46 45 42 41
+50 48 47 44 43
+40 43 46 49 52 54 55 58
+45 43 40 37 35 33 31 29
+35 33 30 27 24 23 20 18
+82 83 84 86 88
+19 16 13 10 9
+37 34 33 32 29
+86 83 80 77 76
+77 78 79 81 84 87 88 90
+13 15 18 21 22 25 27
+6 7 9 11 13 14 17 18
+51 50 48 47 46 44 41 40
+79 80 82 83 85
+74 72 69 67 65 63 62 59
+58 57 55 53 50
+54 57 60 62 64 65 68
+28 30 32 34 37 38
+10 13 15 18 20 22 24 27
+80 79 77 74 73 71 70
+21 20 18 15 13 11 9
+21 23 26 29 31 33 35
+74 75 76 78 81 83
+61 58 56 55 54 53 51 50
+54 55 56 57 60 62 64 65
+45 43 42 41 38 37 35 34
+47 50 53 56 57 59
+98 95 94 93 92 90
+13 12 9 7 6 4 2
+68 70 73 76 79 80 81 84
+59 62 65 68 69 72 75
+80 82 84 87 89 92 95
+63 65 68 70 71 72 73 76
+92 90 87 86 85 82 80 77
+20 18 15 13 11 9 7
+60 59 58 55 54 51 48 47
+18 16 15 13 11 9
+71 68 65 62 61 59 57
+69 68 65 62 60 57 56
+75 74 73 72 70 67 65 62
+17 20 22 25 28 31
+43 45 46 48 50 51
+28 25 22 21 19 17 15
+36 33 30 29 27 24 22 21
+13 14 15 18 20 23
+84 82 81 78 77 76 75
+23 26 27 30 33
+56 53 50 47 46
+25 27 28 30 31 32 34 37
+90 92 94 95 96 99
+82 83 85 88 90 92 95
+49 46 45 43 42 40
+55 58 61 63 65 68 69 72
+61 62 65 66 68 69
+49 52 54 55 56 58 59 61
+41 43 44 46 49
+74 71 70 68 65 62 61 58
+26 29 30 31 32 35 38 40
+11 12 14 15 18 21
+79 76 74 72 71 68 66
+17 20 23 25 27 30 33 35
+52 53 55 58 60
+6 7 9 11 12
+88 85 84 83 81 79 77
+71 74 76 77 79
+70 72 75 78 79
+54 56 58 59 62
+97 96 94 91 90
+6 9 10 11 14 17 20 22
+23 21 18 15 14
+99 98 96 94 91 88 87
+96 93 92 90 89 88
+91 89 88 85 84 82 80 77
+86 87 88 91 94
+3 4 7 10 11 12
+56 59 61 64 67
+40 41 44 46 48 49 52 53
+35 34 32 31 30 27 24 22
+48 47 44 43 42 40 38 36
+31 29 26 23 20 19 16
+25 27 28 29 30 32
+4 7 10 13 15
+36 39 40 42 43 45 48
+20 23 25 27 28 31 34
+40 42 45 48 49 52 54
+14 12 10 9 7 4 2 1
+76 74 71 68 66 64
+25 27 29 30 31
+34 31 29 28 25 24 22
+63 64 67 70 72 73
+95 93 90 89 87 85
+29 27 25 22 20 18
+28 30 32 33 34 37
+53 52 49 46 43 42
+41 40 38 36 33 31 30
+81 79 77 75 74 73
+97 96 95 94 93 90
+77 79 81 82 83
+67 64 62 59 56 54
+55 54 52 50 48 46 45
+74 73 70 69 67
+90 88 85 82 80
+16 14 13 12 11
+32 31 29 26 24 23
+17 18 21 24 27
+21 18 16 14 11 9 6
+37 39 41 42 45 47
+6 8 9 11 13
+35 34 32 30 28 27 25 23
+80 78 77 75 73 71
+4 5 6 9 12 15
+48 51 52 53 55 56 57
+31 33 34 35 37 38 40 42
+75 77 78 80 83 86 87
+39 40 43 46 49 51
+70 71 72 74 75 77 79
+95 92 89 87 85 84 82
+5 7 10 12 14 17 18 20
+68 67 66 65 62
+61 63 64 66 68 69 70 73
+61 59 57 55 53 51
+38 36 33 32 31 30 29
+83 82 79 76 75 74 72 69
+17 20 22 23 26 28
+81 83 86 87 90 93 94
+85 82 81 79 77
+7 10 11 12 13
+94 93 90 87 84 82
+63 64 66 69 70 71 73
+35 36 37 39 42 45
+48 47 45 44 41
+93 92 91 89 88 86
+47 50 52 54 55
+33 35 38 40 43 46 48 49
+70 73 76 77 80
+96 95 92 91 88 87 84 83
+14 17 20 21 22 23 25 28
+14 15 16 17 18 20 21
+72 71 70 68 65 63 60 59
+57 60 61 64 67 68
+18 17 16 13 10
+49 47 44 42 40 38
+30 32 34 37 38
+70 69 68 65 63 62 61
+37 40 43 44 47 48
+55 54 53 52 50 47 45
+90 88 86 85 83 81 80
+90 88 85 83 80
+38 40 43 45 46
+64 67 70 73 75
+91 93 95 98 99
+18 15 12 9 8 6 4 1
+80 77 75 73 70 67 64 62
+29 26 24 21 19 16 15
+61 63 64 67 69 72
+60 59 57 54 53
+63 61 59 57 56 54 53
+49 50 52 53 54
+57 59 60 63 66
+61 63 64 65 66 67 69 70
+24 21 19 18 16 14
+42 39 36 35 34 33
+95 94 92 91 89 86 83
+72 75 77 78 81 83 86
+4 5 6 8 9 12 14
+20 22 25 28 30 33
+65 68 70 71 73 74
+1 3 4 6 9 11 12 15
+75 77 79 81 83 85
+21 22 25 28 29 31 34
+8 7 4 3 2
+39 37 34 31 28
\ No newline at end of file diff --git a/2024/day2/input_test b/2024/day2/input_test new file mode 100644 index 0000000..2d6faf5 --- /dev/null +++ b/2024/day2/input_test @@ -0,0 +1,6 @@ +7 6 4 2 1
+1 2 7 8 9
+9 7 6 2 1
+1 3 2 4 5
+8 6 4 4 1
+1 3 6 7 9
\ No newline at end of file diff --git a/2024/day2/solve.py b/2024/day2/solve.py new file mode 100644 index 0000000..3ec9967 --- /dev/null +++ b/2024/day2/solve.py @@ -0,0 +1,31 @@ +safe = unsafe = 0
+
+
+def is_safe(report: str) -> bool:
+ last_num = 0
+ increase = True
+ for ii, num in enumerate((int(elem) for elem in report.split())):
+ if ii != 0:
+ if ii == 1:
+ increase = num > last_num
+
+ if (num > last_num) != increase:
+ return False
+
+ diff = abs(num - last_num)
+ if diff < 1 or diff > 3:
+ return False
+
+ last_num = num
+
+ return True
+
+
+with open("input") as f:
+ for report in f.readlines():
+ if is_safe(report):
+ safe += 1
+ else:
+ unsafe += 1
+
+print(f"safe: {safe}\nunsafe: {unsafe}")
diff --git a/2024/day2/solve2.py b/2024/day2/solve2.py new file mode 100644 index 0000000..8e2f8e7 --- /dev/null +++ b/2024/day2/solve2.py @@ -0,0 +1,42 @@ +from typing import Generator
+
+safe = unsafe = 0
+
+
+def is_safe_with_dampening(report: str) -> bool:
+ numbers = [int(elem) for elem in report.split()]
+ for ii in range(len(numbers)):
+ if is_safe((elem for idx, elem in enumerate(numbers) if idx != ii)):
+ return True
+
+ return False
+
+
+def is_safe(numbers: Generator[int, None, None]) -> bool:
+ last_num = 0
+ increase = True
+ for ii, num in enumerate(numbers):
+ if ii != 0:
+ if ii == 1:
+ increase = num > last_num
+
+ if (num > last_num) != increase:
+ return False
+
+ diff = abs(num - last_num)
+ if diff < 1 or diff > 3:
+ return False
+
+ last_num = num
+
+ return True
+
+
+with open("input") as f:
+ for report in f.readlines():
+ if is_safe_with_dampening(report):
+ safe += 1
+ else:
+ unsafe += 1
+
+print(f"safe: {safe}\nunsafe: {unsafe}")
\ No newline at end of file diff --git a/2024/day3/input b/2024/day3/input new file mode 100644 index 0000000..64eaed9 --- /dev/null +++ b/2024/day3/input @@ -0,0 +1,6 @@ +from()$&mul(602,165)why()mul(305,64)?(where()-:mul(80,703);)why()*from()%select()mul(290,957)}/?%'from()]mul(851,335)mul(844,49)what()]![from(667,522)]}how()how()mul(938,695)#/)*?@~?@select()mul(706,392)^mul(242,513)who()@]mul(871,132)( ] from()$mul(41,656)^{(&how()from()[when()-when()mul(628,478)mul(287,621)why():'mul(127,825)# ]mul(360,578)select()?^^select() @:why()mul(136,849);{how()%*@%+how()[mul(544,891)mul(436,21)from()}mul(184,294)+/from(81,871) how()&?]mul(297,492)select()/}%;$$~{*mul(161,703)when():+(,mul(335,695) ()&where()?who();'mul(689,420)^how()from()how()what()>]where()don't()}%mul(78,176)~$where():@,>%mul(62,695)@{#how()mul(742,538)who(){$$who()@{+(mul(282,209)%mul(428,514)/+from()}>@<mul(131,844)mul(431,946)&mul(171,87)+mul(164,733)mul(760,223)/^$*@?[mul(485,824)! *(^-^;mul(465,327)@}when()+~&$?[%don't()$:/!]mul(249,931)mul(963,891)}$%>mul(665,815),mul(762,48)[+/mul(591,445)~?who()#mul(36,3)select()~$ [<}*/do()''>~'$mul(109,905)}how(){!@where()%/mul(380,929)*){~:where()mul(547,552)$:*mul(58,881)where(145,89)[why(634,213)mul(699,443)mul(826,660)what()from()-how()}'from()what()<;mul(700,665)] #(*?how()<+mul(507,719))~*/-^(%mul(941,551)$;don't()#;:when()+#>mul(87,663)who()/how()mul(332,238)~mul(290,235)',why()mul(950,204);where(),(when()mul(233,633)-^}@who()^mul(289,147)$>-'$select(736,261)*~]mul(899,836)'why()do()@when()why()from()mul(975,883);select()who()mul(165,847)why();^/{^mul(31,153)?;'don't()( <!from()from()~'(&mul(352,285)mul(912,583)<mul(192,230)/+~}<!mul(710,930)-how(461,167)][^why()do()*#mul(543,422)^*from()/^#~do()mul(832,873)]#when(455,108)^}who()/]mul(448,716)why()#/&mul(319,598)when()]{/ /'why()mul(865,894): +what()>from()+})what()mul(262,509)!*where()}/-#~/mul(308,953);*!]mul(741,76)[mul(256,536)[)>%-who()<^[$mul(382,338)where()[ when():select()<>mul(993,630)@$mul(411,640)/+where(623,926)/~mul(807,676)+*],mul(579,979who()what()from()when()how()what(),mul(882,434)&who()'mul(154,824)from()#<<,,{where()$mul(259,438)from()}?:;mul(641,967?from())<,>~mul(325,912)%select()mul where()do()where()where();(!,[$why()mul(131,307)mul(323,794)mul(570,548+!$from()!}what(588,195)<select()select()mul(622,782)why()mul(304,116)${(mul(942,260why()[?<$mul(420,225);~,>-from()mul(319,524)!/why()mul(737,137)+^&]/mul(228,919)@mul(672,604)+when(773,127)select()+why(941,245)mul(121!<[?$?;from(987,370):mul(904,487)#^what()from()({?mul(791,791)!,::)@^(mul(517,686)what()*how(),why()&mul(218,978)#,who()&$who()how(205,211)where()[mul(70,357)^$[?^$^what()mul(245,237)where()why()?{/mul$when()+},why()mul(264,30)@*:when(628,215):+&why()[mul(346,794){:}~-,select(),mul(115,926)~mul(140,56)[/:#~don't()@</mul(750,438)}::]!*!mul(64,9)}# ^mul(827,948)where(885,400)&mul(795,610)@mul(302,983)>:mul(889,788);;*!<$[when(),%mul(177,883)[mul(815,344)when()@$+ @)where(935,128)}{mul(638,520)why()-] when()] mul(639,171)!>[mulwho()~^:what()why()] <what() mul(595,754);mul(85,286)%<:mul(945,972)-mul(964,104)mul(163,666)don't()how()select(6,421),what()]mul(94,79)select()~[),-?mul(669,316)what()mul(452,152*~@]~why()how()when()mul(33,805)[how()select()[@]>mul(560,354)from()where()/];,how()} mul(980,896)
+>/;%who()&where(504,464);!do(),where()/mul(901,274)!when()mul(76,577)>select()mul(257,297)^+(/what(52,6)@%from()who()mul(331,276),what()when())+]{:&mul(653,163)''; '~mul(946,195)+/[from()mul(345,866)mul(975,684)#-:/why();-<:&mul(416,406)where(864,494)}{mul(343,101where()~ $/!where(331,467)who()@:mul(484,862)' mul(629,780)&%why(436,493)what()$mul(104,102)$,where()mul(2,157)who()%mul(404,895)mul(154,983)):]]%#:do()]from()+/#)/mul(682,696)what(518,168)select()where()+when(518,618)mul(799,756)+}why()}:mul(565,289);mul(687,685);@%!>?why()&;-mul(819,190)}]mul(596,898)mul(113,184)who();<mul(327,372) -when()+mul(327,170)>{@do()@?)why(),*/select()[mul(351,147):{+}}~^from()why()mul(350,104$''(from()<when();$$+mul(992,327);->$!when()<don't()mul(586,163))why()*<:;%mul(698,938)~mul(812,610)))where()^<^^*,<mul(50,331)]),/'}mul(469,997)^&who(){$[!]^#mul(468,630)@(+,}how()mul(97,867)! >mul(574,321)-mul(325,17);<& who(){]mul(960,765)^from())<<$:how()mul(412,562);mul(220,976)<what()how()!~{what()why()@what()mul(350,479)}when()&#@{<mul(135,697)[%mul(419,107)mul(33,102)&mul(430,537)?select(676,300)>*mul(338,463),$/#',from();select()*mul(982,199)&^:&mul(607,915)who()mul(473,531)$mul(490,191)select()&-~+>when()mul(105where()'/!do()<;[#why()mul(453,793)&*,^who()who()what()-<mul(722,985){what()[why()mul(526,659)![mul(863,260)select() /%&what()mul(81,404)}from(947,811)&mul(471,334)//why()}]why()what()~mul(160,947)'mul(679,16)>@why()from(642,548)%^(from()+don't()?-mul(976,65)what();]mul(155,153))where()who()when()[]mul(44,452)}mul(51,177)~$[mul(462,949)$}^select()#[)]mul(743,555)?[mul(750,557)}#{from()%(why()where()mul(807,786)+})>{)what()}do()mul(231 (how()*mul(667,833)when()~from()why(),who()(;)mul(729,999)mul(805,756)when()}what()who()!**who()]mul(920,392*]when(26,462)mul(558,874)!~?+$$';mul(694,195)when()/$?from()mul(198,978)%>;/why()who()}+why()@mul(248,980)$ how()>'select();mul(888,351)mul(476,169)[>@-mul(282,926)#<mul(301,964)mul(736,489)* when()?^mul(306,875) from()%'%from(){+when()<do()~/{#,>why()mul(637,563)-'~@!how()'^what()$mul(303,12)]how()~mul(922,806)^+when()[?don't(){,when()!*select()select(828,14)who()'why()mul(237,256)#mul(603,548)mul(887,362)!>%/how()[,%]don't()&mul(499,574)select()}%how() mul(787,625)what()who()) '*,mul(197,610)?!~('where()%'select()how()mul(840,759)} {$mul(19,916)}/mul(965[)) *who()how()~from()who()how()mul(319,356),where(196,245) who()mulwhat())^when(211,851)select()do()-$>+}'?from();>mul(349,592)&;>mul(473,196)where()~mul(939,515)$?{;^{}what()mul(417,24){??where(390,662)~from(),mul(93,289) when()] #from()$mul(543,426)&;&*;why()where()mulfrom(){-?'>,;who()mul(65,960):!how()*}*mul(544,316)%what(585,366)how():>mul(453,85)&[-from()/-#<select(992,327)mul+$^]from()<%-mul(612,429)/[select(41,104)} }?mul(493,119)$;why();from()%mul(83,70)]><mul}how()-mul(752,957)/%why()#-{mul(148{mul(756,579)who()^-select()-#]mul>?how(829,900)why(){mul(544,588)mul(178,94)from()where()mul(84,939)+^]who()]select()(&mul(951,416)how()[-] mul(324,907)who(){< )mul-select()![@&mul(578,700)mul>@~]%){mul(543,266)#how()!*why()$@%don't()>$what()mul(451,107)/mul(307,230)+@$when()from()?['mul(822,895)$mul(530,529)+mul(792,795]$from()what(158,547){what()mul(851,381)?when(649,20),*mul(73,793)<] :(:@+;mul(93,749)from()];'mul(419,25);:!who()-mul(102,426)'why()+from();mul(186,663)
+select()$how()]%]{~mul(183,456)::,+;![when()>mul(513,696)mul(835,886) from()##* select()%{mul(820,742)don't()why()mul(295,615)^]what()how()-what()*who()why(931,57)when()mul(688,219)!@mul(191,470)how()>?from()from(764,712):where(){:mul(951,673)!mul(536,960)[>?':]mul(353,508)!*how(977,514){)'mul(135,970)}>%select()select()::where()mul(580,976)'^when()mul(144,491)what()%&]mul(360,420(who()how() :@mul(925,707)mul(723,986){mul(465,348) mul(153,323)#~when();from()@}-;<mul(579,823)select())-?$&{select()?~mul(957,611%?from()what()select()('?mul(87,471)#select()-who()@mul(885,437)>] how()[^ :what()mul(990,144)}mul(567,848)select();@where()'(^@mul(620,639))how(711,187)how()select()+?)+^don't()mul(776who()$mul(592,515)what(),who(),mul(870,763)where():when()^>{}mul(503,440)mul(524,563)why(112,173)how()(,[;mul(235,893)how()*?/]mul(524,355%/],^]*^!%where()mul(464,297)select()from()who()};%what();{mul(289,689)#<mul(159,534)-[<why()%~?$<mul(789,482)-{$select()&{how()mul(220,671))!mul(122,701)mul(747,45)#(mul(249,127)~%'#~-where()how(),mul(83,660)}how()!who(882,504)from()where(){{mulwho()<+when(132,720){(from()how()@,mul(829,58):}[mul+)don't()#$?(@'{%where()how()mul(155,396)how()who()];-mul(454,202)mul(733,864))+]<mul(735,897)/ <;mul(80,402))mul(730,574)([*{who(){*who():what()mul(832,674))select()}+(who()-'mul(427,836)mul(79,877)mul(436,288)what(),:,*from()who()how()(mul(327,609)why()!)% &when()mul(372,811)where(623,779)where()@]when()don't()[{from(){mul(842,562)~who()]mul(814,697)']why()mul^*-where()from()>who()[&[mul(604,447)select()~#<;(~^mul(807,738)[~/from()mul(477,588) ^-]-mul(820,399)@-when()>%mul(580,918)mul(401why()*;],why()]]+!mul(343,445)*<+why()$mul(830~@who(),;from()#mul(776,674)?$who(){+mul(295,290){where()when()mul(321,389)&{'@<mul(338,854)*$do()()why()where()select()#where()what()$mul&'$mul(438,58)+mul(176,945)!$<&;do()when())select()}mul]!*why()where()from(),^^(,mul(765,384)@from()why(111,662) }(mul(496,9)*<#mul(391,60)!:;?!]:from()~mul(494,14)(mul(390,353)}@:why()@]where()&mul(885,604)+%@/?mul(254,601)@&:,mul(100,15)%select(301,302)*mul(71,315)(select()mul(871,371)mul(870,594);*#{>$}who()mul(879,995)*{from()/(;)mul(569,107)mul(223,576)~~>*@when()]]mul(624,981)?{^'$>(mul(812,37)what()-?:>&{+mul(731 < %-who()select()mul(656,82)how()'from()mul(446,744)'<;~why()}^:,]mul(461,437)when(245,888);$[%when(896,829)who()>{mul(791,568),-%$! ?#*mul(134,101),~<-'}how(672,596)?/mul(641,129) :from()#?mul(414 )]-%from(),@)(mul(53,315):@& ,who()where(734,227)^mul(271,699)from()>how():when(595,247)'}%',mul(730,933)from()',]why()+ how()where()mul(231,37)~<+&[$:}!:mulwhen(572,105)}who()mul(374,347)/-<mul(660,713)++when()?;who() mul(885,672)>why()*what()how()#!@}mul(230,754)-what()-</# ]don't()~+-:}+why()how()>:mul(759,756)select() $what()]^select()#how()?mul(567,572)mul(757,309)'[mul(530when()+/(*{mul(736,155)+*where(960,885)%: {:mul(713,672)!$*{#%mul(17,60)&what(966,667)what()why(): select(428,568)*!&mul(228,28)where()where()@/])do()}!/{^?{[why()mul(218,633)mul(156,644)>{~^[?mul(377,886) where()%who(159,149));how(909,452)-mul(869,404)>:mul(920,501){what())+how()mul(545,793)~-mul(74,347)where()!-;how()when()>)%mul(647,960})>;&why()mul(767,582)~^+;who()<)<)mul(494,399/;-from()^don't()why()mul(215,704)%%from()mul(392,808)-who()+where()[{-*/mul(869,412)from()mul(501,148)?'don't()from():}select()mul(796,221)select()mul<)@ ,when()}[:[what(96,456)mul(651,592)when()';$ (*why()mul(134,209);select())[mul(434,869)@{+'$mul(292,419)mul(175,874),from()select()$?[{^mul(866,742)
+how()?}% #who()']#!/usr/bin/perlmul(875,840);]:::mul(127,915)>^>select(736,608)why()+ mul(13,855) ++ how()>mul(568,520)<)'mul(332,245)::where()@&mul(625,889):who()^}+<mul(395,46)})mul(123,827){%,~mul(524,599)%-do()#$mul+;when()%where()/]mul(792,461)who()~#~#>who()mul(392,15)*<where(474,62)[-&^mul(908,825),why()what()who(){who()where(168,259)why()&-mul(254,516)[^:who()>how()mul(437,461)select()<who()mul(60,583)/why()+mul(193,822)&,!(}+mul(373,499)mul(574,712)#?)@how()who()mul(365,781)mul(414,354)*#$-;don't()@+from()#(who()mul(798,611)+>]+how()$(!mul(219,47)^mul(518,535)(select()#mul(776,790)who()^how()~)where()mul(622,336)<when(80,174)who()]select()+)]{;mul(506,377)[%(+do()>why(171,784)>];@who()where()mul(255,591) >when()what()-,)&(mul(827,655):)(*mul(457,68)]what()^[&[mul(758</>'/select()mul(351,283)<{&{*%,mul(345,900)&when()<;[:[(when()<mul(752,407){[(,$-select()~<mul[:,]%>select()^(^@mul(904,504){{from()(&mul mul(537,360)why()/{)what())<!how();mul(443,831):&why(),from()%from(644,149)(mul(665,473)$mul(344,505)why()?from()!&don't()!-)'^#*<mul(115,607)~[from():'what()mul(637,79)/@select()when()&#mul(673,108)&&how()}mul(140,971)#select()/mul(659,539)]from()select()select()*mul(855,794)who()/(;&^&/!>mul(812,420){!mul(320,4)who(275,101)who()}^who()^why(562,771)%;-don't()<}}]mul(943,216):{)mul(17,572)&$why()where()mul(86,371)from()$$ +,>,mul(793,733)^?how()&?{;mul(174,855)(#/ what()select()where()[*mul(706,247)who()~why()/#;*mul(459,541) where()}mul(586?(<mul(738,226)(select(){who()mul(395,492)^select()%what():what(661,644)!^^mul(128,575)>mul(470,802)who(773,148){what()?/why(397,830)),where()from()mul(532,611){[select())}why()when()mul(855,381))@?-/) (do()who()mul(4?*select()$select()where()!!mul(758,795)/*:mul(221,874)mul(587,201)~{<mul(495,109)[#{-]? mul(679,206)]}*%-what()*mul(149,552)!mul(422,434))>?{;/why()mul(757,730)'$-$how();do()why(423,32)}%!*from(930,638)mul(196,228)%mul(753,37)<don't()}[>'mul(970,912)[what();~mul(643,558)(where())how()mul(525,660)when()}$#) +mul(770,997)mul(523,352)/%when()mul(139,306)/(mul(435,619)who()$;)mul(353,463)/how()$who()#what()!where()select()mul(218,409)'$:what()^don't()#when()from() &}>where()?mul(41,95)%mul(93,123)mul(615,917)how()^#mul>!@~how()>mul(801,12)select()what(76,678)from()$#}>mul(206,424)/;~select()what()who()%:/mul(920,696)'^+mul(467,893how()mul(732,924)when()*{mul(212,801)select()}$mul(253,942)from(245,298)$%select():mul(200,773)(what() ,mul(484,816%[@:what()$#mul(392,392)select()/mul(603,982){?'}{%mul(767,605)(*select(839,960)from()%,[-{%mul(810,348)<)}:<mul(346,603)%$what()+?$])!mul(915,360)select()who()<!;; )%mul(199,551)&[!'}]*[select()mul(903,980)when()what()what()mul(64)]^-from(),};]mul(492,955)/^%when():what()mul(941,906)/mul(961,134)/when()why()}/,when()mul(21,216)#'when()>$why()-mul(568,717$/*!*:#<<<mul(904,260)why()~why()when()?[{how()$mul(109,697)]when(505,150)--}-why()mul(59,922)?why()&}from(458,92){]mul(177,574)~mul(700,873),#]%#mulwhy()^ mul(671,271)select()&<:~mul(997,472)((mul(995,279)what()(mul(504,172)mul(620,601)!from()<-'@!mul(70,715)&mul(230,991))what())(++mul(448,128)mul(870,892)('mul(583,189)*<why()$!#+;mul(842,739):when()from()why(),what()<select()mul(241,966)from():from(634,254)##-^>mul(519,560)mul(371,303)#mul(444,873)/#;~! mul(825,442)
+;'?,&@@mul(687,295)mul(992,56)from()@$:when();mul(839{*;~mul(577,183)@-where()}why()~@^from()mul(226,901)how() >%when()?[~mul(281,291)#&>#$how()}mul(500,749)&>^-;why()@!@]do()/@?*,</mul(637,962)why())#@]mul(150,192)%(+mulselect()( /mul(455,843)@({-;how()>]~)mul(530,987)who()why()why()@>mul(282,486)*,-from(),>'what()mul(147,97)- /select()<$do()mul(339,632)<+mul(476,603)#$!mul(249,732)![]mul(552,713)}%^:[~who(294,666)!mul(335,971)>#mul(190(how();who():)mul(364,772)[~,when()*mul(350,52;who(640,301)from()-$,%:};mul(407,507))&#why()/{&[mul(668,42),~mul(849,891)what()*-:/who()$mul(335,214)?:why(); ,%mul;}mul(561,325){mul/+?when()<mul(732,879)#+where(){mul(372,617)what()#/mul(307<who()<]where()when()$mul(302,561)where()-mul(165,848):';why()why(){&mul(800,615)how()where()$from()!mul(617,736)select()-~-<!why()$where();mul(505,440)<!;%mul(36,639)!)what() [[}<,mul(100,765)when()(mul(418,224)select();do()-/*!^mul(480,518)>select()#do()!{!)/!mul(398,351)'$]how()%?:)from(716,264)}mul(976,539)when()}/mul(800,619)who())[?mul#+who()}mul(527,856)mul(479,693)[<mul(728,432)*mul(713,727)# }( where()mul(80,482)what()%,~)-'+/'mul(765,963)[mul&-how()mul(887,370)-{/$'-'where()who()what(295,542)mul(107,111)mulwhere()!where() how()/$mul(461,345)!from()mul(707,778);>what()#}{where()where()mul(310,5)$]>mul(687,149))!how(),why()how(941,130)where()when()what()mul(187,693)(mul(24,418){':}mul(304,601)when()mul(66,524)how()']select()from()>what()mul(217,884)~~<where() ^[mul(304,545)/why(){)[-,what()mul(782,464)why()*when(),}}mul(767,112)*mul(620,773)mul(89,154);]how()<::when()where() mul(430,945)*))mul(143,829)from(192,329)#!{who()($-mul(825,949)do()<%where()![mul(467,327)[&mul(727,778)!*(?@~mul(12,864)from()(; what()where()do()mul(975,968)how()mul(572,737):why()[when()mul(6,295)what()(where()$why()){mul(899,746)-where()mul(28,836)!what()!*,mul(362,377)who(),mul(449,514):?/@%{mul(593,723)^who()(!;[;mul<who()}what()$?from() %:]mul(409,707)<why()why()-;mul(847,518)][select(733,913)@-@why()who()when()mul(159,434)~^^#mul(973,188)-( [,#(%why();mul(970,535)~-,;{mul(776,519)select()'(how()+(mul(341,437)+ >-when())?@/mul(62,572)))when(482,658){select(561,928)when()!({mul(388,507)from()/+mul(64,284)who()why(899,74)when()why()mul(734,117)<-+}#:what()mul(567:where()select()mul(694,323)/[select()mul(772,515)[/'>why()when()/(*@mul(663,798)$when()select()$%#<,select()mul(810,58):~,(+select()[from()~'mul(838,509)mul(227,633)] mul(300,309)]>,!}'mul(369,74)$~({ ~'}{]don't()~)&<[>who()>mul(76,891)!]~ }:)${/mul(226,65)~/&<)^mul(981,600)[who(271,199)~-$&;[where(691,309)mul(69,207)*>select()*(+mul(935,119)<> ?;->mul(116,703)'where()-;;from()mul(324,982from()what()@<^mul(144,872)@+mul(569,48)mul(475,850)*how()'~^-mul(486,714)~![why()why()}<<mul(436,514)mul(574,28)when()'!how()@'what()select()mul(181,123))>/select()how()mul(789,342)?select()]!why()#mul(485,483)'%why();?%who()mul(921,916)do()'*]where()how(977,165)@mul(441,964)*-who()]&mul(395,170)> }mul(583,793)<*-how(){{mul(794,26)<how()&mul(670,885)/? -~<+]mul(32,656)(why()/>%~/;mul(297,812)mul(264,703)[select(253,420)select()mul(665)*when()*/>when()from()/where()!mul(264,312)where(756,949),+{}from()+;mul(454,375),do(){mul(72,780)(who() mul(4,67)
+<mul(299,165) -mul(606,634)&select() /@who()<when()^mul(773,105)when(140,544)mul(565,610)>/why()[*>when())from()mul(163,222)who();select()@?select()mul(631,370)where()^%mul(48,604)%where()select()]%:!{mul(492,16):?select(566,72)'@+when()})mul(277,631)when()when()+%#mul(356,136)mul^who() from()!from()~[don't()?:#!mul(536,636){how()why(167,58){from()$;&mul(170,241)-~$mulwho(),mul(295,979)^when()$}mul(872,817)'^+ %%%@%;mul(796,401){@$from():%(@who()where()do()how();,>where()*how()mul(562,34)mul(851,857)([how()mul(870)do()^#]what()mul(855,774)>from()mul(19,63)<mul(20,808)what()when()}mul(9,565)')#where(){;/mul(485,358){?~#),{when()mul(760,344)where()~#what()from()}}{*'mul(76,561) }why();;what()select()where()#?mul(202,590)#{do();mul(537,456)#^'mul(231,127)when()(%],(}[-^mul(928!how()<when()+(mul(278,743)where()$mul(138#{{mul(612,612){select()@what(186,303),mul(577,261)/{*why()mul(739,172)$@-*;~mul(217,239)(-~;%who()why(681,472)where()who()mul(2%mul(30,720)'what()(~~mul(414,37)/when()%*}}%why()^mul(293,928)%,$#when()/^'don't()&from()mul(662,652why()when()mul(134,920)what()*?!;!how()@from()do()*!~~mul(472,62)])mul:*?@<$when()mul(403,2)mul(682,860):,when(198,260)?:[}[,&mul(940,144<+]*#:mul(274,552)*select()#}<mul(721,529),:who()mul(938,454)[where()mul(816,770)$#^*what()select()'~{select()mul(201,567where(223,485)^]from(721,470)why()>)from()/'#mul(502,592)$(mul(330,265)-*'why()/<@mul(919,336)'when()when()(~ mul(222,37)mul}*?mul(716,440);how(254,405)#mul(938,798)]why()+mul(370,761);+select())mul(308,872):!who()%mul(376,736)when()[don't()$;#~,how():select()~what()mul(793,522)){?who()/mul(812,372)<;@mul(627,289)[!don't()^+)how()$from()##mul(500,501)#{why(120,25)mul(571,651):&{?mul(792,25))@$(@>don't()who()?^')' from()[mul(323,38)when()where()*/who()%mul(623,356)?mul(629,625))}+how()mul(950,826)(+,#mul(947,453)why();'how()&]from()mul(510,94)-?[from(){mul(34,148){when()mul(661,839)do()/}who()mul(597,740)^;mul(6,887)~#how(287,928) $>?}:don't()/-%(,;/))mul(910,743)!:%,%}/mul(626,661)((&([mul(320,446){what()'~<-@mul(573,309)^:?why(352,585)how(328,377)(@mul(996,815),~don't()mul(558,873), what()?>]^$mul(647,533);$@]!when();;when()mul(508,819)&select()( select()mul(823,518)/<when():when()~why(744,571){mul(405,772):;where();(mul(132,162)] !how(74,640):select()/mul(721,482)$why(),*{mul(925,155)*!!<-!}don't(){)+#^mul(990,837)?,mul(867,142)mul(764,232)mul(754,292)$#,select()>-how(),]mul(584,720)mul(127,993)''why()'/![where()mul(130,642)*what()<?where()mul(325,585)select()when()>when()mul(648,223)#}])don't() !when(647,635)+&$ mul(154,204)@~~?mul(90,691)when()]^&from()'[mul(236,768)~where())^~->(&mul(378,233)<?mul(366,515)how()},don't()*what()what()~/select()mul(507,554)<+<mul(145,19)mul(444,536)%!%mul(861,889)#where()}-:{:^ mul(790,870)!from()why(343,804){*-how()from()mul(989,194)<!!when(586,215)where(238,474)}mul(430,90){+who(308,211),mul(365,640)mul(684,600)$^:}from()'&mul(745,81)how()select()who(897,36)]$+?&^don't()what()who(){from()}('$mul(782,153)mul(270,449)#*mul(371,710)]&what()*!{?mul(487,920)(mul(474,993)@%mul(70,96)what()?<@~*mul(639,92)<?%-(mul(154,267));mul(588,135)*$*: [where()mul(2,108)who()/~(why()~/,^mul(364,558)who()#'do()[select()(: when()mul(324,801)where())'#,mul(696,843)*,[mul(946,677)}[how(532,32)[when()'-where(){mul(254,222){select()
diff --git a/2024/day3/input_test b/2024/day3/input_test new file mode 100644 index 0000000..2e1a90a --- /dev/null +++ b/2024/day3/input_test @@ -0,0 +1 @@ +xmul(2,4)%&mul[3,7]!@^do_not_mul(5,5)+mul(32,64]then(mul(11,8)mul(8,5))
\ No newline at end of file diff --git a/2024/day3/input_test2 b/2024/day3/input_test2 new file mode 100644 index 0000000..b774ec9 --- /dev/null +++ b/2024/day3/input_test2 @@ -0,0 +1 @@ +xmul(2,4)&mul[3,7]!^don't()_mul(5,5)+mul(32,64](mul(11,8)undo()?mul(8,5))
\ No newline at end of file diff --git a/2024/day3/solve.py b/2024/day3/solve.py new file mode 100644 index 0000000..a651ff3 --- /dev/null +++ b/2024/day3/solve.py @@ -0,0 +1,12 @@ +import re
+
+pattern = re.compile('mul\\(([0-9]{1,3}),([0-9]{1,3})\\)')
+
+with open("input") as f:
+ data = f.read()
+
+result = 0
+for match in pattern.findall(data):
+ result += int(match[0]) * int(match[1])
+
+print(result)
diff --git a/2024/day3/solve2.py b/2024/day3/solve2.py new file mode 100644 index 0000000..3564eca --- /dev/null +++ b/2024/day3/solve2.py @@ -0,0 +1,38 @@ +import re
+
+pattern = re.compile('mul\\(([0-9]{1,3}),([0-9]{1,3})\\)')
+do_pattern = re.compile('do\\(\\)')
+dont_pattern = re.compile("don't\\(\\)")
+
+with open("input") as f:
+ data = f.read()
+
+do_dont_intervals = []
+
+for match in do_pattern.finditer(data):
+ do_dont_intervals.append((match.start(), True))
+
+for match in dont_pattern.finditer(data):
+ do_dont_intervals.append((match.start(), False))
+
+do_dont_intervals.sort(key=lambda elem: elem[0])
+
+
+def get_do_state(intervals: list[tuple[int, bool]], pos: int):
+ current_state = True
+ for elem in intervals:
+ if elem[0] > pos:
+ break
+ else:
+ current_state = elem[1]
+
+ return current_state
+
+
+result = 0
+for match in pattern.finditer(data):
+ if get_do_state(do_dont_intervals, match.start()):
+ result += int(match.group(1)) * int(match.group(2))
+
+
+print(result)
|