2020.13. more days setup for that year too

This commit is contained in:
2023-09-28 07:31:43 +02:00
parent b4d5cb3077
commit d1c4e55ac0
19 changed files with 366 additions and 0 deletions
+17
View File
@@ -0,0 +1,17 @@
{
// See https://go.microsoft.com/fwlink/?LinkId=733558
// for the documentation about the tasks.json format
"version": "2.0.0",
"tasks": [
{
"label": "zig build",
"type": "shell",
"command": "zig build",
"problemMatcher": [],
"group": {
"kind": "build",
"isDefault": true
}
}
]
}
View File
View File
View File
View File
+9
View File
@@ -0,0 +1,9 @@
19
37
383
23
13
29
457
41
17
+47
View File
@@ -0,0 +1,47 @@
const input = @embedFile("input.txt");
const std = @import("std");
pub fn main() !void {
var it = std.mem.tokenize(u8, input, "\n");
var busses:[10]u32 = std.mem.zeroes([10:0]u32);
var i: u32 = 0;
while(it.next())
|line|
:(i+=1)
{
busses[i] = (try std.fmt.parseInt(u32, line, 10));
}
std.debug.print("Busses:\n", .{});
for(busses)|bus|{
std.debug.print("{d}\n", .{bus});
}
const start: u32 = 1000391;
var n: u32 = start;
var found = false;
while(n > 0 and !found):(n+=1){
if(n % 1000 == 0)
std.debug.print("Tick: {d}\n", .{n});
for(busses)|bus|{
//skip
if(bus == 0){
continue;
}
if(n % bus == 0){
found = true;
std.debug.print("Found! bus {d}, tick {d}, wait {d}, answer {d}\n", .{bus, n, n - start, (n-start)*bus});
break;
}
}
}
}
View File
View File