Monday, January 2, 2017

2016 Holiday Challenge: Results for Challenge 2, Candy Cane Word-Find

My readers appear to have solved this puzzle much faster than I did. Congratulations to reader Sharmin, who solved it first—a copy of Word Games 5 is on its way!


By the way, the email edition of yesterday's post was missing an embedded video, so for the benefit of my email subscribers, here's a direct link to Lisa Simpson challenging Bart Simpson to a game of rock/paper/scissors. (The video underlines that you shouldn't necessarily attribute rationality to your opponents!)

Getting back to Challenge 2, I thought people might like to see the process I use to create these word-find puzzles, so here is some detail on that.

The first thing is to rank the letters of the alphabet according to their visual density. I'll skip the steps for this and give the result:

I, Z, L, T, Y, P, C, F, J, E, S, A, B, R, G, K, H, V, X, D, U, O, Q, M, W, N

Next, we rank the words in the dictionary according to their dynamic range. Ideally, we want words like NINJA, which include both low-density letters (I, J) and high-density letters (N). That allows us to "paint" with a broad palette. But I had a hard time coming up with a holiday puzzle about ninjas, so I downloaded a list of holiday theme words from a teacher website:

ANGEL, BELLS, BIRTH, BLIZZARD, BLUSTERY, BOOTS, BOUGH, BOW, BOX, CANDLE, CANDY, CANDYCANE, CAP, CARD, CAROLERS, CAROLING, CAROLS, CELEBRATE, CELEBRATION, CEREMONY, CHARITY, CHESTNUTS, CHILL, CHILLY, CHIMNEY, CHRISTMAS, CHRISTMASCARD, CHRISTMASCAROL, CHRISTMASEVE, CHRISTMASTIDE, CHRISTMASTREE, CHRISTMASTREESTAND, CIDER, COAL, COLD, COOKIE, CRECHE, DECEMBER, DECORATE, DECORATIONS, DISPLAY, EGGNOG, ELF, ELVES, EVE, EVERGREEN, EXCHANGE, FAMILY, FAMILYREUNION, FATHERCHRISTMAS, FEAST, FELIZNAVIDAD, FESTIVAL, FESTIVE, FIR, FIREPLACE, FIREWOOD, FRANKINCENSE, FROSTY, FROSTYTHESNOWMAN, FRUITCAKE, GARLAND, GIFT, GIFTGIVING, GINGERBREAD, GINGERBREADHOUSE, GINGERBREADMAN, GINGERBREADWOMAN, GIVE, GOLD, GOODWILL, GOOSE, GREEN, GREETINGS, GUEST, HAPPY, HOLIDAY, HOLLY, HOPE, HOTCHOCOLATE, HOTCIDER, HUG, ICESKATES, ICICLE, ICY, IVY, JACKFROST, JESUS, JINGLEBELLS, JOLLY, JOY, JOYFUL, JOYEUXNOEL, KINGS, KRAMPUS, KRISKRINGLE, LIGHTS, LIST, LOG, LOVE, MANGER, MERRY, MERRYCHRISTMAS, MINCEPIE, MISTLETOE, MITTENS, MYRRH, NATIVITY, NAUGHTY, NICE, NIPPY, NOEL, NORTHPOLE, NUTCRACKER, OCCASION, ORNAMENTS, PACKAGE, PAGEANT, PARADE, PARTRIDGE, PARTY, PIE, PINETREE, PINECONE, PLUMPUDDING, POINSETTIA, POPCORNSTRING, PRESENTS, RECEIVE, RED, REINDEER, REJOICE, REUNION, RIBBON, RITUAL, RUDOLPH, SAINTNICHOLAS, SALES, SANTACLAUS, SANTASELVES, SANTASHELPERS, SANTASLIST, SANTASWORKSHOP, SCARF, SCROOGE, SEASON, SEASONSGREETINGS, SHOPPING, SKATE, SLED, SLEIGH, SLEIGHBELLS, SNOW, SNOWBALL, SNOWBOUND, SNOWFALL, SNOWFLAKE, SNOWMAN, SNOWY, SOCKS, SPIRIT, STAR, STNICK, STOCKING, STOCKINGSTUFFER, SUGARPLUM, SWEATER, TIDINGS, TINSEL, TOBOGGAN, TOGETHERNESS, TOY, TRADITION, TREE, TRIMMING, TRIPS, TURKEY, UNWRAP, VACATION, VISIT, WASSAIL, WINTER, WINTERTIME, WINTRY, WISEMEN, WISH, WONDER, WORKSHOP, WRAP, WRAPPINGPAPER, WREATH, XMAS, YULE, YULELOG, YULETIDE

Sorting these according to their dynamic range yields

{{WINTRY}, {NICE}, {NOEL}, {TRIMMING}, {WINTER}, {TOY, WISH}, {GOODWILL}, {WINTERTIME}, {MITTENS}, {NIPPY}, {TIDINGS}, {PINECONE}, {WISEMEN}, {CHIMNEY}, {LOG}, {TRADITION}, {FAMILYREUNION}, {MINCEPIE}, {COLD}, {SNOWFALL}, {SNOWY}, {REUNION}, {TINSEL}, {SNOWBALL}, {STNICK}, {PLUMPUDDING}, {NATIVITY}, {KINGS}, {HOLLY, IVY, JOY}, {OCCASION}, {CANDY}, {SAINTNICHOLAS}, {VACATION}, {CAROLING}, {STOCKING}, {GIFTGIVING}, {RIBBON}, {SHOPPING}, {HOLIDAY}, {CANDLE}, {NORTHPOLE}, {POINSETTIA}, {GOLD}, {POPCORNSTRING}, {FELIZNAVIDAD}, {COOKIE}, {LOVE}, {ANGEL}, {FIREWOOD}, {FAMILY}, {MISTLETOE}, {COAL}, {YULELOG}, {FRANKINCENSE}, {JOYEUXNOEL}, {JOYFUL}, {CEREMONY}, {CANDYCANE}, {FROSTYTHESNOWMAN}, {DECORATIONS, ORNAMENTS}, {YULE}, {NAUGHTY}, {SNOWFLAKE}, {JOLLY}, {UNWRAP}, {WRAP}, {RITUAL}, {WASSAIL}, {BOOTS}, {CELEBRATION}, {YULETIDE}, {HOTCIDER}, {PINETREE}, {CHESTNUTS}, {KRISKRINGLE}, {RUDOLPH}, {REINDEER}, {HOTCHOCOLATE}, {GIVE}, {VISIT}, {WRAPPINGPAPER}, {BLIZZARD}, {SANTASLIST}, {JINGLEBELLS}, {PAGEANT}, {GREETINGS}, {CIDER}, {GARLAND}, {STOCKINGSTUFFER}, {HOPE}, {CHRISTMASTIDE}, {SANTACLAUS, WREATH}, {GINGERBREADWOMAN}, {SUGARPLUM}, {TOBOGGAN}, {MERRY}, {SLED}, {BIRTH}, {GINGERBREADMAN}, {CHRISTMAS}, {SNOW}, {SEASON}, {MYRRH}, {SEASONSGREETINGS}, {CHRISTMASTREESTAND}, {SANTASWORKSHOP}, {LIGHTS}, {MERRYCHRISTMAS}, {CHRISTMASCAROL}, {NUTCRACKER}, {FROSTY}, {PRESENTS}, {TURKEY}, {MANGER}, {GREEN}, {SNOWMAN}, {DISPLAY}, {TOGETHERNESS}, {FIR}, {CAROLS}, {REJOICE}, {CHILL}, {SWEATER}, {SLEIGH}, {WORKSHOP}, {WONDER}, {CHRISTMASCARD}, {GUEST}, {BOW}, {CHRISTMASEVE}, {GINGERBREAD, SANTASELVES}, {FRUITCAKE}, {DECORATE}, {XMAS}, {KRAMPUS}, {EXCHANGE}, {BLUSTERY}, {GIFT}, {CHRISTMASTREE}, {PARTRIDGE}, {GINGERBREADHOUSE}, {FATHERCHRISTMAS}, {CHARITY}, {SANTASHELPERS}, {SCROOGE}, {GOOSE}, {EGGNOG}, {SOCKS}, {CHILLY}, {DECEMBER}, {CAROLERS, FESTIVAL}, {SLEIGHBELLS}, {FESTIVE}, {JACKFROST}, {SNOWBOUND}, {CARD}, {SPIRIT}, {RECEIVE}, {ELVES}, {EVERGREEN}, {TRIPS}, {HAPPY}, {RED}, {JESUS}, {BELLS}, {PARADE}, {EVE}, {BOX}, {PIE}, {PARTY}, {ICESKATES}, {LIST, STAR}, {SKATE}, {FIREPLACE}, {TREE}, {CRECHE}, {BOUGH}, {CELEBRATE}, {PACKAGE}, {ICICLE}, {SALES}, {ELF}, {CAP}, {FEAST}, {HUG, ICY}, {SCARF}}

Some of these looked good (like TOY) but didn't quite work out. Eventually I tried CANDY, doing an image search online for a line drawing of a candy cane. I was looking for a blocky image that would remain recognizable when converted to a low-resolution letter grid. Here was the image I chose:


I resized the image to 72 pixels by 40 pixels, and then created a histogram of pixel saturation:


Eyeballing the peaks in the histogram, I assigned a letter to each pixel according to the following rule:
  • Pixel saturation 0.9 or less:  Replace pixel with C or Y (flip a coin)
  • Pixel saturation between 0.9 and 2:  Replace pixel with letter A
  • Pixel saturation between 2 and 3.5: Replace pixel with letter D
  • Pixel saturation greater than 3.5:  Replace pixel with letter N.
Now I had a grid of letters resembling a candy cane. I ran the grid through a word-search-solver that I wrote a long time ago, just to see what words were present in the grid. I found several instances of short words like AND, with maybe a CYCAD or two—but no CANDY.

Even after ten thousand attempts, I still didn't have a grid with CANDY. I diagnosed the problem as not enough Ds next to Ys (or something like that), so I added some blurring to the pixel rule for saturation above 3.5. Instead of replacing all of these pixels with Ns, I set it to be 93% likely to replace the pixel with an N, with 7% likelihood of C, D, or Y. With this rule, the image still looked like a candy cane, and it only took around 500 attempts to produce a grid with one instance of CANDY in it. (I had to solve the puzzle myself, because my word-search solver tells me which words are in a grid, but not where they are located!)

From there I adjusted the font size and spacing of the grid in Microsoft Word, and the puzzle was finished.


Most ASCII art looks a lot nicer than this, as you can see from a google search. In part, that's because of the crudeness of my algorithm; it's also because most ASCII art uses a much larger character set with much greater dynamic range. Some programs even help themselves to different font colors.


I'll leave you with the first known example of typewriter art, this butterfly created by Flora Stacey in 1898. Stacey created striking effects by the technique of rotating her paper in the typewriter.


Nowadays you can upload images to websites like this one and have them converted into ASCII instantaneously.

Results of Challenge 3, Lewis Carroll's problem of the two walkers, coming next!

No comments: