This file contains hidden or 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 heapq | |
class Task: | |
def __init__(self, time): | |
self.time = time | |
def __lt__(self, other): | |
return self.time < other.time | |
def __repr__(self): |
This file contains hidden or 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 curses | |
SPADE, HEART, DIAMOND, CLUB = '♠♥♦♣' | |
BOX = { | |
'light': ('┌───┐', | |
'│ │', | |
'│ │', | |
'└───┘'), | |
'heavy': ('┏━━━┓', |
This file contains hidden or 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 curses | |
class Menu: | |
def __init__(self, y, x, options): | |
self.y = y | |
self.x = x | |
self.options = options | |
self.height = len(options) | |
self.width = max(len(opt) for opt in options) | |
self.win = curses.newwin(self.height + 2, self.width + 8, y, x) |
This file contains hidden or 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
-- Agda version 2.6.0.1.20191219 | |
open import Agda.Builtin.Equality | |
open import Agda.Builtin.Nat renaming (Nat to ℕ) | |
open import Agda.Builtin.Sigma | |
ℕ×ℕ : Set | |
ℕ×ℕ = Σ ℕ λ _ → ℕ | |
record Cont : Set where |
This file contains hidden or 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
#!/bin/sh | |
if [ "$1" = "--help" ] || [ $1 = "-h" ]; then | |
echo "Usage: listdays [year] [format]" | |
exit | |
fi | |
if [ -n "$1" ]; then | |
year="$1" | |
else | |
year=`date "+%Y"` |
This file contains hidden or 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
-- Based on https://mazzo.li/epilogue/index.html%3Fp=324.html | |
data W (S : Set) (P : S → Set) : Set where | |
_◁_ : (s : S) → (P s → W S P) → W S P | |
data 𝟘 : Set where | |
data 𝟙 : Set where | |
● : 𝟙 |
This file contains hidden or 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 ℕ : Set where | |
zero : ℕ | |
suc : ℕ → ℕ | |
data ℤ : Set where | |
nonneg : ℕ → ℤ | |
negsuc : ℕ → ℤ | |
data ℚ : Set where | |
frac_/suc_ : ℤ → ℕ → ℚ |
This file contains hidden or 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
module Discrete where | |
open import Agda.Builtin.Equality public | |
data ⊥ : Set where | |
¬_ : ∀{a} → Set a → Set a | |
¬ A = A → ⊥ | |
data Dec {a} (A : Set a) : Set a where |
This file contains hidden or 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
open import Agda.Builtin.List | |
open import Agda.Builtin.Nat renaming (Nat to ℕ) | |
open import Agda.Builtin.String | |
Num = ℕ | |
record Var : Set where | |
constructor var | |
field | |
idx : ℕ |
This file contains hidden or 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 sys | |
class stdio_redirect: | |
def __init__(self, stdin=None, stdout=None, stderr=None): | |
self.stdin, self.sys_stdin = stdin, sys.stdin | |
self.stdout, self.sys_stdout = stdout, sys.stdout | |
self.stderr, self.sys_stderr = stderr, sys.stderr | |
def __enter__(self): | |
sys.stdin = self.stdin |