There are a few issues with the given code. Here's the fixed version:
main.rb158 chars7 lines
Here's an explanation of the changes made:
Isogram
with a capital letter to follow Ruby naming conventions.word
. The Chinese characters 词
were replaced with word
for readability.gsub(/\s+/, '')
.chars
.uniq
to remove duplicate characters and compared it with the original array of characters to check if they are the same.This implementation checks if the given word is an isogram (i.e., a word with no repeating characters) and returns true
or false
accordingly.
gistlibby LogSnag