RockstarLang / rockstar

Home of the Rockstar programming language
https://codewithrockstar.com/
GNU Affero General Public License v3.0
6.88k stars 223 forks source link

Advent of Code 2019 Day 3 solution #245

Closed jerryjeremiah closed 3 years ago

jerryjeremiah commented 4 years ago

It isn't idiomatic, but...

shatter "" into the path
let the minimum at 0 be 10000

draw takes the location, the direction, the distance, and the identifier
cut the location into pieces using ","
cast pieces at 0 into x
cast pieces at 1 into y
while the distance ain't nothing
if the direction is "R"
build x up

if the direction is "L"
knock x down

if the direction is "U"
build y up

if the direction is "D"
knock y down

let the location be x plus "," plus y
let the value be the path at the location
if the value ain't empty and the value ain't the identifier 
if x is lower than 0
let x be 0 without x

if y is lower than 0
let y be 0 without y

let the sum be x with y
if the sum is lower than the minimum at 0
let the minimum at 0 be the sum

let the path at the location be the identifier
knock the distance down

give back the location

measure takes the location, the instruction, and the identifier
cut the instruction into pieces
let the direction be pieces at 0
cast pieces at 1 into the distance
if pieces is higher than 2
cast pieces at 2 into the ones
let the distance be 10 times the distance plus the ones

put draw taking the location, the direction, the distance, and the identifier into the location
give back the location

the row is 1
listen to the input
while the input ain't nothing
let the location be "0,0"
shatter the input into the instructions using ","
the index is 0
while the index ain't the instructions
let the item be the instructions at the index
put measure taking the location, the item, and the row into the location
build the index up

build the row up
listen to the input

shout the minimum at 0
dylanbeattie commented 3 years ago

Nice work - but not really an issue. :)

jerryjeremiah commented 3 years ago

I guess I thought https://codewithrockstar.com/advent/ could use a solution for Day 3, but a pull request might have been a better choice