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
using System; | |
using System.Diagnostics.CodeAnalysis; | |
[Serializable] | |
public struct Unit : IEquatable<Unit>, IComparable, IComparable<Unit> | |
{ | |
public override bool Equals([NotNullWhen(true)] object? obj) | |
{ | |
return obj is Unit; | |
} |
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 Forklift extends Game | |
var boxes; | |
method Forklift(List boxes) | |
end | |
method MakeLeftOptions(Number left, Number left2, List right) | |
if left == 0 then | |
return Forklift([left2, right].Flatten); |
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 Subtraction extends ImpartialGame | |
var lrset; // The subtraction set | |
var n; // The heap size | |
method Subtraction(Set lrset, Number n) | |
end | |
override method Options(Player player) | |
return setof(Subtraction(lrset, n - k) for k in lrset where n - k >= 0); |
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 itertools import count | |
def prime(): | |
def sieve(ints): | |
i = next(ints) | |
yield i | |
for n in sieve(k for k in ints if k % i != 0): | |
yield n | |
return sieve(count(2)) |
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 os | |
import os.path | |
import sys | |
import glob | |
def map(char): | |
a = ord(char) | |
if 48 <= a <= 57: | |
return "~" + char | |
elif char == "-": |
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
<!DOCTYPE html> | |
<html> | |
<head> | |
<meta charset="utf-8"> | |
<title>Repetition-Increasing Sequence</title> | |
</head> | |
<body> | |
<h1>Repetition-Increasing Sequence</h1> | |
<math style="font-size: xxx-large"> | |
<msub> |
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 os | |
import sys | |
import glob | |
import shutil | |
import tkinter as tk | |
from tkinter import messagebox | |
from tkinter import filedialog | |
from PIL import Image, ImageTk, ImageDraw |
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 chainer import Parameter, Chain | |
from chainer.links import Convolution2D | |
from chainer.functions import einsum, softmax | |
from chainer.initializers import Zero | |
def dot(a, b): | |
return einsum("...ji,...ik->...jk", a, b) | |
class SelfAttention(Chain): |
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 numpy as np | |
from chainer import Link | |
from chainer.functions import pad, convolution_2d | |
def lanczos(x, n): | |
return 0.0 if abs(x) > n else np.sinc(x) * np.sinc(x / n) | |
class Lanczos2xDownsampler(Link): | |
def __init__(self, n=3): |
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 numpy as np | |
from chainer import Link | |
from chainer.functions import pad, convolution_2d, depth2space | |
def cubic(b, c): | |
def k(x): | |
if abs(x) < 1: | |
return 1 / 6 * ((12 - 9 * b - 6 * c) * abs(x) ** 3 + (-18 + 12 * b + 6 * c) * abs(x) ** 2 + (6 - 2 * b)) | |
elif 1 <= abs(x) < 2: | |
return 1 / 6 * ((-b - 6 * c) * abs(x) ** 3 + (6 * b + 30 * c) * abs(x) ** 2 + (-12 * b - 48 * c) * abs(x) + (8 * b + 24 * c)) |