/aocg/ - Advent of Code 2018 General #1

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.

Attached: illiteracy.png (1878x937, 169K)

Other urls found in this thread:

maurits.vdschee.nl/scatterplot/
adventofcode.com/2016/day/11
github.com/mevdschee
twitter.com/AnonBabble

First for C++

WHERE MUH PYTHON BOIS @???

WE RUN DIS SHIT

Attached: honkhonkmotherfucker.jpg (277x245, 35K)

I'm retarded.

third for emacs

WE IN HERE LADS

I made a thing for day 1, what do you think?

Attached: day1.png (512x512, 35K)

Now do it in one line.

Congrats user

Apart from the instructions, do these puzzles get harder?

I don't understand what it is supposed to represent

Fuck off and do you own homework

What are they going for this time?

Attached: AOC_18 beginning of a pattern.png (698x247, 5K)

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.

Couldn't get easier.

A far cry from my performance last year

Attached: 2017.png (621x683, 36K)

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
}
}
}

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.

nice.

Bane?

tfw
it's ok I know I'm retarded

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

maurits.vdschee.nl/scatterplot/

2017 looks much better on paper than 2015 or 2016

>day 11 in 2016

kek, do you have a link to the puzzle?

Attached: lain_laugh.gif (700x704, 295K)

Is it too late to join? What kind of biolerplate library is generally useful from past years?

adventofcode.com/2016/day/11
This shit was hard

python :^)

It's never too late to join.
Boilerplate? Just something to read the inputs, ideally by line. The rest is up to you.

whre the fuck is part 2, i only see some shits about a 3 frequency examples and making it compute frequency sum

at least I look ok on the Jow Forums leaderboard

based kotlin user

based user #264793 already getting us near the top of the global leaderboard, we can do it Jow Forums

Attached: [Ohys-Raws] New Game! - 11 (AT-X 1280x720 x264 AAC).mp4_snapshot_08.00_[2016.09.12_19.33.49]2.jpg (698x712, 283K)

Have you submitted your answer, Pajeet?

If you know how to declare a set and access data in that set in the same line then let me know 'cause otherwise it's not possible.

>#100 in the global leaderboard
I should savor my win, it won't last

>part 1
>int num = [copy-pasted data here];
>printf("%i\n", num);

Attached: 1533073235776.webm (414x422, 113K)

i didn't sign up, i don't like signing up for random shit. i did do the first part in java though.

maybe a snowman

>based user #264793
Do not depend on me for this. I'm going to drop like a rock after today

Attached: bocchi me.png (503x375, 56K)

kek

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.

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.

finally, 50 Jow Forums anons completed the first day after one (1!) hour

Best hurry, user. We're going to be on java 48 by sometime next week.

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

>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?

>tfw made it in top 50 despite starting 40 minutes late and losing 10 minutes writing input to list
wew the rush is real

>the 8 Jow Forumstards who did part one but not part two

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

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.

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

Scores are computed differently in privatesleaderboards

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.

Someone email this guy github.com/mevdschee and tell him to update maurits.vdschee.nl/scatterplot/ for 2018

Not very interesting.

Attached: 1512379006490.png (1612x881, 36K)

Oooooh...

We still need a picture for day 1 lads

Zoom on that top part

Attached: 1532967635204.png (1567x867, 54K)

zoom on the y-axis around the 0 line

OP pic is it

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.

i think OP's got it

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.

1.8 secs with eval()
0.09 secs with int()

Wtf evalbros

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

> 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.

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.

#!/usr/bin/env ruby
require 'set'

input = File.read("input.txt").chomp.split.map(&:to_i)

# Part 1
puts input.sum

# Part 2
freqs = Set[0]
total = 0

input.cycle do |n|
total += n
break if freqs.include? total
freqs

Attached: 231nhyk8yv001.png (282x179, 4K)

Who here taking their fucking time in Rust?

eval was never about performance my boy

I did a practice one in rust, realized it was a horrible idea and practiced my haskell.

I'm doing it in Haskell as well, part 2 was pretty hard for me though.

you save more time than that in typing with the simple eval line so its net gain still

Made this

Attached: aoc_day1.webm (400x300, 489K)

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.

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.

top kek

I already did it in Rust, but my Rust solution takes like a full second for some reason while my javascript solution takes 150ms

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.

>First hundred users to get both stars on Day 1:
>
> 1) Dec 01 00:01:48 petertseng
Jesus

Attached: buddy.jpg (179x189, 14K)

I did rust last year because I didn't care about the times. Once was enough.
Gonna be Python and Go this year.

Attached: Screenshot from 2018-12-01 03-20-10.png (1002x270, 76K)

>an agreement that binds them to a moral obligation

Attached: 1511722365582.jpg (220x220, 7K)

Never mind, I'm dumb. Compiled it with optimizations enabled and now it takes 50ms

Rust is going down the shitter, why would you want to learn it? Look at their new site.

>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.

user, I...

Attached: 7189SFT92BL._SX334_BO1,204,203,200_.jpg (336x505, 38K)

Goddamn rust is so fucking "noisy"

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..

Take your time rust-anons

Attached: day1.png (1152x703, 115K)

>>solve account two in a few seconds
That's not how these are timed.

>Works in software
>Finds a faulty system
>Tries to solve the problem with "moral contracts"
Ayyyyyyy

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?

That's pretty close to what I have. Why aren't you using iter().cycle() for part two though?

Attached: Screen Shot 2018-12-01 at 12.26.49 AM.png (576x237, 18K)

HOLLA HOLLA
PYTHON GANG REPRESENT

because you're required to use a github or other social media account

>go to Jow Forums leaderboard
>anonymous user hyperlink
>wait what?
>click
>github account
hahahahaha... Such anonymous. Such wow

You can literally use a gmail. I have dozens of throwaways and they take seconds to set up.

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

it could be easily automated using bots with selenium web driver or something similar.

>you can make a burner r*ddit account with no email needed

Attached: Screenshot_2018-11-30_22-31-01.png (432x329, 21K)

Cause I didn't know that existed! Thanks that's handy.

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.

just use maildrop.cc or whatever

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.

Gmail asks for a valid mobile number. Haven't been able to create one for years.