/aocg/ - Advent of Code 2018 General #18

Tyler Peterson
Tyler Peterson

70 minutes to midnight edition

Previous thread: jowforums.com/thread/68802928/technology

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 (currently full):

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:

208834-4a1a9383

Attached: advent-of-code.png (173 KB, 495x276)

All urls found in this thread:

jowforums.com/thread/68802928/technology
adventofcode.com/
catawiki.com/p/477-catawiki-advent-of-code-2018-raffle
youtube.com/watch?v=hjGZLnja1o8
youtube.com/watch?v=NiJsYVLj8Bo
youtube.com/watch?v=tyneiz9FRMw
youtube.com/watch?v=P-3GOo_nWoc
en.wikipedia.org/wiki/Fortune's_algorithm
reddit.com/r/adventofcode/comments/a3kr4r/2018_day_6_solutions/
hastebin.com/jasitobefo
pastebin.com/cDMMgRyE
jowforums.com/thread/68809132/technology

Christian Ortiz
Christian Ortiz

Don't forget to micronap in 3 minutes

Jeremiah Russell
Jeremiah Russell

First for Aisha!

Attached: 1503200562241.gif (900 KB, 500x333)

Leo Wilson
Leo Wilson

can't nap.
I'm doing a release that starts in 11 seconds ago :(

Gabriel Myers
Gabriel Myers

It is 2:05 in here. Last three days I went to bed 4 am. This can't be healthy.

Nathan Long
Nathan Long

Same man. I can't fucking wait for the weekend so I can sleep more than 2 hours at a time.

Kayden Murphy
Kayden Murphy

Problem is that I should be studying for my finals.

Henry Sanders
Henry Sanders

is it just me or have these threads lost a lot of momentum?

Daniel Walker
Daniel Walker

maybe because its 11pm

Anthony Diaz
Anthony Diaz

They get really busy at midnight to 2am, but It makes sense that they'll probably slow down a bit after the first couple and people get bored/give up.

Jace Brown
Jace Brown

How long until advent of code is used as a recruitment platform.

Anthony Thompson
Anthony Thompson

He doesn't know about the AoC recruitment platform

John Baker
John Baker

first two days
competitively doing the challenges as soon as they come out, close to getting on the leaderboard
work week hits, no longer willing to stay up late enough to do the challenges as they come out
start doing them the next afternoon
way more relaxing and enjoyable
Honestly this is better. The competition doesn't really matter, and doing the problems without racing is way more pleasant.

Benjamin Turner
Benjamin Turner

Brainlet filter.

Joseph Diaz
Joseph Diaz

Plus, you don't stand a chance unless you're using Python or Ruby, which not everyone wants to do.

Attached: point.jpg (44 KB, 601x625)

Jackson Robinson
Jackson Robinson

Python and Ruby confirmed the best programming languages

Jayden Sanders
Jayden Sanders

What do you guys think it's going to be about today?
Day 6 last year was looping over a list of numbers and incrementing them...

Brayden James
Brayden James

I'm certainly not being overly competative but it's still fun to stay up late and fuck around in these threads. It's all in good fun. But the ranking really doesn't matter so if you enjoy them more the next day then you should absolutely do that.

Benjamin Watson
Benjamin Watson

Who /6am/ here?

Attached: 1402503399891.png (477 KB, 1200x659)

Nathaniel Reyes
Nathaniel Reyes

best at shitting out code that only has to run once, sure

Henry Flores
Henry Flores

Will tonight be the brainlet filter?

Ryan Reed
Ryan Reed

Was yesterday the brainlet filter?

Justin Parker
Justin Parker

Nah, yesterday was like the comfy one.

Blake Hill
Blake Hill

you aren't kidding. my python code make me very uncomfortable

Bentley Johnson
Bentley Johnson

T-MINUS 30 MINUTES

Attached: IMG-0252.gif (130 KB, 500x281)

Mason Morales
Mason Morales

Would have been if the input was a bit bigger. My O(N^2) solution came out after 20 minutes.

Sebastian Brooks
Sebastian Brooks

Will tonight be the brainlet filter?
Was yesterday the brainlet filter?
the last 8 threads in a nutshell

Brandon Phillips
Brandon Phillips

Hey Jow Forums I was looking through the AoC sponsors and I saw that Catawiki is holding a free raffle for anyone who can get 35 stars
You'll need to have an AoC username

catawiki.com/p/477-catawiki-advent-of-code-2018-raffle

Attached: Screenshot-from-2018-12-05-23-28-37.png (79 KB, 1123x737)

Ryder Foster
Ryder Foster

People have been saying this since Day 3

Jacob Parker
Jacob Parker

I'm so fucking hungry, but there's only 26 minutes left. what do?

Matthew Torres
Matthew Torres

order pizza user

Attached: pizza.png (192 KB, 1043x436)

Jordan Morris
Jordan Morris

It'll only get here when the challenge starts, and I don't want to have to get the door, and have greasy fingers while trying to not be a brainlet. Should have ordered one like an hour ago. I think I'm just gonna go eat some sand.

Logan Bennett
Logan Bennett

raffle
200
fuck that

Christopher James
Christopher James

/ourguy/'s gonna take out the villians today!

James Clark
James Clark

T MINUS TWENTY MINUTES

ITS REAL NIBBA HOURS, WHO UP????

Attached: sundowner.jpg (58 KB, 500x540)

Juan James
Juan James

That's cool as heck. Education vouchers too.

Juan Diaz
Juan Diaz

how the fuck to bypass captcha? i just had to do 15 of those stupid image things just now.

Asher Lewis
Asher Lewis

I'm currently eating fried bologna and buttered toast with melted cheese on it, quick to make and eat, as well as tasty.

Aiden Sullivan
Aiden Sullivan

tfw 25 days of autism starts at the same time as this

how do i juggle this

Justin Turner
Justin Turner

Someone posted this in the old thread...I work for this guy. Small world.

Attached: 1544065731018.png (15 KB, 774x192)

Michael Anderson
Michael Anderson

enable noJS captcha on 4chanx, it forces it to do a standard one where you just select 3 out of 1 set of images, the easiest one

Cameron Torres
Cameron Torres

man, I wish I had bread lol. eh, I've got 15 minutes. I'll see what I can find.

Samuel Jenkins
Samuel Jenkins

what is that?

Jack Morales
Jack Morales

But how can they prevent people from using posted solutions to get the stars? Seems like they can't, unless they restrict it to people with global points for every day.
I guess it's a small raffle anyway, so it doesn't matter too much

Nathan Myers
Nathan Myers

Yearly /a/ rewatch of toradora + other shows

Charles Rogers
Charles Rogers

they can't, that's why its just a raffle

Parker Flores
Parker Flores

our tech recruiter James might take a look at your profile and get in touch with you later
I'll pass

Attached: Capture.png (16 KB, 583x181)

Julian Barnes
Julian Barnes

14 minutes

Nicholas James
Nicholas James

14
7777
14 14

Brody Ramirez
Brody Ramirez

Time and digits checked

Dominic Garcia
Dominic Garcia

you don't want a shitty sql/ruby job?

Charles Bell
Charles Bell

Guarantee you there are people trying to recruit from the top 100 already
I've gotten emails from google recruiters citing my ICPC results from 5+ years ago, I'm sure I would have the same for AOC if I wasn't playing anonymously

Brayden Smith
Brayden Smith

TEN MINUTES

Elijah Wilson
Elijah Wilson

Am I a brainlet? I'm a 19 y/o college student and the closest I've gotten was 150th place. Is it too late?

Thomas Torres
Thomas Torres

jowforums.com/thread/68802928/technology
don't forget to throw on your hacker tunes for extra usb keyboard points

Carson Torres
Carson Torres

Yeah, you're already breathing wrong.

Xavier Martin
Xavier Martin

Yes you should give up
There's only room for 149 programmers in the world

Jordan Richardson
Jordan Richardson

Nice find, signing up

Jordan Kelly
Jordan Kelly

150th out of 15k-20k looks pretty good
hard to say how many of them started on time though, but still

Landon Richardson
Landon Richardson

inb4 he meant the Jow Forums'derboard

Jaxon Davis
Jaxon Davis

