flyingfisch posted this link in #omnimaga and I thought y'all might like it: http://adventofcode.com/
I'm going to try to do all of them on the right days, but I dunno if I'll have the time. Post your solutions to the problems in the thread. I'll update this post as I solve the puzzles
Instead of updating this post whenever I finish a new puzzle, I've put them all in a github repo: https://github.com/Ivoah/AdventofCode
Oh, nice, I'm gonna try that.
Not sure if I will participate, since I have no clue what it involves (although I assume you must write code for daily problems that are posted there?), but this is what I get when logging in from Twitter:
Internal Server Error
The server encountered an internal error or misconfiguration and was unable to complete your request.
Please contact the server administrator, webmaster@localhost and inform them of the time the error occurred, and anything you might have done that may have caused the error.
More information about this error may be available in the server error log.
Quote from: DJ Omnimaga on December 03, 2015, 05:27:04 PM
Not sure if I will participate, since I have no clue what it involves (although I assume you must write code for daily problems that are posted there?), but this is what I get when logging in from Twitter:
Internal Server Error
The server encountered an internal error or misconfiguration and was unable to complete your request.
Please contact the server administrator, webmaster@localhost and inform them of the time the error occurred, and anything you might have done that may have caused the error.
More information about this error may be available in the server error log.
It's like an advent calendar, but instead of little gifts, it has little programming puzzles to solve. Also, I don't know why it's not working for you :( It works just fine for me.
Ah I see, thanks for explaining. There was literally no explanation on the pages I could access.
Works fine for me as well. The 2nd part of Day 3 was kinda hard for some reason.
Quote from: Juju on December 03, 2015, 05:46:03 PM
Works fine for me as well. The 2nd part of Day 3 was kinda hard for some reason.
I only had to add 4 lines and change 1, so it was pretty easy for me :)
Woo, I managed to get on the leaderboard for today :3 I lost some time due to a wrong answer and some stupid stuff I was doing in my code, but still.
(http://img.codewalr.us/Capture%20d%E2%80%99e%CC%81cran%202015-12-04%20a%CC%80%2000.22.26.png)
Oh nice Juju. I hope you can get higher :D. Good luck everyone :)
Heh, I'll try tomorrow xD
In short you have to be online at exactly midnight EST and be in the 100 first people who finished every puzzle before to finish today's puzzle. As in, currently, before 0:15. That's some serious speedcoding here xD
I should probably get interested in completing the challenges as soon as they appear, since I just made the 4th one in, like, a minute, in PHP.
[spoiler]$i = 0;
while (strpos(md5('ckczppom' . ++$i), '00000') !== 0);
echo $i;
[/spoiler]
Sounds fun :)
I finished Day 4 in bed on my iPad :D
You coded while asleep? O.O
Made it on the leaderboard today (54th), but next time I'll make sure to correctly read all the rules, because I lost around 2 minutes because of a stupid mistake :P
[spoiler] $total = 0;
foreach(file('day_5.txt') as $line)
{
if ( (1 === preg_match('/(.*[aeiou].*){3}/', $line))
&& (1 === preg_match('/(.)\\1/', $line))
&& (1 !== preg_match('/(ab|cd|pq|xy)/',$line)) )
{
$total++;
}
}
echo $total . "\n";
$total = 0;
foreach(file('day_5.txt') as $line)
{
if ( (1 === preg_match("/(..).*\\1/", $line))
&& (1 === preg_match("/(.).\\1/", $line)) )
{
$total++;
}
}
echo $total . "\n";
[/spoiler]
Also, I like the top 1's solution (https://github.com/edanaher/advent-solutions/commit/23cf2588e18b354c87d643f362ac67e7bd493979?diff=unified) I should have thought of using grep piping directly, it really was the right tool for the job!
Yay 27th today. Learned my lesson to properly read the rules fully, got both parts right on first try.
I wished I remembered how to properly init big PHP arrays with values though ; I had to Google that >.>
Behold the unoptimized code...
[spoiler]ini_set('memory_limit','1G');
function day_6_1()
{
$total = 0;
$map = array();
$b = array();
$b = array_pad($b,1000,0);
$map = array_pad($map,1000,$b);
foreach(file('day_6.txt') as $line)
{
$line = trim($line);
preg_match('/(turn on|turn off|toggle) (\d+),(\d+) through (\d+),(\d+)/', $line, $matches);
$row1 = (int)$matches[2];
$col1 = (int)$matches[3];
$row2 = (int)$matches[4];
$col2 = (int)$matches[5];
switch ($matches[1])
{
case 'toggle':
for($tmpr = $row1; $tmpr <= $row2; $tmpr++)
{
for($tmpc = $col1; $tmpc <= $col2; $tmpc++)
{
if ($map[$tmpr][$tmpc] === true)
{
$map[$tmpr][$tmpc] = false;
} else {
$map[$tmpr][$tmpc] = true;
}
}
}
break;
case 'turn on':
for($tmpr = $row1; $tmpr <= $row2; $tmpr++)
{
for($tmpc = $col1; $tmpc <= $col2; $tmpc++)
{
$map[$tmpr][$tmpc] = true;
}
}
break;
case 'turn off':
for($tmpr = $row1; $tmpr <= $row2; $tmpr++)
{
for($tmpc = $col1; $tmpc <= $col2; $tmpc++)
{
$map[$tmpr][$tmpc] = false;
}
}
break;
default:
echo "asd";
break;
}
}
for ($j=0; $j<=999; $j++)
{
for ($i=0; $i<=999; $i++)
{
if ($map[$j][$i] === true)
$total++;
}
}
return $total;
}
function day_6_2()
{
$total = 0;
$map = array();
$b = array();
$b = array_pad($b,1000,0);
$map = array_pad($map,1000,$b);
foreach(file('day_6.txt') as $line)
{
$line = trim($line);
preg_match('/(turn on|turn off|toggle) (\d+),(\d+) through (\d+),(\d+)/', $line, $matches);
$row1 = (int)$matches[2];
$col1 = (int)$matches[3];
$row2 = (int)$matches[4];
$col2 = (int)$matches[5];
switch ($matches[1])
{
case 'toggle':
for($tmpr = $row1; $tmpr <= $row2; $tmpr++)
{
for($tmpc = $col1; $tmpc <= $col2; $tmpc++)
{
$map[$tmpr][$tmpc] += 2;
}
}
break;
case 'turn on':
for($tmpr = $row1; $tmpr <= $row2; $tmpr++)
{
for($tmpc = $col1; $tmpc <= $col2; $tmpc++)
{
$map[$tmpr][$tmpc] += 1;
}
}
break;
case 'turn off':
for($tmpr = $row1; $tmpr <= $row2; $tmpr++)
{
for($tmpc = $col1; $tmpc <= $col2; $tmpc++)
{
if ($map[$tmpr][$tmpc] > 0)
$map[$tmpr][$tmpc] -= 1;
}
}
break;
default:
echo "asd";
break;
}
}
for ($j=0; $j<=999; $j++)
{
for ($i=0; $i<=999; $i++)
{
$total += $map[$j][$i];
}
}
return $total;
}
[/spoiler]
Damn you, I only ranked 43th.
What would be considered a good rank at this point?
I guess making it in the leaderboard is somewhat some proof of being proficient enough in some language and algorithmic skills, but within the leaderboard itself, it depends, and the time indicator can let you see how well you performed compared to others (which the rank only may not, if times are very close)
bump. I updated the OP with more solutions.
Cool, hopefully they help :)
There's a new private leaderboard feature, use code 18310-5850abfa to join mine ^_^
http://adventofcode.com/leaderboard/private/view/18310
Welp, it took 4 hours to fill the leaderboard up today... and I'm 42th o.o
Nice! Better than what I could do :P
Maybe I'll just try to do #24 :P
Have the ones here who participated so far gotten any luck with newer challenges? I didn't get much time to check what they were since I was so busy in the last 8 days.
The last few ones are haaaard. Well, let's say it's not for the faint of heart. The easiest ones takes less than 30 minutes to fill the leaderboard up, but in a few cases, like those ones who requires a lot of computation and if you're doing it wrong you'll take days to compute the answer, it may take 3-4 hours.
O.O that is crazy O.O
For that stuff I would die since I am not that good at that type of coding
Also what place are you
@Juju ?
97th on the leaderboard and ready for the last one.
Wow that isn"t bad IMHO, considering how many people are participating.
Guess who's back
http://adventofcode.com/2016/
welp.
Too bad I'm not in the right timezone anymore to be able to compete with other people at right time :/
At first, I thought the Advent of code from last year was still going on but died in popularity last Spring so I was like WTF. But I'M glad it's now a yearly event. :)