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
#! /usr/bin/env python3 | |
import argparse | |
import json | |
import os | |
import requests | |
import subprocess | |
import sys | |
import urllib.request | |
from rich.progress import (Progress, SpinnerColumn, TimeElapsedColumn) |
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
#!/usr/bin/env python3 | |
#-*- coding: utf-8 -*- | |
import datetime | |
import math | |
import zoneinfo | |
def rise_set(lat, long, fordate, tz=None): | |
refdate = datetime.datetime(2000, 1, 1, 12, 0, 0, tzinfo=datetime.timezone.utc) | |
n = (fordate - refdate.date()).days |
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
codes = {'.-' : 'a', | |
'-...' : 'b', | |
'-.-.' : 'c', | |
'-..' : 'd', | |
'.' : 'e', | |
'..-.' : 'f', | |
'--.' : 'g', | |
'....' : 'h', | |
'..' : 'i', | |
'.---' : 'j', |
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
def myhash(fs, gs, text): | |
out = [0] * len(text) | |
out[0] = gs[(fs[text[0]] + fs[text[-1]]) % 10] | |
for i in range(1, len(out)): | |
out[i] = gs[(out[i-1] + fs[text[i]]) % 10] | |
return "".join(str(d) for d in out) | |
letters = 'abcdefghijklmnopqrstuvwxyz' | |
def crack(c): |
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 collections import defaultdict | |
def winner(ballots): | |
eliminated = [] | |
while True: | |
tally = defaultdict(int) | |
for b in ballots: | |
pruned = [c for c in b if c not in eliminated] | |
if pruned: | |
tally[pruned[0]] += 1 | |
totals = [(votes, candidate) for (candidate, votes) in tally.items()] |
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 random | |
from math import sin, cos, radians, sqrt, atan2, degrees, asin, pi | |
import sys | |
import contextlib | |
scale = 100 | |
@contextlib.contextmanager | |
def svg(f=sys.stdout, h=(scale * 2), w=(scale * 2)): | |
print('<html><body><svg height="{}" width="{}">'.format(h, w), file=f) |
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
// Quick brute-force solution to | |
// https://fivethirtyeight.com/features/to-solve-the-eccentric-billionaires-puzzle-you-must-first-defeat-the-banker/ | |
#include <iostream> | |
#include <random> | |
#include <functional> | |
auto roll = std::bind(std::uniform_int_distribution<int>(0, 5), | |
std::default_random_engine()); |
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
#!/usr/bin/env python3 | |
import argparse | |
import sys | |
import collections | |
def main(): | |
parser = argparse.ArgumentParser() | |
parser.add_argument('scorefile') | |
args = parser.parse_args() |
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
#!/usr/bin/env python3 | |
import argparse | |
import sys | |
import collections | |
def main(): | |
areas = { 'a' : 12, | |
'b' : 12, | |
'c' : 12, |
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
#!/usr/bin/env python3 | |
import argparse | |
import sys | |
def main(): | |
for pop in range(101): | |
for v1 in range(pop + 1): | |
v2 = pop - v1 | |
if v1 // 10 == v2 % 10 and v1 % 10 == v2 // 10: |
NewerOlder