Previous thread: Jow Forums learns to read edition
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.
Yes. These are the easy "Hello World" puzzles to make you feel good. A week or two from now will be the ones that aren't just speed typing competitions.
fun part1 (): Int { val input = File("src\\main\\resources\\day1.txt").bufferedReader().readLines() var frequency = 0 input.forEach { if (it[0]=='+') frequency += it.substring(1).toInt() else frequency -= it.substring(1).toInt() } return frequency } fun part2 (): Int { val input = File("src\\main\\resources\\day1.txt").bufferedReader().readLines() var frequency = 0 var map: HashMap = HashMap() while(true){ input.forEach { if (it[0]=='+') frequency += it.substring(1).toInt() else frequency -= it.substring(1).toInt() if (map.containsKey(frequency)) return frequency else map[frequency] = 0 } } }
Zachary Gray
yes. last year it was a pretty gradual increase in difficulty the first few days and then there would be a crazy one thrown in, then back to gentle increase, then another crazy spike, etc. etc.
Noah Hill
nice.
Brody Jackson
Bane?
Asher Allen
tfw it's ok I know I'm retarded
Asher Hall
the early puzzles are literally just "who can type the fastest", it gets more legit in a few days
the global leaderboard though still stays pretty competitive with people finishing even the hard shit in like five minutes
Just use an alt or throwaway account, it's worth it. If you want to give as little info as possible, you can make a burner r*ddit account with no email needed.
Brody Wood
checked and agreed, i'll do that user. trying to refresh myself on java because i haven't touched java since java 7. it's coming back pretty fast.
Kevin Thomas
finally, 50 Jow Forums anons completed the first day after one (1!) hour
Charles White
Best hurry, user. We're going to be on java 48 by sometime next week.
Christian Johnson
Nice. My part 1: data = map(int, open("Day 01 input.txt", "r").read().split("\n")) raw_input(sum(data))
Might as well have been a one-liner. Already posted part 2 here
Justin Bailey
>Getting a star first is worth 100 points, second is 99,
So today you can have max score of 200. So how come in private Jow Forums leaderboard we have anons with more than 200 points? Or is second column something else?
Kevin Richardson
>tfw made it in top 50 despite starting 40 minutes late and losing 10 minutes writing input to list wew the rush is real
Nolan Sanders
>the 8 Jow Forumstards who did part one but not part two
Well I finished like 700th. I type slow, it's my first time doing anything like this, and I specialize in systems stuff where the only lang I use regularly is C.
Ethan Scott
that's only the global leaderboards where its top 100
i think since our leaderboard has 124 members, first place gets 124 instead and second gets 123 etc for both stars
Cooper Anderson
Scores are computed differently in privatesleaderboards
Christopher Edwards
Nobody has time to sit around twiddling their thumbs like a lapdog. They should figure out a way so you can work on it in your own time while somehow preventing cheating.
Had to do something else by the time I started the second half so yeah. And once I got back i didn't understand what I was supposed to do.
Liam Wright
i think OP's got it
Jason Gonzalez
There's no feasible way to do that if everyone's question is the same, and if everyone's question is different than it's not a fair race.
Leo Rogers
1.8 secs with eval() 0.09 secs with int()
Wtf evalbros
Dylan White
uhh, I opened the thread without looking at OP's pic and started shitposting right away my bad also wtf is up with the captcha? Fucking fading bullshit
James Foster
> tfw spent 20 minutes on part 2 'cause I didn't read the question right. Each year I do this I'm reminded how much of a brainlet I am.
Brody Adams
I still can't believe how long it took me to realize I wasn't even PARSING THE INPUT RIGHT with my test file setup. Tomorrow will be better.
minor improvements using a specialization on the builtin set. from itertools import cycle, takewhile class superset(set): def add(self, other): super().add(other) return other def accumusum(iterable): i = 0 for j in cycle(map(int, iterable)): yield i i += j
def mapwhile(func, pred, iterable): yield from (func(i) for i in takewhile(pred, iterable))
s = superset() print(list(mapwhile(lambda x: s.add(x), lambda x: x not in s, accumusum(data)))[-1])
I don't know if it's possible to be more expressive than this.
Gabriel Garcia
I was hoping to do this year in Haskell, but I fucked up and haven't used it in like 6 months, and I actually want to finish the problems. Maybe next year, or I'll just retry them when I have more time.
Tyler Martinez
top kek
Isaac Lopez
I already did it in Rust, but my Rust solution takes like a full second for some reason while my javascript solution takes 150ms
Luke Clark
Have people click an agreement that binds them to a moral obligation to not share the question. Likewise, the morally conscientious won't seek out any leaked question and will instead wish to test themselves in good faith.
Nolan Thompson
>First hundred users to get both stars on Day 1: > > 1) Dec 01 00:01:48 petertseng Jesus
Never mind, I'm dumb. Compiled it with optimizations enabled and now it takes 50ms
Justin Clark
Rust is going down the shitter, why would you want to learn it? Look at their new site.
Cooper Cruz
>make two accounts >solve it on account one >then open it on account two >solve account two in a few seconds >no sharing was done You could make a gentleman's agreement leaderboard for people who only want to start as of X time (say noon the next day), but again it's still a gentleman's agreement.
The only time i've ever used rust is AoC 2017.. Cargo is comfy and by the end of the month at least I don't spend the whole time looking at the documentation..
>>solve account two in a few seconds That's not how these are timed.
Jaxson Lewis
>Works in software >Finds a faulty system >Tries to solve the problem with "moral contracts" Ayyyyyyy
David Green
Hang on, why the fuck don't the fastest scorers just use dummy accounts to fill up the extra spaces and artificially inflate their own scores when they throw the dummies away later?
Isaiah Morris
That's pretty close to what I have. Why aren't you using iter().cycle() for part two though?
because you're required to use a github or other social media account
Aiden Cook
>go to Jow Forums leaderboard >anonymous user hyperlink >wait what? >click >github account hahahahaha... Such anonymous. Such wow
Christopher Cox
You can literally use a gmail. I have dozens of throwaways and they take seconds to set up.
Angel Mitchell
these early ones are competitive enough that the amount of time it takes for them to paste their other account's input in to get the solution, like 20 new people have placed
Noah Ramirez
it could be easily automated using bots with selenium web driver or something similar.
Aaron Adams
>you can make a burner r*ddit account with no email needed
Cause I didn't know that existed! Thanks that's handy.
Ryder Thompson
Right. If they were timed by "how long your account took to solve the problem" (presumably how long between receiving your input and solving it) then it would work that way and be easily beaten. I was explaining why that wouldn't work since the original question was about how can you make it so you can solve them on your own time.
Private leaderboards recalculate when an account leaves. The global board that would work, but any time they spend getting the first star quick on their second account is time not spent on getting the second star on their first. Considering every second counts it's not worth it. Maybe if they could finish the second star before the first 100 are full, but that's a rare situation.
William Torres
just use maildrop.cc or whatever
Noah Murphy
help(list)
wow= wow.strip().split()
wow = [int(i) for i in wow] k= [] j = 0 wow = wow *10 for i in wow: j = j + i if j in k : print(j) break k.append(j)
literally wrote this in under a minute.
Why doesn't it work?
If it gave no result I would know I need a longer list (or a while loop), but it keeps giving me an incorrect result.
Andrew James
Gmail asks for a valid mobile number. Haven't been able to create one for years.