Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- * ================================================================
- * AdventOfCode2021-Day1.js - goes in your \Documents\My Games\EXAPUNKS\some-player-id\custom\ folder
- * ================================================================
- */
- // For the latest Axiom VirtualNetwork+ scripting documentation,
- // please visit: http://www.zachtronics.com/virtualnetwork/
- function getTitle() {
- return "ADVENT OF CODE 2021 DAY 1";
- }
- function getSubtitle() {
- return "POWERED BY EXAS® (and javascript)";
- }
- function getDescription() {
- return "https://adventofcode.com/2021/day/1 \nSanta is scanning the seabed for his sleigh keys! Count how many times the depth measurement *increases*. The depth reading log can be found in *file 300*. Hurry, Christmas is counting on you!\nPart 2, take the *rolling sum of three readings*, and count how many times that rolling sum increases.";
- }
- const INPUT_DATA = [/* PASTE YOUR INPUT DATA HERE*/];
- /* To format your input data, replace all newlines with commas, producing an array */
- function initializeTestRun(testRun) {
- //exapunks doesn't let numbers go higher than 9999? lmao time to cheat with both hands and do it in js
- let cmpA0 = 0, cmpA1 = 0, cmpA2 = 0, cmpB0 = 0, cmpB1 = 0, cmpB2 = 0;
- //we actually do need to use the default host for some register-making
- var targetHost = createHost("EMPTYHOST", 5, 0, 4, 3);
- createNormalFile(getPlayerHost(), 300, FILE_ICON_DATA, INPUT_DATA);
- var cmpA0Register = createRegister(targetHost, 5, 2, "CMA0");
- setRegisterWriteCallback(cmpA0Register, function(value) { cmpA0 = value; });
- setRegisterReadCallback(cmpA0Register, function() { return cmpA0; });
- var cmpA1Register = createRegister(targetHost, 6, 2, "CMA1");
- setRegisterWriteCallback(cmpA1Register, function(value) { cmpA1 = value; });
- setRegisterReadCallback(cmpA1Register, function() { return cmpA1; });
- var cmpA2Register = createRegister(targetHost, 7, 2, "CMA2");
- setRegisterWriteCallback(cmpA2Register, function(value) { cmpA2 = value; });
- setRegisterReadCallback(cmpA2Register, function() { return cmpA2; });
- var cmpB0Register = createRegister(targetHost, 5, 0, "CMB0");
- setRegisterWriteCallback(cmpB0Register, function(value) { cmpB0 = value; });
- setRegisterReadCallback(cmpB0Register, function() { return cmpB0; });
- var cmpB1Register = createRegister(targetHost, 6, 0, "CMB1");
- setRegisterWriteCallback(cmpB1Register, function(value) { cmpB1 = value; });
- setRegisterReadCallback(cmpB1Register, function() { return cmpB1; });
- var cmpB2Register = createRegister(targetHost, 7, 0, "CMB2");
- setRegisterWriteCallback(cmpB2Register, function(value) { cmpB2 = value; });
- setRegisterReadCallback(cmpB2Register, function() { return cmpB2; });
- var cmpDiffRegister = createRegister(targetHost, 8, 1, "CMDF");
- setRegisterReadCallback(cmpDiffRegister, function() {
- //sumifications on demand
- //but you gotta move values to and from registers yourself bruh
- var sumOld = cmpA0 + cmpA1 + cmpA2;
- var sumNew = cmpB0 + cmpB1 + cmpB2;
- return sumNew - sumOld;
- });
- }
- function onCycleFinished() {
- }
- /*
- * ================================================================
- * EXA code - these go into the actual in-game EXAs, using the headers for which name is which
- * ================================================================
- */
- /*
- EXAcode for first puzzle:
- -- XA --
- GRAB 300
- COPY F X
- MARK GETDIFFS
- COPY X T
- COPY F X
- SUBI X T M
- TEST EOF
- FJMP GETDIFFS
- -- XB --
- COPY 0 X
- MARK READDIFFS
- TEST M > 0
- FJMP READDIFFS
- ADDI X 1 X
- JUMP READDIFFS
- solution is XB's X register
- ---
- EXAcode for second puzzle:
- -- XA --
- GRAB 300
- LINK 800
- ;//INITIAL SETUP
- COPY F #CMA0
- COPY F #CMA1
- COPY #CMA1 #CMB0
- COPY F #CMA2
- COPY #CMA2 #CMB1
- MARK LOOP
- COPY F #CMB2
- COPY -1 M;//SIGNAL XB
- VOID M;//XB DONE
- COPY #CMA1 #CMA0
- COPY #CMA2 #CMA1
- COPY #CMB2 #CMA2
- COPY #CMB1 #CMB0
- COPY #CMB2 #CMB1
- TEST EOF
- FJMP LOOP
- NOOP;//RUN 2 HERE 4 ANSWER
- -- XB --
- LINK 800
- ;//X STARTS AT 0
- MARK LOOP
- VOID M;//XA DONE
- TEST #CMDF > 0
- COPY -1 M;//SIGNAL XA GO
- FJMP LOOP
- ADDI X 1 X
- JUMP LOOP
- fast-run to the NOOP at the end of XA, then result is XB's X register
- */
Add Comment
Please, Sign In to add comment