Register for your free account! | Forgot your password?

Go Back   elitepvpers > Coders Den > General Coding
You last visited: Today at 06:06

  • Please register to post and access all features, it's quick, easy and FREE!

Advertisement



Advent of Code 2018

Discussion on Advent of Code 2018 within the General Coding forum part of the Coders Den category.

Reply
 
Old   #1


 
Cups's Avatar
 
elite*gold: 152
Join Date: Mar 2015
Posts: 149
Received Thanks: 1,281
Advent of Code 2018

For all of the programmers that are celebrating the festive season, the Advent of Code is here! If you wish to talk about some of the challenges or participate, please visit the website at ! The input (and hence answers) are different for everyone, but you can still share the code you used to solve them. There is no API for the site so you'll need to read your input from a file.

Best of luck to all! Let me know how you go! Please keep discussions to English only! If you post code on elitepvpers please make sure its in spoiler tags - click Hastebin / Github links at your own discretion knowing that it may contain spoilers!

My solutions -
Cups is offline  
Thanks
1 User
Old 12/01/2018, 13:01   #2
 
elite*gold: 100
Join Date: Apr 2008
Posts: 860
Received Thanks: 1,487
Wow ... Day 1 Part 2 really took a lot of cycles (142). I even considered my input to be broken.
florian0 is offline  
Old 12/01/2018, 13:30   #3


 
Cups's Avatar
 
elite*gold: 152
Join Date: Mar 2015
Posts: 149
Received Thanks: 1,281
Quote:
Originally Posted by florian0 View Post
Wow ... Day 1 Part 2 really took a lot of cycles (142). I even considered my input to be broken.
I updated my post - feel free to post your solutions as long as they're in a spoiler tag (if it's a code block on the forum), or feel free to just post a link to your Github repository / Hastebin if you feel like sharing your answers! I've updated the main post to include a link to my solutions.

Glad you found the puzzles challenging, things like this keep the mind active!
Cups is offline  
Old 12/01/2018, 13:43   #4
 
elite*gold: 100
Join Date: Apr 2008
Posts: 860
Received Thanks: 1,487
Quote:
Originally Posted by Cups View Post
Glad you found the puzzles challenging, things like this keep the mind active!
I chose std::list, which was not a good choice regarding speed. So finding the frequency initially took roughly 1:30min. Thats why I considered my set to be wrong ;D

I'm now using unordered_set, which is way faster in this case.
florian0 is offline  
Old 12/01/2018, 13:50   #5


 
Cups's Avatar
 
elite*gold: 152
Join Date: Mar 2015
Posts: 149
Received Thanks: 1,281
Quote:
Originally Posted by florian0 View Post
I chose std::list, which was not a good choice regarding speed. So finding the frequency initially took roughly 1:30min. Thats why I considered my set to be wrong ;D

I'm now using unordered_set, which is way faster in this case.
You can make the code even simpler by using the return values of std::unordered_list#emplace - it returns a pair of <Iterator, bool>. The bool value will be false if a duplicate entry exists as a set only allows one of each element in its collection
Cups is offline  
Thanks
1 User
Old 12/01/2018, 16:54   #6
 
sk8land​'s Avatar
 
elite*gold: 50
Join Date: Nov 2018
Posts: 1,065
Received Thanks: 2,594

sk8land​ is offline  
Thanks
1 User
Old 12/02/2018, 14:35   #7


 
Cups's Avatar
 
elite*gold: 152
Join Date: Mar 2015
Posts: 149
Received Thanks: 1,281
Repository has been updated with solutions for day 2! No cheating now :P

Cups is offline  
Old 12/02/2018, 20:45   #8
 
sk8land​'s Avatar
 
elite*gold: 50
Join Date: Nov 2018
Posts: 1,065
Received Thanks: 2,594
Quote:
Originally Posted by Cups View Post
Repository has been updated with solutions for day 2! No cheating now :P

I consider LINQ to be cheating.


sk8land​ is offline  
Old 12/03/2018, 01:42   #9


 
Cups's Avatar
 
elite*gold: 152
Join Date: Mar 2015
Posts: 149
Received Thanks: 1,281
Quote:
Originally Posted by sk8land​ View Post
I consider LINQ to be cheating.


Then I'd go so far as to say you're being rather silly, especially in this scenario! Firstly, it's important to make the distinction that the Advent of Code is by no means a programming challenge, but a problem solving exercise.

Second, LINQ in this use case is not providing any functionality that any other language with high order functions like Map, Reduce, Fold and Zip would provide. Would you consider it cheating if I wrote my answers in Haskell? The code would be much more concise and be using the exact same functions that LINQ provides.

Edit: After writing that response I decided to try a functional language for the first time ever. Could probably be improved a lot and isn't totally idiomatic F# but it's my first program ever using the language. I don't fully understand the functional idioms just yet :P

Cups is offline  
Old 12/03/2018, 14:51   #10
 
sk8land​'s Avatar
 
elite*gold: 50
Join Date: Nov 2018
Posts: 1,065
Received Thanks: 2,594
Quote:
Originally Posted by Cups View Post
Then I'd go so far as to say you're being rather silly, especially in this scenario! Firstly, it's important to make the distinction that the Advent of Code is by no means a programming challenge, but a problem solving exercise.

Second, LINQ in this use case is not providing any functionality that any other language with high order functions like Map, Reduce, Fold and Zip would provide. Would you consider it cheating if I wrote my answers in Haskell? The code would be much more concise and be using the exact same functions that LINQ provides.

Edit: After writing that response I decided to try a functional language for the first time ever. Could probably be improved a lot and isn't totally idiomatic F# but it's my first program ever using the language. I don't fully understand the functional idioms just yet :P

Calm down, kangaroo. It was just a joke.


Edit: I would like to solve one of those with Haskell as well, but it's been ages since I was exposed to Haskell in uni and I forgot the whole syntax. The last time I tried to get into Haskell again it gave me autism.
sk8land​ is offline  
Old 12/03/2018, 16:59   #11
 
elite*gold: 100
Join Date: Apr 2008
Posts: 860
Received Thanks: 1,487
Had to skip Day 2, got a bad headache.

Reading is definitely not one of my strengths. I didn't read day 3 to the end and "accidentally" build an algorithm to find the largest single rectangle of all overlapping claims. lol.
florian0 is offline  
Thanks
1 User
Old 12/04/2018, 02:33   #12
 
0xFADED's Avatar
 
elite*gold: 7
Join Date: Dec 2013
Posts: 446
Received Thanks: 187
My take on Day 3:

Probably overcomplicated af, but it works
0xFADED is offline  
Thanks
1 User
Old 12/04/2018, 10:17   #13


 
Cups's Avatar
 
elite*gold: 152
Join Date: Mar 2015
Posts: 149
Received Thanks: 1,281
Quote:
Originally Posted by 0xFADED View Post
My take on Day 3:

Probably overcomplicated af, but it works
Hey what matters is that it works :P

Updated repository with solutions to day 4 -
Cups is offline  
Old 12/04/2018, 16:43   #14
 
sk8land​'s Avatar
 
elite*gold: 50
Join Date: Nov 2018
Posts: 1,065
Received Thanks: 2,594

I would appreciate any tips on how to simplify this.

Day 5:
sk8land​ is offline  
Reply


Similar Threads Similar Threads
Advent Advent ein Lichtlein brennt
11/30/2011 - Off Topic - 76 Replies
Erst eins dan zwei dann drei dann vier... Weihnachten steht kurtz vor der tür und ich dachte mir ich verlose hier ein paar kleinigkeiten... zu gewinnen gibt es 23x "10 e*gold" und 1x eine fette "25€ Paysafecard" also eigentlich eine art Adventskalender.
Advent Advent :)
12/01/2010 - Off Topic - 1 Replies
Advent Advent 1Lichtlein brennt :D
Final Fantasy VII - Advent Children
09/19/2005 - Main - 7 Replies
hiho wollt ma fragen ob den hier schon jemand geschaut hat. wenn ja, wie ihr den film so findet?? :p ich hab ihn seit kurzen fertig geladen, werd den vlt später gucken^^ mfg hoffe das thema gabs net schon. hab suche benutzt, aber nix gefunden :o



All times are GMT +1. The time now is 06:06.


Powered by vBulletin®
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
SEO by vBSEO ©2011, Crawlability, Inc.
This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

Support | Contact Us | FAQ | Advertising | Privacy Policy | Terms of Service | Abuse
Copyright ©2025 elitepvpers All Rights Reserved.