From 504784b28eb573ae0368baeb5865befd729c99e4 Mon Sep 17 00:00:00 2001 From: Martin Wickham Date: Tue, 30 Nov 2021 17:39:45 -0600 Subject: [PATCH] Add aliases for useful std lib functions --- src/day01.zig | 27 +++++++++++++++++++++++++-- src/day02.zig | 27 +++++++++++++++++++++++++-- src/day03.zig | 27 +++++++++++++++++++++++++-- src/day04.zig | 27 +++++++++++++++++++++++++-- src/day05.zig | 27 +++++++++++++++++++++++++-- src/day06.zig | 27 +++++++++++++++++++++++++-- src/day07.zig | 27 +++++++++++++++++++++++++-- src/day08.zig | 27 +++++++++++++++++++++++++-- src/day09.zig | 27 +++++++++++++++++++++++++-- src/day10.zig | 27 +++++++++++++++++++++++++-- src/day11.zig | 27 +++++++++++++++++++++++++-- src/day12.zig | 27 +++++++++++++++++++++++++-- src/day13.zig | 27 +++++++++++++++++++++++++-- src/day14.zig | 27 +++++++++++++++++++++++++-- src/day15.zig | 27 +++++++++++++++++++++++++-- src/day16.zig | 27 +++++++++++++++++++++++++-- src/day17.zig | 27 +++++++++++++++++++++++++-- src/day18.zig | 27 +++++++++++++++++++++++++-- src/day19.zig | 27 +++++++++++++++++++++++++-- src/day20.zig | 27 +++++++++++++++++++++++++-- src/day21.zig | 27 +++++++++++++++++++++++++-- src/day22.zig | 27 +++++++++++++++++++++++++-- src/day23.zig | 27 +++++++++++++++++++++++++-- src/day24.zig | 27 +++++++++++++++++++++++++-- src/day25.zig | 27 +++++++++++++++++++++++++-- src/util.zig | 28 ++++++++++++++++++++++++++-- 26 files changed, 651 insertions(+), 52 deletions(-) diff --git a/src/day01.zig b/src/day01.zig index 919c34c..dcb7274 100644 --- a/src/day01.zig +++ b/src/day01.zig @@ -1,7 +1,5 @@ const std = @import("std"); const Allocator = std.mem.Allocator; -const assert = std.debug.assert; -const print = std.debug.print; const List = std.ArrayList; const Map = std.AutoHashMap; const StrMap = std.StringHashMap; @@ -16,3 +14,28 @@ const data = @embedFile("../data/day01.txt"); pub fn main() !void { } + +// Useful stdlib functions +const tokenize = std.mem.tokenize; +const split = std.mem.split; +const indexOf = std.mem.indexOfScalar; +const indexOfAny = std.mem.indexOfAny; +const indexOfStr = std.mem.indexOfPosLinear; +const lastIndexOf = std.mem.lastIndexOfScalar; +const lastIndexOfAny = std.mem.lastIndexOfAny; +const lastIndexOfStr = std.mem.lastIndexOfLinear; +const trim = std.mem.trim; +const sliceMin = std.mem.min; +const sliceMax = std.mem.max; + +const min = std.math.min; +const min3 = std.math.min3; +const max = std.math.max; +const max3 = std.math.max3; + +const print = std.debug.print; +const assert = std.debug.assert; + +const sort = std.sort.sort; +const asc = std.sort.asc; +const desc = std.sort.desc; diff --git a/src/day02.zig b/src/day02.zig index a272de9..a128d6c 100644 --- a/src/day02.zig +++ b/src/day02.zig @@ -1,7 +1,5 @@ const std = @import("std"); const Allocator = std.mem.Allocator; -const assert = std.debug.assert; -const print = std.debug.print; const List = std.ArrayList; const Map = std.AutoHashMap; const StrMap = std.StringHashMap; @@ -16,3 +14,28 @@ const data = @embedFile("../data/day02.txt"); pub fn main() !void { } + +// Useful stdlib functions +const tokenize = std.mem.tokenize; +const split = std.mem.split; +const indexOf = std.mem.indexOfScalar; +const indexOfAny = std.mem.indexOfAny; +const indexOfStr = std.mem.indexOfPosLinear; +const lastIndexOf = std.mem.lastIndexOfScalar; +const lastIndexOfAny = std.mem.lastIndexOfAny; +const lastIndexOfStr = std.mem.lastIndexOfLinear; +const trim = std.mem.trim; +const sliceMin = std.mem.min; +const sliceMax = std.mem.max; + +const min = std.math.min; +const min3 = std.math.min3; +const max = std.math.max; +const max3 = std.math.max3; + +const print = std.debug.print; +const assert = std.debug.assert; + +const sort = std.sort.sort; +const asc = std.sort.asc; +const desc = std.sort.desc; diff --git a/src/day03.zig b/src/day03.zig index b900bf8..2c61289 100644 --- a/src/day03.zig +++ b/src/day03.zig @@ -1,7 +1,5 @@ const std = @import("std"); const Allocator = std.mem.Allocator; -const assert = std.debug.assert; -const print = std.debug.print; const List = std.ArrayList; const Map = std.AutoHashMap; const StrMap = std.StringHashMap; @@ -16,3 +14,28 @@ const data = @embedFile("../data/day03.txt"); pub fn main() !void { } + +// Useful stdlib functions +const tokenize = std.mem.tokenize; +const split = std.mem.split; +const indexOf = std.mem.indexOfScalar; +const indexOfAny = std.mem.indexOfAny; +const indexOfStr = std.mem.indexOfPosLinear; +const lastIndexOf = std.mem.lastIndexOfScalar; +const lastIndexOfAny = std.mem.lastIndexOfAny; +const lastIndexOfStr = std.mem.lastIndexOfLinear; +const trim = std.mem.trim; +const sliceMin = std.mem.min; +const sliceMax = std.mem.max; + +const min = std.math.min; +const min3 = std.math.min3; +const max = std.math.max; +const max3 = std.math.max3; + +const print = std.debug.print; +const assert = std.debug.assert; + +const sort = std.sort.sort; +const asc = std.sort.asc; +const desc = std.sort.desc; diff --git a/src/day04.zig b/src/day04.zig index 9d54417..9deadf5 100644 --- a/src/day04.zig +++ b/src/day04.zig @@ -1,7 +1,5 @@ const std = @import("std"); const Allocator = std.mem.Allocator; -const assert = std.debug.assert; -const print = std.debug.print; const List = std.ArrayList; const Map = std.AutoHashMap; const StrMap = std.StringHashMap; @@ -16,3 +14,28 @@ const data = @embedFile("../data/day04.txt"); pub fn main() !void { } + +// Useful stdlib functions +const tokenize = std.mem.tokenize; +const split = std.mem.split; +const indexOf = std.mem.indexOfScalar; +const indexOfAny = std.mem.indexOfAny; +const indexOfStr = std.mem.indexOfPosLinear; +const lastIndexOf = std.mem.lastIndexOfScalar; +const lastIndexOfAny = std.mem.lastIndexOfAny; +const lastIndexOfStr = std.mem.lastIndexOfLinear; +const trim = std.mem.trim; +const sliceMin = std.mem.min; +const sliceMax = std.mem.max; + +const min = std.math.min; +const min3 = std.math.min3; +const max = std.math.max; +const max3 = std.math.max3; + +const print = std.debug.print; +const assert = std.debug.assert; + +const sort = std.sort.sort; +const asc = std.sort.asc; +const desc = std.sort.desc; diff --git a/src/day05.zig b/src/day05.zig index ecff690..f673aed 100644 --- a/src/day05.zig +++ b/src/day05.zig @@ -1,7 +1,5 @@ const std = @import("std"); const Allocator = std.mem.Allocator; -const assert = std.debug.assert; -const print = std.debug.print; const List = std.ArrayList; const Map = std.AutoHashMap; const StrMap = std.StringHashMap; @@ -16,3 +14,28 @@ const data = @embedFile("../data/day05.txt"); pub fn main() !void { } + +// Useful stdlib functions +const tokenize = std.mem.tokenize; +const split = std.mem.split; +const indexOf = std.mem.indexOfScalar; +const indexOfAny = std.mem.indexOfAny; +const indexOfStr = std.mem.indexOfPosLinear; +const lastIndexOf = std.mem.lastIndexOfScalar; +const lastIndexOfAny = std.mem.lastIndexOfAny; +const lastIndexOfStr = std.mem.lastIndexOfLinear; +const trim = std.mem.trim; +const sliceMin = std.mem.min; +const sliceMax = std.mem.max; + +const min = std.math.min; +const min3 = std.math.min3; +const max = std.math.max; +const max3 = std.math.max3; + +const print = std.debug.print; +const assert = std.debug.assert; + +const sort = std.sort.sort; +const asc = std.sort.asc; +const desc = std.sort.desc; diff --git a/src/day06.zig b/src/day06.zig index 93bf972..9e8be99 100644 --- a/src/day06.zig +++ b/src/day06.zig @@ -1,7 +1,5 @@ const std = @import("std"); const Allocator = std.mem.Allocator; -const assert = std.debug.assert; -const print = std.debug.print; const List = std.ArrayList; const Map = std.AutoHashMap; const StrMap = std.StringHashMap; @@ -16,3 +14,28 @@ const data = @embedFile("../data/day06.txt"); pub fn main() !void { } + +// Useful stdlib functions +const tokenize = std.mem.tokenize; +const split = std.mem.split; +const indexOf = std.mem.indexOfScalar; +const indexOfAny = std.mem.indexOfAny; +const indexOfStr = std.mem.indexOfPosLinear; +const lastIndexOf = std.mem.lastIndexOfScalar; +const lastIndexOfAny = std.mem.lastIndexOfAny; +const lastIndexOfStr = std.mem.lastIndexOfLinear; +const trim = std.mem.trim; +const sliceMin = std.mem.min; +const sliceMax = std.mem.max; + +const min = std.math.min; +const min3 = std.math.min3; +const max = std.math.max; +const max3 = std.math.max3; + +const print = std.debug.print; +const assert = std.debug.assert; + +const sort = std.sort.sort; +const asc = std.sort.asc; +const desc = std.sort.desc; diff --git a/src/day07.zig b/src/day07.zig index ddc0ef0..591fb37 100644 --- a/src/day07.zig +++ b/src/day07.zig @@ -1,7 +1,5 @@ const std = @import("std"); const Allocator = std.mem.Allocator; -const assert = std.debug.assert; -const print = std.debug.print; const List = std.ArrayList; const Map = std.AutoHashMap; const StrMap = std.StringHashMap; @@ -16,3 +14,28 @@ const data = @embedFile("../data/day07.txt"); pub fn main() !void { } + +// Useful stdlib functions +const tokenize = std.mem.tokenize; +const split = std.mem.split; +const indexOf = std.mem.indexOfScalar; +const indexOfAny = std.mem.indexOfAny; +const indexOfStr = std.mem.indexOfPosLinear; +const lastIndexOf = std.mem.lastIndexOfScalar; +const lastIndexOfAny = std.mem.lastIndexOfAny; +const lastIndexOfStr = std.mem.lastIndexOfLinear; +const trim = std.mem.trim; +const sliceMin = std.mem.min; +const sliceMax = std.mem.max; + +const min = std.math.min; +const min3 = std.math.min3; +const max = std.math.max; +const max3 = std.math.max3; + +const print = std.debug.print; +const assert = std.debug.assert; + +const sort = std.sort.sort; +const asc = std.sort.asc; +const desc = std.sort.desc; diff --git a/src/day08.zig b/src/day08.zig index e844618..d876eea 100644 --- a/src/day08.zig +++ b/src/day08.zig @@ -1,7 +1,5 @@ const std = @import("std"); const Allocator = std.mem.Allocator; -const assert = std.debug.assert; -const print = std.debug.print; const List = std.ArrayList; const Map = std.AutoHashMap; const StrMap = std.StringHashMap; @@ -16,3 +14,28 @@ const data = @embedFile("../data/day08.txt"); pub fn main() !void { } + +// Useful stdlib functions +const tokenize = std.mem.tokenize; +const split = std.mem.split; +const indexOf = std.mem.indexOfScalar; +const indexOfAny = std.mem.indexOfAny; +const indexOfStr = std.mem.indexOfPosLinear; +const lastIndexOf = std.mem.lastIndexOfScalar; +const lastIndexOfAny = std.mem.lastIndexOfAny; +const lastIndexOfStr = std.mem.lastIndexOfLinear; +const trim = std.mem.trim; +const sliceMin = std.mem.min; +const sliceMax = std.mem.max; + +const min = std.math.min; +const min3 = std.math.min3; +const max = std.math.max; +const max3 = std.math.max3; + +const print = std.debug.print; +const assert = std.debug.assert; + +const sort = std.sort.sort; +const asc = std.sort.asc; +const desc = std.sort.desc; diff --git a/src/day09.zig b/src/day09.zig index 95702e7..1735350 100644 --- a/src/day09.zig +++ b/src/day09.zig @@ -1,7 +1,5 @@ const std = @import("std"); const Allocator = std.mem.Allocator; -const assert = std.debug.assert; -const print = std.debug.print; const List = std.ArrayList; const Map = std.AutoHashMap; const StrMap = std.StringHashMap; @@ -16,3 +14,28 @@ const data = @embedFile("../data/day09.txt"); pub fn main() !void { } + +// Useful stdlib functions +const tokenize = std.mem.tokenize; +const split = std.mem.split; +const indexOf = std.mem.indexOfScalar; +const indexOfAny = std.mem.indexOfAny; +const indexOfStr = std.mem.indexOfPosLinear; +const lastIndexOf = std.mem.lastIndexOfScalar; +const lastIndexOfAny = std.mem.lastIndexOfAny; +const lastIndexOfStr = std.mem.lastIndexOfLinear; +const trim = std.mem.trim; +const sliceMin = std.mem.min; +const sliceMax = std.mem.max; + +const min = std.math.min; +const min3 = std.math.min3; +const max = std.math.max; +const max3 = std.math.max3; + +const print = std.debug.print; +const assert = std.debug.assert; + +const sort = std.sort.sort; +const asc = std.sort.asc; +const desc = std.sort.desc; diff --git a/src/day10.zig b/src/day10.zig index d0a1a5d..e9f95f5 100644 --- a/src/day10.zig +++ b/src/day10.zig @@ -1,7 +1,5 @@ const std = @import("std"); const Allocator = std.mem.Allocator; -const assert = std.debug.assert; -const print = std.debug.print; const List = std.ArrayList; const Map = std.AutoHashMap; const StrMap = std.StringHashMap; @@ -16,3 +14,28 @@ const data = @embedFile("../data/day10.txt"); pub fn main() !void { } + +// Useful stdlib functions +const tokenize = std.mem.tokenize; +const split = std.mem.split; +const indexOf = std.mem.indexOfScalar; +const indexOfAny = std.mem.indexOfAny; +const indexOfStr = std.mem.indexOfPosLinear; +const lastIndexOf = std.mem.lastIndexOfScalar; +const lastIndexOfAny = std.mem.lastIndexOfAny; +const lastIndexOfStr = std.mem.lastIndexOfLinear; +const trim = std.mem.trim; +const sliceMin = std.mem.min; +const sliceMax = std.mem.max; + +const min = std.math.min; +const min3 = std.math.min3; +const max = std.math.max; +const max3 = std.math.max3; + +const print = std.debug.print; +const assert = std.debug.assert; + +const sort = std.sort.sort; +const asc = std.sort.asc; +const desc = std.sort.desc; diff --git a/src/day11.zig b/src/day11.zig index 774f658..55102d5 100644 --- a/src/day11.zig +++ b/src/day11.zig @@ -1,7 +1,5 @@ const std = @import("std"); const Allocator = std.mem.Allocator; -const assert = std.debug.assert; -const print = std.debug.print; const List = std.ArrayList; const Map = std.AutoHashMap; const StrMap = std.StringHashMap; @@ -16,3 +14,28 @@ const data = @embedFile("../data/day11.txt"); pub fn main() !void { } + +// Useful stdlib functions +const tokenize = std.mem.tokenize; +const split = std.mem.split; +const indexOf = std.mem.indexOfScalar; +const indexOfAny = std.mem.indexOfAny; +const indexOfStr = std.mem.indexOfPosLinear; +const lastIndexOf = std.mem.lastIndexOfScalar; +const lastIndexOfAny = std.mem.lastIndexOfAny; +const lastIndexOfStr = std.mem.lastIndexOfLinear; +const trim = std.mem.trim; +const sliceMin = std.mem.min; +const sliceMax = std.mem.max; + +const min = std.math.min; +const min3 = std.math.min3; +const max = std.math.max; +const max3 = std.math.max3; + +const print = std.debug.print; +const assert = std.debug.assert; + +const sort = std.sort.sort; +const asc = std.sort.asc; +const desc = std.sort.desc; diff --git a/src/day12.zig b/src/day12.zig index b027d7b..8e4c32d 100644 --- a/src/day12.zig +++ b/src/day12.zig @@ -1,7 +1,5 @@ const std = @import("std"); const Allocator = std.mem.Allocator; -const assert = std.debug.assert; -const print = std.debug.print; const List = std.ArrayList; const Map = std.AutoHashMap; const StrMap = std.StringHashMap; @@ -16,3 +14,28 @@ const data = @embedFile("../data/day12.txt"); pub fn main() !void { } + +// Useful stdlib functions +const tokenize = std.mem.tokenize; +const split = std.mem.split; +const indexOf = std.mem.indexOfScalar; +const indexOfAny = std.mem.indexOfAny; +const indexOfStr = std.mem.indexOfPosLinear; +const lastIndexOf = std.mem.lastIndexOfScalar; +const lastIndexOfAny = std.mem.lastIndexOfAny; +const lastIndexOfStr = std.mem.lastIndexOfLinear; +const trim = std.mem.trim; +const sliceMin = std.mem.min; +const sliceMax = std.mem.max; + +const min = std.math.min; +const min3 = std.math.min3; +const max = std.math.max; +const max3 = std.math.max3; + +const print = std.debug.print; +const assert = std.debug.assert; + +const sort = std.sort.sort; +const asc = std.sort.asc; +const desc = std.sort.desc; diff --git a/src/day13.zig b/src/day13.zig index 9dbfd06..e62a13a 100644 --- a/src/day13.zig +++ b/src/day13.zig @@ -1,7 +1,5 @@ const std = @import("std"); const Allocator = std.mem.Allocator; -const assert = std.debug.assert; -const print = std.debug.print; const List = std.ArrayList; const Map = std.AutoHashMap; const StrMap = std.StringHashMap; @@ -16,3 +14,28 @@ const data = @embedFile("../data/day13.txt"); pub fn main() !void { } + +// Useful stdlib functions +const tokenize = std.mem.tokenize; +const split = std.mem.split; +const indexOf = std.mem.indexOfScalar; +const indexOfAny = std.mem.indexOfAny; +const indexOfStr = std.mem.indexOfPosLinear; +const lastIndexOf = std.mem.lastIndexOfScalar; +const lastIndexOfAny = std.mem.lastIndexOfAny; +const lastIndexOfStr = std.mem.lastIndexOfLinear; +const trim = std.mem.trim; +const sliceMin = std.mem.min; +const sliceMax = std.mem.max; + +const min = std.math.min; +const min3 = std.math.min3; +const max = std.math.max; +const max3 = std.math.max3; + +const print = std.debug.print; +const assert = std.debug.assert; + +const sort = std.sort.sort; +const asc = std.sort.asc; +const desc = std.sort.desc; diff --git a/src/day14.zig b/src/day14.zig index 3b59760..b48eed5 100644 --- a/src/day14.zig +++ b/src/day14.zig @@ -1,7 +1,5 @@ const std = @import("std"); const Allocator = std.mem.Allocator; -const assert = std.debug.assert; -const print = std.debug.print; const List = std.ArrayList; const Map = std.AutoHashMap; const StrMap = std.StringHashMap; @@ -16,3 +14,28 @@ const data = @embedFile("../data/day14.txt"); pub fn main() !void { } + +// Useful stdlib functions +const tokenize = std.mem.tokenize; +const split = std.mem.split; +const indexOf = std.mem.indexOfScalar; +const indexOfAny = std.mem.indexOfAny; +const indexOfStr = std.mem.indexOfPosLinear; +const lastIndexOf = std.mem.lastIndexOfScalar; +const lastIndexOfAny = std.mem.lastIndexOfAny; +const lastIndexOfStr = std.mem.lastIndexOfLinear; +const trim = std.mem.trim; +const sliceMin = std.mem.min; +const sliceMax = std.mem.max; + +const min = std.math.min; +const min3 = std.math.min3; +const max = std.math.max; +const max3 = std.math.max3; + +const print = std.debug.print; +const assert = std.debug.assert; + +const sort = std.sort.sort; +const asc = std.sort.asc; +const desc = std.sort.desc; diff --git a/src/day15.zig b/src/day15.zig index 9d50ab2..5c24786 100644 --- a/src/day15.zig +++ b/src/day15.zig @@ -1,7 +1,5 @@ const std = @import("std"); const Allocator = std.mem.Allocator; -const assert = std.debug.assert; -const print = std.debug.print; const List = std.ArrayList; const Map = std.AutoHashMap; const StrMap = std.StringHashMap; @@ -16,3 +14,28 @@ const data = @embedFile("../data/day15.txt"); pub fn main() !void { } + +// Useful stdlib functions +const tokenize = std.mem.tokenize; +const split = std.mem.split; +const indexOf = std.mem.indexOfScalar; +const indexOfAny = std.mem.indexOfAny; +const indexOfStr = std.mem.indexOfPosLinear; +const lastIndexOf = std.mem.lastIndexOfScalar; +const lastIndexOfAny = std.mem.lastIndexOfAny; +const lastIndexOfStr = std.mem.lastIndexOfLinear; +const trim = std.mem.trim; +const sliceMin = std.mem.min; +const sliceMax = std.mem.max; + +const min = std.math.min; +const min3 = std.math.min3; +const max = std.math.max; +const max3 = std.math.max3; + +const print = std.debug.print; +const assert = std.debug.assert; + +const sort = std.sort.sort; +const asc = std.sort.asc; +const desc = std.sort.desc; diff --git a/src/day16.zig b/src/day16.zig index 966970c..eeaa678 100644 --- a/src/day16.zig +++ b/src/day16.zig @@ -1,7 +1,5 @@ const std = @import("std"); const Allocator = std.mem.Allocator; -const assert = std.debug.assert; -const print = std.debug.print; const List = std.ArrayList; const Map = std.AutoHashMap; const StrMap = std.StringHashMap; @@ -16,3 +14,28 @@ const data = @embedFile("../data/day16.txt"); pub fn main() !void { } + +// Useful stdlib functions +const tokenize = std.mem.tokenize; +const split = std.mem.split; +const indexOf = std.mem.indexOfScalar; +const indexOfAny = std.mem.indexOfAny; +const indexOfStr = std.mem.indexOfPosLinear; +const lastIndexOf = std.mem.lastIndexOfScalar; +const lastIndexOfAny = std.mem.lastIndexOfAny; +const lastIndexOfStr = std.mem.lastIndexOfLinear; +const trim = std.mem.trim; +const sliceMin = std.mem.min; +const sliceMax = std.mem.max; + +const min = std.math.min; +const min3 = std.math.min3; +const max = std.math.max; +const max3 = std.math.max3; + +const print = std.debug.print; +const assert = std.debug.assert; + +const sort = std.sort.sort; +const asc = std.sort.asc; +const desc = std.sort.desc; diff --git a/src/day17.zig b/src/day17.zig index d3048c7..0b9c9e7 100644 --- a/src/day17.zig +++ b/src/day17.zig @@ -1,7 +1,5 @@ const std = @import("std"); const Allocator = std.mem.Allocator; -const assert = std.debug.assert; -const print = std.debug.print; const List = std.ArrayList; const Map = std.AutoHashMap; const StrMap = std.StringHashMap; @@ -16,3 +14,28 @@ const data = @embedFile("../data/day17.txt"); pub fn main() !void { } + +// Useful stdlib functions +const tokenize = std.mem.tokenize; +const split = std.mem.split; +const indexOf = std.mem.indexOfScalar; +const indexOfAny = std.mem.indexOfAny; +const indexOfStr = std.mem.indexOfPosLinear; +const lastIndexOf = std.mem.lastIndexOfScalar; +const lastIndexOfAny = std.mem.lastIndexOfAny; +const lastIndexOfStr = std.mem.lastIndexOfLinear; +const trim = std.mem.trim; +const sliceMin = std.mem.min; +const sliceMax = std.mem.max; + +const min = std.math.min; +const min3 = std.math.min3; +const max = std.math.max; +const max3 = std.math.max3; + +const print = std.debug.print; +const assert = std.debug.assert; + +const sort = std.sort.sort; +const asc = std.sort.asc; +const desc = std.sort.desc; diff --git a/src/day18.zig b/src/day18.zig index f18f728..4f43cca 100644 --- a/src/day18.zig +++ b/src/day18.zig @@ -1,7 +1,5 @@ const std = @import("std"); const Allocator = std.mem.Allocator; -const assert = std.debug.assert; -const print = std.debug.print; const List = std.ArrayList; const Map = std.AutoHashMap; const StrMap = std.StringHashMap; @@ -16,3 +14,28 @@ const data = @embedFile("../data/day18.txt"); pub fn main() !void { } + +// Useful stdlib functions +const tokenize = std.mem.tokenize; +const split = std.mem.split; +const indexOf = std.mem.indexOfScalar; +const indexOfAny = std.mem.indexOfAny; +const indexOfStr = std.mem.indexOfPosLinear; +const lastIndexOf = std.mem.lastIndexOfScalar; +const lastIndexOfAny = std.mem.lastIndexOfAny; +const lastIndexOfStr = std.mem.lastIndexOfLinear; +const trim = std.mem.trim; +const sliceMin = std.mem.min; +const sliceMax = std.mem.max; + +const min = std.math.min; +const min3 = std.math.min3; +const max = std.math.max; +const max3 = std.math.max3; + +const print = std.debug.print; +const assert = std.debug.assert; + +const sort = std.sort.sort; +const asc = std.sort.asc; +const desc = std.sort.desc; diff --git a/src/day19.zig b/src/day19.zig index 76e3fbe..379b06e 100644 --- a/src/day19.zig +++ b/src/day19.zig @@ -1,7 +1,5 @@ const std = @import("std"); const Allocator = std.mem.Allocator; -const assert = std.debug.assert; -const print = std.debug.print; const List = std.ArrayList; const Map = std.AutoHashMap; const StrMap = std.StringHashMap; @@ -16,3 +14,28 @@ const data = @embedFile("../data/day19.txt"); pub fn main() !void { } + +// Useful stdlib functions +const tokenize = std.mem.tokenize; +const split = std.mem.split; +const indexOf = std.mem.indexOfScalar; +const indexOfAny = std.mem.indexOfAny; +const indexOfStr = std.mem.indexOfPosLinear; +const lastIndexOf = std.mem.lastIndexOfScalar; +const lastIndexOfAny = std.mem.lastIndexOfAny; +const lastIndexOfStr = std.mem.lastIndexOfLinear; +const trim = std.mem.trim; +const sliceMin = std.mem.min; +const sliceMax = std.mem.max; + +const min = std.math.min; +const min3 = std.math.min3; +const max = std.math.max; +const max3 = std.math.max3; + +const print = std.debug.print; +const assert = std.debug.assert; + +const sort = std.sort.sort; +const asc = std.sort.asc; +const desc = std.sort.desc; diff --git a/src/day20.zig b/src/day20.zig index 3e637e4..ff2e7e0 100644 --- a/src/day20.zig +++ b/src/day20.zig @@ -1,7 +1,5 @@ const std = @import("std"); const Allocator = std.mem.Allocator; -const assert = std.debug.assert; -const print = std.debug.print; const List = std.ArrayList; const Map = std.AutoHashMap; const StrMap = std.StringHashMap; @@ -16,3 +14,28 @@ const data = @embedFile("../data/day20.txt"); pub fn main() !void { } + +// Useful stdlib functions +const tokenize = std.mem.tokenize; +const split = std.mem.split; +const indexOf = std.mem.indexOfScalar; +const indexOfAny = std.mem.indexOfAny; +const indexOfStr = std.mem.indexOfPosLinear; +const lastIndexOf = std.mem.lastIndexOfScalar; +const lastIndexOfAny = std.mem.lastIndexOfAny; +const lastIndexOfStr = std.mem.lastIndexOfLinear; +const trim = std.mem.trim; +const sliceMin = std.mem.min; +const sliceMax = std.mem.max; + +const min = std.math.min; +const min3 = std.math.min3; +const max = std.math.max; +const max3 = std.math.max3; + +const print = std.debug.print; +const assert = std.debug.assert; + +const sort = std.sort.sort; +const asc = std.sort.asc; +const desc = std.sort.desc; diff --git a/src/day21.zig b/src/day21.zig index 03cdde3..b02295c 100644 --- a/src/day21.zig +++ b/src/day21.zig @@ -1,7 +1,5 @@ const std = @import("std"); const Allocator = std.mem.Allocator; -const assert = std.debug.assert; -const print = std.debug.print; const List = std.ArrayList; const Map = std.AutoHashMap; const StrMap = std.StringHashMap; @@ -16,3 +14,28 @@ const data = @embedFile("../data/day21.txt"); pub fn main() !void { } + +// Useful stdlib functions +const tokenize = std.mem.tokenize; +const split = std.mem.split; +const indexOf = std.mem.indexOfScalar; +const indexOfAny = std.mem.indexOfAny; +const indexOfStr = std.mem.indexOfPosLinear; +const lastIndexOf = std.mem.lastIndexOfScalar; +const lastIndexOfAny = std.mem.lastIndexOfAny; +const lastIndexOfStr = std.mem.lastIndexOfLinear; +const trim = std.mem.trim; +const sliceMin = std.mem.min; +const sliceMax = std.mem.max; + +const min = std.math.min; +const min3 = std.math.min3; +const max = std.math.max; +const max3 = std.math.max3; + +const print = std.debug.print; +const assert = std.debug.assert; + +const sort = std.sort.sort; +const asc = std.sort.asc; +const desc = std.sort.desc; diff --git a/src/day22.zig b/src/day22.zig index 782a434..1994ed6 100644 --- a/src/day22.zig +++ b/src/day22.zig @@ -1,7 +1,5 @@ const std = @import("std"); const Allocator = std.mem.Allocator; -const assert = std.debug.assert; -const print = std.debug.print; const List = std.ArrayList; const Map = std.AutoHashMap; const StrMap = std.StringHashMap; @@ -16,3 +14,28 @@ const data = @embedFile("../data/day22.txt"); pub fn main() !void { } + +// Useful stdlib functions +const tokenize = std.mem.tokenize; +const split = std.mem.split; +const indexOf = std.mem.indexOfScalar; +const indexOfAny = std.mem.indexOfAny; +const indexOfStr = std.mem.indexOfPosLinear; +const lastIndexOf = std.mem.lastIndexOfScalar; +const lastIndexOfAny = std.mem.lastIndexOfAny; +const lastIndexOfStr = std.mem.lastIndexOfLinear; +const trim = std.mem.trim; +const sliceMin = std.mem.min; +const sliceMax = std.mem.max; + +const min = std.math.min; +const min3 = std.math.min3; +const max = std.math.max; +const max3 = std.math.max3; + +const print = std.debug.print; +const assert = std.debug.assert; + +const sort = std.sort.sort; +const asc = std.sort.asc; +const desc = std.sort.desc; diff --git a/src/day23.zig b/src/day23.zig index ae7ddbf..9fffb21 100644 --- a/src/day23.zig +++ b/src/day23.zig @@ -1,7 +1,5 @@ const std = @import("std"); const Allocator = std.mem.Allocator; -const assert = std.debug.assert; -const print = std.debug.print; const List = std.ArrayList; const Map = std.AutoHashMap; const StrMap = std.StringHashMap; @@ -16,3 +14,28 @@ const data = @embedFile("../data/day23.txt"); pub fn main() !void { } + +// Useful stdlib functions +const tokenize = std.mem.tokenize; +const split = std.mem.split; +const indexOf = std.mem.indexOfScalar; +const indexOfAny = std.mem.indexOfAny; +const indexOfStr = std.mem.indexOfPosLinear; +const lastIndexOf = std.mem.lastIndexOfScalar; +const lastIndexOfAny = std.mem.lastIndexOfAny; +const lastIndexOfStr = std.mem.lastIndexOfLinear; +const trim = std.mem.trim; +const sliceMin = std.mem.min; +const sliceMax = std.mem.max; + +const min = std.math.min; +const min3 = std.math.min3; +const max = std.math.max; +const max3 = std.math.max3; + +const print = std.debug.print; +const assert = std.debug.assert; + +const sort = std.sort.sort; +const asc = std.sort.asc; +const desc = std.sort.desc; diff --git a/src/day24.zig b/src/day24.zig index 5d7553f..38f1804 100644 --- a/src/day24.zig +++ b/src/day24.zig @@ -1,7 +1,5 @@ const std = @import("std"); const Allocator = std.mem.Allocator; -const assert = std.debug.assert; -const print = std.debug.print; const List = std.ArrayList; const Map = std.AutoHashMap; const StrMap = std.StringHashMap; @@ -16,3 +14,28 @@ const data = @embedFile("../data/day24.txt"); pub fn main() !void { } + +// Useful stdlib functions +const tokenize = std.mem.tokenize; +const split = std.mem.split; +const indexOf = std.mem.indexOfScalar; +const indexOfAny = std.mem.indexOfAny; +const indexOfStr = std.mem.indexOfPosLinear; +const lastIndexOf = std.mem.lastIndexOfScalar; +const lastIndexOfAny = std.mem.lastIndexOfAny; +const lastIndexOfStr = std.mem.lastIndexOfLinear; +const trim = std.mem.trim; +const sliceMin = std.mem.min; +const sliceMax = std.mem.max; + +const min = std.math.min; +const min3 = std.math.min3; +const max = std.math.max; +const max3 = std.math.max3; + +const print = std.debug.print; +const assert = std.debug.assert; + +const sort = std.sort.sort; +const asc = std.sort.asc; +const desc = std.sort.desc; diff --git a/src/day25.zig b/src/day25.zig index 2fc4e69..9126594 100644 --- a/src/day25.zig +++ b/src/day25.zig @@ -1,7 +1,5 @@ const std = @import("std"); const Allocator = std.mem.Allocator; -const assert = std.debug.assert; -const print = std.debug.print; const List = std.ArrayList; const Map = std.AutoHashMap; const StrMap = std.StringHashMap; @@ -16,3 +14,28 @@ const data = @embedFile("../data/day25.txt"); pub fn main() !void { } + +// Useful stdlib functions +const tokenize = std.mem.tokenize; +const split = std.mem.split; +const indexOf = std.mem.indexOfScalar; +const indexOfAny = std.mem.indexOfAny; +const indexOfStr = std.mem.indexOfPosLinear; +const lastIndexOf = std.mem.lastIndexOfScalar; +const lastIndexOfAny = std.mem.lastIndexOfAny; +const lastIndexOfStr = std.mem.lastIndexOfLinear; +const trim = std.mem.trim; +const sliceMin = std.mem.min; +const sliceMax = std.mem.max; + +const min = std.math.min; +const min3 = std.math.min3; +const max = std.math.max; +const max3 = std.math.max3; + +const print = std.debug.print; +const assert = std.debug.assert; + +const sort = std.sort.sort; +const asc = std.sort.asc; +const desc = std.sort.desc; diff --git a/src/util.zig b/src/util.zig index c484c05..dc11ea4 100644 --- a/src/util.zig +++ b/src/util.zig @@ -1,7 +1,5 @@ const std = @import("std"); const Allocator = std.mem.Allocator; -const assert = std.debug.assert; -const print = std.debug.print; const List = std.ArrayList; const Map = std.AutoHashMap; const StrMap = std.StringHashMap; @@ -12,3 +10,29 @@ var gpa_impl = std.heap.GeneralPurposeAllocator(.{}){}; pub const gpa = &gpa_impl.allocator; // Add utility functions here + + +// Useful stdlib functions +const tokenize = std.mem.tokenize; +const split = std.mem.split; +const indexOf = std.mem.indexOfScalar; +const indexOfAny = std.mem.indexOfAny; +const indexOfStr = std.mem.indexOfPosLinear; +const lastIndexOf = std.mem.lastIndexOfScalar; +const lastIndexOfAny = std.mem.lastIndexOfAny; +const lastIndexOfStr = std.mem.lastIndexOfLinear; +const trim = std.mem.trim; +const sliceMin = std.mem.min; +const sliceMax = std.mem.max; + +const min = std.math.min; +const min3 = std.math.min3; +const max = std.math.max; +const max3 = std.math.max3; + +const print = std.debug.print; +const assert = std.debug.assert; + +const sort = std.sort.sort; +const asc = std.sort.asc; +const desc = std.sort.desc;