Skip to content

Conversation

@Avokadoen
Copy link
Contributor

Note: I made an error merging with my self so there are two commits for "solve day04 in zig" (15cde6c and 7adcaf2). The only consequence is the commit log being polluted by two commits, but the files should be correct.

Copy link
Owner

@Arxcis Arxcis left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Two more days of Zig 🙏 Loved every line ❤️

Comment on lines +7 to +17
const PassportField = enum(u8) {
invalid = 0b00000000,
cid = 0b00000001,
byr = 0b00000010,
iyr = 0b00000100,
eyr = 0b00001000,
hgt = 0b00010000,
hcl = 0b00100000,
ecl = 0b01000000,
pid = 0b10000000,
required = 0b11111110,
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cool enum 😎

Comment on lines +36 to +38
switch(self) {
.byr, .iyr, .eyr => {
const value: i32 = try std.fmt.parseInt(i32, field_value, 10);
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cool enum switch 😎

Comment on lines +83 to +84
or mem.eql(u8, field_value, "blu")
or mem.eql(u8, field_value, "brn")
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cool mem.eql() 😄

var i: usize = 0;
while(i < field_value.len) : (i += 1) {
switch (field_value[i]) {
'0'...'9' => continue,
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cool shorthand case: 1 ,case: 2, case: 3, case:4, case: 5, case: 6, case: 7, case: 8, case: 9 🥇

Comment on lines +52 to +53
comptime const row_extractor = LineSegmentParser('F', 'B', 127);
comptime const col_extractor = LineSegmentParser('L', 'R', 7);
Copy link
Owner

@Arxcis Arxcis Dec 9, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Woow 👍
Compile time struct baking? 🍰

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hell yeah

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Metaprogramming with uniform syntax to the main language was the main drive for zig in the beginning i believe 😄

@Arxcis Arxcis merged commit 3b0544e into Arxcis:main Dec 9, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants