Day 21.1
change
commit d2f5cf0cec08034e44827067156e96f537c590b1
author Alpha Chen <alpha.chen@gmail.com>
date
parent b083499a
diff --git a/ruby/day_21.rb b/ruby/day_21.rb
index 3e6945d..68a4c91 100644
--- a/ruby/day_21.rb
+++ b/ruby/day_21.rb
@@ -66,13 +66,13 @@ equipments = weapons.flat_map {|weapon|
       Equipment.new(weapon, armor, rings)
     }
   }
-}.sort_by {|e| e.cost }
+}.sort_by {|e| -e.cost }
 
 BOSS = Dude.new("boss", 100, 8, 2)
 YOU = Dude.new("you", 100, 0, 0)
 
 puts equipments.find {|e|
-  YOU.equipped(e).win_against?(BOSS)
+  !YOU.equipped(e).win_against?(BOSS)
 }.cost
 
 __END__