Skip to content

Commit ab166f2

Browse files
committed
DX changes
1 parent fc0335c commit ab166f2

13 files changed

+38
-233
lines changed

build.zig

+1-14
Original file line numberDiff line numberDiff line change
@@ -48,19 +48,6 @@ pub const Solution = struct {
4848

4949
pub const logo = @embedFile("./logos/0000.txt");
5050

51-
pub const logos = [_][]const u8{
52-
@embedFile("./logos/2015.txt"),
53-
@embedFile("./logos/2016.txt"),
54-
@embedFile("./logos/2017.txt"),
55-
@embedFile("./logos/2018.txt"),
56-
@embedFile("./logos/2019.txt"),
57-
@embedFile("./logos/2020.txt"),
58-
@embedFile("./logos/2021.txt"),
59-
@embedFile("./logos/2022.txt"),
60-
@embedFile("./logos/2023.txt"),
61-
@embedFile("./logos/2024.txt"),
62-
};
63-
6451
pub fn build(b: *Build) !void {
6552
use_color_escapes = false;
6653
if (std.io.getStdErr().supportsAnsiEscapeCodes()) {
@@ -97,7 +84,7 @@ pub fn build(b: *Build) !void {
9784
const year: usize = b.option(usize, "year", "Select Yeay") orelse 0;
9885
const day: usize = b.option(usize, "day", "Select Day") orelse 0;
9986

100-
const req_logo = if (year == 0 or day == 0) logo else logos[year - 2015];
87+
const req_logo = logo;
10188

10289
const header_step = PrintStep.create(b, req_logo);
10390
const work_path = "solutions";

logos/2015.txt

-28
This file was deleted.

logos/2016.txt

-34
This file was deleted.

logos/2017.txt

-27
This file was deleted.

logos/2018.txt

Whitespace-only changes.

logos/2019.txt

-25
This file was deleted.

logos/2020.txt

-25
This file was deleted.

logos/2021.txt

-25
This file was deleted.

logos/2022.txt

-27
This file was deleted.

logos/2023.txt

-26
This file was deleted.

logos/2024.txt

Whitespace-only changes.

readme.md

+7-2
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@ Root
1212
|- .
1313
|- ..
1414
|- inputs
15+
|- |- test
16+
| | |- test.txt
1517
| |- year
1618
| | |- 01.txt
1719
| | |- ...
@@ -25,11 +27,14 @@ Root
2527
| |- ...
2628
|- build.zig
2729
|- build.zig.zon
30+
|- readme.md
31+
|- template.zig
2832
```
2933

3034
> Points to Remember:
31-
> The inputs must be provided by the user in the required format.
32-
> The year in the directory structure are the years 2015 to now.
35+
> The inputs must be provided by the user via the approprite file.
36+
> The year in the directory structure are from 2015 and forward along with a test file in the inputs directory for testing purposes.
37+
> There is a template file for the solutions which takes care of the file input in the root of the directory.
3338
3439
## Instructions to Run
3540

template.zig

+30
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
const std = @import("std");
2+
3+
const print = std.debug.print;
4+
5+
fn getInput(ac: std.mem.Allocator) ![]const u8 {
6+
const args = try std.process.argsAlloc(ac);
7+
defer std.process.argsFree(ac, args);
8+
const file_name = try std.fmt.allocPrint(ac, "inputs/{s}/{s}.txt", .{ args[1], args[2] });
9+
defer ac.free(file_name);
10+
var input_file = try std.fs.cwd().openFile(file_name, .{ .mode = .read_only });
11+
defer input_file.close();
12+
const file_size = (try input_file.stat()).size;
13+
const buffer = try ac.alloc(u8, file_size);
14+
try input_file.reader().readNoEof(buffer);
15+
return buffer;
16+
}
17+
18+
pub fn main() !void {
19+
var gpa = std.heap.GeneralPurposeAllocator(.{}){};
20+
const ac = gpa.allocator();
21+
defer _ = gpa.deinit();
22+
const input = try getInput(ac);
23+
defer ac.free(input);
24+
try solve(input, ac);
25+
}
26+
27+
fn solve(input: []const u8, ac: std.mem.Allocator) !void {
28+
_ = input;
29+
_ = ac;
30+
}

0 commit comments

Comments
 (0)