回答編集履歴

1

修正

2020/12/17 09:30

投稿

sfdust
sfdust

スコア1137

test CHANGED
@@ -36,23 +36,17 @@
36
36
 
37
37
  for i in range(len(serial_numbers)):
38
38
 
39
- if i == len(serial_numbers)-1:
39
+ if i==len(serial_numbers)-1 or serial_numbers[i+1]-serial_numbers[i] != 1:
40
40
 
41
41
  len(group) > 0 and ret.append(group)
42
42
 
43
- break
43
+ group = []
44
44
 
45
- if serial_numbers[i+1]-serial_numbers[i] == 1:
45
+ else:
46
46
 
47
47
  len(group) == 0 and group.append(serial_numbers[i])
48
48
 
49
49
  group.append(serial_numbers[i+1])
50
-
51
- else:
52
-
53
- len(group) > 0 and ret.append(group)
54
-
55
- group = []
56
50
 
57
51
 
58
52