Skip to content

Instantly share code, notes, and snippets.

'''
Code to solve the puzzle [Circular Prison of Unknown Size](https://puzzling.stackexchange.com/questions/16168/the-circular-prison-of-unknown-size)
'''
import random
import logging
from itertools import chain, combinations
def powerset(iterable):
"powerset([1,2,3]) --> () (1,) (2,) (3,) (1,2) (1,3) (2,3) (1,2,3)"
import random
import logging
log = logging.getLogger(__name__)
MAX_NUM_PRISONERS = 12
NUM_PRISONERS = random.randrange(2, MAX_NUM_PRISONERS + 1)
def main():
print(f'Number of prisoners: {NUM_PRISONERS}')
#define WIFI_SSID ""
#define WIFI_PW ""
#define KEY ""
#define API_URL ""
#define NAME ""
#define ROLE ""
#include <ESP8266WiFi.h>
#include <ESP8266mDNS.h>
#include <WiFiUdp.h>
@tkeith
tkeith / esp8266.c
Created March 20, 2020 15:48
ESP8266 code
#include <ESP8266WiFi.h>
#include <ESP8266mDNS.h>
#include <WiFiUdp.h>
#include <ArduinoOTA.h>
const char* ssid = "...";
const char* password = "...";
void setup() {
Serial.begin(115200);
@tkeith
tkeith / transactions.py
Created September 22, 2015 17:25
SQLAlchemy Transaction Management
dbe = sqlalchemy.create_engine(config.DB_URL, isolation_level='SERIALIZABLE')
dbs = scoped_session(sessionmaker(bind=dbe, autoflush=True, autocommit=False))
in_dbt = False
tdata = dict()
in_retry = False
@contextmanager
def dbt_cm(save=True, top=False, _retry=False):
global in_dbt
global in_nested_dbt