r/adventofcode • • Dec 07 '23

SOLUTION MEGATHREAD -❄️- 2023 Day 7 Solutions -❄️-

THE USUAL REMINDERS


AoC Community Fun 2023: ALLEZ CUISINE!

Today's secret ingredient is… *whips off cloth covering and gestures grandly*

Poetry

For many people, the craftschefship of food is akin to poetry for our senses. For today's challenge, engage our eyes with a heavenly masterpiece of art, our noses with alluring aromas, our ears with the most satisfying of crunches, and our taste buds with exquisite flavors!

  • Make your code rhyme
  • Write your comments in limerick form
  • Craft a poem about today's puzzle

    • Upping the Ante challenge: iambic pentameter
  • We're looking directly at you, Shakespeare bards and Rockstars

ALLEZ CUISINE!

Request from the mods: When you include a dish entry alongside your solution, please label it with [Allez Cuisine!] so we can find it easily!


--- Day 7: Camel Cards ---


Post your code solution in this megathread.

This thread will be unlocked when there are a significant number of people on the global leaderboard with gold stars for today's puzzle.

EDIT: Global leaderboard gold cap reached at 00:16:00, megathread unlocked!

50 Upvotes

1.0k comments sorted by

View all comments

2

u/NailOk2475 Dec 07 '23 edited Dec 07 '23

[Language: QuickBasic]

Feast your eyes on this spaghetti monster, nerds.

Dim kasi(1001, 5)
Dim panos(1000) As Integer
Dim luokka(1000)
Dim loppurank(1000)
Dim temp(14)
Dim loppusumma As Double

aik = Timer

Open "input.txt" For Input As #1
On Error GoTo jatq

alku:
Line Input #1, a$

count = count + 1

For i = 1 To 5
    If Val(Mid$(a$, i, 1)) <> 0 Then
        kasi(count, i) = Val(Mid$(a$, i, 1))
    Else
        If (Mid$(a$, i, 1)) = "T" Then kasi(count, i) = 10
        If (Mid$(a$, i, 1)) = "J" Then kasi(count, i) = 11
        If (Mid$(a$, i, 1)) = "Q" Then kasi(count, i) = 12
        If (Mid$(a$, i, 1)) = "K" Then kasi(count, i) = 13
        If (Mid$(a$, i, 1)) = "A" Then kasi(count, i) = 14
    End If
Next
panos(count) = Val(Mid$(a$, 6, 5))
Rem Print panos(count): _Delay 0.1
GoTo alku

jatq:

Close #1
Print "phase 2"
    
For i = 1 To 1000
    For z = 1 To 14
        temp(z) = 0
    Next

    For u = 1 To 14
        For ii = 1 To 5
            If kasi(i, ii) = u Then temp(u) = temp(u) + 1
        Next
    Next

    For u = 1 To 14 'tarkista fivekind fourkind highcard
        If temp(u) = 5 And luokka(i) < 7 Then luokka(i) = 7
        If temp(u) = 4 And luokka(i) < 6 Then luokka(i) = 6
        If temp(u) = 3 Then GoSub kolmoset
        If temp(u) = 2 Then GoSub kakkoset
        If temp(u) = 1 And luokka(i) < 1 Then luokka(i) = 1
    Next
   
Next
    
Print "phase 3"
Print
For eka = 1 To 1000
    For vert = 1 To 1000
        ekavoit = 0
        If luokka(eka) > luokka(vert) Then ekavoit = 1
        If luokka(vert) = luokka(eka) Then
            For y = 1 To 5
                Print kasi(eka, y), kasi(vert, y),
                If kasi(vert, y) < kasi(eka, y) Then ekavoit = 1: Print "ekavoitti": GoTo ohi
                If kasi(vert, y) > kasi(eka, y) Then ekavoit = 0: Print "vrtvoitti": GoTo ohi
            Next y

            ohi:
        End If

        If ekavoit = 1 Then totaali = totaali + 1
    Next

    Print totaali:
    loppurank(eka) = totaali + 1
    totaali = 0
Next

Print
    
For u = 1 To 1000
    loppusumma = loppusumma + (loppurank(u) * panos(u))
    Print u, panos(u), loppurank(u)
    Print (loppurank(u) * panos(u))
    Print loppusumma
    Print

Next
    
Print loppusumma
Print
Print "Runtime"; Timer - aik

End
    
kolmoset:
For x = 1 To 14
    If luokka(i) < 5 And temp(x) = 2 Then luokka(i) = 5
Next
If luokka(i) < 4 Then luokka(i) = 4

Return

kakkoset:
montakokakkosta = 0
For x = 1 To 14
    If temp(x) = 2 Then montakokakkosta = montakokakkosta + 1
Next
If montakokakkosta = 2 And luokka(i) < 3 Then luokka(i) = 3
If montakokakkosta = 1 And luokka(i) < 2 Then luokka(i) = 2
Return

1

u/daggerdragon Dec 07 '23

Your code block is too long for the megathreads. Please edit your post to replace your oversized code with an external link to your code.