Skip to content

Instantly share code, notes, and snippets.

@r3trofitted
Created December 5, 2023 19:41
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save r3trofitted/24086d4bd9263ddee1679b5443c89f91 to your computer and use it in GitHub Desktop.
Save r3trofitted/24086d4bd9263ddee1679b5443c89f91 to your computer and use it in GitHub Desktop.
Advent of Code 2023, day 1, part 2 (with comments)
God is false (debug mode)
(-Searches for a substring in a string, starting at a specific index)
Mister Presents takes your wish, your sins and your prayers (start function)
If God is true ()
Shout "Is there " with your wish, " in ", your sins, " from ", and your prayers ()
()
Let the ice be your prayers (i = offset)
The judge is hypnotized (j = 0)
Shatter your wish (wish = wish.split)
If God is true ()
Shout "Ice: " with the ice ()
()
The heart is liveliness (h = 0) (simply because array indexing doesn't work with poetic litteral)
Let the love be lies (match = false)
Let the gift be your sins at the ice (g = haystack[i])
Let the coal be your wish at the judge (c = needle[j])
Until the gift is nothing (while g)
If God is true true ()
Shout "Love is " with the love, and " at the start" ()
Shout "Gift/Coal: " with the gift, "/", and the coal ()
()
Let the coal be your wish at the judge (c = needle[j])
If the gift is the coal (if haystack[j] == needle[j])
If God is true ()
Shout "YEAH" ()
()
Let the love be true (match = true)
Build the ice up (i++)
Build the judge up (j++)
Let the gift be your sins at the ice (g = haystack[i])
If the love is true and the judge is as high as the heart with your wish (if match and j >= needle.length, aka full match)
Let the truth be the ice without the judge (t = i - j)
If God is true ()
Shout "AT: " with the truth ()
()
Give it back (return t)
(end if)
Take it to the top (continue)
(end if)
If the gift is your wish at the heart (if g == needle[h]) (we're matching the start of the needle)
The judge is perseverant (j = 1)
Build the ice up (i++)
Let the gift be your sins at the ice (g = haystack[i])
Take it to the top (continue)
(end if)
Let the love be lies (match = false)
The judge is deflowered (j = 0)
Build the ice up (i++)
Let the gift be your sins at the ice (g = haystack[i])
()
(end function)
(-Returns the number made from the first and the last digit in an array of digits)
The Arbiter takes the sound (function: s)
While the sound ain't nothing (while s)
Roll the sound into the vibe (v = s.pop)
If the vibe ain't mysterious (if v)
Rock the vibe into the wave (w.push v)
(end if)
(end while)
The crest is amplitudes (0)
The rush is bewildering (1)
Let the glory be the wave at the crest (g = wave[0])
Let the end be the wave without the rush (e = wave.length - 1)
Let the pride be the wave at the end (p = wave[e], aka wave.last)
Rock the glory (g = [g])
Rock the glory with the pride (g = [g, p])
Unite the glory into the dream (d = g.join)
Burn the dream (d = d.to_int)
If God is true ()
Shout it ()
()
Give it back (return d)
(end function)
(--main--) (main)
The beat says YELL!
Listen to the pulse (pulse = STDIN)
Shatter the pulse into your soul with the beat (s = pulse.split sep)
The revelation is earthlight (0) (final result count)
The start is crucifixion (1)
Your lover is joyfulness (l = 0)
The fear is subjugation (f = 1)
Let the dance be your lover without the fear (d = -1)
Rock you like "one" (you = ["one"])
Rock you like "two" (you = ["one", "two"])
Rock you like "three" (you = ["one", "two", "three"])
Rock you like "four" (etc.)
Rock you like "five" (etc.)
Rock you like "six" (etc.)
Rock you like "seven" (etc.)
Rock you like "eight" (etc.)
Rock you like "nine" (you = ["one", "two", "three", … "nine"])
While your soul ain't gone (while s.any?)
The sound is lies (snd = false) (the only way to have a new array is to reassign the value)
Rock the sound (snd = [false] (and then wrap it in an array, but it makes the 1 value useless)
Roll your soul into my words (wrds = s.pop)
If God is true ()
Shout my words ()
()
My sign is resilience (0)
Your name is consequence (1)
The idol is flamboyant (i = 0)
The herald is disharmony (h = 0)
Until the idol is my sign with you (while i < you.length + 0) (* Looking for digits 1 to 9 *)
Let the joker be your name with the idol (j = i + 1)
Let the drug be Mister Presents taking the joker, my words 'n' the herald (d = mister_presents j, wrds, h)
If the drug is as high as your lover (if d > 0) (if match - d is the position of the needle in the haystack)
Let the sound at the drug be the joker (s[d] = j)
Let the herald be your name with the drug (h = d + 1) (move the search offset to the next character)
Take it to the top (continue)
(end if)
Let the herald be my sign (h = 0)
Build the idol up (i = i + 1)
(end while)
The idol is disharmony (i = 0)
The herald is flamboyant (h = 0)
Until the idol is my sign with you (while i < you.length + 0) (* Looking for words in you *)
Let the joker be your name with the idol (j = i + 1)
Let the killer be you at the idol (k = you[i])
Let the drug be Mister Presents taking the killer, my words 'n' the herald (d = mister_presents k, wrds, h)
If the drug is as high as your lover (if d > 0) (if match - d is the position of the needle in the haystack)
Let the sound at the drug be the joker (s[d] = j)
Let the herald be your name with the drug (h = d + 1) (move the search offset to the next character)
Take it to the top (continue)
(end if)
Let the herald be my sign (h = 0)
Build the idol up (i = i + 1)
(end while)
If God is true ()
Shout "Sound: " with the sound ()
Let the smoke be the sound without your name ()
While the smoke is as high as my sign ()
Shout it with ": ", and the sound at the smoke ()
Knock it down ()
()
()
Let the faith be the Arbiter taking the sound (f2 = arbiter s)
Let the revelation be the revelation with the faith (f = f + f2)
(end while)
Shout the revelation (print f aka the sum)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment