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.
Yikes! Well, at least it is fast. I guess.
Wow. At first I thought it would run slowly because of the recursion. So I ran it in my computer. Turns out, it is fast. I finally realized it was because of the globals. +1 for cleverness, for sure. The downside, of course, is there has to be globals for this to work. Still, way to make it work with recursion!
Thanks, the echo was for testing and I forgot to remove it for the last button mash. Thanks again!
+1 because it just makes sense. Nice job.
Probably don't need the echo statement inside of a method that is returning a boolean, but this code is very readable and not difficult to understand.
I like two things about this solution: 1. the use of the mb_ string functions; and 2. the use of array_merge and array_diff.
Outside of that, formatting could use a lot of help. No need to have commented-out code in your answer. Also, no need for any of the print_r() statements. And the indentation is inconsistent.
I like your solution. A lot of people used recursion, which is admittedly clever. But a recursive solution will not only require more memory, but is also harder to understand. I would take this code in production any day of the week over a more difficult one to understand. Also, you do a check for getSortingString, which is nice because it gives you a quick out of a lot of cases.
If I had one bone to pick, it would be the $nb variable name. What does it stand for? But really, overall, very nice.
Is it broken? Because both ($part1 === "cwdr" && $part2 === "oeas") and ($part1 === "code" && $part2 === "wasr") should return false.
Alright, but can you do it without having to nest loops four deep?
You overwrite
$return
on every single line, so they could all be false except for the last call and it would return true. Right?Explain, please. I mean, what is going on here? Bit-shifting. Magic numbers. Nested ternarys. I give high marks for cleverness, but I have no idea how this works. Walk me through it. Leave some comments.
I didn't know about filter_var at the moment I tried to solve that problem. Now I would probably use something similar to your solution.
On a 32-bit system, depending on the ip address, a valid result might be negative due to integer overflow. Also, ip2long can work with incomplete IP addresses, so it should be used carefully (see: https://secure.php.net/manual/en/function.ip2long.php#115761)
Interesting solution. I wonder if you need the check for "255.255.255.255" though. When I run ip2long() on that, I get a valid result. Also, depending on the system, ip2long can work with incomplete IP addresses, so it should be used carefully (see: https://secure.php.net/manual/en/function.ip2long.php#115761)
Make sense. Thanks for your comment. I appreciate it.
Since you only use the $alphabet variable inside the
countWordScore()
function, why not define it there instead of in thehigh()
method and then passing it in?Did you try writing it without having to create an alphabet array at all?
Loading more items...