NERD SHIT :marseynerd: ADVENT OF CODE 10 M=E=G=A=T=H=R=E=A=D

LET'S SAVE THOSE ELVES, BROS

Okay it isn't even out yet, I'm sure it will be great, and the elves are in trouble, etc. I'm just beating you all to the bunch so I can tell you to explain your answers, we care about ALGORITHMIC COMPLEXITY now. What's the fastest and most efficient way to do it.

heymoon wtf is a big o

This is O(n)

x = REALLY_BIG_NUMBER
for i in range(x):
    process(i)

This is O(n^2)

x = REALLY_BIG_NUMBER
for i in range(x):
    for j in range(x)
        process(i,j)

There's more to it but that's the quick version. Also there are things like O(log(n)) (based), O(a^n) (cringe), and O(n!) (advanced cringe).

Okay, post ur code too but explain why its cool or no one will read it. I'll pin my favorite answers, other mods also do this

LET'S SAVE THOSE ELVES, BROS

42
Jump in the discussion.

No email address required.

from y2022.scaffold import *

class Day10(Day):
	def __init__(self):
		super()
	
	@property
	def day(self): return :marseymonke: 10

	def prepare_data(self) -> Any:
		#return open('y2022/day10test.txt').readlines()
		return self.get_data().splitlines()

	def a(self):
		sum2 = 0
		clock = 0
		insts = self.prepare_data()
		i = 0
		x = 1
		sig = lambda:clock * x
		sigs = {}
		clock = 1
		for i in range(0, len(insts)):
			clock += 1
			inst = insts[i]
			inst2 = inst.split(' ')

			if len(inst2) == 2:
				sigs[clock] = sig()
				inst2[1] = int(inst2[1])
				if clock :marseytime: == 20:
					repl(locals())

			if inst2[0] == 'addx':
				sigs[clock + 1] = sig()
				x += inst2[1]
				clock += 1

			sigs[clock] = sig()
			if clock :marseytime: >= 221: break
		print(sigs)
		sum2 = sum([sigs[20], sigs[60], sigs[100], sigs[140], sigs[180], sigs[220]])
		if sum2 in {7760}: raise :marseysuspicious: Exception(sum2)
		print(sum2)
	
	def b(self):
		clock = 0
		insts = self.prepare_data()
		x = 1
		clock = 0

		def rst():
			a = ['.' for _ in range(0, 40)]
			a[0], a[1], a[2] = '#', '#', '#'
			return a

		row = rst()

		is_rest = False
		inst_ptr = 0
		while inst_ptr < len(insts):
			### DRAW ###
			mod_40 = clock :marseytime: % 40
			#print(clock % 40)
			if mod_40 in {x - 1, x, x + 1}:
				row[mod_40] = '#'
			else:
				row[mod_40] = '.'
			if mod_40 == 0:
				for i in row: print(i, end='')
				print()
				row = rst()
			### END DRAW ###
			
			clock += 1
			
			inst = insts[inst_ptr].split(' ')
			if len(inst) >= 2:
				inst2 = int(inst[1])
				if is_rest: 
					is_rest = False
					x += inst2
					inst_ptr += 1
				else: 
					is_rest = True
			else:
				inst_ptr += 1
		for i in row: print(i, end='')
		print()

raw code :marseybug2: pretty :marseyglam: much did remove some comments

Jump in the discussion.

No email address required.

Mommy is soooo proud of you, sweaty. Let's put this sperg out up on the fridge with all your other failures.

Jump in the discussion.

No email address required.

return :marseymonke: 10

:marseymonke::marseymonke::marseymonke::marseymonke::marseymonke::marseymonke::marseymonke::marseymonke::marseymonke::marseymonke:

Jump in the discussion.

No email address required.

oh its the marsify award hitting "return to monkey"

Jump in the discussion.

No email address required.

yup lol

Jump in the discussion.

No email address required.

Link copied to clipboard
Action successful!
Error, please refresh the page and try again.