fix it: `class isogram def self.isogram?(词) = 词.match(/(\w+).*\1/i) !~ end` in ruby

There are a few issues with the given code. Here's the fixed version:

main.rb
class Isogram
  def self.isogram?(word)
    normalized_word = word.downcase.gsub(/\s+/, '')
    normalized_word.chars.uniq == normalized_word.chars
  end
end
158 chars
7 lines

Here's an explanation of the changes made:

  1. Renamed the class to Isogram with a capital letter to follow Ruby naming conventions.
  2. Fixed the method signature to accept a parameter called word. The Chinese characters were replaced with word for readability.
  3. Added a line to normalize the word by downcasing it and removing any spaces using gsub(/\s+/, '').
  4. Converted the normalized word to an array of characters using chars.
  5. Used 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