aboutsummaryrefslogtreecommitdiff
path: root/challenge-215/robert-dicicco/ruby/ch-1.rb
blob: acf5ca9845769b31cc78901ed403afd0ef44f1c0 (plain)
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
28
29
30
31
32
33
34
35
36
37
38
39
40
#!/usr/bin/env ruby
=begin
----------------------------------------
AUTHOR: Robert DiCicco
DATE  : 2023-05-01
Challenge 215 Odd One Out ( Ruby )
----------------------------------------
=end

words = [["abc","xyz","tsu"],["rat", "cab", "dad"],["x", "y", "z"]]

words.each do |wds|
    cnt = 0
    puts("Input: @words = #{wds}")
    wds.each do |w|
        srt = w.chars.sort.join
        if w != srt
            cnt += 1
        end
    end
    puts("Output: #{cnt}")
    puts
end

=begin
----------------------------------------
SAMPLE OUTPUT
ruby .\OddOneOut.rb
Input: @words = ["abc", "xyz", "tsu"]
Output: 1

Input: @words = ["rat", "cab", "dad"]
Output: 3

Input: @words = ["x", "y", "z"]
Output: 0
----------------------------------------
=end