STORE = <<-STORE Weapons: Cost Damage Armor Dagger 8 4 0 Shortsword 10 5 0 Warhammer 25 6 0 Longsword 40 7 0 Greataxe 74 8 0 Armor: Cost Damage Armor Leather 13 0 1 Chainmail 31 0 2 Splintmail 53 0 3 Bandedmail 75 0 4 Platemail 102 0 5 Rings: Cost Damage Armor Damage +1 25 1 0 Damage +2 50 2 0 Damage +3 100 3 0 Defense +1 20 0 1 Defense +2 40 0 2 Defense +3 80 0 3 STORE WEAPON_COUNT_RANGE = [1..1] ARMOR_COUNT_RANGE = [0..1] RING_COUNT_RANGE = [0..2] INITIAL_HIT_POINTS = 100 Equipment = Struct.new(:name, :cost, :damage, :armor) do def + other Equipment.new("", cost + other.cost, damage + other.damage, armor + other.armor) end end class Store attr_reader :type, :equipment def initialize(string) lines = string.split("\n") @type = lines[0].split(":")[0] @equipment = lines[1..].map do |line| chunks = line.split Equipment.new(chunks[0..-4].join(" "), chunks[-3].to_i, chunks[-2].to_i, chunks[-1].to_i) end end end stores = STORE.split("\n\n").map{ |store| Store.new(store) } WEAPON_COUNT_RANGE.map do |weapon_count| weapon_combinations = ARMOR_COUNT_RANGE.map do |armor_count| RING_COUNT_RANGE.map do |ring_count| end end end input = STDIN.read p input.split("\n\n")