forked from CoderAcademy-BRI/ruby-challenges
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path24_isogram.rb
More file actions
27 lines (19 loc) · 738 Bytes
/
Copy path24_isogram.rb
File metadata and controls
27 lines (19 loc) · 738 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
# Isogram
# Difficulty: medium
# An isogram is a word that has no repeatting letters;
# consecutive or non-consecutive.
# Implement a method that determines whether a string
# that contains only letters is an isogram.
# The function will take the string as input, and will
# return either true or false.
# *E.g.* isogram?("hello") should return false
# *E.g.* isogram?("scary") should return true
# Terse
def isogram?(input)
input.chars == input.chars.uniq
end
# It would be easy to code a method that stops as soon as it finds a duplicate,
# but since the longest possible isogram is 26 letters long, who cares.
# Test your code here
puts isogram?("hello") #should return false
puts isogram?("scary") #should return true