Advent of Nim 2022

2022-12-20 Thread bg
You may already be aware of this, but if you don't want to use symbols, you can 
make a `max=` proc in nim:


proc `max=`*(a: var int, b: int) = a = max(a,b)
var x = 5
let y = 7
x.max= y
assert x == 7


Run


Advent of Nim 2022

2022-12-02 Thread bg
It is really clever! Nim is so flexible that the input can be interpreted as 
valid Nim code and run!

That said, I don't prefer that approach in my own solutions. When I clean up my 
solutions I tend to want to make them run faster, and for those purposes I 
consider baking the input into the executable to be cheating (note: in my 
opinion). For two reasons: 1) I like being able to, in principle, run the 
executable on multiple different inputs without recompiling, which I can't do 
if specific input is baked in, and 2) if I'm doing input-dependent calculations 
at compile-time, I might as well compute the full solutions to all the days at 
compile time too, at which point measuring the run-time duration is meaningless.


Advent of Nim 2022

2022-11-30 Thread bg
I'm in a similar situation as some others: I probably won't have time to do all 
the days as they come.

I plan to share my answers here: 


Can I haz splat operator

2022-01-11 Thread bg
It's not hard to roll your own (which I know many have done). eg:






Advent of Nim 2021

2021-12-02 Thread bg
Hi all! Sharing my repo too: