Skip to content

Instantly share code, notes, and snippets.

Chris Patuzzo tuzz

Block or report user

Report or block tuzz

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View parker_square.snt
int8 m, n, p, q;
m2 = m.square;
n2 = n.square;
p2 = p.square;
q2 = q.square;
# ceil(log2(sqrt((2 ** (bits - 1)) ** 2 ** 2 * 3)) + 1)
int16 inner, outer1, outer2;
int2 i;
tuzz / magic_square_7_of_8.snt
Last active Jan 8, 2020
Search for magic squares of square numbers that have one mistake, either a row, column or diagonal
View magic_square_7_of_8.snt
#!/usr/bin/env sentient -c -o -r -n 0 -m lingeling magic_square_7_of_8.snt
# Based on:
# Written in Sentient:
function main() {
int12 a, b, c, d, e, f, g, h, i;
# Needs to be: ceil(log2((2^(bits - 1))^2 * 3)) + 1
int25 magicSum;
tuzz / bandits.rb
Created Dec 15, 2019
Playing with 'bandits' from reinforcement learning
View bandits.rb
EPSILON = 0.001
def greedy_action { |(v, o), i| [v, o, i] }.max_by(&:first).last
def random_action
tuzz / digit-reversal.snt
Last active Oct 27, 2019
A Sentient program to find solutions to questions posed in 'Digit Reversal Without Apology'
View digit-reversal.snt
#!/usr/bin/env sentient -c -o -r -n 0 -m lingeling digit-reversal.snt
# This program explores 'Open question one'
array5<int9> digits;
base = 198;
max = 197;
tuzz / superpermutation-spiral.html
Created Mar 6, 2019
A very quick experiment to draw superpermutations as colored spirals moving out from the center.
View superpermutation-spiral.html
<canvas id="canvas" width="1000" height="1000"></canvas>
var canvas = document.getElementById("canvas");
var context = canvas.getContext("2d");
var done = false;
function circle_around(callback) {
View simplesupersat.rb
# This is a greatly simplified version of
# It reduces the superpermutation problem to boolean satisfiability.
# To generate a SAT problem for N=3, LENGTH=9:
# ruby simplesupersat.rb 3 9
# And to run a SAT solver on it:
# lingeling 3-9.dimacs
N = Integer(ARGV[0])
tuzz / subset.snt
Last active Oct 22, 2018
A proof-of-concept Sentient program for a set membership problem.
View subset.snt
# A proof-of-concept Sentient program for a set membership problem.
# $ sentient subset.snt --assign '{ target: [1, 1, 0, 1], max_selections: 2 }'
# Outputs: {"members":[false,false,false,false,true,false,false,false,true,false,false,false]}
# Corresponding to: uk - scotland
# Given: a set of all the countries in the world, and a set of possible
# groupings of those countries (e.g. “Scandinavia” or “Central America”, or
# “All”), given a set of arbitrary countries, I want to compute the most concise
tuzz / superpermutation.rb
Created Oct 19, 2018
Reduce the problem of finding superpermutations of N digits to SAT
View superpermutation.rb
# Attempts to find a superpermutation for a given number of digits that fit into a given string length.
# Run: ruby superpermutation.rb | lingeling -f
# The program will be satisfiable if it is possible, but won't actually print the solution.
# I need to add some code to decode the output.
digits = 4
length = 33
tuzz /
Last active Sep 17, 2018
An attempt to write a function 'zip_if' in Rust
// Implements:
// The basic idea is we store a vector of cursors that advance through the
// nested list and build up the result. If the predicate for the current
// element is false we append a row padded with zeroes, otherwise we move
// along to the next nested list until we reach the last one. When we do,
// we append the fully saturated row to the result and move to the next
// element in each of the nested lists.
// At the end we need to check if there are any elements that matched the
tuzz /
Created Aug 6, 2018
A Rust proof-of-concept from the August 2018 Rust meeting in London.
/* This is a proof-of-concept, inspired by clojure, that stores just the
* transitions between multiple Foo structs, rather than copying the entire
* struct's fields each time.
#[derive(Default)] // <-- this derives Foo::default() which creates a Foo struct
// with a and b initialized to zero.
struct Foo {
a: u8,
b: u8,
You can’t perform that action at this time.