LOADING: An error occurred. Update Chrome, try Firefox, or visit this post for more details.

⚠️Reddit changed how removals work, which breaks Reveddit's website. Install the extension to track removed content:Add to chromeAdd to firefoxWhat changed?
βœ–οΈŽ
about reveddit
βš™F.A.Q.add-ons
r/
status
copy sharelink
[+] show filters
74
SOLUTION MEGATHREAD-πŸŽ„- 2022 Day 11 Solutions -πŸŽ„-(self.adventofcode)
submitted 3 years, 1 month ago* (edited 17 minutes after) by daggerdragon to /r/adventofcode (134.8k)
1036 commentsredditother-discussionssubreddit-indexmessage modsop-focus

WIKI NEWS

  • The FAQ section of the wiki on [Code Formatting](https://www.reddit.com/r/adventofco...

... view full text

since 3 years, 1 month ago
8 of 8

Tip Reveddit Real-Time can notify you when your content is removed.

your account history
(check your username's removed content. why?)
Tip Check if your account has any removed comments.
view my removed comments
you are viewing a single comment's thread.
view all comments
[–][deleted]4 points3 years, 1 month ago* (edited 30 minutes after)

Raku (Perl 6)

I'm doing different language each day, all solutions here.

Today's Raku: src

I really wanted to try Raku's Grammar feature for this. Took ages till it worked and anyone even remotely familiar with the language will probably scoff the following, but I tend to like it:

grammar Monkey {
    token TOP       { <monkey><items><operation><test><iftrue><iffalse> }
    token monkey    { 'Monkey ' <num> ':'\n }
    token items     { '  Starting items: ' [<num> ', '?]+\n }
    token operation { '  Operation: new = old ' <op>' '[<num> | 'old']\n }
    token test      { '  Test: divisible by ' <num>\n }
    token iftrue    { '    If true: throw to monkey ' <num>\n }
    token iffalse   { '    If false: throw to monkey ' <num> }
    token num       { \d+ }
    token op        { ['*' | '+'] }
}
permalinkhide replies (3)as-of
[–]EatonMesss2 points3 years, 1 month ago

Great minds think alike

permalinkparentcontexthide replies (1)author-focusas-ofpreserve
[–][deleted]2 points3 years, 1 month ago

Even better: We both did day 4 in C and yesterday in the shell of choice (try Fish, it's great)! I like.

permalinkparentcontexthide replies (1)as-of
[–]EatonMesss1 point3 years, 1 month ago

And we both commented about liking grammar :D

I will follow your progress for sure!

permalinkparentcontextauthor-focusas-ofpreserve
[–]mschaap2 points3 years, 1 month ago

Nice! See also my solution, which uses a very similar grammar.

permalinkparentcontextauthor-focusas-ofpreserve
[–]mschaap1 point3 years, 1 month ago

No scoffing here (at all), but a couple of regex tips:

  • [<num> ', '?]+ can be written as <num>+ % ', '. (One or more <num>s separated by ', '.)
  • Most of the tokens (all but num and op which really are a token) can be better written as a rule. These use :sigspace which basically makes any whitespace match any whitespace. You can then remove the \ns and be a bit more sloppy with leading/trailing whitespace.
permalinkparentcontexthide replies (1)author-focusas-ofpreserve
[–][deleted]1 point3 years, 1 month ago

Is % Raku special? I found it in its docs, but nowhere else. Actually looked at rule, but disregarded it thinking whitespace prabably was the reason it didn't work, don't want it to be even more significant. Didn't understand it means any whitespace matches any whitespace, looks cleaner now, thanks!

permalinkparentcontexthide replies (1)as-of
[–]mschaap1 point3 years, 1 month ago

Raku's regexes in general are completely reinvented. % for β€œseparated by” is definitely not a thing in Perl (compatible) regexes; there might be other regex variants that use it, but I haven't seen them.

permalinkparentcontextauthor-focusas-ofpreserve
r/revedditremoved.substack.com
🚨 NEWS 🚨
βœ–οΈŽ

Important: Reddit Changed How Removals Work

A recent Reddit update makes mod-removed content disappear from profile pages, which breaks Reveddit's website.

Install the browser extension to receive removal alerts.

Add to chromeAdd to firefox

What changed?

r/revedditremoved.substack.com