Last active
June 7, 2022 06:20
-
-
Save youz/6e50af6185d23cbca000499530094b2d to your computer and use it in GitHub Desktop.
atan魔方陣 https://twitter.com/toku51n/status/1533401499983749121 をxyzzyで検証
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とする | |
(let* ((l (mapcar #'frac2comp row)) | |
(p (reduce #'* l)) | |
(sa (reduce #'+ (mapcar #'phase l))) | |
(ok? (and (integerp p) (< (abs (- (* 2 pi) sa)) 1d-2)))) | |
(format t "~a: ~:[ng~;ok~] Π=~a Σarg=~a~%" desc ok? p sa)))) | |
(let ((m (read-data "data.txt"))) | |
(dotimes (i 16) | |
(verify1 (format nil "→~a" i) (nth i m)) | |
(verify1 (format nil "↓~a" i) (mapcar #'(lambda (l) (nth i l)) m))) | |
(verify1 "\" (loop for i to 15 collect (nth i (nth i m)))) | |
(verify1 "/" (loop for i to 15 collect (nth i (nth (- 15 i) m)))))) |
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
→0: ok Π=28574842746751575601507416152178564453125 Σarg=6.283186 | |
↓0: ok Π=2694115124952777088420153901838049740625 Σarg=6.283186 | |
→1: ok Π=74464444597257664886143740323293343400625 Σarg=6.283186 | |
↓1: ok Π=244331023900548270790308342156217827265625 Σarg=6.283185 | |
→2: ok Π=91787877424280097285579261111324768578125 Σarg=6.283185 | |
↓2: ok Π=364485918036519778217822637356301522265625 Σarg=6.283185 | |
→3: ok Π=280660894099274185616629426782072314453125 Σarg=6.283185 | |
↓3: ok Π=241706671266656329004532084368076923828125 Σarg=6.283185 | |
→4: ok Π=79519294177931557346182700515956494140625 Σarg=6.283185 | |
↓4: ok Π=546562351379809417181962977879890470703125 Σarg=6.283185 | |
→5: ok Π=105966135071751780025570301374408449453125 Σarg=6.283186 | |
↓5: ok Π=226275128890363192997917128989381413765625 Σarg=6.283185 | |
→6: ok Π=425804347376179249589620046122447819328125 Σarg=6.283185 | |
↓6: ok Π=17199359902335431118176230016852821765625 Σarg=6.283185 | |
→7: ok Π=241217124402603698239465659412103277258445 Σarg=6.283185 | |
↓7: ok Π=168047129395669820160881121671245514290625 Σarg=6.283185 | |
→8: ok Π=79050321573014280793667319528121133178125 Σarg=6.283185 | |
↓8: ok Π=123548023376498407899624595839766038651125 Σarg=6.283185 | |
→9: ok Π=1918110855783606257900218716027122332466645 Σarg=6.283185 | |
↓9: ok Π=33704436567405880913801530294248211328125 Σarg=6.283185 | |
→10: ok Π=163841908462292584575950644479837749420125 Σarg=6.283185 | |
↓10: ok Π=273032439595378390134487522307330836765025 Σarg=6.283185 | |
→11: ok Π=1828974110930840770989548972783410644548125 Σarg=6.283185 | |
↓11: ok Π=57659909413055226192398145836043634765625 Σarg=6.283185 | |
→12: ok Π=63561128035258205479830951212215392578125 Σarg=6.283185 | |
↓12: ok Π=3851551823351160315433262808612362468517625 Σarg=6.283185 | |
→13: ok Π=922685165201808988378548285425806328721325 Σarg=6.283186 | |
↓13: ok Π=918150282112652671766964438607724542060625 Σarg=6.283185 | |
→14: ok Π=5639674075902992860490627523432553891625 Σarg=6.283185 | |
↓14: ok Π=76528524366980421689183052855011993498225 Σarg=6.283185 | |
→15: ok Π=71123740457590194046628628858734072265625 Σarg=6.283185 | |
↓15: ok Π=137883879499894706636993181864810004140625 Σarg=6.283186 | |
\: ok Π=878049202419008653353310688887703571240625 Σarg=6.283185 | |
/: ok Π=135463329283292269552413400757187818453125 Σarg=6.283185 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment