Sha256: 34dd6908bd1e810233fce18468a3dbd6170e496e2331ae040e15e8d153b20b6d
Contents?: true
Size: 418 Bytes
Versions: 4
Compression:
Stored size: 418 Bytes
Contents
# frozen_string_literal: true module GuessHandler def respond_to_guess(user, input, code) result = [] numbers = input.split("").map(&:to_i) return "win" if numbers == code numbers.each_with_index do |element, index| if element == code[index] result << "+" elsif code.include?(element) result << "-" end end user.attempts.zero ? "loss" : result end end
Version data entries
4 entries across 4 versions & 1 rubygems