Sha256: 2934e40ec8b80843215013c625354d6e765530ae07a2b2bc8a436acc8d01f8cb
Contents?: true
Size: 404 Bytes
Versions: 1
Compression:
Stored size: 404 Bytes
Contents
# Your code goes here def spiral(arr) result = [] 4.times { |x| result[x] = [] 4.times { |y| result[x][y] = arr[y][3 - x] } } result end arr = [] arr[0] = [1,2,3,4] arr[1] = [5,6,7,8] arr[2] = [9,0,1,2] arr[3] = [3,4,5,6] def print_arr(arr) 4.times { |y| 4.times { |x| print "#{arr[x][y]} " } puts "" } end print_arr(arr) puts "" print_arr(spiral(arr))
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
spiral-path-bm-1.0.0 | lib/spiral-path-bm.rb |