View pi.atl
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
# ref. https://www.cs.ox.ac.uk/people/jeremy.gibbons/publications/spigot.pdf | |
i=2:1+i | |
q=1:10*q*i*~1-2*i | |
r=180:10*u*(q*~2-5*i)+r-y*t | |
t=60:t*u | |
u=6+i*27+i*27 | |
y=((q*~12-27*i)+5*r)/5*t | |
c='0+1001[y | |
([c):'.:>c |
View cookpad-puzzles-2022.rb
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
# https://ruby-puzzles-2022.cookpad.tech/ | |
def answer1(n) | |
n+1 | |
end | |
def answer2(str) |
View Makefile
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
CC = gcc | |
CFLAGS = -Wall -Wextra -std=gnu11 -O0 | |
LIBS = -lmpfr -lgmp | |
SRC = pow.c | |
LIBMBIN = pow_m | |
OPENLIBMBIN = pow_o | |
all: $(LIBMBIN) $(OPENLIBMBIN) | |
$(LIBMBIN): $(SRC) |
View verify.l
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
;;; https://github.com/TokusiN/AtanMagic/blob/main/data.txt を保存して開いておく | |
(labels ((read-data (buf) | |
(with-input-from-buffer (buf) | |
(loop for i to 15 collect | |
(mapcar #'read-from-string (split-string (read-line) #\,))))) | |
(frac2comp (f) | |
(complex (denominator f) (numerator f))) | |
(verify1 (desc row) | |
; 各分数を複素数に変換(p/q → q+pi)し、総乗の虚数部=0 かつ 偏角の総和≒2πならokとする |
View spigot_e.sql
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
drop table if exists consts; | |
drop table if exists digits; | |
create table consts as select 10000 ndigits; | |
create table digits(n int primary key, d int); | |
.timer on | |
insert into digits(n, d) | |
with recursive init(n, num, den) as ( |
View pi_pg.sql
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
-- ref https://www.cs.ox.ac.uk/people/jeremy.gibbons/publications/spigot.pdf | |
with recursive pigen(q, r, t, i, y, n) as ( | |
select 1::decimal, 180::decimal, 60::decimal, 2, 0::decimal, 0 | |
union all select 10*q*i*(2*i-1), 10*u*(q*(5*i-2)+r-y*t), t*u, i+1, y, n+1 | |
from (select q, r, t, i, n, 3*(3*i+1)*(3*i+2) as u, div(q*(27*i-12)+5*r,(5*t)) as y from pigen) as tmp | |
where n < 1000 | |
) | |
select string_agg(y::text, '') pi | |
from pigen where n > 0; |
View pi_spigot.sql
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
-- ref. https://xn--w6q13e505b.jp/program/spigot.html | |
create table consts as | |
select 1000 ndigits; | |
.timer on | |
with a(i) as ( | |
select ndigits/4*14 from consts | |
union all select i-1 from a where i>0 |
View export_wordle_stats.js
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
javascript:((w)=>{let u=new URL(w.location);u.searchParams.set("data",JSON.stringify({"statistics":JSON.parse(w.localStorage.getItem("nyt-wordle-statistics")),"darkTheme":0}));w.prompt("copy url",u.href);})(window); |
View query.sql
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
WITH consts AS ( | |
SELECT | |
8 AS n, -- number of iterations | |
500 AS l, -- width & height of image | |
0.7265425280053609 AS tan36, -- tan(π/5) | |
0.6180339887498948 AS d -- 1/φ | |
), tiles (p, i, t, px, py, qx, qy, rx, ry, sx, sy, tx, ty) AS ( | |
SELECT 0, n, 1, -l/tan36, 0, 0, l, l/tan36, 0, 0, 0, 0, 0 FROM consts | |
UNION ALL SELECT 1, i-1, t, px, py, qx, qy, rx, ry, (qx-px)*d+px, (qy-py)*d+py, (rx-px)*d+px, (ry-py)*d+py |
View grass.rb
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/ruby | |
# | |
# grass.rb - Grass interpreter | |
# with call/cc extension | |
# http://www.blue.sky.or.jp/grass/ | |
# | |
# Copyright (C) 2020-2021 Yousuke Ushiki All rights reserved. | |
# | |
# Redistribution and use in source and binary forms, with or without | |
# modification, are permitted provided that the following conditions |
NewerOlder