aboutsummaryrefslogtreecommitdiff
path: root/2022/03-rucksack-reorganization
diff options
context:
space:
mode:
authorJulien Dessaux2022-12-03 14:43:57 +0100
committerJulien Dessaux2022-12-03 14:43:57 +0100
commit02a81148479b1f7891713bc74a6b2ba1c5418baa (patch)
tree84e2b86fa81650b68ff9739c51427ee79a1c3142 /2022/03-rucksack-reorganization
parent2022-02 in befunge! (diff)
downloadadvent-of-code-02a81148479b1f7891713bc74a6b2ba1c5418baa.tar.gz
advent-of-code-02a81148479b1f7891713bc74a6b2ba1c5418baa.tar.bz2
advent-of-code-02a81148479b1f7891713bc74a6b2ba1c5418baa.zip
2022-03 in zig
Diffstat (limited to '')
-rw-r--r--2022/03-rucksack-reorganization/example7
-rw-r--r--2022/03-rucksack-reorganization/first.zig33
-rw-r--r--2022/03-rucksack-reorganization/input301
-rw-r--r--2022/03-rucksack-reorganization/second.zig43
4 files changed, 384 insertions, 0 deletions
diff --git a/2022/03-rucksack-reorganization/example b/2022/03-rucksack-reorganization/example
new file mode 100644
index 0000000..156e424
--- /dev/null
+++ b/2022/03-rucksack-reorganization/example
@@ -0,0 +1,7 @@
+vJrwpWtwJgWrhcsFMMfFFhFp
+jqHRNqRjqzjGDLGLrsFMfFZSrLrFZsSL
+PmmdzqPrVvPwwTWBwg
+wMqvLMZHhHMvwLHjbvcjnnSBnvTQFn
+ttgJtRGJQctTZtZT
+CrZsJsPPZsGzwwsLwLmpwMDw
+
diff --git a/2022/03-rucksack-reorganization/first.zig b/2022/03-rucksack-reorganization/first.zig
new file mode 100644
index 0000000..38c6d0e
--- /dev/null
+++ b/2022/03-rucksack-reorganization/first.zig
@@ -0,0 +1,33 @@
+const std = @import("std");
+
+const example = @embedFile("example");
+const input = @embedFile("input");
+
+pub fn main() anyerror!void {
+ try std.testing.expectEqual(solve(example), 157);
+ const result = try solve(input);
+ try std.io.getStdOut().writer().print("{}\n", .{result});
+}
+
+fn solve(puzzle: []const u8) !u64 {
+ var it = std.mem.tokenize(u8, puzzle, "\n");
+ var tot: u64 = 0;
+ while (it.next()) |line| {
+ var i: usize = 0;
+ var middle = line.len / 2;
+ outer: while (i < middle) : (i += 1) {
+ var j = middle;
+ while (j < line.len) : (j += 1) {
+ if (line[i] == line[j]) {
+ break :outer;
+ }
+ }
+ }
+ if (line[i] <= 'Z') {
+ tot = tot + line[i] - 'A' + 27;
+ } else {
+ tot = tot + line[i] - 'a' + 1;
+ }
+ }
+ return tot;
+}
diff --git a/2022/03-rucksack-reorganization/input b/2022/03-rucksack-reorganization/input
new file mode 100644
index 0000000..595d32a
--- /dev/null
+++ b/2022/03-rucksack-reorganization/input
@@ -0,0 +1,301 @@
+jLnFTjhwFTLFDGDDvLgvDssBJBbVRNZJPPJBGzBNRVJNRB
+QWmffSmMZCfWrmHlCflQWfSNBpVBNbPSbbJNppcVVzzpcp
+lflrqrWMmfdMlrtWWmZgDjsqwFwhFDsngnvhqs
+CNBGwsWVsdWDNCCVvfPLfQfgZHPBvpgf
+qhJqJlmcFnhJclllPgZjvpHpvfZpPbLn
+lpMJJhhcSMDMMwws
+jphtLMfVpjJRjJscMJptssnrwdNwQrNbwNzQTbcNrwQT
+gSPPSqGGGrdLrNQGrr
+PvWPDvWWCSSBBZPjLVDfhjsLLsDhtR
+hlLwDGLNnTrbNdtbdb
+ZfsvJbsJTrsttHTR
+vjPQJPFcmZjVFZFvbbVcJZJPBBhLMnDBznnGMDLMwBhlmBBl
+JdTJFtwHjJTzPMqPccqzjB
+rggffSCvNBCbWBWt
+ZsSpnnRpLStrZpTDwTVwGTJHDLdH
+sZqswsrcRpCrsCsrrbtpbpDlttlFbbpGtj
+LhNgNvNNhTQMhQMWhvvhfWhllbGGPbPtlPmFlDbjHHdlmg
+ffNBNMhDvQDhvzhBhNTBnSzzrZCZnrsVCSwcnrCC
+hHGhjLjwtFGwGhhhhtwjtlhrDBQrRBHczRcMvsBcRrDDMH
+TTfbZdZbPbVCmCdmnZmCVdfrJBczMrrznvBvQBzzzcBscn
+fdbPZTVVfSdm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gTLVVVVLgThCTggg
+NlfHpttqzltMzRSMSdWRNSfSTTmqgcLgQVcQTcmgQgmZVPVZ
+HWSWpMHNpNWlpNMsMzWGGwwBvvwBnwBvsnnvnB
+mZVVHmmRZlvdjvNpHh
+DFBnFDtnFbBMrQbBMvFLvgtjjNpcLpJdNzJJdhWNpJNWcN
+QTsbrQggBsvsgVTwRVGZCfGZfR
+RGNGlGTWJnJlMcRMGqvSmnDtvDDvtLSLvr
+HfsFhPPdVshfbggDVmzcvSwvStVzDq
+BPPfCgCFfcBbPbHbBHZPFsbBpMGlClRNJRlQTjQWjWpTTlGT
+HQNqQbbRQHbZPZQPqbZTvWFWmCjvFRvRTSrRrr
+lBpBpzLLdBwsLwLLWNggzCFTCmFgWmrF
+VwsswGVBfJfccLBcsJGNdpJHZZqnhtqqnhPHDZHVtPQMZn
+LMHnHnPMnFdJFNFJjZvrJF
+wlTlslptlwtzcvTqvTsVSWWrbJfmJZNZJjcNWfNJmf
+qDlqVthTztSSpSlqtpTTzLvRRnnCvRCPLBQGDBdDGD
+HlmlJgRBBpJLpPBHnlLJsrgJDMttvSdddcMSStWjjWtcSzjs
+qfTbNPTVGhGFCVGTwZfNZNNVWvjSczcjStMMcdSczzczvbcW
+GZVqffQTwNQTmPRlggHLprHQ
+BjsWschcTjjWclQTSnZFrjtFtbzZfqntzF
+qggNGMHgvHMRZMtznbrftMCn
+qvHdqpwgJTsVccwscT
+FJwNPHJmPHTJHglTFwgmwqtShBqDmDBzzBzWhCDWqQ
+fpsjNsMVLVjDCCSzBtjztt
+sLrdfbsMcbMRZZZbbsfrsrNgGNglRwllRnJnwFvnFHnG
+lWWVTJlJCTTzDdWzqdtFFt
+PvPvrhbjhgSjvJQSnQRbjZDZFFHMtGGqFtRMGZFtGH
+rhPrSgfvJPfmwsTpLcsV
+
diff --git a/2022/03-rucksack-reorganization/second.zig b/2022/03-rucksack-reorganization/second.zig
new file mode 100644
index 0000000..25375bf
--- /dev/null
+++ b/2022/03-rucksack-reorganization/second.zig
@@ -0,0 +1,43 @@
+const std = @import("std");
+
+const example = @embedFile("example");
+const input = @embedFile("input");
+
+pub fn main() anyerror!void {
+ try std.testing.expectEqual(solve(example), 70);
+ const result = try solve(input);
+ try std.io.getStdOut().writer().print("{}\n", .{result});
+}
+
+fn solve(puzzle: []const u8) !u64 {
+ var it = std.mem.tokenize(u8, puzzle, "\n");
+ var tot: u64 = 0;
+ while (it.next()) |line1| {
+ if (it.next()) |line2| {
+ if (it.next()) |line3| {
+ var i: usize = 0;
+ outer: while (i < line1.len) : (i += 1) {
+ var j: usize = 0;
+ while (j < line2.len) : (j += 1) {
+ if (line1[i] == line2[j]) {
+ var k: usize = 0;
+ while (k < line3.len) : (k += 1) {
+ if (line1[i] == line3[k]) {
+ break :outer;
+ }
+ }
+ continue :outer; // char on line1 was not found in line3
+ }
+ }
+ continue :outer; // char on line1 was not found in line2
+ }
+ if (line1[i] <= 'Z') {
+ tot = tot + line1[i] - 'A' + 27;
+ } else {
+ tot = tot + line1[i] - 'a' + 1;
+ }
+ }
+ }
+ }
+ return tot;
+}