Add shared util.zig file

This commit is contained in:
Martin Wickham 2021-11-23 23:08:22 -06:00
parent 510ff33dd7
commit 0947abe4f4
26 changed files with 63 additions and 50 deletions

View file

@ -7,8 +7,8 @@ const HashMap = std.AutoHashMap;
const StringHashMap = std.StringHashMap; const StringHashMap = std.StringHashMap;
const BitSet = std.DynamicBitSet; const BitSet = std.DynamicBitSet;
var gpa_impl = std.heap.GeneralPurposeAllocator(.{}){}; const util = @import("util.zig");
const gpa = &gpa_impl.allocator; const gpa = util.gpa;
const data = @embedFile("../data/day01.txt"); const data = @embedFile("../data/day01.txt");

View file

@ -7,8 +7,8 @@ const HashMap = std.AutoHashMap;
const StringHashMap = std.StringHashMap; const StringHashMap = std.StringHashMap;
const BitSet = std.DynamicBitSet; const BitSet = std.DynamicBitSet;
var gpa_impl = std.heap.GeneralPurposeAllocator(.{}){}; const util = @import("util.zig");
const gpa = &gpa_impl.allocator; const gpa = util.gpa;
const data = @embedFile("../data/day02.txt"); const data = @embedFile("../data/day02.txt");

View file

@ -7,8 +7,8 @@ const HashMap = std.AutoHashMap;
const StringHashMap = std.StringHashMap; const StringHashMap = std.StringHashMap;
const BitSet = std.DynamicBitSet; const BitSet = std.DynamicBitSet;
var gpa_impl = std.heap.GeneralPurposeAllocator(.{}){}; const util = @import("util.zig");
const gpa = &gpa_impl.allocator; const gpa = util.gpa;
const data = @embedFile("../data/day03.txt"); const data = @embedFile("../data/day03.txt");

View file

@ -7,8 +7,8 @@ const HashMap = std.AutoHashMap;
const StringHashMap = std.StringHashMap; const StringHashMap = std.StringHashMap;
const BitSet = std.DynamicBitSet; const BitSet = std.DynamicBitSet;
var gpa_impl = std.heap.GeneralPurposeAllocator(.{}){}; const util = @import("util.zig");
const gpa = &gpa_impl.allocator; const gpa = util.gpa;
const data = @embedFile("../data/day04.txt"); const data = @embedFile("../data/day04.txt");

View file

@ -7,8 +7,8 @@ const HashMap = std.AutoHashMap;
const StringHashMap = std.StringHashMap; const StringHashMap = std.StringHashMap;
const BitSet = std.DynamicBitSet; const BitSet = std.DynamicBitSet;
var gpa_impl = std.heap.GeneralPurposeAllocator(.{}){}; const util = @import("util.zig");
const gpa = &gpa_impl.allocator; const gpa = util.gpa;
const data = @embedFile("../data/day05.txt"); const data = @embedFile("../data/day05.txt");

View file

@ -7,8 +7,8 @@ const HashMap = std.AutoHashMap;
const StringHashMap = std.StringHashMap; const StringHashMap = std.StringHashMap;
const BitSet = std.DynamicBitSet; const BitSet = std.DynamicBitSet;
var gpa_impl = std.heap.GeneralPurposeAllocator(.{}){}; const util = @import("util.zig");
const gpa = &gpa_impl.allocator; const gpa = util.gpa;
const data = @embedFile("../data/day06.txt"); const data = @embedFile("../data/day06.txt");

View file

@ -7,8 +7,8 @@ const HashMap = std.AutoHashMap;
const StringHashMap = std.StringHashMap; const StringHashMap = std.StringHashMap;
const BitSet = std.DynamicBitSet; const BitSet = std.DynamicBitSet;
var gpa_impl = std.heap.GeneralPurposeAllocator(.{}){}; const util = @import("util.zig");
const gpa = &gpa_impl.allocator; const gpa = util.gpa;
const data = @embedFile("../data/day07.txt"); const data = @embedFile("../data/day07.txt");

View file

@ -7,8 +7,8 @@ const HashMap = std.AutoHashMap;
const StringHashMap = std.StringHashMap; const StringHashMap = std.StringHashMap;
const BitSet = std.DynamicBitSet; const BitSet = std.DynamicBitSet;
var gpa_impl = std.heap.GeneralPurposeAllocator(.{}){}; const util = @import("util.zig");
const gpa = &gpa_impl.allocator; const gpa = util.gpa;
const data = @embedFile("../data/day08.txt"); const data = @embedFile("../data/day08.txt");

View file

