2020.13. more days setup for that year too
parent
b4d5cb3077
commit
d1c4e55ac0
@ -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
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
@ -0,0 +1,9 @@
|
||||
19
|
||||
37
|
||||
383
|
||||
23
|
||||
13
|
||||
29
|
||||
457
|
||||
41
|
||||
17
|
||||
@ -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;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,68 @@
|
||||
773 8257624 1656010777849708842 165bdfadf35d36ec9e3612f491986b43 /home/sherwood/Documents/zig/aoc2021/day1.zig
|
||||
2933 8257687 1656010785483177218 ed590b856fad29321ebd8190c7cf6de5 /home/sherwood/Documents/zig/aoc2021/zig-cache/o/12fc362c463e88c18830fb03770b9180/builtin.zig
|
||||
5391 5114614 1648297862000000000 99c935b1fadc1095742d1049c16b1f73 /usr/lib/zig/std/std.zig
|
||||
5444 5376446 1648297862000000000 4850b131f27e1df09384f72e7db58d56 /usr/lib/zig/std/special/test_runner.zig
|
||||
5391 5114614 1648297862000000000 99c935b1fadc1095742d1049c16b1f73 /usr/lib/zig/std/std.zig
|
||||
26206 5114562 1648297862000000000 dbc4cb0419e16d4a31e572375da82b3e /usr/lib/zig/std/builtin.zig
|
||||
5444 5376446 1648297862000000000 4850b131f27e1df09384f72e7db58d56 /usr/lib/zig/std/special/test_runner.zig
|
||||
21855 5114612 1648297862000000000 afc30f6da0dcf13f4d3062af48b3ac43 /usr/lib/zig/std/start.zig
|
||||
61008 5114615 1648297862000000000 5b49cc22b6b033715b219b2e4c6df7ac /usr/lib/zig/std/target.zig
|
||||
88870 5376464 1648297862000000000 a4e267754cdf9c71d18dca0dfe685156 /usr/lib/zig/std/target/x86.zig
|
||||
57659 5114591 1648297862000000000 db42026211aa4121bafe18a7268b343c /usr/lib/zig/std/math.zig
|
||||
33618 5114593 1648297862000000000 46535ad7f6a05d9584884e7b8ee186ce /usr/lib/zig/std/meta.zig
|
||||
69235 5114570 1648297862000000000 0d3521a7b6366f64005e31da1083e0b7 /usr/lib/zig/std/debug.zig
|
||||
107395 5114592 1648297862000000000 fcbd1b4b8725bfa78591bba05d9c2d70 /usr/lib/zig/std/mem.zig
|
||||
9813 8257684 1656009313645228950 9f2da8c2d2eda4602a5f35d2f9b80f6b /home/sherwood/Documents/zig/aoc2021/input1
|
||||
98183 5114580 1648297862000000000 a61ad0621302b9f1305f66f425db3436 /usr/lib/zig/std/fmt.zig
|
||||
17188 5114616 1648297862000000000 d31d5393c80a512e00fee584c23bff45 /usr/lib/zig/std/testing.zig
|
||||
41844 5114541 1648297862000000000 809081a3fa77d0f9424a2b6785a9c119 /usr/lib/zig/std/Thread.zig
|
||||
7904 5375872 1648297862000000000 f3b7ac95f2f098f334cb93310d8796bd /usr/lib/zig/std/Thread/Mutex.zig
|
||||
6493 5114585 1648297862000000000 2f1ab48b0aec09df8c98184641d2023d /usr/lib/zig/std/io.zig
|
||||
118163 5114581 1648297862000000000 5b76f8053fc57aaeea4755fbdbccfc60 /usr/lib/zig/std/fs.zig
|
||||
41888 5376041 1648297862000000000 53274430079e3e9594bd5428d82b9b4a /usr/lib/zig/std/fs/file.zig
|
||||
256538 5114597 1648297862000000000 db7c5a6deb052c7881eba11189dfc18a /usr/lib/zig/std/os.zig
|
||||
152897 5376175 1648297862000000000 e4227e4d75b6a322bbe98b52420692f4 /usr/lib/zig/std/os/linux.zig
|
||||
99977 5376187 1648297862000000000 29efc96c70131a7de02bb2142b49b720 /usr/lib/zig/std/os/linux/io_uring.zig
|
||||
3436 5376081 1648297862000000000 52b506e9785d2910ac0c6dc1bc00339b /usr/lib/zig/std/io/writer.zig
|
||||
13907 5375876 1648297862000000000 8076a44960496763cdf5c3049792e2e9 /usr/lib/zig/std/Thread/StaticResetEvent.zig
|
||||
44172 5114576 1648297862000000000 65ec5ab92c40065cd449953a6e6f852b /usr/lib/zig/std/elf.zig
|
||||
12226 5376197 1648297862000000000 ff3e45103aa47b16470414986abd383b /usr/lib/zig/std/os/linux/tls.zig
|
||||
30557 5376170 1648297862000000000 65c11e31a62933504f717be9e26f88d4 /usr/lib/zig/std/mem/Allocator.zig
|
||||
83618 5114583 1648297862000000000 58d5c5778b4baa1368571fa84697db80 /usr/lib/zig/std/hash_map.zig
|
||||
42277 5114571 1648297862000000000 bb8aca7bf5ec61c47aca7b6ebf08cb94 /usr/lib/zig/std/dwarf.zig
|
||||
52325 5114543 1648297862000000000 83b54eba3ec17b5646e8ef82d50bfb55 /usr/lib/zig/std/array_list.zig
|
||||
16198 5376199 1648297862000000000 33eeeaeaf18fad72f964812980a410e5 /usr/lib/zig/std/os/linux/x86_64.zig
|
||||
5853 5376070 1648297862000000000 e4ebd554fff4f4347909d2e820cd323d /usr/lib/zig/std/io/fixed_buffer_stream.zig
|
||||
26615 5376076 1648297862000000000 e3a5103fb13d3c32dbaebed1925a90dd /usr/lib/zig/std/io/reader.zig
|
||||
1117 5376077 1648297862000000000 3f2f071b498497f7d54bcfc458d51f5e /usr/lib/zig/std/io/seekable_stream.zig
|
||||
15524 5114587 1648297862000000000 fd35bd5ce692e376140efff780ae8fd9 /usr/lib/zig/std/leb128.zig
|
||||
3578 5114574 1648297862000000000 5be2b73bab9064c8b8fd700243bac785 /usr/lib/zig/std/dwarf/TAG.zig
|
||||
6494 5114572 1648297862000000000 bbb5283cec1c0d8bce4f3f0c930e7958 /usr/lib/zig/std/dwarf/AT.zig
|
||||
50424 5376043 1648297862000000000 12a03d3246107a6495b60c6a625c29a9 /usr/lib/zig/std/fs/path.zig
|
||||
7889 5376183 1648297862000000000 562fc4eee397a5037d16dffd5e048cd4 /usr/lib/zig/std/os/linux/errno/generic.zig
|
||||
19105 5376172 1648297862000000000 45e8137f667bfff4502578f66d4be5a5 /usr/lib/zig/std/meta/trait.zig
|
||||
32421 5114618 1648297862000000000 16ca37fd4f5ff96730ce35daff9ee049 /usr/lib/zig/std/unicode.zig
|
||||
1314 5114582 1648297862000000000 241bc6f0b7b0f07237a5e145b1d22a8a /usr/lib/zig/std/hash.zig
|
||||
10122 5376054 1648297862000000000 6372ee29c64a8e176138e879d43eb625 /usr/lib/zig/std/hash/wyhash.zig
|
||||
45386 5114584 1648297862000000000 70932a11a45b5bf5a34e6339a8941375 /usr/lib/zig/std/heap.zig
|
||||
4685 5376055 1648297862000000000 bccc2a1210ecea59d9b108bd05b44f4d /usr/lib/zig/std/heap/arena_allocator.zig
|
||||
13435 5114588 1648297862000000000 841107470272eebec404e2b902f8b639 /usr/lib/zig/std/linked_list.zig
|
||||
31592 5114602 1648297862000000000 32ddd57f125944112ecd368187c91caa /usr/lib/zig/std/process.zig
|
||||
14238 5114575 1648297862000000000 cfb89feb086c19f15610196212a5b39a /usr/lib/zig/std/dynamic_library.zig
|
||||
9321 5375873 1648297862000000000 6375a03982cbb853a43d3e581d5e5500 /usr/lib/zig/std/Thread/ResetEvent.zig
|
||||
932 5114578 1648297862000000000 b4c3b5276113dacf836baae9d9f94c34 /usr/lib/zig/std/event.zig
|
||||
68675 5376031 1648297862000000000 c63f2338b6b028fe35892da44a377363 /usr/lib/zig/std/event/loop.zig
|
||||
2956 5114545 1648297862000000000 224c7ee868b5251b2fb3a38a139de8ff /usr/lib/zig/std/atomic.zig
|
||||
12142 5114547 1648297862000000000 960f31a28097b764cc5fbb0f9205d56e /usr/lib/zig/std/atomic/queue.zig
|
||||
22970 5114546 1648297862000000000 2809286560339082772669bb49d3d305 /usr/lib/zig/std/atomic/Atomic.zig
|
||||
10892 5114617 1648297862000000000 31fc51ed299a6e4baa67fa98f200e96a /usr/lib/zig/std/time.zig
|
||||
7373 5375869 1648297862000000000 4d373c2c86127a7ec0f7b3ba579f054c /usr/lib/zig/std/Thread/AutoResetEvent.zig
|
||||
5836 5114548 1648297862000000000 7d2404322fa027582c27f4f202ec6a58 /usr/lib/zig/std/atomic/stack.zig
|
||||
13798 5114539 1648297862000000000 70e9de54160eeb6871485cdaa3755d2e /usr/lib/zig/std/Progress.zig
|
||||
53692 5376056 1648297862000000000 a60642142bf23cc7e76febab706572ec /usr/lib/zig/std/heap/general_purpose_allocator.zig
|
||||
6454 5376156 1648297862000000000 5472dbfd6542719a2f23c0d565670e4e /usr/lib/zig/std/math/log2.zig
|
||||
9090 5114589 1648297862000000000 1180d90b55f45cb947269ff038108378 /usr/lib/zig/std/log.zig
|
||||
3884 5376198 1648297862000000000 3d5de21815d6358b2673061efe48f78d /usr/lib/zig/std/os/linux/vdso.zig
|
||||
36229 5114599 1648297862000000000 8dd156aa070c627fc25ef402c82b8cb0 /usr/lib/zig/std/pdb.zig
|
||||
13263 5114565 1648297862000000000 52436f0b55cf344739d85e1b6989e029 /usr/lib/zig/std/coff.zig
|
||||
127499 5376246 1648297862000000000 c34f941bc683d1597ce7899b65ef7fcc /usr/lib/zig/std/os/windows.zig
|
||||
@ -0,0 +1,112 @@
|
||||
const std = @import("std");
|
||||
/// Zig version. When writing code that supports multiple versions of Zig, prefer
|
||||
/// feature detection (i.e. with `@hasDecl` or `@hasField`) over version checks.
|
||||
pub const zig_version = std.SemanticVersion.parse("0.9.1") catch unreachable;
|
||||
/// Temporary until self-hosted is feature complete.
|
||||
pub const zig_is_stage2 = false;
|
||||
/// Temporary until self-hosted supports the `cpu.arch` value.
|
||||
pub const stage2_arch: std.Target.Cpu.Arch = .x86_64;
|
||||
/// Temporary until self-hosted can call `std.Target.x86.featureSetHas` at comptime.
|
||||
pub const stage2_x86_cx16 = true;
|
||||
|
||||
pub const output_mode = std.builtin.OutputMode.Exe;
|
||||
pub const link_mode = std.builtin.LinkMode.Static;
|
||||
pub const is_test = true;
|
||||
pub const single_threaded = false;
|
||||
pub const abi = std.Target.Abi.gnu;
|
||||
pub const cpu: std.Target.Cpu = .{
|
||||
.arch = .x86_64,
|
||||
.model = &std.Target.x86.cpu.znver2,
|
||||
.features = std.Target.x86.featureSet(&[_]std.Target.x86.Feature{
|
||||
.@"64bit",
|
||||
.adx,
|
||||
.aes,
|
||||
.avx,
|
||||
.avx2,
|
||||
.bmi,
|
||||
.bmi2,
|
||||
.branchfusion,
|
||||
.clflushopt,
|
||||
.clwb,
|
||||
.clzero,
|
||||
.cmov,
|
||||
.cx16,
|
||||
.cx8,
|
||||
.f16c,
|
||||
.fast_15bytenop,
|
||||
.fast_bextr,
|
||||
.fast_lzcnt,
|
||||
.fast_movbe,
|
||||
.fast_scalar_shift_masks,
|
||||
.fma,
|
||||
.fsgsbase,
|
||||
.fxsr,
|
||||
.lzcnt,
|
||||
.mmx,
|
||||
.movbe,
|
||||
.mwaitx,
|
||||
.nopl,
|
||||
.pclmul,
|
||||
.popcnt,
|
||||
.prfchw,
|
||||
.rdpid,
|
||||
.rdrnd,
|
||||
.rdseed,
|
||||
.sahf,
|
||||
.sha,
|
||||
.slow_shld,
|
||||
.sse,
|
||||
.sse2,
|
||||
.sse3,
|
||||
.sse4_1,
|
||||
.sse4_2,
|
||||
.sse4a,
|
||||
.ssse3,
|
||||
.vzeroupper,
|
||||
.wbnoinvd,
|
||||
.x87,
|
||||
.xsave,
|
||||
.xsavec,
|
||||
.xsaveopt,
|
||||
.xsaves,
|
||||
}),
|
||||
};
|
||||
pub const os = std.Target.Os{
|
||||
.tag = .linux,
|
||||
.version_range = .{ .linux = .{
|
||||
.range = .{
|
||||
.min = .{
|
||||
.major = 5,
|
||||
.minor = 15,
|
||||
.patch = 48,
|
||||
},
|
||||
.max = .{
|
||||
.major = 5,
|
||||
.minor = 15,
|
||||
.patch = 48,
|
||||
},
|
||||
},
|
||||
.glibc = .{
|
||||
.major = 2,
|
||||
.minor = 19,
|
||||
.patch = 0,
|
||||
},
|
||||
}},
|
||||
};
|
||||
pub const target = std.Target{
|
||||
.cpu = cpu,
|
||||
.os = os,
|
||||
.abi = abi,
|
||||
};
|
||||
pub const object_format = std.Target.ObjectFormat.elf;
|
||||
pub const mode = std.builtin.Mode.Debug;
|
||||
pub const link_libc = false;
|
||||
pub const link_libcpp = false;
|
||||
pub const have_error_return_tracing = true;
|
||||
pub const valgrind_support = true;
|
||||
pub const position_independent_code = false;
|
||||
pub const position_independent_executable = false;
|
||||
pub const strip_debug_info = false;
|
||||
pub const code_model = std.builtin.CodeModel.default;
|
||||
pub var test_functions: []std.builtin.TestFn = undefined; // overwritten later
|
||||
pub const test_io_mode = .blocking;
|
||||
@ -0,0 +1 @@
|
||||
d4b0dcfc8f393265d7d5fdf515cc7c6400
|
||||
Binary file not shown.
Binary file not shown.
@ -0,0 +1,112 @@
|
||||
const std = @import("std");
|
||||
/// Zig version. When writing code that supports multiple versions of Zig, prefer
|
||||
/// feature detection (i.e. with `@hasDecl` or `@hasField`) over version checks.
|
||||
pub const zig_version = std.SemanticVersion.parse("0.9.1") catch unreachable;
|
||||
/// Temporary until self-hosted is feature complete.
|
||||
pub const zig_is_stage2 = false;
|
||||
/// Temporary until self-hosted supports the `cpu.arch` value.
|
||||
pub const stage2_arch: std.Target.Cpu.Arch = .x86_64;
|
||||
/// Temporary until self-hosted can call `std.Target.x86.featureSetHas` at comptime.
|
||||
pub const stage2_x86_cx16 = true;
|
||||
|
||||
pub const output_mode = std.builtin.OutputMode.Exe;
|
||||
pub const link_mode = std.builtin.LinkMode.Static;
|
||||
pub const is_test = true;
|
||||
pub const single_threaded = false;
|
||||
pub const abi = std.Target.Abi.gnu;
|
||||
pub const cpu: std.Target.Cpu = .{
|
||||
.arch = .x86_64,
|
||||
.model = &std.Target.x86.cpu.znver2,
|
||||
.features = std.Target.x86.featureSet(&[_]std.Target.x86.Feature{
|
||||
.@"64bit",
|
||||
.adx,
|
||||
.aes,
|
||||
.avx,
|
||||
.avx2,
|
||||
.bmi,
|
||||
.bmi2,
|
||||
.branchfusion,
|
||||
.clflushopt,
|
||||
.clwb,
|
||||
.clzero,
|
||||
.cmov,
|
||||
.cx16,
|
||||
.cx8,
|
||||
.f16c,
|
||||
.fast_15bytenop,
|
||||
.fast_bextr,
|
||||
.fast_lzcnt,
|
||||
.fast_movbe,
|
||||
.fast_scalar_shift_masks,
|
||||
.fma,
|
||||
.fsgsbase,
|
||||
.fxsr,
|
||||
.lzcnt,
|
||||
.mmx,
|
||||
.movbe,
|
||||
.mwaitx,
|
||||
.nopl,
|
||||
.pclmul,
|
||||
.popcnt,
|
||||
.prfchw,
|
||||
.rdpid,
|
||||
.rdrnd,
|
||||
.rdseed,
|
||||
.sahf,
|
||||
.sha,
|
||||
.slow_shld,
|
||||
.sse,
|
||||
.sse2,
|
||||
.sse3,
|
||||
.sse4_1,
|
||||
.sse4_2,
|
||||
.sse4a,
|
||||
.ssse3,
|
||||
.vzeroupper,
|
||||
.wbnoinvd,
|
||||
.x87,
|
||||
.xsave,
|
||||
.xsavec,
|
||||
.xsaveopt,
|
||||
.xsaves,
|
||||
}),
|
||||
};
|
||||
pub const os = std.Target.Os{
|
||||
.tag = .linux,
|
||||
.version_range = .{ .linux = .{
|
||||
.range = .{
|
||||
.min = .{
|
||||
.major = 5,
|
||||
.minor = 15,
|
||||
.patch = 48,
|
||||
},
|
||||
.max = .{
|
||||
.major = 5,
|
||||
.minor = 15,
|
||||
.patch = 48,
|
||||
},
|
||||
},
|
||||
.glibc = .{
|
||||
.major = 2,
|
||||
.minor = 19,
|
||||
.patch = 0,
|
||||
},
|
||||
}},
|
||||
};
|
||||
pub const target = std.Target{
|
||||
.cpu = cpu,
|
||||
.os = os,
|
||||
.abi = abi,
|
||||
};
|
||||
pub const object_format = std.Target.ObjectFormat.elf;
|
||||
pub const mode = std.builtin.Mode.Debug;
|
||||
pub const link_libc = false;
|
||||
pub const link_libcpp = false;
|
||||
pub const have_error_return_tracing = true;
|
||||
pub const valgrind_support = true;
|
||||
pub const position_independent_code = false;
|
||||
pub const position_independent_executable = false;
|
||||
pub const strip_debug_info = false;
|
||||
pub const code_model = std.builtin.CodeModel.default;
|
||||
pub var test_functions: []std.builtin.TestFn = undefined; // overwritten later
|
||||
pub const test_io_mode = .blocking;
|
||||
Binary file not shown.
Binary file not shown.
Loading…
Reference in New Issue