# Solution to Careful What You Wish For

#### by Amon Ge

We are presented with a text box to wish for things. Wishing for anything returns an image of that wish, but often the image is not exactly what we expected. When wishing for "money", we see a picture of money in a mug or next to a trophy. When wishing for "friends", we get the response, "FRIENDS not found!"

By trying many wishes, we can start to understand how the puzzle works. Wishes that are less than three characters long or contain nonsense words get no image. Most wishes will return an image of that wish, but with a secret word added to the query. In the "money" example, we actually get an image of "cup money". We can usually find the same image by searching for "cup money" on Google Images (results may vary by user). A small number of otherwise valid wishes (eg. "friends", "success") still return "not found", however.

We find that there are eight secret words being added to our wish queries: story, star, dash, cup, trick, shark, deck, and stock. Wishing for any of these secret words on their own gives a picture of "question" instead, with one or more question marks, which helps confirm that these words are important. We might also notice that while most images are mirrored (to discourage reverse image search), the question images are not, further hinting they are special. But how are these secret words chosen? If we look back at the valid wishes that return "not found", we might notice that either:

1. The first and last letter are the same (as in "success"), or
2. The first and last letter are directly opposite on the letter wheel. That is, their mod(26) distance is 13. For example, the F and S in "friends" are 13 letters apart, regardless of whether you go clockwise or counter-clockwise on the letter wheel.

This suggests that the first and last letters are key in determining the secret word. In fact, we can actually bisect the secret words in two groups. If the first letter comes "before" the last letter, story, star, dash, or cup is added before your wish. If the first letter comes "after" the last letter, trick, shark, deck, or stock is added after your wish.

The first letter comes "before" the last letter when the clockwise distance from first to last letter is shorter than the clockwise distance from last to first letter. For example, in "money", M → Y is shorter than Y → M (distance = 12), so we get an image for "cup money".

The first letter comes "after" the last letter when the clockwise distance from first to last letter is longer than the clockwise distance from last to first letter. For example, in "fame", F → E is longer than E → F (distance = 25), so we get an image for "fame stock".

We may also find this bisection by carefully comparing the returned image with Google image search results, and determining whether the secret word is being prepended or postpended, although we often get similar results regardless of word order. Some examples: "movies" → "star movies" (mostly logos of the TV network Star Movies), not "movies star" (mostly movie celebrities); "tie" → "cup tie" (mostly devices to hold cups), not "tie cup" (mostly cups with pictures of neckties); "ticks" → "ticks stock" (mostly stock images of the parasite), not "stock ticks" (mostly stock ticker images).

Now, we wished for so many things, but what did we really want all along? Consider the secret words in each group. The before words (story, star, dash, cup) can all come before "board": storyboard, starboard, dashboard, and cupboard. The after words (trick, shark, deck, stock) can all come after "card": card trick, card shark, card deck, and cardstock. Indeed, wishing for "card" and "board" alone give images of just that, with no secret word being added.

Finally, card and board can combine to make what we wanted all along: CARDBOARD, the answer to this puzzle. Wishing for "cardboard" returns a green checkmark, confirming you have found the answer to this puzzle.

## More details

The choice of secret word within the two groups is also determined by the first/last letter distance, but this is not important to solving the puzzle. Since there are 12 distances for both the "before" and the "after" group, this is split evenly into four categories of distance 3 to determine the secret word added. Based on letter frequencies, this makes some secret words slightly more likely than others:

• 1–3: STORY (11%)
• 4–6: STAR (9%)
• 7–9: DASH (11%)
• 10–12: CUP (13%); e.g. moneycup money
• 14–16: TRICK (14%)
• 17–19: SHARK (9%)
• 20–22: DECK (11%)
• 23–25: STOCK (12%); e.g. famefame stock

Full list of frequencies here (rows = first letter, columns = last letter) based on the word dictionary used:

## Author’s Notes

I love interactive puzzles, and the idea of embedding a puzzle in a Scribblenauts-style text box with infinite image possibilities sounded interesting. In an earlier revision, there were more tricks like finding a 9-letter word with your search as a substring, or showing images of "card/carp/cart/carb" when the last letter ended in D/P/T/B, and more randomization based on hashing the input string.

After test-solving, we moved to a more deterministic transformation. I cherry-picked harder words like "trick" to be slightly more prominent based on letter frequencies and easier words like "shark" to be less prominent.

I hope solvers were wishing abundantly and working out the puzzle with enough examples for each case rather than carefully reverse image searching (RIS) every result. RIS is very powerful, and I tried to make it as annoying as possible by providing low-resolution, horizontally-flipped, slightly hue-shifted images. Nevertheless, RIS (particularly Yandex) can still identify many image results. This is often a cat-and-mouse consideration for image-based puzzles, with constructors hand-drawing images, using edge-detection filters, obscuring the image with masks, and puzzlers abusing tools like Huntress and RevEye.

Many thanks to Jon for technical help setting up this puzzle. The original implementation used a very hacky web scraper that would have surely collapsed under real hunt load (not to mention Google sending captchas at the server). We upgraded to Google's Custom Search API, and cached 8k+ responses to wishes to minimize the Google API load. Originally, wishing for "cardboard" returned a collage of cardboard things for all previous wishes, along with confetti. This was removed to save Google API calls (and avoid considerations for team-specific session state) but you can enjoy one such collage below.