Skip to content

Instantly share code, notes, and snippets.

@rep-movsd
Last active December 2, 2025 05:09
Show Gist options
  • Select an option

  • Save rep-movsd/a3dd2d9c3188d22c4cc098c6644c9855 to your computer and use it in GitHub Desktop.

Select an option

Save rep-movsd/a3dd2d9c3188d22c4cc098c6644c9855 to your computer and use it in GitHub Desktop.
Advent Of Code 2025
#include <fstream>
#include <string>
#include <iostream>
#include <vector>
#include <iterator>
#include <ranges>
#include <algorithm>
using std::string, std::vector, std::plus;
using std::ifstream, std::istream_iterator, std::cout, std::endl;
using std::ranges::fold_left, std::views::all, std::views::transform;
int main()
{
int state = 50;
auto rotator = [&state](int i) {return !((state += 100 + i) % 100);};
auto parse =[](const string &s) {return (s[0] == 'L' ? -1 : 1) * stoi(s.substr(1));};
using Iter = istream_iterator<string>;
ifstream in("1.txt");
cout << fold_left(
all(vector<string>{Iter{in}, Iter{}}) |
transform(parse) |
transform(rotator), 0, plus<>{}
) << endl;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment