lib/codeguessing/game.rb in codeguessing-0.4 vs lib/codeguessing/game.rb in codeguessing-0.4.1
- old
+ new
@@ -19,10 +19,11 @@
res = ''
code.each_char.with_index do |char, i|
case
when char == secret_code[i]
res += '+'
- when secret_code.count(char) == 1
+ when secret_code.count(char) == 1 &&
+ code.count(char) == 1
hash[char] = '-'
end
end
res += hash.values.join('')
win if res == '++++'