Previous thread: adventofcode.com/ >Advent of Code is a series of small programming puzzles for a variety of skill levels. They are self-contained and are just as appropriate for an expert who wants to stay sharp as they are for a beginner who is just learning to code. Each puzzle calls upon different skills and has two parts that build on a theme. You need to register with an account but you can appear as anonymous.
Private leaderboard join code:
368748-e33dcae3
People who are inactive for 5 days will be kicked, but other leaderboards can be made if desired.
Alternative leaderboard for those waiting for inactives to be kicked from the first:
Doesn't look that bad, he's a jerk for making part of the problem just parsing the input. Unnecessary.
Kayden Taylor
rank 219 and 103, no points :(
Justin Bennett
I figured out how to do it, but I don't know how to parse the sting. Can somebody link me to something on how to do regular expressions in python for this case without giving me the answer?
Luke Johnson
Is Peter Tseng God's gift to programming?
Connor Hill
this just count overlaps in an nxn array
Michael Stewart
Here user, take this
import re
def do_scrub(scrub, s): '''Remove characters designated by `scrub` from `s`.''' # If it starts with '[' then it's probably a regex character class. # Otherwise, assume it's a normal list of characters. if scrub.startswith('['): s = re.sub(scrub, ' ', s) else: for c in scrub: s = s.replace(c, ' ') return s
def get0(scrub=None): '''Get the entire input from stdin. Input is scrubbed using `do_scrub(scrub, _)`.''' s = sys.stdin.read().strip() if scrub is not None: s = do_scrub(scrub, s) return s
def get1(cvt=str, scrub=None): '''Get 1-dimensional input from stdin, one entry per line. Each line is scrubbed, stripped, and converted using `cvt`.''' xs = [] for line in sys.stdin: if scrub: line = do_scrub(scrub, line) line = line.strip() if line: xs.append(cvt(line)) return xs
def get2(cvt=str, scrub=None): '''Get 2-dimensional input from stdin. `cvt` and `scrub` work as in `get1`.''' xs = [] for line in get1(scrub=scrub): xs.append([cvt(part) for part in line.split()]) return xs
Then `get2(int, '[^0-9]')` gets you the input as a list of 5-tuples of ints, so you can do `for n, x, y, w, h in claims: ...`. (Specifically, it reads each line of stdin, replaces non-numeric characters with whitespace, strips and splits the line, and converts each substring from the split to an int.)
David Torres
don't over-engineer .just do it manually (i.e. use the "search and replace" of your IDE)
Connor Parker
Not them, but I'm a fucking idiot for not doing that
Kevin Sanchez
that 2000x2000 array. A=[[432,394,29,14]...]
import numpy as np max([*map(max,A)])
M=np.zeros([2000,2000]) for x,y,dx,dy in A: M[x:x+dx,y:y+dy]+=1
sum(sum(M>1))
for i in range(len(A)): x,y,dx,dy=A[i] if (M[x:x+dx,y:y+dy]==1).all(): print(i+1)
Mason Kelly
Well now I have motivation to install Pygame. I'll see If I can't produce a graphic when this is all said and done.