Loading collection data...
Collections are a way for you to organize kata so that you can create your own training routines. Every collection you create is public and automatically sharable with other warriors. After you have added a few kata to a collection you and others can train on the kata contained within the collection.
Get started now by creating a new collection.
Honestly I couldn't figure this out on my own but when I attempted it - sometimes it would complete and sometimes it would fail.
I came up with a cheat by putting the for loop in a function and running it under a while loop.
If the function doesn't return the same string as before it will run again until it returns the same string as it did before.
Since the triplets are random you can get inaccurate results only parsing over the triplets once. Puayny is correct in their comment "This solution is incomplete though elegant, it will fail for some test cases currently not included. The 'for l in triplets' loop shouldn't run just once, it should run until there are no more swaps.". Their comment is the most efficient solution however since these are triples you could also just run the loop twice which I think is more than enough to get the correct sequence.
you have the wrong solution
if we check it on all possible triplets permutation for first test, then as a secrets we get
defaultdict(<class 'int'>, {'whatisup': 2565, 'tuwhapis': 120, 'uwhatpis': 76, 'twhapisu': 240, 'twhuapis': 6, 'twhapuis': 26, 'whatupis': 79, 'whatpisu': 660, 'whuatpis': 9, 'whatpuis': 16, 'twhaisup': 180, 'twhaupis': 28, 'whatipsu': 285, 'wuhatisp': 35, 'wuhiatsp': 88, 'whiuatsp': 71, 'whiatsup': 195, 'whuatisp': 18, 'whuiatsp': 10, 'uwhatisp': 7, 'uwhiatsp': 11, 'whatiusp': 30, 'whatuisp': 30, 'whiatusp': 60, 'twhiapsu': 60, 'whiatpsu': 75, 'twhiasup': 60})
I recommend using a set comprehension:
Besides being more terse, this doesn't build an extra list temporary.
Hint:
"If I were to buy 9 cars costing c each, I'd only have 1 Zloty left."
"And if I were to buy 7 boats at b each, I'd only have 2 Ringglets left."
is wrong
on python 3.8
@Reno could you please explin how do you get (i%7) & (i%9) idea
its wrong
Right. Thank you for pointing that out.
Not an issue. Don't use global variables.
Not a suggestion.
This comment is hidden because it contains spoiler information about the solution
This comment is hidden because it contains spoiler information about the solution