summaryrefslogtreecommitdiff
path: root/day5
diff options
context:
space:
mode:
authorSteven Le Rouzic <steven.lerouzic@gmail.com>2024-12-06 00:43:31 +0100
committerSteven Le Rouzic <steven.lerouzic@gmail.com>2024-12-06 00:43:31 +0100
commit080b6ba980e4c5a132e06f0d7d8387947d227661 (patch)
tree7dfdc23037e7369955aae9849029ed47bf877117 /day5
parent35ef0a9776e596ff44adfd38cebcfef0ab6c4b03 (diff)
Day 5
Diffstat (limited to 'day5')
-rw-r--r--day5/data.txt1385
-rw-r--r--day5/example.txt28
-rw-r--r--day5/go.mod3
-rw-r--r--day5/main.go113
4 files changed, 1529 insertions, 0 deletions
diff --git a/day5/data.txt b/day5/data.txt
new file mode 100644
index 0000000..8d477d9
--- /dev/null
+++ b/day5/data.txt
@@ -0,0 +1,1385 @@
+48|74
+95|99
+95|97
+94|23
+94|98
+94|56
+19|98
+19|83
+19|62
+19|75
+83|58
+83|49
+83|61
+83|92
+83|93
+75|64
+75|58
+75|39
+75|83
+75|14
+75|24
+59|98
+59|95
+59|23
+59|55
+59|65
+59|69
+59|94
+77|62
+77|28
+77|57
+77|76
+77|34
+77|15
+77|11
+77|26
+72|47
+72|57
+72|81
+72|26
+72|34
+72|28
+72|87
+72|76
+72|19
+87|69
+87|29
+87|63
+87|17
+87|94
+87|57
+87|65
+87|23
+87|33
+87|11
+99|69
+99|29
+99|27
+99|28
+99|81
+99|68
+99|34
+99|77
+99|19
+99|94
+99|76
+98|92
+98|72
+98|23
+98|61
+98|55
+98|69
+98|74
+98|91
+98|39
+98|97
+98|14
+98|63
+14|36
+14|76
+14|99
+14|34
+14|68
+14|11
+14|25
+14|87
+14|19
+14|64
+14|93
+14|39
+14|27
+27|87
+27|55
+27|57
+27|69
+27|19
+27|94
+27|17
+27|65
+27|36
+27|76
+27|29
+27|26
+27|98
+27|68
+97|27
+97|52
+97|72
+97|24
+97|99
+97|87
+97|64
+97|11
+97|39
+97|25
+97|82
+97|59
+97|74
+97|36
+97|57
+82|29
+82|87
+82|62
+82|68
+82|94
+82|57
+82|81
+82|76
+82|11
+82|36
+82|28
+82|77
+82|69
+82|34
+82|19
+82|25
+63|39
+63|52
+63|93
+63|47
+63|25
+63|48
+63|95
+63|64
+63|58
+63|91
+63|56
+63|65
+63|61
+63|83
+63|14
+63|92
+63|72
+24|77
+24|36
+24|33
+24|11
+24|59
+24|15
+24|34
+24|68
+24|27
+24|19
+24|98
+24|28
+24|81
+24|76
+24|17
+24|99
+24|57
+24|82
+15|55
+15|95
+15|65
+15|63
+15|91
+15|74
+15|23
+15|69
+15|92
+15|81
+15|14
+15|49
+15|75
+15|58
+15|48
+15|61
+15|83
+15|33
+15|29
+52|24
+52|25
+52|27
+52|76
+52|34
+52|47
+52|64
+52|82
+52|87
+52|36
+52|28
+52|59
+52|94
+52|72
+52|68
+52|26
+52|62
+52|57
+52|19
+52|11
+91|87
+91|24
+91|92
+91|48
+91|82
+91|39
+91|64
+91|95
+91|14
+91|25
+91|93
+91|77
+91|72
+91|58
+91|61
+91|76
+91|99
+91|52
+91|97
+91|47
+91|56
+74|57
+74|72
+74|19
+74|28
+74|47
+74|25
+74|87
+74|24
+74|11
+74|82
+74|77
+74|59
+74|76
+74|94
+74|36
+74|17
+74|52
+74|26
+74|68
+74|93
+74|34
+74|27
+34|63
+34|62
+34|36
+34|49
+34|33
+34|81
+34|91
+34|15
+34|17
+34|94
+34|29
+34|59
+34|65
+34|75
+34|55
+34|61
+34|83
+34|98
+34|28
+34|58
+34|69
+34|95
+34|23
+17|81
+17|15
+17|95
+17|23
+17|61
+17|97
+17|63
+17|75
+17|62
+17|33
+17|65
+17|94
+17|14
+17|98
+17|55
+17|56
+17|49
+17|29
+17|58
+17|91
+17|28
+17|83
+17|69
+17|48
+92|57
+92|68
+92|93
+92|72
+92|27
+92|52
+92|74
+92|24
+92|59
+92|47
+92|77
+92|94
+92|19
+92|76
+92|17
+92|36
+92|87
+92|11
+92|26
+92|25
+92|64
+92|99
+92|82
+92|34
+93|17
+93|94
+93|28
+93|62
+93|76
+93|19
+93|26
+93|59
+93|27
+93|57
+93|25
+93|52
+93|64
+93|34
+93|68
+93|11
+93|77
+93|82
+93|72
+93|36
+93|99
+93|24
+93|47
+93|87
+28|58
+28|81
+28|15
+28|95
+28|14
+28|83
+28|56
+28|61
+28|48
+28|97
+28|23
+28|92
+28|33
+28|55
+28|98
+28|69
+28|65
+28|62
+28|91
+28|63
+28|49
+28|29
+28|75
+28|39
+25|11
+25|34
+25|81
+25|59
+25|17
+25|29
+25|62
+25|26
+25|69
+25|94
+25|68
+25|75
+25|55
+25|27
+25|28
+25|19
+25|33
+25|76
+25|15
+25|87
+25|77
+25|36
+25|57
+25|98
+47|64
+47|81
+47|15
+47|34
+47|57
+47|59
+47|24
+47|77
+47|28
+47|99
+47|68
+47|25
+47|27
+47|19
+47|76
+47|11
+47|87
+47|62
+47|82
+47|26
+47|98
+47|17
+47|36
+47|94
+81|56
+81|93
+81|92
+81|75
+81|74
+81|58
+81|29
+81|65
+81|48
+81|39
+81|49
+81|33
+81|55
+81|52
+81|14
+81|98
+81|95
+81|61
+81|91
+81|63
+81|69
+81|97
+81|23
+81|83
+68|28
+68|11
+68|33
+68|62
+68|29
+68|55
+68|34
+68|59
+68|49
+68|65
+68|69
+68|17
+68|23
+68|58
+68|63
+68|98
+68|81
+68|83
+68|26
+68|36
+68|91
+68|75
+68|15
+68|94
+69|83
+69|14
+69|56
+69|23
+69|39
+69|61
+69|49
+69|72
+69|65
+69|52
+69|58
+69|29
+69|97
+69|75
+69|63
+69|91
+69|24
+69|47
+69|95
+69|55
+69|92
+69|48
+69|93
+69|74
+11|17
+11|65
+11|33
+11|98
+11|26
+11|58
+11|29
+11|75
+11|81
+11|83
+11|69
+11|62
+11|49
+11|55
+11|91
+11|28
+11|94
+11|15
+11|34
+11|59
+11|36
+11|63
+11|23
+11|61
+29|14
+29|49
+29|47
+29|72
+29|74
+29|23
+29|55
+29|48
+29|52
+29|91
+29|92
+29|56
+29|83
+29|61
+29|39
+29|93
+29|63
+29|65
+29|75
+29|24
+29|95
+29|58
+29|97
+29|64
+64|81
+64|17
+64|57
+64|28
+64|11
+64|76
+64|26
+64|33
+64|77
+64|36
+64|98
+64|27
+64|34
+64|87
+64|62
+64|19
+64|69
+64|82
+64|59
+64|15
+64|25
+64|68
+64|94
+64|99
+61|39
+61|93
+61|56
+61|47
+61|27
+61|87
+61|99
+61|82
+61|68
+61|76
+61|48
+61|64
+61|72
+61|14
+61|19
+61|97
+61|77
+61|24
+61|92
+61|52
+61|74
+61|95
+61|57
+61|25
+58|39
+58|19
+58|24
+58|82
+58|27
+58|76
+58|14
+58|56
+58|61
+58|99
+58|93
+58|25
+58|57
+58|97
+58|47
+58|48
+58|74
+58|87
+58|92
+58|72
+58|95
+58|77
+58|52
+58|64
+55|63
+55|65
+55|95
+55|93
+55|61
+55|23
+55|97
+55|72
+55|49
+55|99
+55|74
+55|82
+55|24
+55|47
+55|64
+55|39
+55|14
+55|92
+55|56
+55|52
+55|58
+55|91
+55|48
+55|83
+49|95
+49|47
+49|99
+49|76
+49|57
+49|48
+49|77
+49|27
+49|93
+49|87
+49|56
+49|72
+49|25
+49|61
+49|97
+49|74
+49|58
+49|14
+49|52
+49|24
+49|39
+49|64
+49|92
+49|82
+26|63
+26|58
+26|14
+26|94
+26|61
+26|91
+26|65
+26|81
+26|49
+26|23
+26|83
+26|29
+26|33
+26|95
+26|55
+26|48
+26|17
+26|15
+26|56
+26|62
+26|69
+26|75
+26|98
+26|28
+39|57
+39|27
+39|25
+39|19
+39|99
+39|77
+39|17
+39|47
+39|64
+39|11
+39|52
+39|92
+39|34
+39|82
+39|36
+39|68
+39|59
+39|74
+39|24
+39|87
+39|93
+39|76
+39|72
+39|26
+57|19
+57|83
+57|65
+57|59
+57|36
+57|68
+57|94
+57|26
+57|15
+57|28
+57|81
+57|63
+57|75
+57|91
+57|62
+57|69
+57|29
+57|23
+57|17
+57|55
+57|11
+57|34
+57|33
+57|98
+23|48
+23|77
+23|14
+23|56
+23|92
+23|74
+23|58
+23|72
+23|47
+23|39
+23|25
+23|91
+23|97
+23|76
+23|99
+23|24
+23|49
+23|61
+23|64
+23|27
+23|93
+23|95
+23|82
+23|52
+76|28
+76|11
+76|69
+76|26
+76|81
+76|15
+76|57
+76|83
+76|94
+76|59
+76|33
+76|68
+76|55
+76|19
+76|36
+76|17
+76|34
+76|62
+76|65
+76|98
+76|75
+76|87
+76|63
+76|29
+33|23
+33|97
+33|93
+33|63
+33|91
+33|14
+33|39
+33|74
+33|56
+33|29
+33|72
+33|95
+33|47
+33|55
+33|58
+33|65
+33|83
+33|61
+33|92
+33|48
+33|49
+33|52
+33|69
+33|75
+36|56
+36|69
+36|91
+36|61
+36|23
+36|26
+36|15
+36|75
+36|63
+36|65
+36|49
+36|29
+36|81
+36|17
+36|94
+36|59
+36|62
+36|28
+36|58
+36|33
+36|83
+36|55
+36|98
+36|95
+62|65
+62|58
+62|49
+62|69
+62|39
+62|23
+62|83
+62|98
+62|55
+62|75
+62|63
+62|14
+62|33
+62|74
+62|95
+62|48
+62|97
+62|81
+62|91
+62|15
+62|29
+62|56
+62|92
+62|61
+65|14
+65|64
+65|58
+65|83
+65|74
+65|47
+65|23
+65|93
+65|72
+65|52
+65|48
+65|97
+65|99
+65|92
+65|95
+65|25
+65|61
+65|91
+65|39
+65|82
+65|77
+65|49
+65|56
+65|24
+56|48
+56|77
+56|52
+56|93
+56|57
+56|14
+56|74
+56|39
+56|72
+56|24
+56|99
+56|34
+56|82
+56|64
+56|25
+56|68
+56|19
+56|11
+56|92
+56|76
+56|87
+56|47
+56|97
+56|27
+48|34
+48|76
+48|27
+48|57
+48|47
+48|72
+48|77
+48|39
+48|82
+48|93
+48|52
+48|99
+48|92
+48|24
+48|97
+48|68
+48|36
+48|64
+48|19
+48|14
+48|25
+48|11
+48|87
+95|14
+95|76
+95|77
+95|48
+95|93
+95|82
+95|56
+95|19
+95|24
+95|72
+95|11
+95|92
+95|74
+95|25
+95|68
+95|27
+95|87
+95|64
+95|39
+95|47
+95|57
+95|52
+94|33
+94|91
+94|75
+94|14
+94|48
+94|58
+94|63
+94|81
+94|61
+94|39
+94|62
+94|69
+94|97
+94|28
+94|49
+94|55
+94|15
+94|65
+94|95
+94|29
+94|83
+19|91
+19|26
+19|55
+19|81
+19|36
+19|23
+19|65
+19|94
+19|63
+19|17
+19|59
+19|69
+19|33
+19|68
+19|11
+19|49
+19|28
+19|34
+19|15
+19|29
+83|77
+83|95
+83|47
+83|27
+83|39
+83|56
+83|64
+83|23
+83|72
+83|48
+83|82
+83|25
+83|74
+83|97
+83|14
+83|99
+83|52
+83|24
+83|91
+75|56
+75|61
+75|63
+75|52
+75|49
+75|55
+75|91
+75|74
+75|65
+75|97
+75|92
+75|48
+75|23
+75|95
+75|99
+75|72
+75|93
+75|47
+59|15
+59|33
+59|28
+59|49
+59|81
+59|91
+59|17
+59|58
+59|61
+59|62
+59|26
+59|75
+59|63
+59|56
+59|83
+59|29
+59|48
+77|75
+77|33
+77|63
+77|81
+77|19
+77|55
+77|27
+77|98
+77|17
+77|36
+77|87
+77|59
+77|94
+77|69
+77|29
+77|68
+72|59
+72|94
+72|99
+72|77
+72|11
+72|68
+72|36
+72|24
+72|62
+72|25
+72|82
+72|15
+72|17
+72|64
+72|27
+87|19
+87|83
+87|68
+87|98
+87|59
+87|81
+87|34
+87|28
+87|55
+87|36
+87|26
+87|62
+87|75
+87|15
+99|17
+99|15
+99|26
+99|36
+99|33
+99|98
+99|25
+99|87
+99|57
+99|82
+99|59
+99|11
+99|62
+98|75
+98|56
+98|33
+98|93
+98|49
+98|95
+98|29
+98|65
+98|52
+98|48
+98|83
+98|58
+14|77
+14|24
+14|97
+14|92
+14|52
+14|57
+14|59
+14|72
+14|82
+14|47
+14|74
+27|28
+27|75
+27|63
+27|59
+27|34
+27|81
+27|62
+27|33
+27|11
+27|15
+97|47
+97|77
+97|68
+97|93
+97|76
+97|92
+97|19
+97|26
+97|34
+82|15
+82|26
+82|33
+82|27
+82|17
+82|98
+82|59
+82|75
+63|82
+63|97
+63|49
+63|24
+63|23
+63|99
+63|74
+24|25
+24|94
+24|26
+24|64
+24|87
+24|62
+15|39
+15|97
+15|56
+15|98
+15|93
+52|15
+52|99
+52|17
+52|77
+91|49
+91|74
+91|27
+74|64
+74|99
+34|26
+
+62,15,81,98,69,29,75,63,65,83,91,58,61,95,48,14,97,39,92
+83,23,49,58,61,95,48,97,39,92,47,25,77
+27,26,19,69,94,34,99,87,25
+47,14,27,24,77,19,76,34,72,57,36,74,97,99,93,82,52,68,87,64,25
+64,99,25,77,27,87,57,19,68,11,34,36,26,17,94,62,81,98,33
+28,62,15,98,33,69,29,75,55,83,91,49,58,95,56,14,97
+63,23,39,69,61,65,49
+82,25,77,27,76,87,57,19,68,11,34,36,26,17,94,28,15,81,33,69,29
+58,49,63,91,29,98,83,55,36,69,15,33,26,65,17,94,34,59,75,61,28,23,62
+97,47,58,61,24,93,95,56,25,92,72,64,74,14,39,23,99,83,48
+28,91,55,75,81,23,58,33,59,36,29,62,83,98,65,11,63,94,49,34,26,15,69
+93,52,47,24,99,77,27,76,87,57,68,11,59,26,28
+47,64,25,77,27,76,87,11,34,26,17
+74,52,24,27,34,26,94
+25,17,19,76,15,59,26,57,27,69,81,94,62,36,99,98,28,87,11,77,68,33,34
+91,49,58,61,95,56,14,97,39,92,74,93,52,72,47,24,64,99,82,25,77,27,76
+99,25,77,87,57,19,68,11,34,36,59,26,17,94,28,62,15,81,98,33,69
+24,64,99,82,25,77,76,87,57,19,68,11,34,36,59,26,17,94,28,62,15,81,98
+47,26,15,64,82,25,59,17,34,28,87,11,99,57,19,27,24,62,68
+58,56,39,72,24,77,27,87,57
+26,23,17,63,75,81,59
+52,39,77,24,72,27,47,97,82,93,14,23,92
+93,52,61,69,75,39,98
+65,49,58,39,74,92,56,82,72
+58,95,56,48,14,74,93,52,47,24,64,99,77,27,57
+92,93,49,72,48,58,91,75,65,14,74,39,63,83,61,29,55,23,97
+74,64,82,19,87,57,24,56,76,52,93,27,25,92,72
+19,72,56,99,87,48,76,27,92,77,95,52,68
+57,34,94,98,55
+76,87,19,68,11,34,36,59,62,81,69,75,55,63,65
+48,99,64,92,39,74,49,93,47,24,14,52,72,87,82,58,27
+68,81,29,65,83,23,49
+49,56,62,98,61,69,59,63,23,29,83,81,65,26,17
+29,28,49,11,63,26,94
+63,14,92,24,64,99,82
+64,76,25,72,87,27,97,99,52,34,82,92,68
+58,81,33,91,75,63,74,93,65
+25,87,19,11,34,59,33,29,75
+17,25,59,11,99,57,36
+62,15,98,33,69,29,75,63,83,23,91,49,58,95,56,48,97
+97,92,93,52,72,47,24,64,99,25,77,76,87,57,19,34,59
+52,72,47,82,25,27,76,87,68,11,36,59,94,28,62
+29,59,87,76,36,68,94,28,33,27,77
+92,93,77,27,57,68,11
+93,64,39,92,63,72,82,48,14,65,52,58,24
+72,47,11,34,59,94,15
+33,55,65,49,56,48,14,97,92,74,72
+17,69,83,34,62,49,63,15,59,94,11,28,33,58,55,23,81
+34,61,26,59,91,23,49
+19,68,34,94,81,33,23
+52,24,99,82,25,87,57,59,62
+48,14,97,39,92,74,93,52,24,99,82,25,27,87,57,19,68,11,34
+55,64,39,95,49,24,65,75,23
+63,83,61,93,52,24,82
+62,33,14,48,81,95,15,75,63,69,49,56,65,97,61,23,29,28,58,91,39
+97,39,52,25,27
+33,36,28,17,25,62,81,76,27,19,64
+97,15,98,33,91,65,56,29,74
+29,63,65,47,69,39,49
+36,59,17,94,62,81,98,55,63,83,23,91,58
+95,52,76,14,99,19,48,39,92,82,24,57,74
+64,25,76,68,34,36,59,15,33
+64,39,47,92,87,93,82,24,72,74,48,97,27,14,19,25,11,52,56
+39,92,74,93,52,72,47,24,99,82,25,77,27,76,87,57,19,68,11,34,36,59,26
+94,28,62,15,81,98,33,69,29,75,55,63,83,23,91,49,58,61,95,48,97
+69,63,34,58,33,49,29,75,81,23,26,94,15,65,28,59,17,98,83,61,36
+49,58,95,56,48,14,97,74,93,52,47,24,64,99,25,77,27,76,87
+97,92,74,93,52,72,24,64,99,82,25,77,27,76,87,19,68,11,34,36,59
+56,48,99,91,47,39,23,65,92,64,93,74,49,24,61,58,52,83,97,72,82,14,95
+47,99,82,25,11,34,26,17,62,15,81
+93,82,24,39,64,74,27,97,48,72,56,61,19
+39,52,25,77,76,19,34,36,26
+99,76,87,57,19,68,28,62,69
+76,62,99,82,59,11,27,98,17,57,68,87,77,81,36,19,15,94,34,25,26
+14,33,93,58,49,48,69,63,91,56,29,65,83,39,74,23,61,55,95
+95,48,61,55,75,47,49,56,69
+65,17,59,56,75,55,83,62,15,29,98
+17,94,81,98,33,75,55,63,23,58,61
+48,25,58,24,74,92,49,97,99,14,39,77,64,52,56,61,76,95,91,72,27
+58,29,14,52,95,48,65,75,49,98,69,63,23
+19,68,34,36,94,81,65,83,91
+72,47,24,64,25,27,76,87,57,68,11,36,59,26,94,62,15
+19,34,59,98,69,75,55,83,91
+62,98,29,55,63,65,83,49,58,56,39
+47,72,24,95,93,83,56,91,52,64,77
+36,26,94,15,81,98,33,29,75,63,65,83,23,91,49,61,95
+65,83,23,58,48,97,39,74,72,99,82
+39,34,27,25,47,93,72,92,99,11,74,19,76,24,97,77,57,14,64,48,68,82,52
+75,55,23,91,58,61,56,48,14,97,93,52,72,24,64
+24,27,26,82,93,34,99,72,92,59,74,57,39,76,11,47,36
+64,25,77,76,87,11,36,17,94,28,62,15,81,98,33
+33,28,87,81,83,36,19,63,62,55,68,75,17,15,34,26,94,57,59
+27,76,87,57,19,68,11,34,36,59,26,17,94,28,62,15,81,98,33,69,75,55,63
+76,11,36,59,17,94,15,98,65
+62,57,68,98,11,81,33,59,63,26,19,15,27,29,76
+55,63,65,83,23,91,49,58,48,14,97,92,93,52,72,47,99
+23,52,29,48,39,14,91,93,58,49,61,63,72,74,69,95,65,55,56
+68,87,48,25,95,19,56
+52,72,47,24,64,99,82,25,27,57,34,59,17,94,62
+95,74,25,56,48,87,64,99,47,93,27,52,97,14,77,57,24
+27,87,57,11,34,26,94,28,15,98,33,69,29,75,63
+59,17,94,81,98,69,55,65,23,91,61,95,56
+74,93,36,57,14,34,87
+25,77,76,87,57,19,68,11,36,59,26,17,94,28,81,98,33,69,75
+97,75,39,14,24,56,95,63,65,48,64,23,83,74,61
+26,94,28,62,81,98,33,29,75,55,63,83,91,61,95
+75,55,63,58,29,62,23,91,95,49,65,48,92,15,81
+33,69,29,75,55,63,65,83,23,49,58,61,95,56,48,14,97,39,92,74,93,52,72
+17,56,81,94,91,15,14,62,23
+97,52,72,47,82,27,87,57,34,36,59
+69,55,63,83,23,58,61,56,14,39,92,74,93
+69,68,55,33,63,94,27,75,34,81,87,28,15,19,36,17,57
+39,92,74,87,25,77,36,72,57,76,64,68,26,93,34,47,99
+24,76,26,52,34,19,47,94,59,25,68,11,93,99,87,82,36,17,64,57,27,74,72
+48,24,99,82,25,77,57,11,34
+15,29,75,65,61,48,92
+77,76,75,87,28,94,27,59,57,33,55,81,17,11,29,19,36
+76,87,19,68,11,34,36,59,26,94,28,62,15,81,98,33,69,29,75,55,65
+26,19,87,47,17
+63,65,83,23,91,49,58,61,95,56,48,14,97,39,92,74,93,52,72,47,64,99,82
+61,25,92,52,58,39,47,97,82,72,56,77,64,74,24,14,93,91,23,27,48,99,95
+65,63,15,75,49,81,23,17,68,83,33,36,69,28,94,98,62,91,26,29,59
+91,98,69,97,63,58,49,83,65,61,48,56,23,29,95,52,74
+28,63,61,94,75,97,55,49,23,15,83,62,58,48,69,65,95,98,91
+99,87,17,74,26,25,92,11,57,59,64,77,72,24,76,93,47,19,52,82,27,36,34
+55,65,49,48,97,74,52,47,99
+26,17,28,62,15,81,98,33,69,29,75,55,63,65,83,23,91,49,58,61,95,56,48
+11,26,87,47,57,64,72,92,34
+47,24,64,99,82,77,76,57,68,11,34,59,26,94,62
+61,65,28,75,91,97,62,29,58,56,83,48,81,39,69,95,98
+57,76,75,69,11,77,87,33,62,94,98,26,25,15,36,59,27,28,81,34,19
+99,82,25,77,27,76,87,57,19,68,11,34,36,59,26,17,94,28,62,15,81,33,69
+55,83,23,91,58,61,48,14,39,92,93,47,24,64,99
+62,15,81,98,69,29,75,55,63,65,83,91,49,58,95,56,14,39,92
+52,64,99,48,82,92,47,97,61,58,76,24,25
+94,28,15,81,33,69,29,65,83,23,49,58,61,14,97
+97,24,14,23,58,39,82,92,74,52,61,64,65,91,83
+77,27,19,34,15,81,55
+95,65,83,28,59,98,36,55,91,62,81,33,17,29,94,75,69,23,58
+68,17,94,28,62,15,81,33,69,75,55,63,49
+28,76,33,64,99,34,94
+94,75,26,11,29,34,27,59,76,55,63,36,68,69,62
+63,65,83,23,91,49,58,61,95,56,48,14,39,92,74,93,52,72,47,24,64,99,82
+24,68,92,95,19,72,57,64,56,93,52,97,48,74,27,99,87,77,76
+52,24,25,27,76,87,19,68,11,59,26,94,62
+59,47,64,57,99,87,25,68,19,24,92,39,82,97,34
+83,23,91,49,58,61,95,56,48,14,97,39,92,74,93,52,72,47,24,64,99,82,25
+58,95,56,14,93,52,72,99,27,87,57
+29,55,65,83,23,91,49,58,61,95,48,14,97,39,92,93,52,72,24
+91,49,56,97,92,93,82,77,76
+77,82,68,25,81
+81,69,75,55,63,65,83,23,91,61,56,14,97,74,93
+93,29,58,92,24,61,95,72,91,97,23,56,55,14,65
+25,92,36,34,72,39,26
+99,34,82,57,52,59,19,25,72,93,74,64,47,36,24,97,68,87,39,11,27,77,92
+64,27,76,19,36,59,26,94,33
+25,64,87,52,72,97,77,92,57,48,34
+98,33,69,29,75,55,63,65,83,23,91,49,58,61,56,48,97,39,92,93,52
+59,23,91,49,58
+11,36,94,28,69,55,65,23,91
+26,28,15,81,33,69,29,55,63,65,23,91,49,58,95,56,48
+25,36,93,77,68,64,99,92,57,19,14,74,82
+87,26,59,83,98,65,81,69,62
+27,17,75,11,59,55,34,68,26,33,63,19,29,69,36,28,94,87,15,81,98,62,76
+83,11,91,58,26,34,69
+52,47,24,64,25,77,59,28,62
+75,55,65,83,49,61,92,74,72
+93,19,48,34,25,47,64
+14,97,39,57,68,34,36
+91,62,26,98,49,61,15,17,69,81,23,83,48,56,95,63,94,28,55,58,75
+61,99,52,74,39,93,25,72,91,58,92,23,82,48,47,56,14
+68,26,99,15,64
+69,94,91,48,63,98,75,23,62,26,61,55,65,83,15,56,95
+26,17,94,28,62,15,81,98,75,55,65,83,23,91,58,61,95,56,48
+47,64,58,97,91,14,49,72,52,25,92,24,23,61,93,95,56,99,27,48,77
+28,58,49,81,75,11,15,55,59
+81,33,93,91,48,98,75,61,58
+29,81,75,65,63,58,61,15,62,95,39,92,55,56,49,23,48,91,97,83,69,33,14
+81,98,33,29,75,65,23,95,56,48,97,39,92,74,93
+63,61,55,58,74,72,52,48,65,69,29,23,91,95,92,97,47
+65,81,17,49,69
+92,74,93,52,72,47,24,99,77,76,19,34,36
+92,55,23,39,47,56,72,24,75,93,91,83,52,14,63,74,29
+91,72,56,64,95,47,75
+17,94,27,99,24,82,68,47,64,62,28,77,59,26,36,76,87,34,57
+14,97,92,74,93,47,24,82,77,57,11,34,36
+81,15,76,87,33,28,94,98,75,27,68,55,36,62,77,11,29,69,34
+97,83,23,29,55,58,75,52,91,56,72,61,65,24,74,48,93,92,63
+76,87,57,19,68,11,34,36,59,17,94,28,62,15,81,98,33,69,29,75,55,63,65
+61,95,56,14,39,72,47,24,25,77,87,57,19
+15,23,81,63,59,34,61,91,28,29,65,83,17,55,75,62,98,94,26,33,58,69,49
+82,25,77,27,76,87,57,19,68,11,34,36,59,17,94,28,62,15,81,98,33,69,29
+95,56,48,39,92,93,52,72,47,24,64,82,25,27,76,87,57,19,68
+49,58,92,93,24,64,82,76,87
+49,72,74,93,24,48,99
+59,26,17,94,28,62,15,81,98,33,69,29,75,55,63,65,83,23,91,49,56
+58,15,59,33,65,23,17,95,94,49,28,91,62,69,98
+17,94,28,62,33,69,23,58,56
+59,94,15,98,29,75,23,91,49,58,61,95,56
+34,28,15,76,98,24,57,26,87
+82,27,15,17,64,34,87,57,68,72,24,77,25,19,94,47,36,62,26,59,28,11,99
+93,48,64,14,75,58,97,49,55
+69,55,63,23,91,49,92,72,47
+34,19,36,68,99,69,27,28,81,59,62,87,82
+48,92,52,24,64,99,82,77,76,87,57,11,34
+23,75,91,15,63,55,33,48,61,98,74
+24,76,77,99,27,25,14,92,47,95,87,64,52,56,39,72,49
+64,99,82,25,77,27,76,87,57,19,68,11,34,36,59,26,17,94,28,62,15,81,98
diff --git a/day5/example.txt b/day5/example.txt
new file mode 100644
index 0000000..63daad3
--- /dev/null
+++ b/day5/example.txt
@@ -0,0 +1,28 @@
+47|53
+97|13
+97|61
+97|47
+75|29
+61|13
+75|53
+29|13
+97|29
+53|29
+61|53
+97|53
+61|29
+47|13
+75|47
+97|75
+47|61
+75|61
+47|29
+75|13
+53|13
+
+75,47,61,53,29
+97,61,53,29,13
+75,29,13
+75,97,47,61,53
+61,13,29
+97,13,75,29,47
diff --git a/day5/go.mod b/day5/go.mod
new file mode 100644
index 0000000..db206d1
--- /dev/null
+++ b/day5/go.mod
@@ -0,0 +1,3 @@
+module stevenlr.com/aoc2024/day5
+
+go 1.22.2
diff --git a/day5/main.go b/day5/main.go
new file mode 100644
index 0000000..1dd1672
--- /dev/null
+++ b/day5/main.go
@@ -0,0 +1,113 @@
+package main
+
+import (
+ "bufio"
+ "fmt"
+ "os"
+ "slices"
+ "sort"
+ "strconv"
+ "strings"
+)
+
+func main() {
+ fmt.Println(doTheThing("example.txt"))
+ fmt.Println(doTheThing("data.txt"))
+}
+
+func fill[T any](s []T, value T) {
+ for i := range s {
+ s[i] = value
+ }
+}
+
+func doTheThing(fileName string) (resultPart1, resultPart2 int) {
+ fp, err := os.Open(fileName)
+ if err != nil {
+ panic(err)
+ }
+
+ scanner := bufio.NewScanner(fp)
+ forbiddenAfter := readForbiddenAfter(scanner)
+ seen := make([]bool, 100)
+ forbidden := make([]bool, 100)
+
+ for scanner.Scan() {
+ seq := readLine(strings.TrimSpace(scanner.Text()))
+ fill(seen, false)
+ fill(forbidden, false)
+
+ ok := true
+
+ for _, n := range seq {
+ if seen[n] {
+ continue
+ }
+
+ if forbidden[n] {
+ ok = false
+ break
+ }
+
+ for _, f := range forbiddenAfter[n] {
+ forbidden[f] = true
+ }
+
+ seen[n] = true
+ }
+
+ if ok {
+ resultPart1 += seq[len(seq)/2]
+ } else {
+ sort.Slice(seq, func(i, j int) bool {
+ return slices.Index(forbiddenAfter[seq[j]], seq[i]) != -1
+ })
+ resultPart2 += seq[len(seq)/2]
+ }
+ }
+
+ return
+}
+
+func readLine(s string) (line []int) {
+ split := strings.Split(s, ",")
+ line = make([]int, len(split))
+ for i, num := range split {
+ n, err := strconv.Atoi(num)
+ if err != nil {
+ panic(err)
+ }
+ line[i] = n
+ }
+ return
+}
+
+func readForbiddenAfter(scanner *bufio.Scanner) (forbiddenAfter map[int][]int) {
+ forbiddenAfter = make(map[int][]int)
+
+ for scanner.Scan() {
+ line := strings.TrimSpace(scanner.Text())
+ if len(line) == 0 {
+ return
+ }
+
+ split := strings.Split(line, "|")
+ if len(split) != 2 {
+ panic("Not enough data for ordering")
+ }
+
+ a, err := strconv.Atoi(split[0])
+ if err != nil {
+ panic(err)
+ }
+
+ b, err := strconv.Atoi(split[1])
+ if err != nil {
+ panic(err)
+ }
+
+ forbiddenAfter[b] = append(forbiddenAfter[b], a)
+ }
+
+ return
+}