Today’s puzzle challenges us to find whether a given word is present in a scramble of letters. We’re to write a function that returns true if so, false if not.

We’re also given the assumption that only lowercase letters are used, and there’s no punctuation.

I’ve got two possibilities for PHP.

The first one analyzes the strings as given:

Unscramble code, string version

The second converts the strings to arrays and takes advantage of arrays being countable:

Unscramble, array version

Both of these require finding lots of needles in haystacks, and since I don’t know the algorithms behind PHP’s array counting and string finding methods, it’s hard to say which turns out to be more performant. If anyone has any guesses (or wants to run these through some actual performance tests) I’d love to hear about it in the comments.

(Thanks to Feggy Art for the loop-de-loop picture.)