-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathzigzag_spec.rb
32 lines (27 loc) · 1.1 KB
/
zigzag_spec.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
require "spec_helper"
describe "zig_zag" do
it "works for n = 1" do
zig_zag(1).should == [[1]]
end
it "works for n = 2" do
zig_zag(2).should == [[1, 2], [4, 3]]
end
it "works for n = 3" do
zig_zag(3).should == [[1, 2, 3], [6, 5, 4], [7, 8, 9]]
end
it "works for n = 4" do
zig_zag(4).should == [[1, 2, 3, 4 ], [8, 7, 6, 5 ], [9, 10, 11, 12], [16, 15, 14, 13]]
end
it "works for n = 10" do
zig_zag(10).should eq [[1, 2, 3, 4, 5, 6, 7, 8, 9, 10],
[20, 19, 18, 17, 16, 15, 14, 13, 12, 11],
[21, 22, 23, 24, 25, 26, 27, 28, 29, 30],
[40, 39, 38, 37, 36, 35, 34, 33, 32, 31],
[41, 42, 43, 44, 45, 46, 47, 48, 49, 50],
[60, 59, 58, 57, 56, 55, 54, 53, 52, 51],
[61, 62, 63, 64, 65, 66, 67, 68, 69, 70],
[80, 79, 78, 77, 76, 75, 74, 73, 72, 71],
[81, 82, 83, 84, 85, 86, 87, 88, 89, 90],
[100, 99, 98, 97, 96, 95, 94, 93, 92, 91]]
end
end