Skip to content

Instantly share code, notes, and snippets.

def sp(s)
s.split("")
end
# should i do this with primes
def sub_anagram(haystack, needle)
is_anagram = true
leftovers = sp(haystack)
sp(needle).each do |letter|
index = leftovers.index(letter)
@litonico
litonico / tinyrogue.rb
Last active April 15, 2016 23:53
Tiny Roguelike
# tinyrogue.rb
# litonico
# This software is licensed to the public domain
require 'io/console'
CLEARALL = "\x1b[2J\x1b[1;1H"
BACKGROUND_MAP = <<-MAP
........
@litonico
litonico / amb.rb
Last active June 6, 2016 23:30
McCarthy's `amb` operator using exceptions
require 'continuation'
# Example implementation using call/cc,
# stolen in part from randomhacks.net blog
class CallCCAmb
def initialize
@backtrack_points = []
end
def backtrack
@litonico
litonico / schemer_glossary.md
Last active March 10, 2021 09:16
Little Schemer Glossary

Little Schemer glossary

Despite being written as '(a b c), a list is more like: (cons 'a (cons 'b '()))

Like this:

Builtins | Definiton

@litonico
litonico / exclusive_between.rb
Created July 15, 2015 03:45
Ruby lacks exclusive between
require 'minitest/autorun'
class TestExclusiveBetween < Minitest::Test
def assert_between min, max, value
# Fill in here
end
def refute_between min, max, value
# Fill in here
end