Questions tagged «continuous»

13
识别列表中的连续数字组
我想识别列表中的连续数字组,以便: myfunc([2, 3, 4, 5, 12, 13, 14, 15, 16, 17, 20]) 返回值: [(2,5), (12,17), 20] 并且想知道实现此目的的最佳方法是什么(特别是如果Python中内置了某些东西)。 编辑:注意,我最初忘记提及个人数字应作为个人数字而不是范围返回。
By using our site, you acknowledge that you have read and understand our Cookie Policy and Privacy Policy.
Licensed under cc by-sa 3.0 with attribution required.