Day 2: Cube Conundrum


Megathread guidelines

  • Keep top level comments as only solutions, if you want to say something other than a solution put it in a new post. (replies to comments can be whatever)
  • Code block support is not fully rolled out yet but likely will be in the middle of the event. Try to share solutions as both code blocks and using something such as https://topaz.github.io/paste/ or pastebin (code blocks to future proof it for when 0.19 comes out and since code blocks currently function in some apps and some instances as well if they are running a 0.19 beta)

FAQ


🔒This post will be unlocked when there is a decent amount of submissions on the leaderboard to avoid cheating for top spots

🔓 Edit: Post has been unlocked after 6 minutes

  • mykl@lemmy.world
    link
    fedilink
    arrow-up
    4
    ·
    1 year ago

    I had some time, so here’s a terrible solution in Uiua (Run it here) :

    Lim ← [14 13 12]
    {"Game 1: 3 blue, 4 red; 1 red, 2 green, 6 blue; 2 green"
     "Game 2: 1 blue, 2 green; 3 green, 4 blue, 1 red; 1 green, 1 blue"
     "Game 3: 8 green, 6 blue, 20 red; 5 blue, 4 red, 13 green; 5 green, 1 red"
     "Game 4: 1 green, 3 red, 6 blue; 3 green, 6 red; 3 green, 15 blue, 14 red"
     "Game 5: 6 red, 1 blue, 3 green; 2 blue, 1 red, 2 green"}
    
    LtoDec ← ∧(+ ×10:) :0
    StoDec ← LtoDec▽≥0. ▽≤9. -@0
    FilterMax! ← /↥≡(StoDec⊢↙ ¯1)⊔⊏⊚≡(/×^1⊢).⊔
    # Build 'map' of draws for each game
    ∵(□≡(∵(⬚@\s↙2 ⊔) ⇌) ↯¯1_2 ↘ 2⊜□≠@\s . ⊔)
    # Only need the max for each colour
    ≡(⊂⊂⊃⊃(FilterMax!(="bl")) (FilterMax!(="gr")) (FilterMax!(="re")))
    # part 1 - Compare against limits, and sum game numbers
    /+▽:+1⇡⧻. ≡(/×≤0-Lim).
    # part 2 - Multiply the maxes in each game and then sum.
    /+/×⍉: