/
ch-2.rb
50 lines (43 loc) · 814 Bytes
/
ch-2.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
#!/usr/bin/env ruby
=begin
---------------------------------------
AUTHOR: Robert DiCicco
DATE : 2023-08-01
Challenge 228 Task 2 Empty Array ( Raku )
---------------------------------------
=end
myints = [[3, 4, 2],[1,2,3]]
myints.each do |i|
puts("Input: @int = #{i}")
cnt = 0
while i.length() > 0
min = i.min()
if (i[0] == min)
i.shift()
else
i.push(i[0])
i.shift()
end
i.length() > 0 ? puts("#{i}") : puts("()")
cnt += 1
end
puts("Output: #{cnt}\n\n")
end
=begin
---------------------------------------
SAMPLE OUTPUT
ruby .\EmptyArray.rb
Input: @int = [3, 4, 2]
[4, 2, 3]
[2, 3, 4]
[3, 4]
[4]
()
Output: 5
Input: @int = [1, 2, 3]
[2, 3]
[3]
()
Output: 3
---------------------------------------
=end