Unable to load image

r/drama Advent of Code S02E01 - Official DISCUSSION Thread

Ok you Python-using heathens. What did you think for difficulty this time around?

Post your coding atrocities below.

For those of you who missed the early signups. Feel free to join the leaderboard late (though rankings are based on time).

42
Jump in the discussion.

No email address required.

Oh shit, it's that time of the year already?

Python was too easy last year, so this time I'm using C++.

#include <iostream>
#include <fstream>
#include <string>
#include <vector>

using std::string;
using std::ifstream;
using std::cout;
using std::vector;

auto main(int argc, char * argv[]) -> int
{
   ifstream readfile("day1_input.txt");
   string readline;
   vector<string> num_strings{"one", "two", "three", "four", "five", "six", "seven", "eight", "nine"};
   int result = 0;

   while(getline(readfile, readline)){
       char first = 'x';
       char second = 'x';
       readline = readline.substr(0, readline.size()-1);

       for(int i=0;i<readline.size();i++) {
           if(readline[i] < 97 || readline[i] > 122\. {
               first = readline[i];
               break;
           }
           else {
               for (int n=0;n<num_strings.size();n++)
                   if((i + num_strings[n].size()) <= readline.size() && readline.substr(i, num_strings[n].size()) == num_strings[n]) {
                       first = '0' + (n+1);
                       break;
                   }
               if (first != 'x') break;
           }
       }
       for(int i=readline.size()-1;i>=0;i--) {
           if(readline[i] < 97 || readline[i] > 122\. {
               second = readline[i];
               break;
           }
           else {
               for (int n=0;n<num_strings.size();n++)
                   if((i + num_strings[n].size()) <= readline.size() && readline.substr(i, num_strings[n].size()) == num_strings[n]) {    
                       second = '0' + (n+1);
                       break;
                   }
               if (second != 'x') break;
           }
       }
       string concat = string{first, second};
       result += std::stoi(concat);
   }
   cout << result << '\n';
}
Jump in the discussion.

No email address required.

>too easy last year

so you must have made the leaderboard every day, huh?

Jump in the discussion.

No email address required.

The challenges open at 5am my time so frick that noise. :marseysipping:

My personal goal is just to get all the stars within 24 hours of them dropping.

Jump in the discussion.

No email address required.

>challenge opens in two hours

neighbor you stay up til 3am anyways, wtf do you care?

Jump in the discussion.

No email address required.

Link copied to clipboard
Action successful!
Error, please refresh the page and try again.