150 on Jow Forums leaderboard or globally? that's pretty good globally, but its really only going to get harder, early days are your best shot to make top 100 when its basically just a speed typing competition

Jaxson Allen
Jaxson Allen

OH GOD
I HAVE TO SHIT SO BAD

Wyatt Ross
Wyatt Ross

Let's get this shit over with

Joseph Hughes
Joseph Hughes

indicating a sharp decrease in interest following a sharp increase in parsing bullshit

Attached: Annotation-2018-12-05-235247.png (45 KB, 969x752)

Kevin Thompson
Kevin Thompson

you have five minutes, go dump it out

Jaxson Wright
Jaxson Wright

I'm 7 in the overflow leaderboard for Jow Forums, 150 is global.

Joshua Scott
Joshua Scott

not coding in the loo
kek it's like he doesn't even want to win

Ethan Flores
Ethan Flores

T-MINUS FIVE MINUTES
PREPARE.

Attached: 1485644540392.jpg (40 KB, 385x503)

Joseph Cruz
Joseph Cruz

youtube.com/watch?v=hjGZLnja1o8

Adrian Torres
Adrian Torres

It's about time.
you better get ready, user

Bentley Evans
Bentley Evans

FIVE MINUTES ANONS!!!
LETS FUCKING DO THIS!!
youtube.com/watch?v=NiJsYVLj8Bo

Attached: -20160524-193513.jpg (126 KB, 752x999)

Owen Rodriguez
Owen Rodriguez

Currently trying to warm up my hands so I don't type all slow and clumsy

Jack Hill
Jack Hill

We maximum pajeet here, coding on the loo will only make it harder.
tfw coding on the side of the shitting street

Charles Nguyen
Charles Nguyen

there's always going to be less people as the thing goes on
that's just how it is with every kind of participatory thing

Luke Reyes
Luke Reyes

Good morning anons
Let's do this

Andrew Ortiz
Andrew Ortiz

that decrease was always going to happen as people realize they don't have what it takes to keep on the schedule like this

Jose Thompson
Jose Thompson

It's time.

Attached: 1537838663033.jpg (76 KB, 731x684)

Brandon Johnson
Brandon Johnson

Too OSU!, can't code to this, spend too much time flailing arms.

Asher Hill
Asher Hill

Best place to code bar none, get all your pajeet friends to help you out

Jeremiah Gray
Jeremiah Gray

caring about your rank instead of enjoying yourself

Attached: 153761863.gif (376 KB, 500x491)

Jonathan Brooks
Jonathan Brooks

ITS TIME

youtube.com/watch?v=tyneiz9FRMw

Attached: himiko.png (373 KB, 509x725)

Hudson Thompson
Hudson Thompson

FUCK

Sorry suffer from prefuckulation.

Christopher Ramirez
Christopher Ramirez

but if we overlay it with the previous years and a brief description of the problem set I'm betting we're going to see a pattern other than the obvious normal loss in interest

Robert Foster
Robert Foster

i swear to god if i see another wall of text...

Attached: file.png (511 KB, 746x982)

Julian Rodriguez
Julian Rodriguez

Rajesh got shit on my keyboard again

Jaxon Sanders
Jaxon Sanders

But it's always a wall of text, user

Landon Taylor
Landon Taylor

I only care this year because Jow Forums leaderboard wankery

Asher Thomas
Asher Thomas

based himikoposter do you ship kokichi with her

Samuel Bell
Samuel Bell

lets go guys

Sebastian Fisher
Sebastian Fisher

Calling it now, an even longer string to parse through. It's manual labor at this point.

Jace Morgan
Jace Morgan

nah, about the same
the bottom questions will somewhat equalize over a few weeks as latecomers pop in

Robert Sanders
Robert Sanders

What was going on in the year 1018 when the next challenge is supposed to take place?

Asher Fisher
Asher Fisher

FUCK

Caleb Reyes
Caleb Reyes

FUCK

Juan Turner
Juan Turner

OH NO SANTA WHY DO YOU HAVE TO MANHATTAN WITH THAT INPUT!!!

FUUUUUUUUUUUUCK!

Blake Sullivan
Blake Sullivan

cyka blyat

Eli Perry
Eli Perry

WARNING GRAPHING PROBLEM DETECTED!!
BRAINLET FILTER IN PROGRESS!!!

WARNING GRAPHING PROBLEM DETECTED!!
BRAINLET FILTER IN PROGRESS!!!

WARNING GRAPHING PROBLEM DETECTED!!
BRAINLET FILTER IN PROGRESS!!!

Angel Robinson
Angel Robinson

FUCK

Hudson Harris
Hudson Harris

manhattan distance
yeah no what do you think i am, smart?

Julian Powell
Julian Powell

short input
I feel good

Benjamin Harris
Benjamin Harris

WHAT IN THE NAME OF FUCK

Oliver Evans
Oliver Evans

How do you know if something is infinite?

Michael Wood
Michael Wood

I think i'd like to go back to text parsing, thank you

Attached: laughterstops.jpg (56 KB, 313x254)

Kevin Rogers
Kevin Rogers

Oh god no

David Taylor
David Taylor

AHHHHHHHHHHHHHHHHHHHHH

Josiah Cox
Josiah Cox

Ah, there it is
The Great Brainlet Filter

Dominic Turner
Dominic Turner

GUYS REUSE YOUR 2017 ALGORITHM!

Carson Thompson
Carson Thompson

what the fuck is taxicab geometry

Thomas Edwards
Thomas Edwards

OwO we just learned about manhattan distance in my game development course

Jace Walker
Jace Walker

youtube.com/watch?v=P-3GOo_nWoc

Kayden Walker
Kayden Walker

can someone explain manhattan distance to a brainlet
pls its all parsed i just need a basic idea on how to do it

Josiah Richardson
Josiah Richardson

I don't have an algo, I just stopped counting after a fuckton of time last year

Logan Phillips
Logan Phillips

UNFAIR ADVANTAGE GET OUT REEEEEEEEEEEEEEEEEEEEEEEE

Hudson Stewart
Hudson Stewart

My men, we have now hit the first brainlet filter

im fucked

John Morris
John Morris

wtf is this question asking I don't understand

Henry Reed
Henry Reed

This is definitely going to take some more time than the previous nights for me.

Hudson Fisher
Hudson Fisher

I have no clue what this is asking.
The problem seems simple, but I don't get the question

Austin Evans
Austin Evans

distance but you're only allowed to move like a D-Pad with 4 directions

Brody Allen
Brody Allen

Ah, here's the brainlet filter.

Attached: 10-years-20-years-200-years-how-about-im-doing-none-of-them.jpg (112 KB, 915x609)

Kevin Harris
Kevin Harris

X distance + Y distance

Carter Allen
Carter Allen

Really good explanation, thank you user

Kevin Turner
Kevin Turner

What is the biggest area you can find that doesn't get into the other areas. They're all infinit in a 2D Grid

Nicholas Gray
Nicholas Gray

really? thanks user

Brayden Ortiz
Brayden Ortiz

the biggest finite* area you can find

Owen Howard
Owen Howard

I know what it's asking, but have no idea where to start

Lincoln Brooks
Lincoln Brooks

so (x1 - x2) + (y1 - y2)?

Christopher Sanchez
Christopher Sanchez

same

Attached: raised.png (8 KB, 172x164)

James Brooks
James Brooks

Oh, I have an idea!

yes.

Nathaniel Foster
Nathaniel Foster

Reading Comprehension 101, pajeet

Nathaniel Campbell
Nathaniel Campbell

I'm done

Logan Barnes
Logan Barnes

tfw my input is short enough that I could just do it by hand

Robert Perry
Robert Perry

I'm not sure you know how to read yourself

Chase Clark
Chase Clark

10/5
Thought I was fucked on the first part cause it was taking me so long
also
tfw abs(x1 - x) + abs(y1 + y)
UFCK

Attached: aoc18day06.png (75 KB, 624x1179)

Zachary Morales
Zachary Morales

I might end up doing the same thing. I'll probably go over to staples and grab some graph paper and finish this tomorrow.

Jaxon Hernandez
Jaxon Hernandez

wtf that's quick!

Lucas Taylor
Lucas Taylor

i think im going to start with a 2d array and place all the points, and now that i think about it i could make it object oriented. each point is an object and the actual coordinate points can be accessed though a global array of pointers, how does that sound? best i could do

