+ 4
Challenge : print all the possible way to split a list in k chunks
you have 1 list [1,2,3,4,5,6] and a number k(3 for example). Your code need to print all the ways to split l in k chunks (20 ways in the example) Make a function using a list l and a number k as inputs, and returns a list, each element of this list being a way to cut l in k pieces. Bonus for one liners !
9 Answers
+ 8
I think Kuba got it, but @Kuba can you change it so that the program prints according to user input?
+ 7
I just assumed empty lists count, too:
https://code.sololearn.com/cTZyOlsEo2pu/?ref=app
+ 7
Aha, okay then. Gimme some time.
+ 6
@VcC Thanks!
I didn't have the time yesterday and can't quite think of a way to put it into a one-liner (I know it's possible, but would become unwieldy), so here's my try:
https://code.sololearn.com/cD2Lx1qi5ptQ/?ref=app
+ 3
Couple of nested one liners
https://code.sololearn.com/cIf4r3XWjwwK/?ref=app
+ 2
cool coding : you need to split the list in k chunks, not just select k elemnts in the list !
+ 2
@kuba congrats for your 100th code here by the way !
+ 1
kuba good but the challenge is a code doing tjis for any k
0
@kuba can you do a Oneliner and onehourer ?