1
1
2
- def string_split ( list )
3
- list . split ( "" )
2
+ def string_split ( array )
3
+ array . split ( "" )
4
4
end
5
5
6
- print string_split ( "bob" " jane" " louis")
6
+ print string_split ( "bob jane louis" )
7
7
8
8
#puts "bob".split("")
9
9
10
10
def item_counts ( array )
11
+ array = string_split ( array )
11
12
counts = { }
12
13
13
14
array . each do |item |
@@ -20,16 +21,30 @@ def item_counts(array)
20
21
counts # This returns the "counts" hash
21
22
end
22
23
23
- puts item_counts ( [ 1 , 2 , 1 , 2 , 1 ] )
24
- puts item_counts ( [ "a" , "b" , "a" , "b" , "a" , "ZZZ" ] )
25
- puts item_counts ( [ ] )
26
- puts item_counts ( [ "hi" , "hi" , "hi" ] )
27
- puts item_counts ( [ true , nil , "dinosaur" ] )
28
- puts item_counts ( [ "a" , "a" , "A" , "A" ] )
24
+ #puts item_counts([1,2,1,2,1])
25
+ #puts item_counts(["a","b","a","b","a","ZZZ"])
26
+ #puts item_counts([])
27
+ #puts item_counts(["hi", "hi", "hi"])
28
+ #puts item_counts([true, nil, "dinosaur"])
29
+ #puts item_counts(["a","a","A","A"])
30
+
31
+ #def final_input(array)
32
+ # final_input(string_split(array), item_counts(array))
33
+ #end
34
+
35
+
36
+ #print final_input("bobjaneus")
29
37
30
38
#p item_counts([1,2,1,2,1]) == {1 => 3, 2 => 2}
31
39
#p item_counts(["a","b","a","b","a","ZZZ"]) == {"a" => 3, "b" => 2, "ZZZ" => 1}
32
40
#p item_counts([]) == {}
33
41
#p item_counts(["hi", "hi", "hi"]) == {"hi" => 3}
34
42
#p item_counts([true, nil, "dinosaur"]) == {true => 1, nil => 1, "dinosaur" => 1}
35
43
#p item_counts(["a","a","A","A"]) == {"a" => 2, "A" => 2}
44
+
45
+
46
+
47
+ # Questions #####
48
+ # On line 11, I attempted to pass in the 'String_Split(array)' result as the definition of array'
49
+ # On line 31-36, I tried passing it in as a new defined method like I had seen in Exercise_36 in the katas
50
+ # Can you point me in the right direction again?
0 commit comments