Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
14
Task/Loops-Nested/Ruby/loops-nested-1.rb
Normal file
14
Task/Loops-Nested/Ruby/loops-nested-1.rb
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
ary = (1..20).to_a.shuffle.each_slice(4).to_a
|
||||
p ary
|
||||
|
||||
catch :found_it do
|
||||
for row in ary
|
||||
for element in row
|
||||
print "%2d " % element
|
||||
throw :found_it if element == 20
|
||||
end
|
||||
puts ","
|
||||
end
|
||||
end
|
||||
|
||||
puts "done"
|
||||
10
Task/Loops-Nested/Ruby/loops-nested-2.rb
Normal file
10
Task/Loops-Nested/Ruby/loops-nested-2.rb
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
p slices = [*1..20].shuffle.each_slice(4)
|
||||
|
||||
slices.any? do |slice|
|
||||
puts
|
||||
slice.any? do |element|
|
||||
print "#{element} "
|
||||
element == 20
|
||||
end
|
||||
end
|
||||
puts "done"
|
||||
Loading…
Add table
Add a link
Reference in a new issue