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
require 'numbers_and_words' | |
def lookup_table(limit = 64) | |
[nil] + (1..limit).map do |i| | |
word = i.to_words | |
('a'..'z').map do |c| | |
('a'..'z').map do |l| | |
count = word.count(l) | |
# plural |
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
# Calculates the priority for a vector of ranges. | |
# Favours those that are similar to a probability density. | |
# Lower is better. | |
require 'canberra_distance' | |
require 'frequency_analyser' | |
class PriorityCalculator | |
def initialize(params = {}) |
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
// gcc main.c -O3 -framework GLUT -framework OpenGL && ./a.out | |
#include <OpenGL/gl.h> | |
#include <OpenGL/glu.h> | |
#include <GLUT/glut.h> | |
// ... |
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
# Run :ruby load "bootstrap.rb" in Vim to re-source your gem. | |
NAME ||= File.basename(Dir.getwd) | |
$".reject! { |f| f =~ /#{NAME}/ } | |
$:.unshift("lib") unless $:.include?("lib") | |
require NAME | |
Vim.command("command! B :ruby load '#{__FILE__}'") |
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
%!/bin/bash | |
previous=IFS | |
IFS=$(echo -en "\n\b") | |
for file in `find /media/hdd -iname '*.mkv'` | |
do | |
if [ ! -f "$file.mp4" ]; | |
then | |
echo "Converting $file..." |
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
"use strict"; | |
var _ = require("underscore"); | |
var TwosComplement = {}; | |
TwosComplement.encode = function (n) { | |
var binary, array; | |
if (n < 0) { |
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
"use strict"; | |
var Sentient = require("../../lib/sentient"); | |
describe("ISBN", function () { | |
var machineCode = Sentient.compile({ | |
instructions: [ | |
{ type: "integer", symbol: "ten0", width: 5 }, | |
{ type: "integer", symbol: "ten1", width: 5 }, | |
{ type: "integer", symbol: "ten2", width: 5 }, |
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
From efc06ffab5435b4686f3889167a7d5260de4e1fe Mon Sep 17 00:00:00 2001 | |
From: Chris Patuzzo <chris@patuzzo.co.uk> | |
Date: Mon, 30 May 2016 11:59:11 +0100 | |
Subject: [PATCH 1/1] Port Riss 4.27 and Coprocessor to Mac OS X | |
--- | |
Makefile | 5 ++--- | |
coprocessor-src/BoundedVariableEliminationParallel.cc | 2 +- | |
coprocessor-src/Coprocessor.cc | 9 +-------- | |
coprocessor-src/Coprocessor.h | 12 +++++------- |
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
require "rspec" | |
def combinations(array, length) | |
if length.zero? | |
[[]] | |
else | |
array.flat_map.with_index do |element, index| | |
tail = array[(index + 1)..-1] | |
combinations(tail, length - 1).map do |combination| |
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
For which N is there a permutation of {1,...,N} s.t. termwise sum with {1,...,N} gives all squares? | |
Here's a solution for N=200, solved with http://sentient-lang.org/ | |
{1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, | |
21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, | |
41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, | |
61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, | |
81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100, | |
101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119, 120, |