mirror of
https://github.com/krgamestudios/Toy.git
synced 2026-04-15 14:54:07 +10:00
WIP: Implementing arrays into the script, read more
I had intended to solve the Advent of Code puzzles in Toy, but they don't work without arrays. I wasn't able to enable arrays in time, so I need to focus on doing things correctly. The most immediate tasks are marked with 'URGENT', and a lot of tests need writing.
This commit is contained in:
27
scripts/advent_1a.toy
Normal file
27
scripts/advent_1a.toy
Normal file
@@ -0,0 +1,27 @@
|
||||
//advent of code thingy
|
||||
var arr = [
|
||||
3, 4,
|
||||
4, 3,
|
||||
2, 5,
|
||||
1, 3,
|
||||
3, 9,
|
||||
3 , 3
|
||||
];
|
||||
|
||||
var total = 0;
|
||||
var counter = 0;
|
||||
|
||||
while (counter < arr.length) {
|
||||
var difference = arr[counter] - arr[counter+1];
|
||||
|
||||
if (difference < 0) {
|
||||
difference = -difference;
|
||||
}
|
||||
|
||||
total += difference;
|
||||
|
||||
counter += 2;
|
||||
}
|
||||
|
||||
print difference;
|
||||
|
||||
Reference in New Issue
Block a user