Like a few other kata I've seen, this is as much a math problem as a coding one. Unlike those, the math problem here is complicated and hard - the square pizza algorithm requires factoring n, which gets much harder as n increases. In combination with the large test numbers and the runtime limit, it becomes a "how many optimization tricks do you know" problem more than a math problem.

As-is, this is more difficult than I think it really needs to be. Depending on the difficulty level you're aiming for, I would recommend either:

Lower the maximum n for test cases to something slightly less absurd, so that less optimized solutions can get past the runtime limit (low difficulty - ~7 kyu).

Keep the high n (higher difficulty - ~5 kyu): You may want to reflavor it as a non-pizza-related geometry problem, so us geometry nerds notice it (and to avoid the issue of crusts on square pizzas).

Additonal suggestions:

Instead of having a fixed scenario of 1 circular & 1 square pizza, consider adding an input variable to indicate what kind of pizzas are involved (could be a string "circle" or "square", a list or other type encoding multiple pizzas, etc.). This would require the same algorithms to solve (we would still need to figure out how to evenly divide circular / square pizzas), but would be more flexible and therefore interesting.

if(zombies==100 and distance==10 and ammo==20)...
the function returns:'You shot 20 zombies before being eaten: overwhelmed.'
Am I wrong in thinking the "reason" was loss of ammo?
there are 20 shots fire. One at each whole second, 1 through 10. One at each half second, 0.5 through 9.5.
So when the zombies arrive, we are out of ammo. Or, does overwhelmed encompass any situation where it is impossible to kill all the zombies even if we had infinite bullets.

The description does mention permutations, so perhaps it was my poor reading and comprehension. Nevertheless, I think adding a shorter example to clarify the directions would help.

Wording is confusing. I thought I was looking through the numbers 1 through 10**5 for matches. Instead, we are adding permutations. Adding more clarifying examples might help.
7 --> 7
77 --> 7 + 7 = 14
122 --> 122 + 122 + 212 + 212 + 221 + 221 = 1110

Thank you for the feedback. I appreciate the thought and detail you put into it.

Like a few other kata I've seen, this is as much a math problem as a coding one. Unlike those, the math problem here is complicated and hard - the square pizza algorithm requires factoring n, which gets much harder as n increases. In combination with the large test numbers and the runtime limit, it becomes a "how many optimization tricks do you know" problem more than a math problem.

As-is, this is more difficult than I think it really needs to be. Depending on the difficulty level you're aiming for, I would recommend either:

Additonal suggestions:

That was pretty much it: in my mind "out of ammo" was the situation where you have run out of ammo and are just waiting for the zombies to get to you.

if(zombies==100 and distance==10 and ammo==20)...

the function returns:'You shot 20 zombies before being eaten: overwhelmed.'

Am I wrong in thinking the "reason" was loss of ammo?

there are 20 shots fire. One at each whole second, 1 through 10. One at each half second, 0.5 through 9.5.

So when the zombies arrive, we are out of ammo. Or, does overwhelmed encompass any situation where it is impossible to kill all the zombies even if we had infinite bullets.

remove ;

remove (n==101)+(n>101)

add (n>100)

The description does mention permutations, so perhaps it was my poor reading and comprehension. Nevertheless, I think adding a shorter example to clarify the directions would help.

The description mentions permutations:

find the sum of all numbers with the same digits(permutations) including duplicates

So do you want a short example

Well, the author is active, maybe he'll consider your suggestion.

Consider this.

def wrong_function(num):

return sum(i for i in range(10**5) if len(str(i))==len(str(num)) and sorted(str(num))==sorted(str(i)))

the example 1185 does show permutation--but it's long and not as obvious as it could be in a simpler example, like 77, and with a refined description.

And didn't you read the examples?

How would that be looking through the numbers

`1`

through`10**5`

for matches?Wording is confusing. I thought I was looking through the numbers 1 through 10**5 for matches. Instead, we are adding permutations. Adding more clarifying examples might help.

7 --> 7

77 --> 7 + 7 = 14

122 --> 122 + 122 + 212 + 212 + 221 + 221 = 1110

does not work (well) for negative numbers.

E.g., if we have an array [1,2,3,4,6,7,8,15,16] then 6 and 16 are non-consecutive.

16 should be 15

The tests are correct.

Please read at the bottom of discourses @ecolban answer.

Sorry, giving a hint would be to give the solution.

## Loading more items...