Skip to content

Instantly share code, notes, and snippets.

Avatar

Marc van Woerkom mvw

  • Germany, European Union
View GitHub Profile
View dp-div-ds.txt
1: 111
2: 112
3: 121
4: 123
5: 132
6: 211
7: 213
8: 231
9: 312
10: 321
View dp-div-ds.rb
def dp(a, b, c)
a*b*c
end
def ds(a, b, c)
a+b+c
end
count = 0
(1..9).each do |a|
View urn.rb
def run
urn = [:blue, :blue, :red, :red, :red]
blue = 0
n = urn.size
(1..n).each do |k|
index = rand(urn.size)
ball = urn.delete_at(index)
#puts "ball=#{ball} urn=#{urn}"
if ball == :blue
blue += 1
View planet.rb
# planet.rb
#
# Planet Ship Intersection
#
# http://math.stackexchange.com/q/2071775/86776
require "matrix.rb"
# problem instance
$x0 = 1.0
View xy-prices.dat
24 36 79
30 36 90
36 36 101
42 36 113
48 36 127
54 36 134
60 36 146
66 36 158
72 36 169
78 36 181
View balls.log
a0 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17]
1. [1, 10, 16]
2. [2, 8, 10]
3. [3, 9, 17]
4. [3, 13, 15]
5. [1, 8, 13]
6. [10, 12, 15]
7. [4, 10, 15]
8. [2, 8, 15]
9. [1, 3, 10]
View balls.rb
# http://math.stackexchange.com/q/2012173/86776
def sim(n, runs)
a0 = Array.new
(1..n).each do |k|
a0 << k
end
puts "a0 = #{a0}"
h = Hash.new
found = 0
View cubes56.rb
# cubes56.rb
# http://math.stackexchange.com/q/2010848/86776
i = 0
(100..999).each do |n|
q = n**3
next if q % 100 != 56
i += 1
puts "#{i}: (#{n})**3 = #{q}"
end
View cookies.rb
# http://math.stackexchange.com/q/2000829/86776
require 'set'
class Jar
@cookies
def initialize
@cookies = Set.new
(1..10).each do |k|
View inverse.rb
# inverse
#
# http://math.stackexchange.com/q/1940277/86776
load "set.rb"
SX = 25
SY = 25
def empty_graph()