Ad
Code
Diff
  • def best_moves(score)
      # return the three best moves to reach 0 from the given score
      if (score.even? && score <= 40)
        return [Throw.new(score / 2, 'D')]
      end
      if score == 50 
        return [Throw.new(50)]
      end
      if score >= 182
        return [Throw.new(20, 'T'), Throw.new(20, 'T'), Throw.new(20, 'T')]
      end
      if score == 170
        return [Throw.new(20, 'T'), Throw.new(20, 'T'), Throw.new(50)]
      end
      if score == 141
        return [Throw.new(19, 'T'), Throw.new(16, 'T'), Throw.new(18, 'D')]
      end
    end
    • def best_moves(score)
    • # return the three best moves to reach 0 from the given score
    • if (score.even? && score <= 40) || score == 50
    • return [score]
    • if (score.even? && score <= 40)
    • return [Throw.new(score / 2, 'D')]
    • end
    • if score == 50
    • return [Throw.new(50)]
    • end
    • if score >= 182
    • return [60, 60, 60]
    • return [Throw.new(20, 'T'), Throw.new(20, 'T'), Throw.new(20, 'T')]
    • end
    • if score == 170
    • return [60,60,50]
    • return [Throw.new(20, 'T'), Throw.new(20, 'T'), Throw.new(50)]
    • end
    • if score == 141
    • return [Throw.new(19, 'T'), Throw.new(16, 'T'), Throw.new(18, 'D')]
    • end
    • if score == 21
    • end
    • end
Code
Diff
  • def best_moves(score)
      # return the three best moves to reach 0 from the given score
      if (score.is_even && score <= 40) || score == 50 do
        return [score]
      end
      if score >= 182 do
        return [60, 60, 60]
      end
      if score == 21 do
      end  
    end
    • def best_moves(score)
    • # return the three best moves to reach 0 from the given score
    • if (score.is_even && score <= 40) || score == 50 do
    • return [score]
    • end
    • if score >= 182 do
    • return [60, 60, 60]
    • end
    • if score == 21 do
    • end
    • end