trackler 2.2.1.127 → 2.2.1.128

Sign up to get free protection for your applications and to get access to all the features.
Files changed (37) hide show
  1. checksums.yaml +4 -4
  2. data/lib/trackler/version.rb +1 -1
  3. data/tracks/c/docs/RESOURCES.md +0 -1
  4. data/tracks/delphi/exercises/isbn-verifier/uTestISBNVerifier.pas +2 -2
  5. data/tracks/ecmascript/config.json +2 -2
  6. data/tracks/elm/config/maintainers.json +11 -11
  7. data/tracks/elm/config.json +170 -245
  8. data/tracks/fsharp/exercises/pov/PovTest.fs +1 -1
  9. data/tracks/java/exercises/queen-attack/.meta/src/reference/java/Queen.java +38 -0
  10. data/tracks/java/exercises/queen-attack/.meta/src/reference/java/QueenAttackCalculator.java +11 -12
  11. data/tracks/java/exercises/queen-attack/.meta/version +1 -1
  12. data/tracks/java/exercises/queen-attack/src/test/java/QueenAttackCalculatorTest.java +50 -44
  13. data/tracks/python/config.json +26 -0
  14. data/tracks/python/exercises/bank-account/README.md +53 -0
  15. data/tracks/python/exercises/bank-account/bank_account.py +18 -0
  16. data/tracks/python/exercises/bank-account/bank_account_test.py +120 -0
  17. data/tracks/python/exercises/bank-account/example.py +35 -0
  18. data/tracks/python/exercises/go-counting/example.py +6 -6
  19. data/tracks/python/exercises/go-counting/go_counting.py +3 -2
  20. data/tracks/python/exercises/go-counting/go_counting_test.py +58 -51
  21. data/tracks/python/exercises/house/example.py +7 -13
  22. data/tracks/python/exercises/house/house_test.py +79 -204
  23. data/tracks/python/exercises/meetup/example.py +10 -1
  24. data/tracks/python/exercises/meetup/meetup_test.py +1 -6
  25. data/tracks/python/exercises/pascals-triangle/example.py +12 -14
  26. data/tracks/python/exercises/pascals-triangle/pascals_triangle.py +1 -9
  27. data/tracks/python/exercises/pascals-triangle/pascals_triangle_test.py +43 -29
  28. data/tracks/python/exercises/sgf-parsing/README.md +110 -0
  29. data/tracks/python/exercises/sgf-parsing/example.py +100 -0
  30. data/tracks/python/exercises/sgf-parsing/sgf_parsing.py +26 -0
  31. data/tracks/python/exercises/sgf-parsing/sgf_parsing_test.py +94 -0
  32. data/tracks/typescript/config.json +1 -1
  33. data/tracks/typescript/exercises/pangram/pangram.example.ts +2 -2
  34. data/tracks/typescript/exercises/pangram/pangram.test.ts +0 -2
  35. data/tracks/typescript/exercises/pangram/pangram.ts +0 -11
  36. metadata +11 -3
  37. data/tracks/java/exercises/queen-attack/.meta/src/reference/java/BoardCoordinate.java +0 -39
@@ -2,90 +2,97 @@ import unittest
2
2
  import go_counting
3
3
 
4
4
 
5
- # Tests adapted from `problem-specifications//canonical-data.json` @ v1.1.0
5
+ # Tests adapted from `problem-specifications//canonical-data.json` @ v1.0.0
6
6
 
7
- board5x5 = "\n".join([
7
+ board5x5 = [
8
8
  " B ",
9
9
  " B B ",
10
10
  "B W B",
11
11
  " W W ",
12
12
  " W "
13
- ])
14
-
15
- board9x9 = "\n".join([
16
- " B B ",
17
- "B B B",
18
- "WBBBWBBBW",
19
- "W W W W W",
20
- " ",
21
- " W W W W ",
22
- "B B B B",
23
- " W BBB W ",
24
- " B B "
25
- ])
13
+ ]
26
14
 
27
15
 
28
16
  class GoCountingTest(unittest.TestCase):
29
- def test_5x5_for_black(self):
17
+ def test_black_corner_territory_on_5x5_board(self):
30
18
  board = go_counting.Board(board5x5)
31
- stone, territory = board.territoryFor((0, 1))
19
+ stone, territory = board.territory(x=0, y=1)
32
20
  self.assertEqual(stone, go_counting.BLACK)
33
- self.assertEqual(territory, set([(0, 0), (0, 1), (1, 0)]))
21
+ self.assertSetEqual(territory, {(0, 0), (0, 1), (1, 0)})
34
22
 
35
- def test_5x5_for_white(self):
23
+ def test_white_center_territory_on_5x5_board(self):
36
24
  board = go_counting.Board(board5x5)
37
- stone, territory = board.territoryFor((2, 3))
25
+ stone, territory = board.territory(x=2, y=3)
38
26
  self.assertEqual(stone, go_counting.WHITE)
39
- self.assertEqual(territory, set([(2, 3)]))
27
+ self.assertSetEqual(territory, {(2, 3)})
40
28
 
41
- def test_5x5_for_open_territory(self):
29
+ def test_open_corner_territory_on_5x5_board(self):
42
30
  board = go_counting.Board(board5x5)
43
- stone, territory = board.territoryFor((1, 4))
31
+ stone, territory = board.territory(x=1, y=4)
44
32
  self.assertEqual(stone, go_counting.NONE)
45
- self.assertEqual(territory, set([(0, 3), (0, 4), (1, 4)]))
33
+ self.assertSetEqual(territory, {(0, 3), (0, 4), (1, 4)})
46
34
 
47
- def test_5x5_for_non_territory(self):
35
+ def test_a_stone_and_not_a_territory_on_5x5_board(self):
48
36
  board = go_counting.Board(board5x5)
49
- stone, territory = board.territoryFor((1, 1))
37
+ stone, territory = board.territory(x=1, y=1)
50
38
  self.assertEqual(stone, go_counting.NONE)
51
- self.assertEqual(territory, set())
39
+ self.assertSetEqual(territory, set())
52
40
 
53
- def test_5x5_for_valid_coordinate(self):
41
+ def test_invalid_because_x_is_too_low(self):
54
42
  board = go_counting.Board(board5x5)
55
- stone, territory = board.territoryFor((-1, 1))
56
- self.assertEqual(stone, go_counting.NONE)
57
- self.assertEqual(territory, set())
43
+ with self.assertRaisesWithMessage(ValueError):
44
+ board.territory(x=-1, y=1)
58
45
 
59
- def test_5x5_for_valid_coordinate2(self):
46
+ def test_invalid_because_x_is_too_high(self):
60
47
  board = go_counting.Board(board5x5)
61
- stone, territory = board.territoryFor((1, 5))
62
- self.assertEqual(stone, go_counting.NONE)
63
- self.assertEqual(territory, set())
48
+ with self.assertRaisesWithMessage(ValueError):
49
+ board.territory(x=5, y=1)
50
+
51
+ def test_invalid_because_y_is_too_low(self):
52
+ board = go_counting.Board(board5x5)
53
+ with self.assertRaisesWithMessage(ValueError):
54
+ board.territory(x=1, y=-1)
64
55
 
65
- def test_one_territory_whole_board(self):
66
- board = go_counting.Board(" ")
56
+ def test_invalid_because_y_is_too_high(self):
57
+ board = go_counting.Board(board5x5)
58
+ with self.assertRaisesWithMessage(ValueError):
59
+ board.territory(x=1, y=5)
60
+
61
+ def test_one_territory_is_the_whole_board(self):
62
+ board = go_counting.Board([" "])
67
63
  territories = board.territories()
68
- self.assertEqual(territories[go_counting.BLACK], set())
69
- self.assertEqual(territories[go_counting.WHITE], set())
70
- self.assertEqual(territories[go_counting.NONE], set([(0, 0)]))
64
+ self.assertSetEqual(territories[go_counting.BLACK], set())
65
+ self.assertSetEqual(territories[go_counting.WHITE], set())
66
+ self.assertSetEqual(territories[go_counting.NONE], {(0, 0)})
71
67
 
72
68
  def test_two_territories_rectangular_board(self):
73
- input_board = "\n".join([
69
+ input_board = [
74
70
  " BW ",
75
71
  " BW "
76
- ])
72
+ ]
77
73
  board = go_counting.Board(input_board)
78
74
  territories = board.territories()
79
- self.assertEqual(territories[go_counting.BLACK], set([(0, 0), (0, 1)]))
80
- self.assertEqual(territories[go_counting.WHITE], set([(3, 0), (3, 1)]))
81
- self.assertEqual(territories[go_counting.NONE], set())
75
+ self.assertSetEqual(territories[go_counting.BLACK], {(0, 0), (0, 1)})
76
+ self.assertSetEqual(territories[go_counting.WHITE], {(3, 0), (3, 1)})
77
+ self.assertSetEqual(territories[go_counting.NONE], set())
82
78
 
83
- def test_9x9_for_open_territory(self):
84
- board = go_counting.Board(board9x9)
85
- stone, territory = board.territoryFor((0, 8))
86
- self.assertEqual(stone, go_counting.NONE)
87
- self.assertEqual(territory,
88
- set([(2, 7), (2, 8), (1, 8), (0, 8), (0, 7)]))
79
+ def test_two_region_rectangular_board(self):
80
+ input_board = [" B "]
81
+ board = go_counting.Board(input_board)
82
+ territories = board.territories()
83
+ self.assertSetEqual(territories[go_counting.BLACK], {(0, 0), (2, 0)})
84
+ self.assertSetEqual(territories[go_counting.WHITE], set())
85
+ self.assertSetEqual(territories[go_counting.NONE], set())
86
+
87
+ # Utility functions
88
+ def setUp(self):
89
+ try:
90
+ self.assertRaisesRegex
91
+ except AttributeError:
92
+ self.assertRaisesRegex = self.assertRaisesRegexp
93
+
94
+ def assertRaisesWithMessage(self, exception):
95
+ return self.assertRaisesRegex(exception, r".+")
89
96
 
90
97
 
91
98
  if __name__ == '__main__':
@@ -1,4 +1,4 @@
1
- parts = [('lay in', 'the house that Jack built'),
1
+ parts = [('lay in', 'the house that Jack built.'),
2
2
  ('ate', 'the malt'),
3
3
  ('killed', 'the rat'),
4
4
  ('worried', 'the cat'),
@@ -14,19 +14,13 @@ parts = [('lay in', 'the house that Jack built'),
14
14
 
15
15
  def verse(verse_num):
16
16
  v = ['This is {}'.format(parts[verse_num][1])]
17
- v.extend(['that {0} {1}'.format(parts[i][0], parts[i][1])
17
+ v.extend(['that {0} {1}'.format(*parts[i])
18
18
  for i in range(verse_num - 1, -1, -1)])
19
- v[-1] += '.'
20
- return v
19
+ return ''.join(v)
21
20
 
22
21
 
23
22
  def recite(start_verse, end_verse):
24
- if start_verse == end_verse:
25
- return verse(start_verse - 1)
26
- else:
27
- result = []
28
- for verse_num in range(start_verse-1, end_verse):
29
- result.extend(verse(verse_num))
30
- result.append("")
31
- result.pop()
32
- return result
23
+ result = []
24
+ for verse_num in range(start_verse-1, end_verse):
25
+ result.append(verse(verse_num))
26
+ return result
@@ -14,267 +14,142 @@ class VerseTest(unittest.TestCase):
14
14
 
15
15
  def test_verse_two(self):
16
16
  expected = [
17
- "This is the malt",
18
- "that lay in the house that Jack built.",
17
+ "This is the malt"
18
+ "that lay in the house that Jack built."
19
19
  ]
20
20
  self.assertEqual(recite(2, 2), expected)
21
21
 
22
22
  def test_verse_three(self):
23
23
  expected = [
24
- "This is the rat",
25
- "that ate the malt",
26
- "that lay in the house that Jack built.",
24
+ "This is the rat"
25
+ "that ate the malt"
26
+ "that lay in the house that Jack built."
27
27
  ]
28
28
  self.assertEqual(recite(3, 3), expected)
29
29
 
30
30
  def test_verse_four(self):
31
31
  expected = [
32
- "This is the cat",
33
- "that killed the rat",
34
- "that ate the malt",
35
- "that lay in the house that Jack built.",
32
+ "This is the cat"
33
+ "that killed the rat"
34
+ "that ate the malt"
35
+ "that lay in the house that Jack built."
36
36
  ]
37
37
  self.assertEqual(recite(4, 4), expected)
38
38
 
39
39
  def test_verse_five(self):
40
40
  expected = [
41
- "This is the dog",
42
- "that worried the cat",
43
- "that killed the rat",
44
- "that ate the malt",
45
- "that lay in the house that Jack built.",
41
+ "This is the dog"
42
+ "that worried the cat"
43
+ "that killed the rat"
44
+ "that ate the malt"
45
+ "that lay in the house that Jack built."
46
46
  ]
47
47
  self.assertEqual(recite(5, 5), expected)
48
48
 
49
49
  def test_verse_six(self):
50
50
  expected = [
51
- "This is the cow with the crumpled horn",
52
- "that tossed the dog",
53
- "that worried the cat",
54
- "that killed the rat",
55
- "that ate the malt",
56
- "that lay in the house that Jack built.",
51
+ "This is the cow with the crumpled horn"
52
+ "that tossed the dog"
53
+ "that worried the cat"
54
+ "that killed the rat"
55
+ "that ate the malt"
56
+ "that lay in the house that Jack built."
57
57
  ]
58
58
  self.assertEqual(recite(6, 6), expected)
59
59
 
60
60
  def test_verse_seven(self):
61
61
  expected = [
62
- "This is the maiden all forlorn",
63
- "that milked the cow with the crumpled horn",
64
- "that tossed the dog",
65
- "that worried the cat",
66
- "that killed the rat",
67
- "that ate the malt",
68
- "that lay in the house that Jack built.",
62
+ "This is the maiden all forlorn"
63
+ "that milked the cow with the crumpled horn"
64
+ "that tossed the dog"
65
+ "that worried the cat"
66
+ "that killed the rat"
67
+ "that ate the malt"
68
+ "that lay in the house that Jack built."
69
69
  ]
70
70
  self.assertEqual(recite(7, 7), expected)
71
71
 
72
72
  def test_verse_eight(self):
73
73
  expected = [
74
- "This is the man all tattered and torn",
75
- "that kissed the maiden all forlorn",
76
- "that milked the cow with the crumpled horn",
77
- "that tossed the dog",
78
- "that worried the cat",
79
- "that killed the rat",
80
- "that ate the malt",
81
- "that lay in the house that Jack built.",
74
+ "This is the man all tattered and torn"
75
+ "that kissed the maiden all forlorn"
76
+ "that milked the cow with the crumpled horn"
77
+ "that tossed the dog"
78
+ "that worried the cat"
79
+ "that killed the rat"
80
+ "that ate the malt"
81
+ "that lay in the house that Jack built."
82
82
  ]
83
83
  self.assertEqual(recite(8, 8), expected)
84
84
 
85
85
  def test_verse_nine(self):
86
86
  expected = [
87
- "This is the priest all shaven and shorn",
88
- "that married the man all tattered and torn",
89
- "that kissed the maiden all forlorn",
90
- "that milked the cow with the crumpled horn",
91
- "that tossed the dog",
92
- "that worried the cat",
93
- "that killed the rat",
94
- "that ate the malt",
95
- "that lay in the house that Jack built.",
87
+ "This is the priest all shaven and shorn"
88
+ "that married the man all tattered and torn"
89
+ "that kissed the maiden all forlorn"
90
+ "that milked the cow with the crumpled horn"
91
+ "that tossed the dog"
92
+ "that worried the cat"
93
+ "that killed the rat"
94
+ "that ate the malt"
95
+ "that lay in the house that Jack built."
96
96
  ]
97
97
  self.assertEqual(recite(9, 9), expected)
98
98
 
99
99
  def test_verse_10(self):
100
100
  expected = [
101
- "This is the rooster that crowed in the morn",
102
- "that woke the priest all shaven and shorn",
103
- "that married the man all tattered and torn",
104
- "that kissed the maiden all forlorn",
105
- "that milked the cow with the crumpled horn",
106
- "that tossed the dog",
107
- "that worried the cat",
108
- "that killed the rat",
109
- "that ate the malt",
110
- "that lay in the house that Jack built.",
101
+ "This is the rooster that crowed in the morn"
102
+ "that woke the priest all shaven and shorn"
103
+ "that married the man all tattered and torn"
104
+ "that kissed the maiden all forlorn"
105
+ "that milked the cow with the crumpled horn"
106
+ "that tossed the dog"
107
+ "that worried the cat"
108
+ "that killed the rat"
109
+ "that ate the malt"
110
+ "that lay in the house that Jack built."
111
111
  ]
112
112
  self.assertEqual(recite(10, 10), expected)
113
113
 
114
114
  def test_verse_11(self):
115
115
  expected = [
116
- "This is the farmer sowing his corn",
117
- "that kept the rooster that crowed in the morn",
118
- "that woke the priest all shaven and shorn",
119
- "that married the man all tattered and torn",
120
- "that kissed the maiden all forlorn",
121
- "that milked the cow with the crumpled horn",
122
- "that tossed the dog",
123
- "that worried the cat",
124
- "that killed the rat",
125
- "that ate the malt",
126
- "that lay in the house that Jack built.",
116
+ "This is the farmer sowing his corn"
117
+ "that kept the rooster that crowed in the morn"
118
+ "that woke the priest all shaven and shorn"
119
+ "that married the man all tattered and torn"
120
+ "that kissed the maiden all forlorn"
121
+ "that milked the cow with the crumpled horn"
122
+ "that tossed the dog"
123
+ "that worried the cat"
124
+ "that killed the rat"
125
+ "that ate the malt"
126
+ "that lay in the house that Jack built."
127
127
  ]
128
128
  self.assertEqual(recite(11, 11), expected)
129
129
 
130
130
  def test_verse_12(self):
131
131
  expected = [
132
- "This is the horse and the hound and the horn",
133
- "that belonged to the farmer sowing his corn",
134
- "that kept the rooster that crowed in the morn",
135
- "that woke the priest all shaven and shorn",
136
- "that married the man all tattered and torn",
137
- "that kissed the maiden all forlorn",
138
- "that milked the cow with the crumpled horn",
139
- "that tossed the dog",
140
- "that worried the cat",
141
- "that killed the rat",
142
- "that ate the malt",
143
- "that lay in the house that Jack built.",
132
+ "This is the horse and the hound and the horn"
133
+ "that belonged to the farmer sowing his corn"
134
+ "that kept the rooster that crowed in the morn"
135
+ "that woke the priest all shaven and shorn"
136
+ "that married the man all tattered and torn"
137
+ "that kissed the maiden all forlorn"
138
+ "that milked the cow with the crumpled horn"
139
+ "that tossed the dog"
140
+ "that worried the cat"
141
+ "that killed the rat"
142
+ "that ate the malt"
143
+ "that lay in the house that Jack built."
144
144
  ]
145
145
  self.assertEqual(recite(12, 12), expected)
146
146
 
147
147
  def test_multiple_verses(self):
148
- expected = [
149
- "This is the cat",
150
- "that killed the rat",
151
- "that ate the malt",
152
- "that lay in the house that Jack built.",
153
- "",
154
- "This is the dog",
155
- "that worried the cat",
156
- "that killed the rat",
157
- "that ate the malt",
158
- "that lay in the house that Jack built.",
159
- "",
160
- "This is the cow with the crumpled horn",
161
- "that tossed the dog",
162
- "that worried the cat",
163
- "that killed the rat",
164
- "that ate the malt",
165
- "that lay in the house that Jack built.",
166
- "",
167
- "This is the maiden all forlorn",
168
- "that milked the cow with the crumpled horn",
169
- "that tossed the dog",
170
- "that worried the cat",
171
- "that killed the rat",
172
- "that ate the malt",
173
- "that lay in the house that Jack built.",
174
- "",
175
- "This is the man all tattered and torn",
176
- "that kissed the maiden all forlorn",
177
- "that milked the cow with the crumpled horn",
178
- "that tossed the dog",
179
- "that worried the cat",
180
- "that killed the rat",
181
- "that ate the malt",
182
- "that lay in the house that Jack built.",
183
- ]
148
+ expected = [recite(i, i)[0] for i in range(4, 9)]
184
149
  self.assertEqual(recite(4, 8), expected)
185
150
 
186
151
  def test_full_rhyme(self):
187
- expected = [
188
- "This is the house that Jack built.",
189
- "",
190
- "This is the malt",
191
- "that lay in the house that Jack built.",
192
- "",
193
- "This is the rat",
194
- "that ate the malt",
195
- "that lay in the house that Jack built.",
196
- "",
197
- "This is the cat",
198
- "that killed the rat",
199
- "that ate the malt",
200
- "that lay in the house that Jack built.",
201
- "",
202
- "This is the dog",
203
- "that worried the cat",
204
- "that killed the rat",
205
- "that ate the malt",
206
- "that lay in the house that Jack built.",
207
- "",
208
- "This is the cow with the crumpled horn",
209
- "that tossed the dog",
210
- "that worried the cat",
211
- "that killed the rat",
212
- "that ate the malt",
213
- "that lay in the house that Jack built.",
214
- "",
215
- "This is the maiden all forlorn",
216
- "that milked the cow with the crumpled horn",
217
- "that tossed the dog",
218
- "that worried the cat",
219
- "that killed the rat",
220
- "that ate the malt",
221
- "that lay in the house that Jack built.",
222
- "",
223
- "This is the man all tattered and torn",
224
- "that kissed the maiden all forlorn",
225
- "that milked the cow with the crumpled horn",
226
- "that tossed the dog",
227
- "that worried the cat",
228
- "that killed the rat",
229
- "that ate the malt",
230
- "that lay in the house that Jack built.",
231
- "",
232
- "This is the priest all shaven and shorn",
233
- "that married the man all tattered and torn",
234
- "that kissed the maiden all forlorn",
235
- "that milked the cow with the crumpled horn",
236
- "that tossed the dog",
237
- "that worried the cat",
238
- "that killed the rat",
239
- "that ate the malt",
240
- "that lay in the house that Jack built.",
241
- "",
242
- "This is the rooster that crowed in the morn",
243
- "that woke the priest all shaven and shorn",
244
- "that married the man all tattered and torn",
245
- "that kissed the maiden all forlorn",
246
- "that milked the cow with the crumpled horn",
247
- "that tossed the dog",
248
- "that worried the cat",
249
- "that killed the rat",
250
- "that ate the malt",
251
- "that lay in the house that Jack built.",
252
- "",
253
- "This is the farmer sowing his corn",
254
- "that kept the rooster that crowed in the morn",
255
- "that woke the priest all shaven and shorn",
256
- "that married the man all tattered and torn",
257
- "that kissed the maiden all forlorn",
258
- "that milked the cow with the crumpled horn",
259
- "that tossed the dog",
260
- "that worried the cat",
261
- "that killed the rat",
262
- "that ate the malt",
263
- "that lay in the house that Jack built.",
264
- "",
265
- "This is the horse and the hound and the horn",
266
- "that belonged to the farmer sowing his corn",
267
- "that kept the rooster that crowed in the morn",
268
- "that woke the priest all shaven and shorn",
269
- "that married the man all tattered and torn",
270
- "that kissed the maiden all forlorn",
271
- "that milked the cow with the crumpled horn",
272
- "that tossed the dog",
273
- "that worried the cat",
274
- "that killed the rat",
275
- "that ate the malt",
276
- "that lay in the house that Jack built.",
277
- ]
152
+ expected = [recite(i, i)[0] for i in range(1, 13)]
278
153
  self.assertEqual(recite(1, 12), expected)
279
154
 
280
155
 
@@ -14,4 +14,13 @@ def _choice(which):
14
14
  return lambda dates: next(d for d in dates if 13 <= d.day <= 19)
15
15
 
16
16
  ix = -1 if (which == 'last') else (int(which[0]) - 1)
17
- return lambda dates: dates[ix]
17
+
18
+ def _func(dates):
19
+ if ix < len(dates):
20
+ return dates[ix]
21
+ raise MeetupDayException('day does not exist')
22
+ return _func
23
+
24
+
25
+ class MeetupDayException(Exception):
26
+ pass
@@ -1,12 +1,7 @@
1
1
  import unittest
2
2
  from datetime import date
3
3
 
4
- from meetup import meetup_day
5
-
6
- try:
7
- from meetup import MeetupDayException
8
- except ImportError:
9
- MeetupDayException = Exception
4
+ from meetup import meetup_day, MeetupDayException
10
5
 
11
6
 
12
7
  # Tests adapted from `problem-specifications//canonical-data.json` @ v1.1.0
@@ -1,14 +1,12 @@
1
- def triangle(nth):
2
- return [row(i) for i in range(nth + 1)]
3
-
4
-
5
- def is_triangle(t):
6
- new_t = triangle(len(t) - 1)
7
- return t == new_t
8
-
9
-
10
- def row(nth):
11
- r = [1]
12
- for i in range(1, nth + 1):
13
- r.append(int(r[-1] * (nth - i + 1) / i))
14
- return " ".join([str(i) for i in r])
1
+ def rows(row_count):
2
+ if row_count < 0:
3
+ return None
4
+ elif row_count == 0:
5
+ return []
6
+ r = []
7
+ for i in range(row_count):
8
+ rn = [1]
9
+ for j in range(i):
10
+ rn.append(sum(r[-1][j:j+2]))
11
+ r.append(rn)
12
+ return r
@@ -1,10 +1,2 @@
1
- def triangle(row_count):
2
- pass
3
-
4
-
5
- def is_triangle(triangle_rows_list):
6
- pass
7
-
8
-
9
- def row(row_count):
1
+ def rows(row_count):
10
2
  pass