I'm trying to avoid regular numbers when thinking about 4-digit passwords. The password string s, which consists of four digits, is entered. If there are two or more of the same numbers, output "NG", otherwise output "OK".
The input is given in the following format.
s
-The first line is given the password string s, which consists of four digits. -The total number of inputs is one, and one line break is inserted at the end of the last line of the input value.
The password string s, which consists of four digits, is entered. If there are two or more of the same numbers, output "NG", otherwise output "OK".
2020
NG
1234
OK
python
a = gets.chomp.chars
if (a.count - a.uniq.count) > 0
puts "NG"
else
puts "OK"
end
A method that deletes duplicate elements in the array elements and returns them as the deleted array
Recommended Posts