Skip to content

Instantly share code, notes, and snippets.

@SizableShrimp
Last active December 3, 2025 09:53
Show Gist options
  • Select an option

  • Save SizableShrimp/1255bf8136821c69242abe5e8d327df2 to your computer and use it in GitHub Desktop.

Select an option

Save SizableShrimp/1255bf8136821c69242abe5e8d327df2 to your computer and use it in GitHub Desktop.
AOC 2025 Day 3 in Scratch (compile with https://github.com/aspizu/goboscript)
%include std/string
costumes "blank.svg";
var input = "";
# var input = "987654321111111\n811111111111119\n234234234234278\n818181911112111";
func chartodig(c) {
return $c + 0;
}
func argmax(bank, start, endExclusive) {
local i = $start;
local maxIdx = 0;
local maxVal = 0;
repeat $endExclusive - $start {
local jolts = chartodig($bank[i]);
if jolts > maxVal {
maxIdx = i;
maxVal = jolts;
}
i++;
}
return maxIdx;
}
func calc(bank, maxDepth) {
local res = "";
local depth = $maxDepth;
local idx = 1;
repeat $maxDepth {
local bestIdx = argmax($bank, idx, length($bank) - depth + 2);
res = res & $bank[bestIdx];
idx = bestIdx + 1;
depth--;
}
return res;
}
proc doit {
}
proc main {
ask "Paste your input below; replace all newline characters with \"\\n\" to make the paste work.";
input = replace(answer(), "\\n", "\n");
split input, "\n";
local part1 = 0;
local part2 = 0;
local i = 1;
repeat length(split) {
part1 += calc(split[i], 2);
part2 += calc(split[i], 12);
i++;
}
say "Part 1: " & part1 & ", Part 2: " & part2;
}
onflag {
doit; # Necessary for other blocks to be executed for some reason?
main;
}
costumes "blank.svg";
Display the source blob
Display the rendered blob
Raw
<svg
version="1.1"
width="0"
height="0"
viewBox="0 0 0 0"
xmlns="http://www.w3.org/2000/svg"
xmlns:xlink="http://www.w3.org/1999/xlink"
></svg>
# Configuration Reference: <https://aspizu.github.io/goboscript/configuration>
std = "2.1.0"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment