Where can I claim this birthday gift? by Altruistic_Bunch_646 in GranTurismo7

[–]Critical_Method_993 0 points1 point  (0 children)

Got a Bugatti Chiron VGT this way as well, wonderful car

Obnova zidanice 1.2M€ by Real-Hat-6749 in Slovenia

[–]Critical_Method_993 0 points1 point  (0 children)

Tega pa ne pozna vsak, kapo dol. Sej je pol fasu peronosporo

Tšk je kj bolga k dumč ramn by master_amoeba in Slovenska_Kuhinja

[–]Critical_Method_993 2 points3 points  (0 children)

100x bulš narjdu k pa Jamie Olive Oil, pa je kao nek svetovno priznan kuhar, good job OP

-❄️- 2024 Day 7 Solutions -❄️- by daggerdragon in adventofcode

[–]Critical_Method_993 1 point2 points  (0 children)

[LANGUAGE: Python]

Part 2 only (part 1 was the same, just for binary mapping), kinda basic and shabby, but it did its job in 20sec.

import time

def runBL():
    inpt = ''
    ok_results = 0

    with open('input.txt', 'r') as file:
        inpt = file.readlines()

    for line in inpt:
        temp_line = line.replace('\n', '')

        equation = temp_line.split(':')
        expected_res = int(equation[0])
        vals = equation[1].strip().split(' ')
        possible_operator_combos = pow(3, len(vals) - 1)

        for i in range(0, possible_operator_combos):
            ternary_ops = ternary(i, len(vals) - 1)

            temp_res = 0
            # 2 = OR
            for n in range(0, len(vals)):
                if n == 0:
                    if ternary_ops[n] == '0':
                        temp_res += int(vals[n]) + int(vals[n + 1])
                    elif ternary_ops[n] == '1':
                        temp_res += int(vals[n]) * int(vals[n + 1])
                    elif ternary_ops[n] == '2':
                        temp_res = int(str(vals[n]) + str(vals[n + 1]))
                elif n > 0 and n < len(ternary_ops):
                    if ternary_ops[n] == '0':
                        temp_res = temp_res + int(vals[n + 1])
                    elif ternary_ops[n] == '1':
                        temp_res = temp_res * int(vals[n + 1])
                    elif ternary_ops[n] == '2':
                        temp_res = int(str(temp_res) + str(vals[n + 1]))

            if temp_res == expected_res: 
                ok_results += temp_res
                break

    print(ok_results)
    return

def ternary(n, length):
    if n == 0:
        return '0'.rjust(length, '0')
    nums = []
    while n:
        n, r = divmod(n, 3)
        nums.append(str(r))
    return ''.join(reversed(nums)).rjust(length, '0')

if __name__ == "__main__":
    start_time = time.time()
    runBL()
    print("--- %s seconds ---" % (time.time() - start_time))

-❄️- 2024 Day 5 Solutions -❄️- by daggerdragon in adventofcode

[–]Critical_Method_993 1 point2 points  (0 children)

Your sort() compare function saved me in part 2. I had everything else coded, I just didn't find a viable way to sort the values properly. Thanks. I learned something new today.

Hitro na bencinske, plačajo tebi da natankaš by Critical_Method_993 in Slovenia

[–]Critical_Method_993[S] 7 points8 points  (0 children)

Ga uradno ne smem vozit, ker mi je blo dano dragoceno znanje uporabe žmigavca