Advent of Code 2018

Only one week to go. Are you prepared?

Attached: AoC yotsuba.png (975x847, 473K)

Other urls found in this thread:

reddit.com/r/adventofcode/comments/9zu1sd/can_someone_help_me_with_day_2_part_1_of_2017/
adventofcode.com/2015
adventofcode.com/2016
adventofcode.com/2017
twitter.com/SFWRedditImages

What's there to prepare?

I'm not even a programmer, you little animuposting brainlet

Mostly just remembering that it exists and not forgetting until a week in, at which point your leaderboard position is shot.

reddit.com/r/adventofcode/comments/9zu1sd/can_someone_help_me_with_day_2_part_1_of_2017/

Attached: 1486431272926[1].png (402x443, 72K)

I forgot about this. Day 1 for last year in pic related makes sense now

Attached: 1542746293551[1].png (3282x2475, 3.35M)

Friendly reminder we already have a private leaderboard
See Libs to get the challenge input automatically and ways to prepare it to transform it if you want to get on the leaderboard

Attached: 1516231521349.png (10000x10000, 378K)

I got in the top 100 for a few days last year without any kind of input-fetching script or library

Yeah but not the top 10

My favorite time of the year
time to grind leetcode for practice

You can learn that language you've always wanted to know and make AoC with it.
Else it's pointless thread.

>advent of code
This is the first time I've heard this. Is this some kind of hackathon?

It's an advent calendar. You get two programming challenges every day, and try to finish them as quickly as possible.

Last year was a lot of fun. It's a great way to learn a new language, or improve your problem solving skills.

you can try previous years if you are curious
adventofcode.com/2015
adventofcode.com/2016
adventofcode.com/2017

Series of simple tasks, wrapped in comfy sometimes-funny christmas-themed story. Each day had 2 rounds, 2nd sometimes tends to punish bad asymptotic complexity, but other times it can just be blindly bruteforced.
Need to make an account on some external website and log through it (probably OAuth2?). You only report an answer, not full code.

I'm going through last years problems and timing myself. Even after having already done all the problems I still only managed to get a global leaderboard time only once.
Is this what it means to be a brainlet?

Can somebody help me with part 1 of day 2 of 2017? I must be doing something wrong.

Attached: programmingisart.png (1048x6408, 704K)

import sys

checksum = 0

for line in sys.stdin:
nums = [int(n) for n in line[:-1].split()]
checksum += max(nums) - min(nums)

print(checksum)

errata: [:-1] is unnecessary and .strip() would be better

What language is this in? Does it matter? Can I do it in C?

Any
No
Yes

Are these hard or am I a brainlet?

Reasonably easy
Check the ones from last year and see for yourself

very easy with ~2.5 exceptions per year

I checked the one from dec 25, 2017, seems pretty hard.

Not really, it has finite (and small) number of states. It could be harder if you was about to write a general solution with a parser for the description, but if you can really just hardcode the states and write a simple state machine with it.

gave it up last year, won't even try this year.

I'm trying to redo the ones from last year, and fuck I had forgotten how tedious it was to crank up working code in a short time
I'm going to train more

there is my simple solution in C (for the example inpit, not real input)
#include

#define BEGIN A
#define STEPS 6

void A(void);
void B(void);


int tape[4096];
int pos = (sizeof(tape)/sizeof(*tape)) / 2;
void (*state)(void) = BEGIN;

void A(void) {
if (tape[pos])
tape[pos--] = 0;
else
tape[pos++] = 1;
state = B;
}

void B(void) {
if (tape[pos])
tape[pos++] = 1;
else
tape[pos--] = 1;
state = A;
}

int checksum(void) {
int sum = 0;
for (int i = 0; i < sizeof(tape)/sizeof(*tape); i++) {
sum += tape[i];
}
return sum;
}

int main(void) {
for (int i = 0; i < STEPS; i++) {
state();
}
printf("%d\n", checksum());
}

If your not using scripting langs for aoc you're doing it wrong

>technically, byte code is a scripting language for hardware

>only other guy that isn't anonymous
I feel like an idiot now

Do you have any advice beside using defaultdicts for everything?

Fuck should I learn C or Lisp to do this? I know Python and C# but I heard Python is too slow and I don't run Windows anymore.

Attached: sentos.jpg (1920x1080, 746K)

Literally how can anyone get to this point and not think "there must be a better way"

Computation time isn't important for this. Python is easy to write, so it's a good choice.

>but I heard Python is too slow
It's more than fast enough for most software. Even if it really was as slow as you think it'd still be fast enough for learning purposes.

Don't lie to yourself, your homework won't be that demanding.

do unit tests (or even assert) for all the sample inputs you get