@ -7,8 +7,8 @@ const HashMap = std.AutoHashMap;
const StringHashMap = std.StringHashMap; const StringHashMap = std.StringHashMap;
const BitSet = std.DynamicBitSet; const BitSet = std.DynamicBitSet;
var gpa_impl = std.heap.GeneralPurposeAllocator(.{}){}; const util = @import("util.zig");
const gpa = &gpa_impl.allocator; const gpa = util.gpa;
const data = @embedFile("../data/day09.txt"); const data = @embedFile("../data/day09.txt");

View file

@ -7,8 +7,8 @@ const HashMap = std.AutoHashMap;
const StringHashMap = std.StringHashMap; const StringHashMap = std.StringHashMap;
const BitSet = std.DynamicBitSet; const BitSet = std.DynamicBitSet;
var gpa_impl = std.heap.GeneralPurposeAllocator(.{}){}; const util = @import("util.zig");
const gpa = &gpa_impl.allocator; const gpa = util.gpa;
const data = @embedFile("../data/day10.txt"); const data = @embedFile("../data/day10.txt");

View file

@ -7,8 +7,8 @@ const HashMap = std.AutoHashMap;
const StringHashMap = std.StringHashMap; const StringHashMap = std.StringHashMap;
const BitSet = std.DynamicBitSet; const BitSet = std.DynamicBitSet;
var gpa_impl = std.heap.GeneralPurposeAllocator(.{}){}; const util = @import("util.zig");
const gpa = &gpa_impl.allocator; const gpa = util.gpa;
const data = @embedFile("../data/day11.txt"); const data = @embedFile("../data/day11.txt");

View file

@ -7,8 +7,8 @@ const HashMap = std.AutoHashMap;
const StringHashMap = std.StringHashMap; const StringHashMap = std.StringHashMap;
const BitSet = std.DynamicBitSet; const BitSet = std.DynamicBitSet;
var gpa_impl = std.heap.GeneralPurposeAllocator(.{}){}; const util = @import("util.zig");
const gpa = &gpa_impl.allocator; const gpa = util.gpa;
const data = @embedFile("../data/day12.txt"); const data = @embedFile("../data/day12.txt");

View file

@ -7,8 +7,8 @@ const HashMap = std.AutoHashMap;
const StringHashMap = std.StringHashMap; const StringHashMap = std.StringHashMap;
const BitSet = std.DynamicBitSet; const BitSet = std.DynamicBitSet;
var gpa_impl = std.heap.GeneralPurposeAllocator(.{}){}; const util = @import("util.zig");
const gpa = &gpa_impl.allocator; const gpa = util.gpa;
const data = @embedFile("../data/day13.txt"); const data = @embedFile("../data/day13.txt");

View file

@ -7,8 +7,8 @@ const HashMap = std.AutoHashMap;
const StringHashMap = std.StringHashMap; const StringHashMap = std.StringHashMap;
const BitSet = std.DynamicBitSet; const BitSet = std.DynamicBitSet;
var gpa_impl = std.heap.GeneralPurposeAllocator(.{}){}; const util = @import("util.zig");
const gpa = &gpa_impl.allocator; const gpa = util.gpa;
const data = @embedFile("../data/day14.txt"); const data = @embedFile("../data/day14.txt");

View file

@ -7,8 +7,8 @@ const HashMap = std.AutoHashMap;
const StringHashMap = std.StringHashMap; const StringHashMap = std.StringHashMap;
const BitSet = std.DynamicBitSet; const BitSet = std.DynamicBitSet;
var gpa_impl = std.heap.GeneralPurposeAllocator(.{}){}; const util = @import("util.zig");
const gpa = &gpa_impl.allocator; const gpa = util.gpa;
const data = @embedFile("../data/day15.txt"); const data = @embedFile("../data/day15.txt");

View file

@ -7,8 +7,8 @@ const HashMap = std.AutoHashMap;
const StringHashMap = std.StringHashMap; const StringHashMap = std.StringHashMap;
const BitSet = std.DynamicBitSet; const BitSet = std.DynamicBitSet;
var gpa_impl = std.heap.GeneralPurposeAllocator(.{}){}; const util = @import("util.zig");
const gpa = &gpa_impl.allocator; const gpa = util.gpa;
const data = @embedFile("../data/day16.txt"); const data = @embedFile("../data/day16.txt");

View file

@ -7,8 +7,8 @@ const HashMap = std.AutoHashMap;
const StringHashMap = std.StringHashMap; const StringHashMap = std.StringHashMap;
const BitSet = std.DynamicBitSet; const BitSet = std.DynamicBitSet;
var gpa_impl = std.heap.GeneralPurposeAllocator(.{}){}; const util = @import("util.zig");
const gpa = &gpa_impl.allocator; const gpa = util.gpa;
const data = @embedFile("../data/day17.txt"); const data = @embedFile("../data/day17.txt");

View file

