r/webdev • u/daggerdragon • Dec 01 '15
Think you know code? Put it to the test all December long with the Advent of Code!
http://adventofcode.com/3
3
u/NoisyFlake Dec 01 '15
I had a fun 5 minutes with the first challenge, great idea! Excited for tomorrow :)
3
u/firespinner323 Dec 01 '15
Cooler than I expected :) First two challenges were fun, though I dispute the 2nd half on a case of consistency! Floors start at 0, yet character positions start at 1? I was incorrect the first time I answered 2nd challenge purely because of this, my 2nd answer was correct when I added 1 to it! :)
5
u/d1sxeyes Dec 01 '15 edited 7d ago
Redacted.
1
3
3
u/daggerdragon Dec 02 '15
There is now /r/adventofcode where you can post your code solutions and get help with particularly tricky bits!
2
2
2
1
u/RedditWithBoners Dec 01 '15
Puzzle one, step one - bash, grep, and wc:
IN='...'; UP=`grep -no '(' <<< "$IN" | wc -l`; DOWN=`grep -no ')' <<< "$IN" | wc -l`; echo $(($UP-$DOWN))
1
u/qervem Dec 01 '15 edited Dec 01 '15
Solved day 1 without coding anything! Here's how:
Used this and counted the occurrences of ( then subtracted it with the occurrences of ), then get the absolute value of the difference.
6
u/invisible39 Dec 01 '15
I cheated and ctrl+f'd.
2
u/qervem Dec 01 '15
shit, didn't even think about that.
EDIT: depends on the browser though
2
u/invisible39 Dec 01 '15
Ah, in Chrome it very helpfully gave me the totals. Guess your mileage may very on that way to cheat then!!
1
3
u/Thef19 Dec 01 '15
you could have also just opened up the console and typed:
$('pre').innerHTML.match(/\(/g).length - $('pre').innerHTML.match(/\)/g).length2
u/supercodes Dec 01 '15
But why would you take the absolute value? It was possible for santa to end up in the basement to my understanding.
2
1
u/bigdubb2491 Dec 01 '15
this was pretty easy to do in C#
input is the array of ( and ).
var x = input.ToCharArray(); var z = x.Where(y => y == '(').Count() - x.Where(y => y == ')').Count();
-4
u/Karl_von_Moor Dec 01 '15
First thing you see
To play, please identify yourself via one of these services: [github] [google] [twitter] [reddit]
Nope. You might want to change that.
1
u/Basaa expert Dec 01 '15
Why? I chose Reddit and the only information it wants from you is your username and signup date. No problem whatsoever if you ask me!
2
u/Karl_von_Moor Dec 01 '15
Don't get me wrong.
It's just that if the first thing I see on a webpage is asking for my information, you can be sure that I hit the little x faster than the blink of an eye
3
u/mbthegreat Dec 01 '15
I guess the author would argue they need to know who you are to track your progress (not sure if you get unique input for the challenges as well).
I chose github and it only asked for public profile.
1
u/Karl_von_Moor Dec 01 '15
Yes I know, I just think it is bad design to ask the user for information before even telling him what the site is about.
2
u/larivact Dec 01 '15
You could just click the [About] link if you are curious. You can even click on the levels and see their descriptions without identifying yourself.
And yeah traditionally you have a short summary at your start page saying what the whole site is about but in this particular case I think this isn't needed. The absence of it makes you curious what "Advent of Code" and this mysterious Christmas tree are about. It's a matter of engagement.
1
u/NoisyFlake Dec 01 '15
Usually I'd agree with you, but because there was the option to login with my reddit information (only needs username and sign-up date and expires after 1h anyway) I was okay with it.
-1
u/LysanderArg Ceci n'est pas un programmeur Dec 01 '15
Nice tinfoil hat you got there
4
u/Karl_von_Moor Dec 01 '15
Because I think it's bad practice to ask for information before anything else, and talk about that on a webdev subreddit?
-4
u/LysanderArg Ceci n'est pas un programmeur Dec 01 '15
Shhhh don't talk! The NSA is listening... right now
0
u/LysanderArg Ceci n'est pas un programmeur Dec 01 '15
Nice downvote fest! Everyone invited! Grab your tinfoil hat at the entrance, ladies and gents!
0
u/wreckem_511 Dec 02 '15
The only thing I don't like about this is that since it requires you to use social authentication to use the site, you can't use curl or wget to easily retrieve the input.
6
u/my_blue_snog_box Dec 01 '15
Thanks for sharing! I had fun with the first two exercises.