Skip to content

Instantly share code, notes, and snippets.

View Vaguery's full-sized avatar

Bill Tozier Vaguery

View GitHub Profile
@Vaguery
Vaguery / 3x3.swift
Last active July 22, 2023 13:14
A brute force magic square guesser in Swift, which is not pretty because it's not supposed to be
import Cocoa
func dupes(nums:[Int])-> Int {
return nums.count - Set(nums).count
}
func r10k() -> Int {Int.random(in: 1...10000)}
struct Solution {
let v:[Int]
@Vaguery
Vaguery / kick.swift
Created October 8, 2021 17:27
trying to understand Swift subclass collections
//
// KickInterpreter.swift
// Kick
//
// Created by Bill Tozier on 10/7/21.
//
import Foundation
@Vaguery
Vaguery / everything-10.txt
Last active July 19, 2021 23:47
some silly Clojure to explore continued fractions
This file has been truncated, but you can view the full file.
{36369/3601 2, 3863/2839 2, 3845/2821 2, 3821/2797 2, 3693/2669 2, 3641/2617 2, 3639/2615 2, 3633/2609 2, 3623/2599 2, 3615/2591 2, 3473/2449 2, 3453/2429 2, 3211/2187 4, 3185/2161 2, 3081/2057 2, 2001/977 2, 1997/973 2, 1985/961 2, 1967/943 2, 1953/929 2, 1947/923 4, 1937/913 2, 1933/909 2, 1927/903 2, 1913/889 2, 1909/885 2, 1889/865 2, 1881/857 2, 1869/845 2, 1867/843 2, 1821/797 2, 1819/795 4, 1811/787 2, 1793/769 2, 1723/699 4, 1719/695 6, 1717/693 2, 1683/659 2, 1645/621 2, 1635/611 2, 1633/609 2, 1625/601 2, 1617/593 2, 1597/573 2, 1595/571 2, 1593/569 2, 1589/565 2, 1583/559 2, 1575/551 2, 1555/531 2, 1519/495 2, 1517/493 2, 1511/487 2, 1505/481 2, 1499/475 2, 1493/469 4, 1491/467 2, 1487/463 2, 1485/461 4, 1483/459 6, 1477/453 4, 1471/447 2, 1455/431 4, 1445/421 4, 1443/419 2, 1441/417 2, 1439/415 2, 1437/413 2, 1435/411 4, 1425/401 6, 1419/395 4, 1415/391 2, 1413/389 2, 1411/387 2, 1389/365 4, 1383/359 4, 1373/349 4, 1369/345 2, 1363/339 4, 1361/337 2, 1355/331 4, 1353/329 4, 1351/327 2, 1347/323 4,
@Vaguery
Vaguery / super_prime.rb
Last active January 31, 2021 13:47
The first 80 "super primes" (delete any single digit and the result is still a prime)
# see http://oeis.org/A051362
require "prime"
def subprimes(number)
digits = number.digits.reverse
digits.collect.with_index do |d,idx|
subset = digits.dup
subset.delete_at(idx)
subset.join.to_i.prime?
@Vaguery
Vaguery / pandigital_products.rb
Created February 22, 2019 15:57
To practice coding, I want to write a function which, given a strictly positive integer `p`, produces the _smallest_ `q` such that `p*q` is pandigital
require 'pp'
require 'prime'
# for integer p in the given range, find the smallest integer q such that p*q is a pandigital number (has at least one of every digit)
p_range = (1..10)
@digits = (0..9).to_a.collect {|d| d.to_s}
def pandigital?(number)
number.to_s.chars.uniq.sort == @digits
@Vaguery
Vaguery / fingers_33.txt
Created February 20, 2018 16:17
Walking through the FizzBuzz program "fingers" with input = 33
clojush.core=> (trace-push fingers [33] 1000)
State after 0 steps:
:exec = ((in1 exec_do*while (exec_do*count (exec_do*count (in1 "buzz" exec_yankdup) integer_div exec_when "fizz" string_take integer_yankdup boolean_frominteger string_take string_dup integer_stackdepth exec_yankdup exec_y integer_sub string_take exec_do*times (integer_lte exec_while ("fizz" "buzz" string_concat exec_flush))))))
:code = nil
:integer = nil
:boolean = nil
:char = nil
:string = nil
:input = (33)
@Vaguery
Vaguery / fingers_6.txt
Created February 20, 2018 15:57
Walking through the FizzBuzz program "fingers" with input = 6
clojush.core=> (trace-push fingers [6] 1000)
State after 0 steps:
;; the program
:exec = ((in1 exec_do*while (exec_do*count (exec_do*count (in1 "buzz" exec_yankdup) integer_div exec_when "fizz" string_take integer_yankdup boolean_frominteger string_take string_dup integer_stackdepth exec_yankdup exec_y integer_sub string_take exec_do*times (integer_lte exec_while ("fizz" "buzz" string_concat exec_flush))))))
:code = nil
:integer = nil
:boolean = nil
:char = nil
:string = nil
@Vaguery
Vaguery / fingers_3.txt
Created February 20, 2018 15:18
Walking through the FizzBuzz program "fingers" with input = 3
clojush.core=> (trace-push fingers [3] 1000)
State after 0 steps:
;; program on :exec
:exec = ((in1 exec_do*while (exec_do*count (exec_do*count (in1 "buzz" exec_yankdup) integer_div exec_when "fizz" string_take integer_yankdup boolean_frominteger string_take string_dup integer_stackdepth exec_yankdup exec_y integer_sub string_take exec_do*times (integer_lte exec_while ("fizz" "buzz" string_concat exec_flush))))))
:code = nil
:integer = nil
:boolean = nil
:char = nil
:string = nil
@Vaguery
Vaguery / fingers_14.txt
Last active February 20, 2018 13:46
Walking through the FizzBuzz "fingers" program with input=14
clojush.core=> (trace-push fingers [14] 1000)
State after 0 steps:
;; program pushed to :exec
:exec = ((in1 exec_do*while (exec_do*count (exec_do*count (in1 "buzz" exec_yankdup) integer_div exec_when "fizz" string_take integer_yankdup boolean_frominteger string_take string_dup integer_stackdepth exec_yankdup exec_y integer_sub string_take exec_do*times (integer_lte exec_while ("fizz" "buzz" string_concat exec_flush))))))
:code = nil
:integer = nil
:boolean = nil
:char = nil
:string = nil
@Vaguery
Vaguery / fizzbuzz_3.txt
Created February 19, 2018 00:48
Trace of a new evolved fizz buzz program in Push with input 3333
clojush.core=> (run-push my-program start-state true)
State after 0 steps:
;; program in :exec
:exec = ((in1 integer_dup in1 integer_stackdepth integer_mod in1 in1 "fizz" integer_stackdepth integer_mod integer_mult integer_mult exec_dup_times string_rest integer_dup integer_stackdepth in1 integer_stackdepth integer_mod exec_dup_times exec_y integer_mod integer_div exec_dup_times "buzz" "buzz" string_concat))
:integer = nil
:boolean = nil
:char = nil
:string = nil
:input = (3333)