{"id":4210,"date":"2025-09-12T11:02:31","date_gmt":"2025-09-12T16:02:31","guid":{"rendered":"https:\/\/laurentlessard.com\/bookproofs\/?p=4210"},"modified":"2025-09-12T11:21:32","modified_gmt":"2025-09-12T16:21:32","slug":"letter-boxed","status":"publish","type":"post","link":"https:\/\/laurentlessard.com\/bookproofs\/letter-boxed\/","title":{"rendered":"Letter Boxed"},"content":{"rendered":"<p>This week&#8217;s <a href=\"https:\/\/thefiddler.substack.com\/p\/can-you-box-the-letters\">Fiddler<\/a> is about the popular NY Times puzzle <a href=\"https:\/\/www.nytimes.com\/puzzles\/letter-boxed\">Letter Boxed<\/a>.<\/p>\n<blockquote><p>\nyou must connect letters together around a square to spell out words (they don&#8217;t have to be actual English words!). However, from any given letter, the next letter cannot be on the same side of the square. How many distinct valid sequences are there that include each letter exactly once?<br \/>\n<img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/laurentlessard.com\/bookproofs\/wp-content\/uploads\/2025\/09\/letterboxed-289x300.png\" alt=\"\" width=\"289\" height=\"300\" class=\"aligncenter size-medium wp-image-4211\" srcset=\"https:\/\/laurentlessard.com\/bookproofs\/wp-content\/uploads\/2025\/09\/letterboxed-289x300.png 289w, https:\/\/laurentlessard.com\/bookproofs\/wp-content\/uploads\/2025\/09\/letterboxed.png 684w\" sizes=\"auto, (max-width: 289px) 85vw, 289px\" \/>\n<\/p><\/blockquote>\n<p>My solution:<br \/>\n<a href=\"javascript:Solution('soln_letterboxed','toggle_letterboxed')\" id=\"toggle_letterboxed\">[Show Solution]<\/a><\/p>\n<div id=\"soln_letterboxed\" style=\"display: none\">\n<h3>A related problem: Counting Carlitz words<\/h3>\n<p>This problem is related to a well-known combinatorial problem involving counting special arrangements of symbols.<\/p>\n<p>Given an ordered list of letters (a word) such as &#8220;MISSISSIPPI&#8221;, one can ask: How many distinct rearrangements of these letters have no adjacent letters the same? This is known as a Carlitz word, named after the American mathematician Leonard Carlitz. There is a stunning formula for calculating this, which is explained in detail in the paper <a href=\"https:\/\/dmtcs.episciences.org\/2369\/pdf\">&#8220;Counting words with Laguerre polynomials&#8221;<\/a> by Jair Taylor.<\/p>\n<p>The result is as follows:<\/p>\n<div style=\"background-color:#AFC8E6; padding:10px\">\n<strong>Theorem<\/strong><br \/>\nThe number of Carlitz words on an alphabet of $m$ symbols with the $i^\\text{th}$ symbol repeated $k_i$ times is given by the formula:<br \/>\n\\[<br \/>\nN = \\int_0^\\infty e^{-t} \\prod_{i=j}^m l_{k_j}(t)\\,\\mathrm{d}t<br \/>\n\\]where the function in the integrand is the polynomial defined as:<br \/>\n\\[<br \/>\nl_k(t) = \\sum_{i=0}^k (-1)^{k+i}\\binom{k-1}{k-i}\\frac{t^i}{i!}<br \/>\n\\]\n<\/div>\n<p>&nbsp;<br \/>\nThe first several such functions are given by:<br \/>\n\\begin{align*}<br \/>\nl_1(t)&#038;= t \\\\<br \/>\nl_2(t)&#038;= \\frac{t^2}{2}-t \\\\<br \/>\nl_3(t)&#038;= \\frac{t^3}{6}-t^2+t \\\\<br \/>\nl_4(t)&#038;= \\frac{t^4}{24}-\\frac{t^3}{2}+\\frac{3 t^2}{2}-t \\\\<br \/>\nl_5(t)&#038;= \\frac{t^5}{120}-\\frac{t^4}{6}+t^3-2 t^2+t<br \/>\n\\end{align*}Therefore, to answer the MISSISSIPPI question, we see that the word is made up of: (M, PP, IIII, SSSS). Applying the formula:<br \/>\n\\begin{align*}<br \/>\nN &#038;= \\int_0^\\infty e^{-t} l_1(t) l_2(t) l_4(t)^2\\,\\mathrm{d}t \\\\<br \/>\n&#038;= \\int_0^\\infty e^{-t} \\, t \\left( \\frac{t^2}{2}-t\\right) \\left(\\frac{t^4}{24}-\\frac{t^3}{2}+\\frac{3 t^2}{2}-t\\right)^2\\,\\mathrm{d}t \\\\<br \/>\n&#038;= 2016<br \/>\n\\end{align*}<strong>NOTE:<\/strong> An easy way to evaluate the integral above is to expand the polynomial part and use the fact that $\\int_0^\\infty e^{-t}t^n\\,\\mathrm{d}t=n!$ This can also convince you that the integrals always evaluate to integers!<\/p>\n<h3>Counting Letter Boxed words<\/h3>\n<p>Back to Letter Boxed, we have a shape with $n=4$ sides, and each side has $m$ distinct symbols. We want to find the total number of words where a symbol from the same side is never used twice in a row.<\/p>\n<p>This is related to the problem of counting Carlitz words; we start by counting the number of Carlitz words where the symbols on a given side are treated as identical. For example, if there are 3 letters per side as in the picture at the top of the page, we count Carlitz words for &#8220;111222333444&#8221;. Each different Carlitz word provides a <em>template<\/em>; we then need to assign the letters from each side to the corresponding number in the template. e.g., the 1&#8217;s encode ABC, and there are 3! ways of ordering those. Then the 2&#8217;s encode DEF, and there are 3! ways of ordering those, and so on. Ultimately, we multiply our number of Carlitz words by $(m!)^n$.<\/p>\n<p>Therefore, a formula for the total number of legal Letter Boxed words played on a shape with $n$ sides and $m$ letters per side is:<\/p>\n<p style=\"text-align: center;\"><span style=\"background-color: #AFC8E6; padding: 25px 10px 25px 10px;\">$\\displaystyle<br \/>\nF(n,m) = (m!)^n \\int_0^\\infty e^{-t}\\, l_m(t)^n\\,\\mathrm{d}t<br \/>\n$<\/span><\/p>\n<p>with $l_m(t)$ defined above.<\/p>\n<p>Here are some values for $F(n,m)$ for $n$ sides and $m$ symbols per side.<br \/>\n\\[<br \/>\n\\begin{array}{c|ccccc}<br \/>\nn\\backslash m &#038; 1 &#038; 2 &#038; 3 &#038; 4 &#038; 5 \\\\ \\hline<br \/>\n1&#038; 1 &#038; 0 &#038; 0 &#038; 0 &#038; 0 \\\\<br \/>\n2&#038; 2 &#038; 8 &#038; 72 &#038; 1152 &#038; 28800 \\\\<br \/>\n3&#038; 6 &#038; 240 &#038; 37584 &#038; 15095808 &#038; 12420864000 \\\\<br \/>\n4&#038; 24 &#038; 13824 &#038; 53529984 &#038; 751480602624 &#038; 27917203599360000 \\\\<br \/>\n5&#038; 120 &#038; 1263360 &#038; 152458744320 &#038; 93995798935633920 &#038; 197726965332480000000000 \\\\<br \/>\n\\end{array}<br \/>\n\\]Some observations:<\/p>\n<ul>\n<li> In the first row, we only have one side. So if that side contains more than one letter, it&#8217;s impossible to make any words since we would be forced to use the same side for consecutive letters. This is why $F(1,m)=1$ if $m=1$ and $0$ otherwise.\n<li> In the first column, we only have one symbol per side. Therefore, we don&#8217;t need to worry about letters from consecutive sides, and we see that $F(n,m)=n!$.\n<\/ul>\n<p>For standard Letter Boxed ($n=4$), we can read off the fourth row:<\/p>\n<ul>\n<li> Two letters per side: $F(4,2) = 13824$.\n<li> Three letters per side: $F(4,3) = 53529984$.\n<\/ul>\n<\/div>\n","protected":false},"excerpt":{"rendered":"<p>This week&#8217;s Fiddler is about the popular NY Times puzzle Letter Boxed. you must connect letters together around a square to spell out words (they don&#8217;t have to be actual English words!). However, from any given letter, the next letter cannot be on the same side of the square. How many distinct valid sequences are &hellip; <a href=\"https:\/\/laurentlessard.com\/bookproofs\/letter-boxed\/\" class=\"more-link\">Continue reading<span class=\"screen-reader-text\"> &#8220;Letter Boxed&#8221;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"om_disable_all_campaigns":false,"_monsterinsights_skip_tracking":false,"_monsterinsights_sitenote_active":false,"_monsterinsights_sitenote_note":"","_monsterinsights_sitenote_category":0,"_uf_show_specific_survey":0,"_uf_disable_surveys":false,"footnotes":""},"categories":[42],"tags":[6,43],"class_list":["post-4210","post","type-post","status-publish","format-standard","hentry","category-the-fiddler","tag-counting","tag-fiddler"],"aioseo_notices":[],"_links":{"self":[{"href":"https:\/\/laurentlessard.com\/bookproofs\/wp-json\/wp\/v2\/posts\/4210","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/laurentlessard.com\/bookproofs\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/laurentlessard.com\/bookproofs\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/laurentlessard.com\/bookproofs\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/laurentlessard.com\/bookproofs\/wp-json\/wp\/v2\/comments?post=4210"}],"version-history":[{"count":20,"href":"https:\/\/laurentlessard.com\/bookproofs\/wp-json\/wp\/v2\/posts\/4210\/revisions"}],"predecessor-version":[{"id":4231,"href":"https:\/\/laurentlessard.com\/bookproofs\/wp-json\/wp\/v2\/posts\/4210\/revisions\/4231"}],"wp:attachment":[{"href":"https:\/\/laurentlessard.com\/bookproofs\/wp-json\/wp\/v2\/media?parent=4210"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/laurentlessard.com\/bookproofs\/wp-json\/wp\/v2\/categories?post=4210"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/laurentlessard.com\/bookproofs\/wp-json\/wp\/v2\/tags?post=4210"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}