This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <algorithm> | |
#include <cassert> | |
#include <cstdint> | |
#include <cstdio> | |
#include <iostream> | |
#include <string> | |
#include <utility> | |
#include <vector> | |
namespace { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <algorithm> | |
#include <cassert> | |
#include <cstdint> | |
#include <cstdio> | |
#include <iostream> | |
#include <string> | |
#include <utility> | |
#include <absl/hash/hash.h> | |
#include <absl/container/flat_hash_set.h> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#ifndef MEMORY_MAPPED_FILE_H_INCLUDED | |
#define MEMORY_MAPPED_FILE_H_INCLUDED | |
#include <utility> | |
#include <cstdlib> | |
#include <span> | |
#include <sys/fcntl.h> | |
#include <sys/mman.h> | |
#include <sys/stat.h> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <algorithm> | |
#include <atomic> | |
#include <cassert> | |
#include <chrono> | |
#include <cstdint> | |
#include <iostream> | |
#include <string> | |
#include <thread> | |
#include <vector> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const DATA: &[u8; 10_000_000] = include_bytes!("../input_extra.txt"); | |
pub fn main() { | |
let mut total = 0; | |
let mut w = 0; | |
let mut n = 1; | |
'main: while n <= 94 { | |
let mut seen = 0u128; | |
for i in (0..n).rev() { | |
let mask = 1 << DATA[w + i]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[ Advent of Code 2022 Day 2: Rock Paper Scissors (part 1) | |
https://adventofcode.com/2022/day/2 | |
Solution in standard Brainfuck (no 8 bit cells, no wraparound) | |
Minimized representation: | |
>,[-<++++++++[->--------<]>>,,>++++++++[<----------->-]<<[->+++<]>>++++<[->++++< | |
[->-----<[->--<[->++++<[->++++<[->--<[->-----<[->++++<]]]]]]]]>[>>[-]+<<[->+<]>[ | |
<+>-[<+>-[<+>-[<+>-[<+>-[<+>-[<+>-[<+>-[<+>-[>>+<<-<[-]>[<+>-]]]]]]]]]]]<[->+<]> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <assert.h> | |
#include <stdio.h> | |
static void update(int top[], int k, int value) { | |
if (value < top[k - 1]) return; | |
int i = k - 1; | |
while (i > 0 && value > top[i - 1]) { | |
top[i] = top[i - 1]; | |
--i; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <assert.h> | |
#include <stdbool.h> | |
#include <stdio.h> | |
#include <stdlib.h> | |
#include <sys/mman.h> | |
#include <sys/stat.h> | |
static void insert(int top[], int k, int value) { | |
if (value <= top[k - 1]) return; | |
int i = k - 1; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <assert.h> | |
#include <stdbool.h> | |
#include <stdio.h> | |
#include <stdlib.h> | |
static void update(int top[], int k, int value) { | |
if (value < top[k - 1]) return; | |
int i = k - 1; | |
while (i > 0 && value > top[i - 1]) { |
This file has been truncated, but you can view the full file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
...v>.vv.........v>.>>.v..>v..............>.v.v>.....vv..>>.>.vv.>>vv>v>...>........v....>......v..v>.....v.>..v...>......v....>......>.>....>..v...>.>v.....>v.vv>.>..>.v>.v.>>...>v....vvv.....v>...vv.......v......>>..v..v.....>v.vvv.....................>.v..v..>.>.vv>..v...>v......v.....>v.>.vvv.v..>>v..v..>.....>.>...v..>...v.vv......>>..v.>...>..v....v..>..>...>....>...>.>...v.v....>......>>.......v.>>v.....v.....v>v>.....>...>.v.>>..>.>.....v..v...>..>.>.>...v....v......v.v........v.......>.>v>..>...>.....>.>v.>>>..>.>...v.....>.....v.....v.....>..>>.v..v.v.....>.>v...v.v...>v.......vv.>............v..v..>.......>v.>...v..>>>...>.>.>....v....>>................>.v..>.>.....v>.v...v.....v..v>......>.....>...v........v.....>....>.>.v>>.......v.....v>.....v.>v.>.>>>...>v>........>.v.>.....v..>>.v....>.........v>v>..v.....>.....>.v..>..v.>..v..>....>.>.vv.>...>..v.>.....v.........>>..vv>........v>....v.......v.v..v.....v..v.>.v.v...>.....>...>.>.....v.......v...>v.>.>v.v>.......>>v.>>>. | |
..v.>...v>v>>v......... |