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 Foundation | |
// This program is mostly generated by ChatGPT o1 in a long conversation | |
// based on this PDF: https://arxiv.org/pdf/2206.12042 | |
// "Experimental Demonstration of Quantum Pseudotelepathy" | |
struct Complex: CustomStringConvertible { | |
var re: Double | |
var im: Double |
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 Foundation | |
// MARK: — Complex number struct | |
struct Complex { | |
var re: Double | |
var im: Double | |
func conjugate() -> Complex { | |
Complex(re: re, im: -im) |
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
#lang racket/base | |
(require racket/file racket/string) | |
(for ([fname (current-command-line-arguments)]) | |
(displayln fname) | |
(define ls (file->lines fname)) | |
(display-lines-to-file | |
(map (λ (s) (string-trim (string-replace s "\t" " ") " " #:left? #f #:repeat? #t)) ls) | |
fname #:exists 'replace)) |
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 std.stdio, core.bitop, std.array, std.format, std.exception : enforce; | |
struct Entry(K,V) { | |
K key; | |
V value; | |
uint id; | |
} | |
enum maxShift = 25; |
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
enum Ible[e] { | |
case MkIter(Int32, Int32 -> e) | |
} | |
instance Iterable[Ible] { | |
pub def iterator(rc: Region[r], s: Ible[a]): Iterator[a, r, r] \ r = | |
let Ible.MkIter(n, f) = s; | |
Iterator.range(rc, 0, n) |> Iterator.map(f) | |
} |
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
#lang br | |
(require br-parser-tools/lex brag/support br/macro "grammar.rkt") | |
(define-lex-abbrev digits (:+ numeric)) | |
(define-lex-abbrev reserved-terms | |
(:or "+" "-" "*" "/" "=" "in" ";" "{" "}" "(" ")" "," "=>" "if" "then" "else" "==" "<")) | |
(define (tokenize ip) | |
(port-count-lines! ip) | |
(define my-lexer |
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
#lang brag | |
s-prog: s-stmt (/";" s-stmt)* | |
@s-stmt: s-assn | s-fundef | s-expr | |
s-funcall: NAME /"(" [s-expr (/"," s-expr)*] /")" | |
s-fundef: NAME /"(" [NAME (/"," NAME)* ] /")" "=>" s-expr | |
s-block: /"{" [s-stmt (/";" s-stmt)* /"in"] s-expr /"}" | |
s-assn: NAME /"=" s-expr | |
s-expr: s-compterm | if | |
if: /"if" s-expr /"then" s-expr /"else" s-expr | |
s-compterm: s-term [("<" | "==") s-term] |
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
L=11 | |
@field = Array.new(32*32) {0} | |
@vecs = [[1,0], [0,-1], [-1,0], [0,1]] | |
def fld(x,y) @field[y*32+x] end | |
def set(x,y,v) @field[y*32+x] = v end | |
def step(x, y, ang) | |
vx,vy = @vecs[ang & 3] | |
return x+vx, y+vy | |
end |
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 Text.Read | |
import Data.Foldable | |
sampleData = | |
[ | |
["10", "20", "30"], | |
["0", "1", "aa", "2"], | |
["0", "eheh", "1", "bb", "2"], | |
["2", "really", "bad"], | |
["3", "4", "5"] |
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 std.stdio, std.parallelism, std.range, std.algorithm; | |
enum L = 12; | |
struct V {int x,y;} | |
int optLen(int seed) { | |
int[32*32] field; | |
V[4] vecs = [V(1,0), V(0,-1), V(-1,0), V(0,1)]; | |
V[L] path; |
NewerOlder