repl.it
@rshields/

FixedSecondaryComputation

Ruby

No description

fork
loading
Files
  • main.rb
main.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
sol_cnt = 0
10.times do |a|
  10.times do |b|
  next if b == a
    10.times do |i|
    next if i == a || i == b
      10.times do |p|
        next if p == a || p == b || p == i
        if eval("2*(#{i}*10+#{a}) == #{p}*10+#{b}")
          puts "a=#{a} b=#{b} i=#{i} p=#{p}"
          sol_cnt += 1
        end
      end
    end
  end
end
puts "Solutions: #{sol_cnt}"
ruby 2.5.5p157 (2019-03-15 revision 67260) [x86_64-linux]
?