I got the whole number as input. If I get 1234567, I want to make a list like [765], [432], [1] Is there a way?
python
Please refer to the following
import itertools as it
nums = sorted(range(1, 8), reverse=True)
list(iter(lambda i=iter(nums) : list(it.islice(i, 3)), []))
[[7, 6, 5], [4, 3, 2], [1]]
val nums = (1 to 7).reverse
nums.grouped(3).toList
=> List(Vector(7, 6, 5), Vector(4, 3, 2), Vector(1))
© 2024 OneMinuteCode. All rights reserved.