I had a hunch that this kata could be solved very quickly and elegantly in Prolog, so for that reason I've authored a Prolog translation!
This is my first time translating (and actually publishing) a CodeWars challenge, so please be kind with my efforts. I think SWI-Prolog runs a touch slower in this case than, for example, Haskell, so I've kept the number of random trials quite low. Let me know if I've done well.
(To be safe, I think I'll just double-check everything I've done after making a quick cup of tea 😃)
Some potentially helpful reading: https://docs.codewars.com/training/troubleshooting#maxbuffer
haha 😆. Which language did you do?
I had a hunch that this kata could be solved very quickly and elegantly in Prolog, so for that reason I've authored a Prolog translation!
This is my first time translating (and actually publishing) a CodeWars challenge, so please be kind with my efforts. I think SWI-Prolog runs a touch slower in this case than, for example, Haskell, so I've kept the number of random trials quite low. Let me know if I've done well.
(To be safe, I think I'll just double-check everything I've done after making a quick cup of tea 😃)
It's a really good one for a speed challenge. You can see some of the users above struggling to get their code working fast enough even for this one!
This comment is hidden because it contains spoiler information about the solution
why can't we mutate the input? I tested the code outside of codewars and it worked fine, but I get errors for all the results based on the tests.
based
I don't really understand the need for the isinstance(i, bool) thing. Is it accounting for some contingency I'm not thinking of?