Journal: 2025-12-15
Show code
fn get_direction(instr) {
let sign = 1;
if instr[0] == "L" {
sign = -1;
}
return sign * parse_int(instr.sub_string(1,))
}
let code = ["L68", "L30", "R48", "L5", "R60", "L55", "L1", "L99", "R14", "L82"];
// I can query blocks like data! I pasted the assignment code to a block and linked it here
//let code = get_block("ca4f707e-4baf-4da3-8fab-44a9ade32072")["content"].split();
let zeros = 0;
let currentValue = 50;
for element in code {
currentValue = (get_direction(element) + currentValue + 100) % 100;
if currentValue == 0 {
zeros += 1;
}
}
print(zeros)Writing Advent of Code in LifeLab
I thought it would be cool to write and publish the solution for advent of code. I wanted to learn rhai as a an exercise and as a test of LifeLab as a jupyter notebook replacement. Since the data is another block I can directly query, I thought it would be pretty convenient!
Turns out it was not that cool. I had to constantly refer to the rhai book for basic syntax and the autocomplete kinda sucked. That being said, I wonder if I would code similarly in vscode for a language I don't know? I have not learned a new programming language in so long, I am not fully sure how it works, but I am happy to announce I wrote this for loop by myself after learning the syntax which might be the most programming thinking I have done this year.
One other thought I had was how should I reuse code between blocks. In a jupyter notebook you have explicit context (despite not having ordering), here you... kinda do but kidna don't? You can query blocks on this page and you can just import (evaluate) other blocks but it seems clunky to manually manage dependencies.