Skip to content

Instantly share code, notes, and snippets.

@chubbc
Last active December 10, 2020 19:36
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save chubbc/b09abcc963fffe019c3d35b5da6e98a7 to your computer and use it in GitHub Desktop.
Save chubbc/b09abcc963fffe019c3d35b5da6e98a7 to your computer and use it in GitHub Desktop.
## Input
D = parse.(Int, readlines("./10.txt"));
diffs = [D[1]; diff(sort(D)); 3]
## Part 1
p1 = sum(diffs.==1)*sum(diffs.==3);
## Part 2
v = [1;0;0];
for d = diffs
global v;
if d == 1
v = [1 1 1;1 0 0;0 1 0]*v;
elseif d == 2
v = [1 1 0;0 0 0;1 0 0]*v;
else
v = [1 0 0;0 0 0;0 0 0]*v;
end
end
p2 = v[1];
## Output
println((p1, p2));
@octomike
Copy link

Wow! You're sorting twice, though. :)

@chubbc
Copy link
Author

chubbc commented Dec 10, 2020

Wow! You're sorting twice, though. :)

You can never be too sure lol. Whoops, missed that when compressing up the messy code I originally ran for the solution, thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment