This file contains hidden or 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
1: 111 | |
2: 112 | |
3: 121 | |
4: 123 | |
5: 132 | |
6: 211 | |
7: 213 | |
8: 231 | |
9: 312 | |
10: 321 |
This file contains hidden or 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
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| |
This file contains hidden or 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
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 |
This file contains hidden or 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
# planet.rb | |
# | |
# Planet Ship Intersection | |
# | |
# http://math.stackexchange.com/q/2071775/86776 | |
require "matrix.rb" | |
# problem instance | |
$x0 = 1.0 |
This file contains hidden or 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
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 |
This file contains hidden or 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
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] |
This file contains hidden or 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
# 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 |
This file contains hidden or 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
# 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 |
This file contains hidden or 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
# inverse | |
# | |
# http://math.stackexchange.com/q/1940277/86776 | |
load "set.rb" | |
SX = 25 | |
SY = 25 | |
def empty_graph() |
NewerOlder