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.
The new leaderboard with empty space is join-code: 43046-941b8011
The old (full) leaderboard is join-code: 194764-c554ff91
>tfw no more of these comfy threads after the 25th I'll probably be doing last year's, but these threads are some of the comfiest on this board.
Hunter Cox
Ended up wasting an hour or two because I overlooked how I kept track of the previous location when turning (it kept thinking it was where it was two steps ago one step ago at corners).
Gavin Flores
we could make threads for weekly challenges in other sites like codwars or codefights.
Kevin Thompson
>these threads are some of the comfiest on this board totally agree. we should keep up a Sup Forums daily challenge thread of sorts
Justin Diaz
Don't forget codeforces, csacademy and atcoder
Christopher Hall
I've wasted an hour just processing the input, more or less.
First challenge: Fizzbuzz
Isaiah Martinez
aye
Liam Morris
^
Angel Ward
idk, once more than one site will be used it will get chaotic
Christian Morgan
I mean, we could make a really simple site for it that links out to the challenge of the day or whatever
Ayden Martin
That sounds good I guess.
Aiden Scott
You mean algorithmical or regarding code style?
Blake Turner
Hi guys, brainlet here.
I can't even do the first day challenge. I'm working in python. Can you recommend any textbooks?
Henry Bell
nothing lasts forever, user. enjoy the experience while it lasts.
Lincoln Baker
No textbook is going to teach you basic problem solving
Adam Thompson
I feel like I know how to solve it but I can't work well enough with the programming langauge to express what I want to do.
I thought I had the right answer (878) but evidently I didn't.
Nicholas Torres
877
Blake Lee
Ah, off by one. Thank you!
Austin Kelly
I'm fucking retarded and printed the sent count of program:p=0 (as in "the first of the two programs, i.e. program 1 (out of 2), rite, sheesh") and it's obvious in retrospect* that I'm retarded and it's program:p=1.sent. Gold star for gryffindor
Turns out I forgot to strip the newline character off the input file string, meaning the last step didn't get parsed.
Adrian Martinez
Algorithmical. I'm not paying attention to code style for these contests, just hacking it together.
Ayden Fisher
Just make a dummy reddit account. They don't even ask for email
Hudson Edwards
Why do you post this every fucking thread you retard. Get your turbo autismo back to /dpt/ where you belong nigger
Liam Miller
don't feed the troll shitty b8 deserves to be ignored
Ayden Baker
Rank my O(sqrt(n)) solution to day 3 problem 1. (Could be O(1) if I wasn't lazy)
const int N = 312051; int main() { for (int i = 0;; ++i){ int left, up, right, down; left = 1 + 4*i*i + i; up = 1 + 4*i*i - i; right = 1 + 4*i*i - 3*i; down = 1 + 4*i*i + 3*i; if (i >= abs(N - left)){ std::cout = abs(N - right)){ std::cout = abs(N - up)){ std::cout = abs(N - down)){ std::cout
Carter Howard
um no sweetie
Joseph Nelson
How long did you wait for Day 16 Part 2 solution?
I did one round according to the steps in the input. Derived permutation cycle and then applied the permutation cycle on the dancers 1bil times. Takes too long.
Any hints how to speed it up?
Eli Ward
183 ms It could be faster but it's more than good enough for me.
Isaiah Ortiz
>How long did you wait for Day 16 Part 2 solution? about 50 ms >Any hints how to speed it up? don't brute force it. you do not need to run it 1 billion times.
Thomas Roberts
>I've wasted an hour just processing the input, more or less. language? what did you attempt?
Bentley Wood
>self-contained *snort*
Connor Parker
40ms, but I'm going to try and improve it. tip: you don't need to run it 1 billion times
Wyatt Phillips
Thanks. Figured it out. The configurations starts to repeat after some iterations.
Christopher Gutierrez
Yeah. By the way even if you could get your hash function to run in 0.5ms it would still take over 5 days to get your solution.
John Roberts
Got it down to 22ms average but I can't seem to get it down any further. Still satisfied tho.
Nolan Walker
I did days 1-9 then stopped because schoolwork caught up.
What are the hardest/most interesting ones of days 10-19?
Charles Lee
>Solution doesn't handle the case of a letter being next to a turning + >No such case appears in my input who here /devilish/
Nathaniel Hill
Hardest: day 18 Most interesting: day 16
Hunter Garcia
>tfw stuck in day 3 part II
Isaac Brown
Day 17 is the most interesting because I got it to run under 0.1ms (zero point one millisecond). Try to best me.
Chase Moore
Literally all you have to do is hashmap the coordinates of the squares to their values
What's the problem?
Logan Barnes
Talking about part 2 of course.
Wyatt Brown
Forgot to actually ask because meme
Do you guys actually generate the asked grid, or calculate the solution?
Easton Robinson
So no need to run it and insert all 50mil values?
Henry Martinez
no need to insert anything
Ryan Adams
I didn't keep the entire grid. Only some parts.
Nicholas Walker
Can it be calculated directly? What area of math/cs should I read?
Landon Sullivan
Yes I generate the grid in a spiral until I get the answer
Blake Turner
post yfw you see my code for day 7 part 2 :^)
Just use your brain. Try to print out the first few iteration.
Mason Walker
The trick is that 0 is always at index 0 so the value after 0 is always at index 1 You don't actually have to insert into an array to keep track of its length and the index of the current position
Easton Green
>giving him the solution >not letting user figure it out to better himself >mfw
Adrian Wilson
I used a calculator for part one, and made the whole grid for part two.
Jose Scott
>tfw solution for part 2 was off by 1 again
Bentley Long
⎕io ← 0 data ← ⊃((⎕ucs 10)∘≠⊂⊢)⎕nread'I:\2017d19.txt'⎕ntie 0
∇ (list step) ← follow maze; dir pos path take pari temp next list ← '' step ← 1
pari ← ∼2 ∣ dir temp ← 1 + (0 ≠ take path) ⍳ 1 list ,← (∊∘(⎕A)/⊙⊢) temp ↑ take maze pos[pari] +← temp × ¯1 * ⌊dir ÷ 2 step +← temp dir ← next[path[⊂pos]-1;dir] → 12 ↑⍨ path[⊂pos] ≠ 5 ∇
Not as nice as I hoped.
Brandon Campbell
how 2 lern apl?
Elijah Russell
what language is this?
Juan Clark
For part 1 isn't necessary since the position of the value can be calculated by simple math. For part 2 you have to generate the square.
Zachary Gray
>tfw too brainlet to solve day 13
Robert Martinez
is programming with runes as magical as it looks, or is it like any other programming language once you learn it?
i'm impressed with how quickly you do these because they're completely fucking incomprehensible to me.
Colton Morales
it's really like any other each "rune" is basically just applying a function
Liam Green
Google (or equivalent) is your friend.
APL.
Not really. Elegance becomes more of a concern than speed, though, and many things aren't done in a very straightforward way. For example, take path ← 0 5 6 9 10 ⍳ (maze = '+') ∧ 2 ⊥ ⊃ ¯1 1 (∘.⊖,∘.⌽) ⊂ maze ∊ '|-', ⎕A
First take the entire input as a matrix (maze) and check, for each element, whether or not it is contained in the set {'|-', ⎕A} (where ⎕A is the vector of all uppercase letters). Then make a scalar out of that vector (⊂) and rotate it up, down, left and right (¯1 1 (∘.⊖,∘.⌽)), in that order. Then make it a 3-dimensional array (⊃), that is, 4 by whatever the input was, and consider the sections of the four planes as 4-bit numbers (2 ⊥). Then mask it (∧, which is actually both LCM and logical AND) with the result of checking, for each element of the input, whether or not it is equal to '+' (maze = '+'). Finally, find the position of each element of the resulting matrix (⍳) in the vector [0 5 6 9 10].
What you get is a matrix with zeroes everywhere, except for pluses in the original input, which have been replaced by 1..4, depending on what kind of corner they represented.
Leo Miller
∇∘⎕'12∘∊_⌊⎕'⊤666⌊⎕∇ ⍳↑∘⍳∘∩⊥'4*'∊⌈'○⌊*_' ⌊∇'⎕4∘○
Joseph Thomas
how is this log (n), it looks linear
Jason Cox
How do I run and test execution time on my system to comapre with mine on diff lang?
Joseph Morris
appreciate the explanation. if I wasn't a brainlet it might have helped
Adam Cook
The axes are on log scales
Luis Rogers
What do you use to build these graphs?
Nicholas Johnson
Looks like some office suite's spreadsheet app. Probably LibreOffice or Google Sheets
Easton Hernandez
Free GoogleSheets can do that? I didn't know.
Zachary Gomez
I use Gnumeric which is generally a little more useful than LibreOffice, but all office suites are terrible
Kind of reminds me of that pipes screensaver, just in reverse.
Asher Kelly
Added posts to today's calendar image.
Blake Campbell
Who had two paths?
Christian Garcia
Fuck you, problem 19. If you wanted Longs you should have said Longs. If you were expecting to overflow any reasonable data set you should have specified the register size.
Luis Rogers
A guy who read his input wrong
Noah Green
glad to see my code made it..
Carson Nguyen
>Try this thing out >Code the trivial first exercise >Copy paste input >Submit solution, it's wrong >Recheck things >Nothing >Download input and copy paste from gedit instead >It's right Wut
Luke Sanchez
Yep, using long longs for every int from now on Learned my lesson
Carter Howard
Are you ready boys?
Dominic Watson
N-no.
Evan Fisher
I just hope our AoC overlords have mercy with us today. I want to sleep at least 4 hours for once.
Michael Martinez
READY
Chase Gomez
FUCK
Hudson Hernandez
FUCK
Thomas Bell
Stayed up but don't have the energy to program. This one definitely has a simple formula though.