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 BitSet = std.DynamicBitSet;
var gpa_impl = std.heap.GeneralPurposeAllocator(.{}){};
const gpa = &gpa_impl.allocator;
const util = @import("util.zig");
const gpa = util.gpa;
const data = @embedFile("../data/day01.txt");

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

@ -7,8 +7,8 @@ const HashMap = std.AutoHashMap;
const StringHashMap = std.StringHashMap;
const BitSet = std.DynamicBitSet;
var gpa_impl = std.heap.GeneralPurposeAllocator(.{}){};
const gpa = &gpa_impl.allocator;
const util = @import("util.zig");
const gpa = util.gpa;
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