Skip to content

Instantly share code, notes, and snippets.

Avatar

Leslie Viljoen lesliev

View GitHub Profile
@lesliev
lesliev / heyo.rb
Created May 14, 2018
All the heyos
View heyo.rb
heyo = 'heyo'.scan(/./)
heyo.each do |c1|
(heyo-[c1]).each do |c2|
(heyo-[c1, c2]).each do |c3|
(heyo-[c1, c2, c3]).each do |c4|
puts "#{c1} #{c2} #{c3} #{c4}"
end
end
end
@lesliev
lesliev / heyo.py
Last active May 15, 2018
All the heyos
View heyo.py
heyo = set(['h', 'e', 'y', 'o'])
for c1 in heyo:
for c2 in (heyo - set([c1])):
for c3 in (heyo - set([c1, c2])):
for c4 in (heyo - set([c1, c2, c3])):
print (" ".join([c1, c2, c3, c4]))
@lesliev
lesliev / wires.txt
Created Dec 11, 2015
Wires from circuits
View wires.txt
wire_a: 956
wire_aa: 221
wire_ab: 1021
wire_ac: 84
wire_ad: 65451
wire_ae: 937
wire_af: 2025
wire_ag: 680
wire_ah: 64855
wire_ai: 1345
View circuits3.rb
#! /usr/bin/env ruby
class Circuit
def initialize(doc)
@doc = doc.split("\n").map(&:strip)
program = create(@doc)
File.open('program.rb', 'w'){|f| f.puts program}
puts
eval(program.join("\n"))
end
@lesliev
lesliev / circuits2.rb
Last active Dec 10, 2015
Better circuits
View circuits2.rb
#! /usr/bin/env ruby
class Circuit
def initialize(doc)
@doc = doc.split("\n").map(&:strip)
program = create(@doc)
File.open('program.rb', 'w'){|f| f.puts program}
puts
eval(program.join("\n"))
end
View circuits.rb
#! /usr/bin/env ruby
class Circuit
def initialize(doc)
@doc = doc.split("\n").map(&:strip)
program = create(@doc)
eval(program.join("\n"))
end
def create(doc)
@lesliev
lesliev / Static variables in CoffeeScript
Created Aug 11, 2013
How do you refer to @tileSize and @tile in the constructor there? They are undefined.
View Static variables in CoffeeScript
class MapGenerator
@tileSize: 20 # width and height of a tile
# should this be a power of 2 for WebGL TilingSprite?
@tile:
floor: 0 # clear floor that objects can move through
wall: 1 # wall, creating an obstacle
deadspace: -1
constructor: (width, height) ->