@ -7,8 +7,8 @@ const HashMap = std.AutoHashMap;
const StringHashMap = std.StringHashMap; const StringHashMap = std.StringHashMap;
const BitSet = std.DynamicBitSet; const BitSet = std.DynamicBitSet;
var gpa_impl = std.heap.GeneralPurposeAllocator(.{}){}; const util = @import("util.zig");
const gpa = &gpa_impl.allocator; const gpa = util.gpa;
const data = @embedFile("../data/day18.txt"); const data = @embedFile("../data/day18.txt");

View file

@ -7,8 +7,8 @@ const HashMap = std.AutoHashMap;
const StringHashMap = std.StringHashMap; const StringHashMap = std.StringHashMap;
const BitSet = std.DynamicBitSet; const BitSet = std.DynamicBitSet;
var gpa_impl = std.heap.GeneralPurposeAllocator(.{}){}; const util = @import("util.zig");
const gpa = &gpa_impl.allocator; const gpa = util.gpa;
const data = @embedFile("../data/day19.txt"); const data = @embedFile("../data/day19.txt");

View file

@ -7,8 +7,8 @@ const HashMap = std.AutoHashMap;
const StringHashMap = std.StringHashMap; const StringHashMap = std.StringHashMap;
const BitSet = std.DynamicBitSet; const BitSet = std.DynamicBitSet;
var gpa_impl = std.heap.GeneralPurposeAllocator(.{}){}; const util = @import("util.zig");
const gpa = &gpa_impl.allocator; const gpa = util.gpa;
const data = @embedFile("../data/day20.txt"); const data = @embedFile("../data/day20.txt");

View file

@ -7,8 +7,8 @@ const HashMap = std.AutoHashMap;
const StringHashMap = std.StringHashMap; const StringHashMap = std.StringHashMap;
const BitSet = std.DynamicBitSet; const BitSet = std.DynamicBitSet;
var gpa_impl = std.heap.GeneralPurposeAllocator(.{}){}; const util = @import("util.zig");
const gpa = &gpa_impl.allocator; const gpa = util.gpa;
const data = @embedFile("../data/day21.txt"); const data = @embedFile("../data/day21.txt");

View file

@ -7,8 +7,8 @@ const HashMap = std.AutoHashMap;
const StringHashMap = std.StringHashMap; const StringHashMap = std.StringHashMap;
const BitSet = std.DynamicBitSet; const BitSet = std.DynamicBitSet;
var gpa_impl = std.heap.GeneralPurposeAllocator(.{}){}; const util = @import("util.zig");
const gpa = &gpa_impl.allocator; const gpa = util.gpa;
const data = @embedFile("../data/day22.txt"); const data = @embedFile("../data/day22.txt");

View file

@ -7,8 +7,8 @@ const HashMap = std.AutoHashMap;
const StringHashMap = std.StringHashMap; const StringHashMap = std.StringHashMap;
const BitSet = std.DynamicBitSet; const BitSet = std.DynamicBitSet;
var gpa_impl = std.heap.GeneralPurposeAllocator(.{}){}; const util = @import("util.zig");
const gpa = &gpa_impl.allocator; const gpa = util.gpa;
const data = @embedFile("../data/day23.txt"); const data = @embedFile("../data/day23.txt");

View file

@ -7,8 +7,8 @@ const HashMap = std.AutoHashMap;
const StringHashMap = std.StringHashMap; const StringHashMap = std.StringHashMap;
const BitSet = std.DynamicBitSet; const BitSet = std.DynamicBitSet;
var gpa_impl = std.heap.GeneralPurposeAllocator(.{}){}; const util = @import("util.zig");
const gpa = &gpa_impl.allocator; const gpa = util.gpa;
const data = @embedFile("../data/day24.txt"); const data = @embedFile("../data/day24.txt");

View file

@ -7,8 +7,8 @@ const HashMap = std.AutoHashMap;
const StringHashMap = std.StringHashMap; const StringHashMap = std.StringHashMap;
const BitSet = std.DynamicBitSet; const BitSet = std.DynamicBitSet;
var gpa_impl = std.heap.GeneralPurposeAllocator(.{}){}; const util = @import("util.zig");
const gpa = &gpa_impl.allocator; const gpa = util.gpa;
const data = @embedFile("../data/day25.txt"); const data = @embedFile("../data/day25.txt");

13
src/util.zig Normal file
View file

@ -0,0 +1,13 @@
const std = @import("std");
const Allocator = std.mem.Allocator;
const assert = std.debug.assert;
const print = std.debug.print;
const ArrayList = std.ArrayList;
const HashMap = std.AutoHashMap;
const StringHashMap = std.StringHashMap;
const BitSet = std.DynamicBitSet;
var gpa_impl = std.heap.GeneralPurposeAllocator(.{}){};
pub const gpa = &gpa_impl.allocator;
// Add utility functions here