Unable to load image
Reported by:

rDrama Advent of Code Day 1: Warm up

I hope this fine morning finds you well, saars.

The word of the day is collections.Counter

The rdrama leaderboard invite code is 632268-30587026

I created the ping group: !AOC, I'm sure it will be useful offseason too.

Charts! https://github.com/jeroenheijmans/advent-of-code-charts

19
Jump in the discussion.

No email address required.

std::ifstream in("1.txt", std::ios::in);
std::string str;
std::multiset<int> l_set, r_set;

while (std::getline(in, str)) {
    l_set.insert(std::stoi(str.substr(0, 5)));
    r_set.insert(std::stoi(str.substr(8, 5)));
}
auto r_it = r_set.begin();
auto l_it = l_set.begin();
int sum = 0, sim = 0;
while (l_it != l_set.end()) {
    sim += r_set.count(*l_it) * (*l_it);
    sum += std::abs(*l_it++ - *r_it++);  
 
}

Wheres the APLChad from last year?

Jump in the discussion.

No email address required.

A B←(⊂∘⍋⌷⊢)¨↓⍉↑⍎¨⊃⎕NGET'input.txt'1
⎕←+/∊|A-B
⎕←+/∊A∘(⊣×=)¨B

The actual APLchads are laughing at me for using ¨ instead of understanding matrix ranks :marseyitsover:

Jump in the discussion.

No email address required.

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