Data commit

This commit is contained in:
Ingy döt Net 2023-07-01 11:58:00 -04:00
parent 7387c8f97b
commit cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions

View file

@ -0,0 +1,16 @@
(define (in-variants n1 o1 n2 o2 n3 o3 n4)
(let ([o1n (object-name o1)]
[o2n (object-name o2)]
[o3n (object-name o3)])
(with-handlers ((exn:fail:contract:divide-by-zero? (λ (_) empty-sequence)))
(in-parallel
(list (o1 (o2 (o3 n1 n2) n3) n4)
(o1 (o2 n1 (o3 n2 n3)) n4)
(o1 (o2 n1 n2) (o3 n3 n4))
(o1 n1 (o2 (o3 n2 n3) n4))
(o1 n1 (o2 n2 (o3 n3 n4))))
(list `(((,n1 ,o3n ,n2) ,o2n ,n3) ,o1n ,n4)
`((,n1 ,o2n (,n2 ,o3n ,n3)) ,o1n ,n4)
`((,n1 ,o2n ,n2) ,o1n (,n3 ,o3n ,n4))
`(,n1 ,o1n ((,n2 ,o3n ,n3) ,o2n ,n4))
`(,n1 ,o1n (,n2 ,o2n (,n3 ,o3n ,n4))))))))

View file

@ -0,0 +1,15 @@
(define (find-solutions numbers (goal 24))
(define in-operations (list + - * /))
(remove-duplicates
(for*/list ([n1 numbers]
[n2 (remove-from numbers n1)]
[n3 (remove-from numbers n1 n2)]
[n4 (remove-from numbers n1 n2 n3)]
[o1 in-operations]
[o2 in-operations]
[o3 in-operations]
[(res expr) (in-variants n1 o1 n2 o2 n3 o3 n4)]
#:when (= res goal))
expr)))
(define (remove-from numbers . n) (foldr remq numbers n))