and it looks like the max size is 300x300, after that they are all infinite

Gabriel Butler
Gabriel Butler

OUR HERO

Eli Cook
Eli Cook

Jesus christ dude. You must be the fastest pajeet in the west.

Jason Gomez
Jason Gomez

im gonna do this tomorrow, night lads

Lincoln Rogers
Lincoln Rogers

what does the second part look like?

Juan Miller
Juan Miller

Sounds like an excellent way to find the closest points.

Adam Rivera
Adam Rivera

To clarify what's going on here:

Part 1:
Since infinite regions are excluded, and any region that extends past the bounding box of the points will be infinite (imagine a voronoi diagram), we can limit ourselves to counting points inside the bounding box plus some margin (the `off` in `gogo1`). To detect if a region is infinite, just turn up the margin: if the region gets bigger, then it must run past the edge of the box, and so it's infinite. So I compute "number of points nearest point `i`" for two margin sizes (10 for `bkt1` and 20 for `bkt2`) and print the largest region that's the same size in both `bkt1` and `bkt2`.

Part 2:
EZ, I just ran with two different margins to make sure I got all the points inside the region inside my box+margin. If `gogo(10)` and `gogo(20)` had printed different results, I would have cranked it up until the result stopped changing.

Count the number of grid points for which the sum of the distances to all the input points is less than 10000

Henry Martin
Henry Martin

IT'S HAPPENING YOU GUYS
PETERTSENG GOT 9TH ON PART 1 BUT HASN'T PLACED ON PART 2 YET
THERE ARE 51 PEOPLE DONE AND CLIMBING

Justin Collins
Justin Collins

holy shit /ourguy/ is gonna win it again

Zachary Barnes
Zachary Barnes

hes fourth rn holly shit

Isaac Martinez
Isaac Martinez

nigga dis problem bucket fill

Attached: day06.jpg (43 KB, 728x464)

Bentley Morris
Bentley Morris

best one yet and finally scored

Attached: 59.png (31 KB, 877x384)

Adam Smith
Adam Smith

i was thinking about tbat, but didn't think about using offsets

Landon Diaz
Landon Diaz

no please not me
i am not a brainlet ! ! !

Attached: 1516873080607.jpg (168 KB, 1029x1029)

James Long
James Long

He just placed at 69th. His lead on me just dropped from 160 points to 97
Gonna have to start watching Simon Parent, mserrano, and betaveros too now. The top 5 is getting pretty tight (only 108 points between 1st and 5th)

Jeremiah King
Jeremiah King

/ourguy/ keep it up my man, we are all proud of you

Camden Reed
Camden Reed

haha should be calendar pic for today

Daniel Lewis
Daniel Lewis

oh fuck

Attached: The-Wall-Game-of-thrones.jpg (144 KB, 970x545)

Jace Adams
Jace Adams

      -------Part 1--------   -------Part 2--------
Day Time Rank Score Time Rank Score
6 00:18:07 109 0 00:27:28 108 0

AAAAAAAAAAAAAA
FUCK YOU
LOST TOO MUCH TIME ON STUPID MISTAKES

Attached: 1544038395638.png (248 KB, 430x407)

Ethan Clark
Ethan Clark

Fuck dude that's rough

Gabriel Evans
Gabriel Evans

I think it should be pic related.

Attached: distancesigns.jpg (96 KB, 960x640)

Ryder Cox
Ryder Cox

ok i get what it's asking and I know how to brute-force calculate it but im pretty sure this is gonna be like O(n^2) with an input dataset of around 100,000

David Foster
David Foster

A variation on distance signs may be good.

Xavier Morris
Xavier Morris

The actual dataset is tiny, you don't need anything fancy unless you're going for the bigboi

Ryder Moore
Ryder Moore

alright that was fun, see you guys next year

Chase Russell
Chase Russell

just drop uni user, advent is the real shit

Caleb Wood
Caleb Wood

Brainlet's last stop: 0 KM

Caleb Nelson
Caleb Nelson

BRAINLET DETECTED HAHAHAHAH

Ryder Wilson
Ryder Wilson

WHY ISN'T IT WORKING AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAHH

    data = get_input()
data = [list(line_nums(x)) for x in data]
overall = 0
for x in range(500):
for y in range(500):
total = 0
for i, thing in enumerate(data):
a = thing[0]
b = thing[1]
total += abs(a - x) + abs(b - y)
if total < 10000:
print(x, y, "had total", total)
overall += 1

Jason Cruz
Jason Cruz

My code, if anyone's interested

Attached: day6.png (58 KB, 862x557)

Matthew Baker
Matthew Baker

I should have learned python. This is tedious to do both in haskell and C.
Fuck you Jow Forums for memeing me into big brain languages.

Isaiah Roberts
Isaiah Roberts

Who is /our guy/?

Jordan Rivera
Jordan Rivera

user

Nolan Baker
Nolan Baker

i hope you don't think using those languages is bad user, they just require more effort

William Ward
William Ward

Left: Normieland
Right: Wizardworld
You Are Here: Brainlet pits

Luke Morales
Luke Morales

So for part 1, you're basically doing the same as me but with margin of 0? I wasn't sure if that would work which is why I added the margin

Christopher Gutierrez
Christopher Gutierrez

read the prompt harder luser

Logan Kelly
Logan Kelly

kovleventer what happened to you?

Connor Moore
Connor Moore

That's it
I'm also making my parsing function in advance now

Eli Howard
Eli Howard

it's a voronoi diagram using manhattan distances

Ryder Bennett
Ryder Bennett

no = False

THE ABSOLUTE STATE OF PYTHON

Jordan Nelson
Jordan Nelson

he hasn't seen

True, False = False, True

Liam Miller
Liam Miller

HEY!!! I'M WALKING HERE! I'M WALKING HERE!

Attached: 81a80643716aff09df2219f0703ae8d2.png (769 KB, 960x541)

Jeremiah Price
Jeremiah Price

Oh dear god

Attached: Capture.png (14 KB, 641x453)

Daniel Cox
Daniel Cox

Are there multiple regions and you have to choose 1 or something? I've read over it multiple times AND my solution works for the test input.

Blake Ward
Blake Ward

en.wikipedia.org/wiki/Fortune's_algorithm

Nolan Ward
Nolan Ward

Fixed in python3 fortunately

Jonathan Barnes
Jonathan Barnes

Gotta go fast

Yeah. But I lost time on these
first tried a min(L, lambda = manhattan). didn't work because it didn't account for equal distances
then I break at the first d == mini, stopping it from reaching smaller distances

For part 2:
IT ABSOLUTELY HAS TO BE < 10000, <= 10000 IS WRONG

Attached: 1534240853481.jpg (58 KB, 552x291)

Cameron Murphy
Cameron Murphy

Fuck I'm so slow at typing

Attached: scrot-2018-12-06-12:41:55.png (21 KB, 600x204)

Matthew Bell
Matthew Bell

    center = tuple(map(lambda x: sum(x)//len(x),zip(*data)))
goal = 10000
bsize = goal//len(data)
prev = None
while True:
inc = 0
for l in range(center[0]-bsize,center[0]+bsize + 1):
for r in range(center[1]-bsize,center[1]+bsize+1):
if sum(abs(l-ll)+abs(r-rr) for ll,rr in data) < goal:
inc += 1
if inc == prev:
return inc
prev = inc
bsize += 100

Leo Adams
Leo Adams

Anyone have sample input and answer?
My solution gets 17 for the part 1 sample but doesn't give me my right answer

Sebastian Hernandez
Sebastian Hernandez

I have the same. I'm pretty sure my answer is correct as well.

If you add all the digits of your answer, do you get 29?

Dominic Ortiz
Dominic Ortiz

Attached: voronoi.png (5 KB, 300x300)

Dylan Kelly
Dylan Kelly

fixed in 2.7.16 from the looks of it but only on true

Adam Young
Adam Young

ok so for part one, i found the centers points that are not infinite, but i'm clueless on what to do next

is there an algorithm to find the area closest to my center point if i can find the points closest to it in every direction???

Attached: junior.png (90 KB, 660x714)

Liam Watson
Liam Watson

data = '''
275, 244
'''.strip().splitlines()
from collections import defaultdict
data = dict(enumerate(sorted((int(l),int(r)) for line in data for l,r in [line.strip().split(', ')])))

def md(data,l,r):
mdd = {n:sum(map(lambda x: abs(x[0]-x[1]), zip(lr,(l,r)))) for n,lr in data.items()}
mind = min(mdd.values())
nlist = [n for n,d in mdd.items() if d == mind]
if len(nlist) == 1:
return nlist[0]

def p1(data):
scape = dict()
minl = min(l for l,r in data.values())
minr = min(r for l,r in data.values())
maxl = max(l for l,r in data.values())
maxr = max(r for l,r in data.values())
for l in range(minl-maxl,maxl+1+minl):
for r in range(minr-maxr,maxr+1+minl):
scape[(l,r)] = md(data,l,r)
qualified = set(data.keys())
for l in (minl-maxl,maxl+minl):
for r in range(minr-maxr,maxr+1+minl):
qualified.discard(scape[(l,r)])
for l in range(minl-maxl,maxl+1+minl):
for r in (minr-maxr,maxr+minl):
qualified.discard(scape[(l,r)])
return max(sum(1 for x in scape.values() if x == q) for q in qualified)

def p2(data):
data = list(data.values())
center = tuple(map(lambda x: sum(x)//len(x),zip(*data)))
goal = 10000
bsize = goal//len(data)
prev = None
while True:
inc = 0
for l in range(center[0]-bsize,center[0]+bsize + 1):
for r in range(center[1]-bsize,center[1]+bsize+1):
if sum(abs(l-ll)+abs(r-rr) for ll,rr in data) < goal:
inc += 1
if inc == prev:
return inc
prev = inc
bsize += 100

if __name__ == '__main__':
print(p1(data))
print(p2(data))

Nathaniel Long
Nathaniel Long

meh, I spent a while thinking about what would be an efficient way to do this
then I said fuck it and just made a big 2d array and filled in the values
and the input is so small that it works no problem, program runs in a split second

fuck me.
That's what I get for not doing it the retarded way from the get go

Ryan Howard
Ryan Howard

Brainlet filter avoided for now. Got star 1.

Attached: s9NR21p.png (144 KB, 800x800)

Cooper Baker
Cooper Baker

You have 149 points.

-------Part 1-------- -------Part 2--------
Day Time Rank Score Time Rank Score
6 00:26:10 239 0 00:38:30 228 0
5 00:24:27 1382 0 00:27:34 820 0
4 00:43:47 874 0 00:59:35 1056 0
3 00:16:48 730 0 00:27:34 851 0
2 00:04:00 150 0 00:09:10 149 0
1 00:00:42 11 90 00:04:04 42 59

Deciding I'm too much of a brainlet to really compete for points makes doing this much nicer. I liked today's, even if I came up with a disgustingly pajeetish answer.

Kayden Flores
Kayden Flores

108, 324
46, 91
356, 216
209, 169
170, 331
332, 215
217, 104
75, 153
110, 207
185, 102
61, 273
233, 301
278, 151
333, 349
236, 249
93, 155
186, 321
203, 138
103, 292
47, 178
178, 212
253, 174
348, 272
83, 65
264, 227
239, 52
243, 61
290, 325
135, 96
165, 339
236, 132
84, 185
94, 248
164, 82
325, 202
345, 323
45, 42
292, 214
349, 148
80, 180
314, 335
210, 264
302, 108
235, 273
253, 170
150, 303
249, 279
255, 159
273, 356
275, 244

4166
42250

Ayden Miller
Ayden Miller

disgustingly pajeetish answer
same here, i'm disappointed with my pajeet brute force solution that took 5 seconds

i can't wait for a smart user to tell me the algorithmically smart way

Grayson Price
Grayson Price

yay

Attached: firefox-2018-12-05-23-50-47.png (5 KB, 689x81)

Jeremiah Miller
Jeremiah Miller

tfw drunk and cant figure out what's wrong with your solution

Attached: 1529250801870.png (918 KB, 870x720)

Colton Sanchez
Colton Sanchez

Keep at it, akkoposter!

Attached: bocchi-wah-hah-hah.jpg (7 KB, 159x124)

Jonathan Torres
Jonathan Torres

rank 800 on part 1
Kill me

Gabriel Bennett
Gabriel Bennett

Part 2 or Part 1?

Jonathan Cruz
Jonathan Cruz

with open("input", "r") as f:
data = f.read().split("\n")

points = []
for point in data:
if len(point) > 0:
x = int(point[:point.index(",")])
y = int(point[point.index(",") + 2:])

points.append((x, y))

region = 0
for x in range(500):
for y in range(500):
totalDist = 0
for p in points:
totalDist += abs(p[0] - x) + abs(p[1] - y)

if totalDist < 10000:
region += 1

print(region)

can someone tell me why the fuck this doesn't work.

Grayson Myers
Grayson Myers

looking forward to the more difficult ones where I will place top 100

Attached: rank.png (10 KB, 619x218)

Caleb Lee
Caleb Lee

keep at it bocchiposter

i had to google what the fuck a manhattan distance was so i think this score is ok ????

Attached: z.png (8 KB, 848x135)

Zachary Ramirez
Zachary Ramirez

Part 1

I can post my code but I warn you that it is extremely disgusting

Attached: zCapture.jpg (61 KB, 500x491)

Luis Thomas
Luis Thomas

can someone help us out and just explain in plain english/psuedo code what the key algorithm is for part one? i can get all of the relevant pieces but have no idea what to do with them

Attached: diarrhea.png (87 KB, 218x218)

Dominic Brown
Dominic Brown

meant to reply to

paint by numbers?

here's my ultra-pajeet trick for finding the infinite ones:
chances are that any region an edge location to will be infinite, so when you get to a point where x == 0 or x == max_x or y == 0 or y == max_y, find the closest point and add it to a blacklist. When you calculate your part1 solution, just remove all the blacklisted points from consideration.

thank you
once again my complete ignorance of geometric algorithms bites my ass

Josiah Flores
Josiah Flores

Fuck I get 4166 for your part one as well but I still have the wrong answer for mine

177, 51
350, 132
276, 139
249, 189
225, 137
337, 354
270, 147
182, 329
118, 254
174, 280
42, 349
96, 341
236, 46
84, 253
292, 143
253, 92
224, 137
209, 325
243, 195
208, 337
197, 42
208, 87
45, 96
64, 295
266, 248
248, 298
194, 261
157, 74
52, 248
243, 201
242, 178
140, 319
69, 270
314, 302
209, 212
237, 217
86, 294
295, 144
248, 206
157, 118
155, 146
331, 40
247, 302
250, 95
193, 214
345, 89
183, 206
121, 169
79, 230
88, 155

Tell me you don't get 3358 For the answer to this

Xavier Edwards
Xavier Edwards

My code is wrong for part 1 and I have no idea why.

def manhattan_distance(first, second):
return abs(first[0] - second[0]) + abs(first[1] - second[1])
def p1(data):
d = [[(-9999, -9999) for _ in range(500)] for _ in range(500)]
for x, y in data:
for i,j in product(range(500), range(500)):
other = d[i][j]
if other is None:
continue
else:
distance = manhattan_distance((x,y), (i,j))
other_distance = manhattan_distance(other, (i,j))
if distance < other_distance:
d[i][j] = (x,y)
elif distance == other_distance:
d[i][j] = None
infinite = set([d[k][0] for k in range(500)] + [d[0][k] for k in range(500)] + [d[499][k] for k in range(500)] + [d[k][499] for k in range(500)])
c = Counter([d[i][j] for i, j in product(range(500), range(500))])
print(sorted([k for k in c.items() if k[0] not in infinite], key=lambda m: m[1], reverse=True))
return max([k for k in c.items() if k[0] not in infinite], key=lambda m: m[1])

Basically it sets an entire 2D grid to a super far distance and the other points just fill up the spots that are closer, and any spots where the range is the same it gets transformed to None and ignored from thereon after

Benjamin Clark
Benjamin Clark

I don't think there's anything smarter than bruteforcing it
I mean, you need to check every coordinates pair

Aaron Green
Aaron Green

same problem here, i've re-read the description a few times and i think this is exactly what it's asking for

Jaxon Russell
Jaxon Russell

PART 2 IS BUGGED FOR SOME PEOPLE

I WAS JUST OUTSIDE THE TOP 100 FIRST PART ONE AND COULD HAVE BEEN TOP 100 FOR PART TWO FEELING HELLA DABBED ON RIGHT NOW LADS

Attached: dabbed.png (153 KB, 426x470)

Parker Cooper
Parker Cooper

Day   Global   Jow Forums
1 17 1
2 48 2
3 71 4
4 89 7
5 -- 7
6 -- 4

Iterate over row,column pairs over a fuckhuge array. Make a set of all potential hubs. Remove the hubs that have closest points touching the edge. Iterate over the hubs that are left, checking how many there are for each.

I do. Are you sure you copied the full input?

Aaron Ramirez
Aaron Ramirez

The top 5 so far
Looks like I really need to keep an eye on Simon Parent (purple line)

Attached: graph.png (8 KB, 1100x500)

Andrew Watson
Andrew Watson

here's my ultra-pajeet trick for finding the infinite ones

yeah i have that part down, its the rest i'm lost on. do we literally iterate for every point in the grid and just decide which coordinate it belongs to? that seems like the wrong way to do it, i feel like there should be an equation or something if i just have a center coordinate and the closest point in each direction

Aaron Evans
Aaron Evans

PART 2 IS BUGGED FOR SOME PEOPLE
Elaborate.

Brandon Thompson
Brandon Thompson

is this real?

Samuel Sanchez
Samuel Sanchez

Tell me you don't get 3358 For the answer to this
different user here and no. according to mine it's off by quite a bit

Robert Foster
Robert Foster

wow

Christopher Jenkins
Christopher Jenkins

HIT OR MISS

Attached: AYAYA.jpg (9 KB, 240x240)

Jace Roberts
Jace Roberts

it was pretty easy though. Way sorter than part1.

Christian Reyes
Christian Reyes

It doesn't accept the right answer.

Ryder Brown
Ryder Brown

Yes I'm bretty sure I copied the full input I see the head and the tail of it are just the same as the input file open in my browser. And I saved it directly from browser to my test case folder before opening it with python.
I think this problem may just be bugged sadly

James Morris
James Morris

me too. same for others on plebbit.

Jordan Adams
Jordan Adams

there are a bunch of people on reddit saying part 2 is bugged for them also

Ryder Ward
Ryder Ward

test my input with someone's else's solution
get correct answer

use test input from user in thread with my solution
get correct answer

FUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUCK

Attached: 1516187988001.png (308 KB, 530x617)

Ethan Barnes
Ethan Barnes

range 500 x to 500 y
is the problem
think about how close the nearest/furthest point is to (0,0) or (500,500) for example

Hudson Campbell
Hudson Campbell

He fucked up.

Attached: trd2f7u73f63ykxdqgnl-400x400[1].jpg (19 KB, 400x400)

Eli Cruz
Eli Cruz

no, the region is well within [0,500)

Christopher Fisher
Christopher Fisher

NOW WHO'S THE BRAINLET YOU ONIONS GUZZLING BASEDBOY FAGGOT

Gabriel Williams
Gabriel Williams

Oh shit, I wonder if that's what happened to petertseng

Jason Jones
Jason Jones

do we literally iterate for every point in the grid and just decide which coordinate it belongs to? that seems like the wrong way to do it
that's what i did, and it worked. i'm certain there's a better way but i'm too sleepy to figure it out

but off the top of my head, you would first need to treat each location as a node in a fully-connected graph, and then find the minimum spanning tree. Then, there should be a way to use an equation to get the boundaries between each node in the min spanning tree.

Anthony Bennett
Anthony Bennett

mfw part 2 is easier than part 1

Bentley James
Bentley James

You probably have an extra new line that's getting added as a [0,0] coordinate. Might be something else though.
"It's wrong!!" ... No, you're wrong.

Mason Garcia
Mason Garcia

I have no idea why.

me neither

Jayden Barnes
Jayden Barnes

who here corrupted

input start: 84, 212
part 2 answer: 44634

Juan Davis
Juan Davis

i am sorry anons, i would like to help but the code looks scary

Attached: 1536346654683.png (6 KB, 253x199)

Benjamin Young
Benjamin Young

hello sirs, please to be joining indian coding contest of highest quality

Isaiah Moore
Isaiah Moore

[01:00] PLEASE HOLD - INVESTIGATION IN PROGRESS

Ryan Johnson
Ryan Johnson

Forgive me for linking to r*ddit but it's pretty clear part 2 is actually bugged
reddit.com/r/adventofcode/comments/a3kr4r/2018_day_6_solutions/

Let's just hope they drop it from the score

Ayden Bell
Ayden Bell

Attached: shits-fucked-yo.png (215 KB, 1366x768)

Adrian Powell
Adrian Powell

Climbed up to #8. Hope my rank won't drop so easily.

Attached: Screenshot-2018-12-06-14-04-37-350-com.android.chrome~01.png (71 KB, 1080x293)

Lincoln Powell
Lincoln Powell

Looks like a few anons got fucked by the bug.

Attached: -g--leaderboard.png (49 KB, 783x262)

Nathaniel Perez
Nathaniel Perez

0:[(0,0)]
1:[(1,0), (0,1), (-1,0), (0,-1)]
2:[(2,0), (1,1), (0,2), (-1,1), (-2,0), (-1,-1), (0,-2), (1,-1)]

Jayden Ward
Jayden Ward

Im getting issues with part 1 not taking my answers
seems other people are dealing with this too

Angel Lewis
Angel Lewis

That's not the right answer.
I'm getting filtered, fuck

def starone(listf):
border = [(0,0),(500,500)]
SWX, SWY, NEX, NEY = border[0][0], border[0][1], border[1][0], border[1][1]
board = dict()
for i in range(border[1][0]+1):
for j in range(border[1][1]+1):
distances = [abs(i-x)+abs(j-y) for x,y in listf]
abso = sorted(distances.copy())
if abso[0] == abso[1]: board[(i,j)] = -1
else: board[(i,j)] = distances.index(abso[0])
areas = list(board.values())
removal = set()
for i in range(SWX,NEX+1):
removal.add(board[(i,SWY)])
removal.add(board[(i,NEY)])
for i in range(SWY,NEY+1):
removal.add(board[(SWX,i)])
removal.add(board[(NEX,i)])
circles = [areas.count(i) for i in range (0, len(listf)) if i not in removal]
return(max(circles))

Noah Phillips
Noah Phillips

[01:10] Update

/u/topaz2078 has confirmed there is a bug in the answer of some of the inputs. We are actively working to correct the bug right now and will follow-up with more information as soon as it is resolved.

Luke Rodriguez
Luke Rodriguez

sorry bro, you got wrecked by the newline at eof

with open("input", "r") as f:
data = f.read().strip().split("\n")

Austin Turner
Austin Turner

When does the lynching start?

Matthew Flores
Matthew Flores

part 1
issues with part 1 answers right?
I'm getting this too on part 1

Not sure how they have handled this stuff in the past

Elijah Edwards
Elijah Edwards

SOMEONE POST THEIR CODE FOR PART 1 WHILE THEY FIX THIS REEE IM NOT A BRAINLET

Landon Long
Landon Long

Damn, how I just had an if statement to check if I accumulated over 10k area...I tried excluding the max x/y points and it still ran infinitely long. What's the trick to this?

Gabriel Lopez
Gabriel Lopez

part 1 solution doesn't work
solution from thread gives same answer
W-who cares about the leaderboard anyway? It's just for fun, r-right?

Attached: angry.jpg (149 KB, 700x700)

Caleb Thompson
Caleb Thompson

i-i would've b-been 1st place if it weren't f-for the b-bug

Aiden Perry
Aiden Perry

I got the 181, 184 bugged one with same answer
MOTHERFUCKER

Leo Richardson
Leo Richardson

So do we get a redo/do-over like in NC-9?

Henry Bell
Henry Bell

notice

if len(point) > 0:

also, if that were the problem, the calls to point.index() would throw exceptions

just stop trying user

Attached: 1501698547890.png (78 KB, 1000x1000)

Joseph Sanders
Joseph Sanders

I demand a refund.

Asher Garcia
Asher Garcia

WHY DOESNT IT WORK AAAAAAAAAAA

from collections import Counter

points = open("input", 'r').readlines()
points = [(int(l.split(", ")[0]), int(l.split(", ")[1][:-1]) ) for l in points]

maxX = 400
maxY = 400

points = Counter(points)
grid = [[0 for y in range(maxY)] for x in range(maxX)]

def getClosestPoint(x,y,points):
minDist = float('inf')
minpoint = None
distances = []

for p in points:
dist = abs(x-p[0]) + abs(y-p[1])
distances.append(dist)
if dist < minDist:
minpoint = p
minDist = dist

if len(set(distances)) < len(distances):
return None
else:
return minpoint

for x in range(-100,maxX):
for y in range(-100,maxY):
if (x,y) in points: continue

nearestPoint = getClosestPoint(x,y,list(points))
if nearestPoint:
grid[x][y] = nearestPoint
points[nearestPoint] += 1

for x in range(-100, maxX):
del points[grid[x][0]]
del points[grid[x][maxY-1]]
for y in range(-100, maxY):
del points[grid[0][y]]
del points[grid[maxX-1][y]]

print(points)
print(points[max(points, key=lambda x: points[x])])

Attached: 1520591311441.jpg (6 KB, 145x145)

Caleb Ramirez
Caleb Ramirez

dude, if don't believe me
print points
and look at your last two points
(275, 244), (275, 244)
and then look at your input file

Carter Thomas
Carter Thomas

tfw brainlet

how do I filter out the infinite regions?

Jaxson Jenkins
Jaxson Jenkins

alright have an input
hastebin.com/jasitobefo
I get 7418 with this garbage

Angel Moore
Angel Moore

If they're infinite they must be at the edge.

Carson Hall
Carson Hall

If you enter one higher than your answer and it says your answer was too high, but your actual answer just says wrong without saying too high, you're input is bugged.

Benjamin Davis
Benjamin Davis

AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA

sorry for bullying you user.
how does this even happen though?

Attached: 1494547620463.jpg (54 KB, 597x597)

Grayson Davis
Grayson Davis

Part 1 and Part 2 confirmed to have broken answers

Nathan Lewis
Nathan Lewis

nnnneeeeeeeerrrrrrddddsss

Attached: reddit-right-now.jpg (106 KB, 494x550)

Gabriel Cook
Gabriel Cook

because you forgot to put
points.append((x, y))
inside the if block

Carter Parker
Carter Parker

lol

that's easier than expected lmao

Jack Moore
Jack Moore

AYYYYYYYYYYYY LMAO

Elijah Nguyen
Elijah Nguyen

I wasted 80 minutes of my time. This is the last time I fall for reddit games.

Jace King
Jace King

 if i in (minx, maxx) or j in (miny, maxy):
coords[mindistC[0]] = -1

THESE TWO FUCKING LINES COST ME LIKE 30 MINUTES, FUUUUUUUUUUUUUUUUCK

Joshua Murphy
Joshua Murphy

Could someone who's done part 1 tell me what this output should result in? I might go insane trying to figure out what the fuck im doing wrong:

pastebin.com/cDMMgRyE

Attached: 1520633635131.jpg (18 KB, 354x423)

Dylan Cruz
Dylan Cruz

Dude saaaame fuck

Cooper Ramirez
Cooper Ramirez

the x and y vars don't lose scope after the if statement. so when "point" is actually a newline character, that if statement is skipped and the same x, y pair gets added to points as last time.

Brody Morales
Brody Morales

you could break out when there hasn't been a new point in x steps
or you could just let it run for 2 seconds and insert a breakpoint and check the value manually

Nicholas Sanchez
Nicholas Sanchez

im done

Attached: 1496283362742.gif (27 KB, 250x350)

Zachary Fisher
Zachary Fisher

okay, I've thoroughly scrutinized my code. it does not accept my answer. I've tried some code posted here. It won't accept that either.

Julian White
Julian White

Bugs fixed, yay #900 on the leaderboard.

Julian Wood
Julian Wood

There goes my nice place on the leaderboard, god damn it

Attached: 1481949010931.jpg (29 KB, 403x330)

Caleb Price
Caleb Price

I'm getting 4290

Luke Cruz
Luke Cruz

BUG FIXED

Anthony Perry
Anthony Perry

im surprised my pajeet code worked

data=open("freq.txt", "r").readlines()

poo = []

def manhattan_distance(p, q):

if(len(p) != len(q)):
print("Be sure that both vectors are the same dimension!")
return

return sum([abs(p[i]-q[i]) for i in range(len(p))])

for i in range(400):
poo.append(['*']*400)
i=0

places=[]
for line in data:
i+=1
x = int(line[:line.index(',')])
y = int(line[line.index(',')+2:].strip())

poo[x][y]=i
places.append([x,y,i])



for i in range(len(poo)):
match=True
for j in range(len(poo[i])):
mindist=801
for place in places:
dist = manhattan_distance(place[:2],[i,j])
if dist<mindist:
mindist=dist
name=place[-1]
match=False
elif dist==mindist:
match=True
if not match:
poo[i][j]=name
else:
poo[i][j]='*'

removed=[]
for j in range(len(poo[0])):
if poo[0][j] not in removed:
removed.append(poo[0][j])

if poo[j][0] not in removed:
removed.append(poo[j][0])

if poo[j][-1] not in removed:
removed.append(poo[j][-1])

if poo[-1][j] not in removed:
removed.append(poo[-1][j])


codes=[0]*51
for i in range(len(poo)):
for j in range(len(poo[i])):
if poo[i][j] != '*' and poo[i][j] not in removed:
codes[poo[i][j]]+=1

print(codes)
top=0
for key in codes:
if key>top:
top=key


print(top)

Brayden Robinson
Brayden Robinson

Felt like real pajeet this time.
Is there any elegant solution to this? I ended up just calculating min distances from every point in the grid to all other interest points.
Took me like 20 minutes to debug that I should check all distances before discarding on collision.

Carter Cox
Carter Cox

This region, which also includes coordinates D and E, has a total size of 16.

I'm getting a region of 12 (4x3). What the hell am I doing wrong?!

Attached: infinite-brainlet.png (27 KB, 586x578)

Parker Garcia
Parker Garcia

BUGS FIXED BUGS FIXED BUGS FIXED BUGS FIXED

i'm close to you, though one night i just fell asleep lol

Attached: Capture.png (12 KB, 617x226)

Hudson Adams
Hudson Adams

My answer says "too high" but I'm going to just believe it's bugged.

Attached: 1426733267047.png (25 KB, 400x400)

Jayden Butler
Jayden Butler

tfw ruined by the bug

Attached: JUST.png (10 KB, 582x74)

Isaac Russell
Isaac Russell

Thanks, this should help me diagnose things

Attached: 1520628327056.png (41 KB, 217x232)

Camden Peterson
Camden Peterson

fuck i'm getting filtered guys

David Torres
David Torres

maybe you're missing the red ones?

Attached: 1543502780365.png (7 KB, 133x270)

Logan Bailey
Logan Bailey

bug is fixed
verify solution twice
Because you have guessed incorrectly 7 times on this puzzle, please wait 10 minutes before trying again.
time to get locked out

Aiden Baker
Aiden Baker

BUGS FIXED
put in new correct and verified answer

You gave an answer too recently; you have to wait after submitting an answer before trying again. You have 6m 57s left to wait.

Justin Harris
Justin Harris

wait it increases penalty time the more you get wrong answer? 10 mins is hella long

Aaron Watson
Aaron Watson

[01:26] Update - not fixed :(
Apparently the bug is in both parts 1 and 2. Stand by for further updates.

HAHAHAHAHA

Samuel Cox
Samuel Cox

FUCKING HELL the bug lost me so much time and my place on the leaterboard

Attached: bug.png (735 KB, 1000x1119)

Joshua Evans
Joshua Evans

bruteforce edition

#!/usr/bin/python3
import csv
import operator
from math import *

with open('input') as f:
data = [[int(row[0]), int(row[1])] for row in csv.reader(f, delimiter=',')]

minx = min(x for x,y in data)
maxx = max(x for x,y in data)
miny = min(y for x,y in data)
maxy = max(y for x,y in data)
print(minx,miny,maxx,maxy)
szx = maxx - minx
szy = maxy - miny
print(szx,szy)

maxd = szy+szx
grid = [[[None,maxd+1] for _ in range(szx+1)] for _ in range(szy+1)]

def graph():
global grid
for i,p in enumerate(data):
for y in range(miny,maxy+1):
for x in range(minx,maxx+1):
d = grid[y-miny][x-minx]
dist = abs(x-p[0]) + abs(y-p[1])
if dist < d[1]:
grid[y-miny][x-minx] = [i, dist]
elif dist == d[1]:
grid[y-miny][x-minx] = [None, dist]

def cull():
global grid
inf = set()
for x in range(szx+1):
if grid[0][x][0] not in inf:
inf.add(grid[0][x][0])
if grid[szy][x][0] not in inf:
inf.add(grid[szy][x][0])
for y in range(szy+1):
if grid[y][0][0] not in inf:
inf.add(grid[y][0][0])
if grid[y][szx][0] not in inf:
inf.add(grid[y][szx][0])
sizes = {}
for y in range(0,szy+1):
for x in range(0,szx+1):
e = grid[y][x]
if e[0] == None:
continue
if e[0] in inf:
grid[y][x] = [None,maxd+1]
else:
if e[0] not in sizes:
sizes[e[0]] = 0
sizes[e[0]] += 1
#print(sizes)
maxsz = max(sizes.items(), key=operator.itemgetter(1))[1]
return maxsz

def count(maxd):
sz = 0
for y in range(miny,maxy+1):
for x in range(minx,maxx+1):
dist = 0
for p in data:
dist += abs(x-p[0]) + abs(y-p[1])
if (dist < maxd):
sz += 1
return sz

graph()
print(cull())
print(count(10000))

Aaron Rogers
Aaron Rogers

[email protected] /m/D/t/s/0/2/06> hyperfine ./prog.py
Benchmark #1: ./prog.py
Time (mean ± σ): 671.2 ms ± 7.2 ms [User: 630.5 ms, System: 36.8 ms]
Range (min … max): 660.6 ms … 682.2 ms

Xavier Reyes
Xavier Reyes

Bug is fixed my ass
Fuck you for baiting me into the 4th failed attempt

Cooper Flores
Cooper Flores

Fucking forgot to abs the value of my manhatten distance.

Carson Morales
Carson Morales

315, 342
59, 106
44, 207
52, 81
139, 207
93, 135
152, 187
271, 47
223, 342
50, 255
332, 68
322, 64
250, 72
165, 209
129, 350
139, 118
282, 129
311, 264
216, 246
134, 42
66, 151
263, 199
222, 169
236, 212
320, 178
202, 288
273, 190
83, 153
88, 156
284, 305
131, 90
152, 88
358, 346
272, 248
317, 122
166, 179
301, 307
156, 128
261, 290
268, 312
89, 53
324, 173
353, 177
91, 69
303, 164
40, 221
146, 344
61, 314
319, 224
98, 143

what the fuck is wrong with this input?! I'm stuck on 4290 and its NOT correct

Joseph Jackson
Joseph Jackson

out of everything you could have done wrong, that is probably the stupidest

Noah Perez
Noah Perez

I'm on my 7th

Sebastian Sanchez
Sebastian Sanchez

Eric Wastl? more like Eric Wasted amirite?

Attached: scrot.png (72 KB, 600x531)

Jonathan Cook
Jonathan Cook

Does this work? It's my code and accepted its answers for my input.

Connor Moore
Connor Moore

i feel like the person who made these problems doesn't understand that there should at least be some optimisation required to get a solution that runs in a feasible time. but the datasets are always small enough that you can solve it in a dumb way

Attached: 1526633521430.jpg (59 KB, 800x800)

Caleb Nguyen
Caleb Nguyen

part 1 is 4290
part 2 is between 37k and 38k

Michael Campbell
Michael Campbell

no, still 4290

Joseph Cook
Joseph Cook

Well guess I was one of the lucky ones.
At least you know your code is correct.

Sebastian Rodriguez
Sebastian Rodriguez

Argh. Kept coming up with the same answer and getting rejected and didn't know why. Should have read the fucking thread.
[spoils]Finally submitted the 2nd biggest region I found and that got accepted[/spoils]

Asher Phillips
Asher Phillips

mfw I wasn't affected by the bug

Attached: 1512220115363.jpg (29 KB, 249x291)

Angel Gutierrez
Angel Gutierrez

god what a mess

there goes the accuracy of the leaderboards now that 33% of the entire userbase is being fucked over

Enjoy the handicap everyone

Attached: qpavae.webm (1.84 MB, 800x450)

Zachary Gomez
Zachary Gomez

it's definitely 4290
unless you forgot to copy/paste a point or something

Jeremiah Myers
Jeremiah Myers

ok so if i increase the size of my dummy grid, my part 1 answer increases. this must mean i'm not filtering out all of the "infinite cases", right?

Kevin Cook
Kevin Cook

EVERYONE'S CODE KEEPS SAYING IT'S 3894
MY CODE SAYS IT'S 3894
AOC SAYS IT IS NOT 3894
FUCK THIS SHIT

Attached: 1526013756477.jpg (11 KB, 372x268)

James Rivera
James Rivera

Wait until later, it'll get harder. Later puzzles will need optomisation.

Nathan Gutierrez
Nathan Gutierrez

I think that they are trying to be "inclusive" and try to make it so that even a first year CS student could solve them, but I agree they should at least include some large input test to separate the people who just don't smack their face into their python interpreter

William Wilson
William Wilson

but it's not correct if the answer is wrong D:

Benjamin Adams
Benjamin Adams

correct

Aiden Adams
Aiden Adams

RIGGED RIGGED RIGGED

Jaxon Powell
Jaxon Powell

no, it's not

Charles Russell
Charles Russell

NEW THREAD
jowforums.com/thread/68809132/technology
jowforums.com/thread/68809132/technology
jowforums.com/thread/68809132/technology

NEW THREAD
jowforums.com/thread/68809132/technology
jowforums.com/thread/68809132/technology
jowforums.com/thread/68809132/technology

Jose Diaz
Jose Diaz

It looks like my dummy container for shared nodes isn't working but I think I'm gonna pass out before it's fixed s

Attached: Manhattan.png (6 KB, 360x351)

Leo Hughes
Leo Hughes

can someone test my dataset and see what they get? part 1 is definitely 3894 but AoC won't take it.

45, 315
258, 261
336, 208
160, 322
347, 151
321, 243
232, 148
48, 202
78, 161
307, 230
170, 73
43, 73
74, 248
177, 296
330, 266
314, 272
175, 291
75, 142
278, 193
279, 337
228, 46
211, 164
131, 100
110, 338
336, 338
231, 353
184, 213
300, 56
99, 231
119, 159
180, 349
130, 193
308, 107
140, 40
222, 188
356, 44
73, 107
304, 313
199, 238
344, 158
49, 225
64, 117
145, 178
188, 265
270, 215
48, 181
213, 159
174, 311
114, 231
325, 162

Zachary Miller
Zachary Miller

3894
nope, it's a value between 3400 and 3700

Elijah Bell
Elijah Bell

3894 is what I get

Thomas Campbell
Thomas Campbell

3551
?

Jose Allen
Jose Allen

Brute forced it, wrote some ugly as O(n^2) code with a grid of "closest points" whose dimensions are the maximum x and y values of my points. Got the solutions right on the first try, but I don't like what I wrote. It's hot garbage.

Also fought with the borrow checker a bit.

Fuck, I'd never heard of this one. I've got an algorithms final coming up though, so I'll keep that in mind in case I have a problem that involves something like this.

Carson Mitchell
Carson Mitchell

Submit you second biggest region. I want to tell you it, but now that I put in that other number, it's saying my answer is 3894.

Joseph Gutierrez
Joseph Gutierrez

    lists = [file.readline().rstrip().split(',') for i in file]
lists = [(int(i),int(j)) for i,j in lists]

I NEED TO KILL MYSELF AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA

Ayden White
Ayden White

doesn't take that either.

Isaac Edwards
Isaac Edwards

Holy fuck can't believe my code worked on 1st try.

def distance(x1, y1, x2, y2):
return abs(x1 - x2) + abs(y1 - y2)
fd = open("day6.txt", "r")
lines = fd.read().splitlines()
fd.close()
locations = []
for line in lines:
coords = line.split(", ")
for i in range(len(coords)):
coords[i] = int(coords[i])
locations.append(coords)
print(locations)
MIN_X = 9999; MIN_Y = 9999; MAX_X = 0; MAX_Y = 0
for loc in locations:
if loc[0] < MIN_X:
MIN_X = loc[0]
if loc[1] < MIN_Y:
MIN_Y = loc[1]
if loc[0] > MAX_X:
MAX_X = loc[0]
if loc[1] > MAX_Y:
MAX_Y = loc[1]
print(MIN_X, MIN_Y, MAX_X, MAX_Y)
L = MIN_X; T = MIN_Y; W = MAX_X; H = MAX_Y
total_locations = len(locations)
total_points = MAX_X * MAX_Y
points = [[[0 for i in range(total_locations + 1)] for x in range(MAX_X)] for y in range(MAX_Y)]
for y in range(MAX_Y):
for x in range(MAX_Y):
MIN = 999
for loc in range(total_locations):
points[y][x][loc] = distance(x, y, locations[loc][0], locations[loc][1])

if points[y][x][loc] < MIN:
MIN = points[y][x][loc]
points[y][x][total_locations] = loc #point belongs to loc
elif points[y][x][loc] == MIN:
points[y][x][total_locations] = 0 #belongs to nobody

coverage = [0] * total_locations
for y in range(MAX_Y):
for x in range(MAX_Y):
owner = points[y][x][total_locations]
coverage[owner] += 1
if (x == L or x == W-1 or y == T or y == H-1): #edge = disqualify
coverage[owner] = -99999
print(coverage)
print(max(coverage))

Austin Gutierrez
Austin Gutierrez

Am High on Benzos. Rate.

import re, collections, itertools
with open('input.txt') as f:
parse = lambda x: tuple(map(int, re.findall(r'\d+', x)))
points = [*map(parse, f.read().splitlines())]
ys = [min(y for _,y in points), max(y for _,y in points)]
xs = [min(x for x,_ in points), max(x for x,_ in points)]
def part_2(*p1):
return 10000 > sum(m_dist(*p1, *p2) for p2 in points)
args = [(x,y) for y in range(*ys) for x in range(*xs)]
def part_1(*p1):
table = {p2: m_dist(*p1, *p2) for p2 in points}
point = min(table, key = table.get)
if [*table.values()].count(table[point]) < 2:
result[point] += 1
result = collections.defaultdict(int)
def m_dist(x, y, x1, y1):
return abs(x1 - x) + abs(y1 - y)
[part_1(*p1) for p1 in args]; print('part 1:',
max(result.values())); print('part 2:',
sum(1 for p1 in args if part_2(*p1)))

Attached: More-Bored.gif (1.4 MB, 500x281)

Isaiah Cooper
Isaiah Cooper

my second biggest is 3551 but it won't take that.

Levi Kelly
Levi Kelly

4613?

Caleb Barnes
Caleb Barnes

If anyone is interested in working solution, here is cleaned up code

def distances(part2=False):
coords = {(x, y): 0 for (x, y) in [map(int, line.split(", ")) for line in open('input.txt').readlines()]}
min_x = min([x for (x, _) in coords.keys()])
max_x = max([x for (x, _) in coords.keys()])
min_y = min([y for (_, y) in coords.keys()])
max_y = max([y for (_, y) in coords.keys()])

in_region = 0
for i in range(min_x, max_x + 1):
for j in range(min_y, max_y + 1):
min_dist, min_dist_coord, total_dist = 1e10, None, 0
for (x, y) in coords.keys():
dist = abs(x - i) + abs(y - j)
total_dist += dist
if dist < min_dist:
min_dist = dist
min_dist_coord = (x, y)
elif dist == min_dist:
min_dist_coord = None
if total_dist < 10_000:
in_region += 1
if min_dist_coord:
if i in (min_x, max_x) or j in (min_y, max_y):
coords[min_dist_coord] = -1e10
else:
coords[min_dist_coord] += 1

return in_region if part2 else max(coords.values())

Camden Cox
Camden Cox

can some explain this problem for a brainlet,
I'm really fucking lost

Kayden Parker
Kayden Parker

dunno then. Maybe they fixed the bug in the meantime, so now you need to give the right answer

Juan Watson
Juan Watson

Based aisha poster

Attached: Aisha-from-outlaw-star--c554e413668d6c827ba97363b65eaa33.jpg (68 KB, 640x480)

Anthony Foster
Anthony Foster

thanks for your help, anons. I'm done with this shit. I've been top 20 on the Jow Forums leaderboard this entire, I guess someone here gets to move up a bit because I'm done with this shit. If the shitty site doesn't even work right, then it's not worth losing sleep over this thing.

nope. That one wasn't even in my list of areas.

Elijah Watson
Elijah Watson

b-but it can't be not working!
we just had some hard inputs user

Jace Price
Jace Price

and of course I now get to sit here and wait another 7 minutes. I'll try one more but after that I'm done. Nothing I do gets a right answer, even copy-pasting code from this thread.

Nathan Carter
Nathan Carter

passed the filter
feelsgoodman

David Long
David Long

I'll just implement fortune's algorithm later when I wake up

Gavin Hill
Gavin Hill

bye guys

Attached: Screenshot-20181206-010947.png (3 KB, 410x27)

Adam Cooper
Adam Cooper

good riddance, brainlet

Carson Anderson
Carson Anderson

but how is this even possible why the fuck doesnt our inputs work reeee

Bentley Hall
Bentley Hall

passed the file.readlines() filter after two fucking hours of head scratching
well fucking played
also this works perfectly, and the input had me running in circles for TWO HOURS

it's re from now on, literally reeeeeeeeeee

Andrew Hall
Andrew Hall

user WHAT THE SHIT
it works now for me
the same solution that before was wrong

3894

Asher Wood
Asher Wood

I hope faggot is tracking who and answer tried to submit

Jacob Edwards
Jacob Edwards

    file = open("input.txt", 'r')
inputstring = file.read()
file.close()
print("whole input is:", inputstring)
print("of lines:", inputstring.count('\n')+1)
expr = re.compile('(\d+), (\d+)')
lists = re.findall(expr, inputstring)
lists = [(int(i),int(j)) for i,j in lists]
file = open("Z:\input.txt", 'r')
lines = file.readlines()
print("file.readlines() is:", lines)
print("of len:", len(lines))
file.close()
file = open("Z:\input.txt", 'r')
print("file.readline() are:")
length = 0
for i in file:
print(i)
length += 1
print("of len", length)

aneurysms, how do they work?

David King
David King

Haha, we're fucking it up in the same way

Jeremiah Harris
Jeremiah Harris

user REPLY ME ->

Easton Kelly
Easton Kelly

So

min_dist
is simply some huge number you use to start with, then once you measure, say, point (x,y) to point (i,j), you assigned that distance to
min_dist
and then make sure that same distance, right? And so that's how you know when to stop, so to speak, when labeling the map. Any equidistant points aren't labeled and long distances are likely undercut by some shorter distance.

Jonathan Rogers
Jonathan Rogers

No, notice that there is "elif" there, not just another "if" so, it's mutually exclusive.
A. dist < min_dist
- 1. min_dist is now dist
- 2. min_dist_coord is current coordinate being checked
B. dist == min_dist
This means, that there are more than one coordinate, with the same (minimal distance) to location, therefore it's a tie and neither of them is counted (min_dist_cord = None)

Ayden Howard
Ayden Howard

*make sure that the same distance doesn't come up

Jacob Rivera
Jacob Rivera

On day with guards I put in wrong answer "too high"... changed code got ne answer which was bigger than "too high" one. Oh well, lets try it "too low"...
do not believe that "hi lo" bs

Disable AdBlock to view this page

Disable AdBlock to view this page

Confirm your age

This website may contain content of an adult nature. If you are under the age of 18, if such content offends you or if it is illegal to view such content in your community, please EXIT.

Enter Exit

About Privacy

We use cookies to personalize content and ads, to provide social media features and to analyze our traffic. We also share information about your use of our site with our advertising and analytics partners.

Accept Exit