Skip to content

Instantly share code, notes, and snippets.

@pokutuna
Created February 12, 2011 12:59
Show Gist options
  • Save pokutuna/823745 to your computer and use it in GitHub Desktop.
Save pokutuna/823745 to your computer and use it in GitHub Desktop.
# -*- coding: utf-8 -*-
@turu = { :head => 1, :leg => 2, :wing => 2 }
@kame = { :head => 1, :leg => 4, :wing => 0 }
@tonbo = { :head => 1, :leg => 6, :wing => 4 }
raise ArgumentError if [@turu, @kame, @tonbo].any? { |a| a[:head] != 1 }
def calc(head, leg, wing)
(0..head).each do |t|
(0..(head - t)).each do |k|
to = head - t - k
legs = t * @turu[:leg] + k * @kame[:leg] + to * @tonbo[:leg]
wings = t * @turu[:wing] + k * @kame[:wing] + to * @tonbo[:wing]
puts "turu:#{t}, kame:#{k}, tonbo:#{to}" if legs == leg && wings
end
end
end
head = 12
leg = 54
wing = 30
calc(head, leg, wing)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment