Last active
December 6, 2019 10:49
-
-
Save lars-erik/4dcf568919f408ee488173eda5043dae to your computer and use it in GitHub Desktop.
OMG, I solved AdventOfCode 2019 Dec. 4 A with RockStar!
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
validate takes code | |
let hasDouble be no | |
let char be 1 | |
let max be 6 | |
while char is weaker than max | |
let thisvalue be code at char | |
let thatvalue be code at char without 1 | |
if thisvalue is weaker than thatvalue (can't use array refs here) | |
give back no | |
else | |
if thisvalue is thatvalue | |
hasDouble is yes | |
build char up | |
give back hasDouble | |
the lower is 193651 (122345 (193651) | |
the upper is 649629 (649629) | |
blank is "" | |
build the upper up | |
put the lower into the index | |
total is 0 | |
while the index is weaker than the upper | |
let the string be the index with blank | |
put validate taking the string into result | |
if result (shout the string with " " with result) | |
build total up (total is total with 1 messes up - 54) | |
build the index up | |
give back total |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
One is 1 | |
Gods takes Sacrifice | |
Compassion is lies | |
Let Our Minds be One | |
Demons are heroes | |
While Our Minds is weaker than Demons | |
Let Love be Sacrifice at Our Minds | |
Let Fire be Sacrifice at Our Minds without One | |
If Love is weaker than Fire | |
Give back lies | |
Else | |
If Love is Fire | |
Compassion is right | |
Build Our Minds up | |
Give back Compassion | |
Hell is a purgatory for beaten power o | |
The World is broken lust sleepless dreams of screaming | |
Let Emptiness be "" | |
Build The World up | |
Let The Angels be Hell | |
Put 0 into Mercy | |
While The Angels is weaker than The World | |
Let Punishment be The Angels with Emptiness | |
Let Revenge be Gods taking Punishment | |
If Revenge is right | |
Build Mercy up | |
Build The Angels up | |
Give back Mercy |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
NextDigit takes the divisor and the index | |
put the current at 0 into the numerator | |
let the result be the numerator over the divisor | |
turn down the result | |
let the removal be the result times the divisor | |
put the numerator without it into the current at 0 | |
let digits at the index be the result | |
Proceeding takes something | |
put the index into the current at 0 | |
NextDigit taking 100000, 0 | |
NextDigit taking 10000, 1 | |
NextDigit taking 1000, 2 | |
NextDigit taking 100, 3 | |
NextDigit taking 10, 4 | |
NextDigit taking 1, 5 | |
Compare takes thisdigit and thatdigit | |
if thisdigit is weaker than thatdigit | |
give back -1 | |
else | |
if thisdigit is stronger than thatdigit | |
give back 1 | |
else | |
give back 0 | |
Validate takes something | |
let hasdouble be no | |
let counter be 1 | |
while counter is weaker than 6 | |
let thisdigit be digits at counter | |
let thatdigit be digits at counter without 1 | |
let comparison be Compare taking thisdigit, thatdigit | |
if comparison is -1 | |
give back no | |
else | |
if comparison is 0 | |
let hasdouble be yes | |
build counter up | |
give back hasdouble | |
the lower is 193651 (122345 (193651) | |
the upper is 649629 (649629) | |
build the upper up | |
put the lower into the index | |
let the current at 0 be 0 | |
let digits at 0 be 0 | |
let totalValid be 0 | |
while the index is weaker than the upper | |
Proceeding taking nothing | |
let validity be Validate taking nothing | |
if validity | |
build totalValid up | |
build the index up | |
shout totalValid |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment