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
data "local_file" "input" { | |
filename = "${path.module}/input.txt" | |
} | |
locals { | |
games = [ | |
for line in split("\n", chomp(data.local_file.input.content)) : | |
{ | |
game = tonumber(substr(split(":", line)[0], 5, -1)) | |
observations = [ |
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
data "local_file" "input" { | |
filename = "${path.module}/input.txt" | |
} | |
locals { | |
reps = { | |
one = "1" | |
two = "2" | |
three = "3" | |
four = "4" |
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 <unistd.h> | |
#include <sys/time.h> | |
#include <iostream> | |
#include <thread> | |
#include <mutex> | |
#include <condition_variable> | |
#include <chrono> | |
using namespace std; |
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
from threading import Thread, get_ident | |
import time | |
from queue import Queue | |
THREAD_COUNT = 10 | |
POOL_GET_TIMEOUT = 10.0 | |
POOL_SIZE = 2 | |
pool = Queue() | |
for i in range(POOL_SIZE): |
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
from threading import Condition, Thread | |
import time | |
# This is a sample implementation of something like an object pool. It uses | |
# a condition variable to ensure that at most `counter` threads are allowed | |
# to execute at a time. | |
THREAD_COUNT = 10 | |
counter = 1 | |
cnd = Condition() |
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
<?php | |
function _substr($data, $pos, $len) { | |
if (0 <= $pos && $pos + $len <= strlen($data) && $pos <= $pos + $len) { | |
return substr($data, $pos, $len); | |
} | |
return null; | |
} | |
function _unpack_byte($data, $pos) { | |
$str = _substr($data, $pos, 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
class script : callback_base { | |
scene@ g; | |
array<dustman@> players; | |
script() { | |
@g = get_scene(); | |
} | |
void step(int num_entities) { | |
int nc = num_cameras(); |
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 <iostream> | |
#include <vector> | |
#include <algorithm> | |
using namespace std; | |
int mexp(int v, int e, int MOD) { | |
int ret = 1; | |
if (e == 0) return ret; | |
for(int i = 31 - __builtin_clz(e); i >= 0; 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 <iostream> | |
#include <vector> | |
#include <set> | |
#include <map> | |
#include <algorithm> | |
using namespace std; | |
int gcd(int a, int b) { | |
return b ? gcd(b, a % b) : a; |
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
import abc | |
import asyncio | |
import itertools | |
import sys | |
class Instruction(metaclass=abc.ABCMeta): | |
PARAMS = 0 | |
def __init__(self, comp, offset, mode): |
NewerOlder