-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmumbling.rb
61 lines (53 loc) · 1.25 KB
/
mumbling.rb
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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
# def accum(s)
# return s.split("").map.with_index { |x, i| x.upcase + x.downcase * i }.join("-")
# end
#
# def accum(s)
# s.split("").map.with_index { |x, i| x.upcase + x.downcase * i }.join("-")
# end
def accum(s)
arr = s.split("")
new_array = []
# print arr
# print arr[1].upcase
for i in arr do
print arr[i]
# new_array.push(arr[i].upcase + (arr[i].downcase * i))
end
# new.array.join("-")
end
# testing
# def accum(s)
# letters = s.split("")
# accumulated_letters = []
# upper_limit = letters.length()
#
# # (arr.length).times do |i|
# # (0..arr.length - 1).each do |i|
# # letters.each do |letter|
# # for i in 0..upper_limit
# # print letters[i]
# # accumulated_letters.push(letters[i].upcase + (letters[i].downcase * i))
# # end
#
# i = 0
# while i < letters.length
# print letters[i]
# accumulated_letters.push(letters[i].upcase + (letters[i].downcase * i))
# i += 1
# end
#
# accumulated_letters.join("-")
# end
# cleaned up version of above
def accum(s)
letters = s.split("")
accumulated_letters = []
i = 0
while i < letters.length()
accumulated_letters.push(letters[i].upcase + (letters[i].downcase * i))
i += 1
end
accumulated_letters.join("-")
end
accum("ZpglnRxqenU")