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
// Based on https://www.youtube.com/watch?v=dLh1n2dErzE | |
#define SHIFT_DATA 2 | |
#define SHIFT_CLK 3 | |
#define SHIFT_LATCH 4 | |
#define EEPROM_D0 5 | |
#define EEPROM_D7 12 | |
#define WRITE_EN 13 | |
void setAddress(int address, bool outputEnable) { |
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
[package] | |
name = "sliding_puzzle_message" | |
version = "0.1.0" | |
authors = ["Chris Patuzzo <[email protected]>"] | |
edition = "2018" | |
[dependencies] | |
sliding_puzzle = "*" | |
pathfinding = "*" |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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
# A quick Sentient program to solve the sudoku posted in this tweet: | |
# https://twitter.com/crypticcracking/status/1293897459912056833 | |
function main () { | |
array9<array9<int5>> sudoku; | |
sudoku.each(function (row) { | |
invariant row.uniq?; | |
invariant row.all?(function (n) { |
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
[package] | |
name = "foo" | |
version = "0.1.0" | |
edition = "2018" | |
[dependencies] | |
legion = "0.2.4" |
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
#!/usr/bin/env ruby | |
# Generate the weights/ offsets for an efficient two-pass Gaussian blur filter of different sizes. | |
# Based on: http://rastergrid.com/blog/2010/09/efficient-gaussian-blur-with-linear-sampling/ | |
# | |
# Usage: ./gaussian [epsilon] | |
require "bigdecimal/util" | |
EPSILON = Float(ARGV[0] || 0.05) |
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
// The EventHandler::new method takes three arguments: | |
// | |
// 1) The Rust function to call to handle the event | |
// 2) The registration function | |
// 3) The deregistration function | |
// | |
// The deregistration function is called when the EventHandler is dropped. | |
// This is similar to React's useEffect cleanup pattern. | |
pub struct EventHandler { |
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
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; |
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
#!/usr/bin/env sentient -c -o -r -n 0 -m lingeling magic_square_7_of_8.snt | |
# Based on: https://twitter.com/standupmaths/status/1214921447644250113 | |
# Written in Sentient: https://sentient-lang.org/ | |
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; |
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
NUMBER_OF_BANDITS = 4 | |
EPSILON = 0.001 | |
VALUES_AND_OCCURENCES = NUMBER_OF_BANDITS.times.map { [0, 0] } | |
def greedy_action | |
VALUES_AND_OCCURENCES.map.with_index { |(v, o), i| [v, o, i] }.max_by(&:first).last | |
end | |
def random_action |
NewerOlder