Method: Codeguessing::Game#get_mark
- Defined in:
- lib/codeguessing/game.rb
#get_mark(code) ⇒ Object
23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/codeguessing/game.rb', line 23 def get_mark(code) return false unless valid?(code) hash = {} res = '' secret_code.each_char.with_index do |char, i| if code[i] == char res += '+' code[i] = '_' hash.delete(char) elsif code.include?(char) hash[char] = '-' end end res += hash.values.join('') end |