{"id":6342,"date":"2025-02-11T21:13:45","date_gmt":"2025-02-11T21:13:45","guid":{"rendered":"https:\/\/robertjwallace.com\/?p=6342"},"modified":"2025-02-12T00:35:10","modified_gmt":"2025-02-12T00:35:10","slug":"new-york-times-game-letterbox-bookmarklet-cheat","status":"publish","type":"post","link":"https:\/\/robertjwallace.com\/es\/new-york-times-game-letterbox-bookmarklet-cheat\/","title":{"rendered":"Truco para el marcador del juego &quot;Letterbox&quot; del New York Times"},"content":{"rendered":"<p class=\"\">Escrib\u00ed un bookmarklet que encuentra una soluci\u00f3n de dos palabras para el juego &quot;Letterbox&quot; del New York Times. Funcion\u00f3, pero por diversi\u00f3n decid\u00ed que una IA lo reescribiera para que fuera m\u00e1s r\u00e1pido. Aqu\u00ed est\u00e1 el c\u00f3digo que cre\u00f3, pero tard\u00f3 varios intentos antes de que pudiera abrir una nueva pesta\u00f1a. Funciona mucho m\u00e1s r\u00e1pido que lo que escrib\u00ed.<br><\/p>\n\n\n\n<!--more-->\n\n\n\n<pre class=\"wp-block-code\"><code>javascript:(function(){\n    const gameData = window.gameData;\n    if (!gameData?.sides || !gameData?.dictionary) return alert(\"Game data not found!\");\n\n    const sides = gameData.sides.join('');\n    const requiredChars = {};\n    for (let c of sides) requiredChars&#91;c] = (requiredChars&#91;c] || 0) + 1;\n    \n    const words = gameData.dictionary.map(w => ({ w, f: w&#91;0], l: w.at(-1) }));\n    const validCombinations = &#91;];\n\n    function usesAllChars(w1, w2) {\n        const count = { ...requiredChars };\n        for (let c of w1 + w2) if (count&#91;c]) count&#91;c]--;\n        return !Object.values(count).some(v => v > 0);\n    }\n\n    for (let i = 0; i &lt; words.length; i++) {\n        for (let j = 0; j &lt; words.length; j++) {\n            if (i !== j &amp;&amp; words&#91;i].l === words&#91;j].f &amp;&amp; usesAllChars(words&#91;i].w, words&#91;j].w)) {\n                validCombinations.push(&#91;words&#91;i].w, words&#91;j].w]);\n            }\n        }\n    }\n\n    validCombinations.sort((a, b) => a.join('').length - b.join('').length);\n\n    const newTab = window.open(\"\", \"_blank\");\n    if (!newTab || newTab.closed) {\n        alert(\"Pop-up blocked! Please allow pop-ups for this site.\");\n        return;\n    }\n\n    newTab.document.write(`&lt;!DOCTYPE html>\n        &lt;html>&lt;head>&lt;title>Letterbox Solver&lt;\/title>\n        &lt;style>body{font-family:Arial;padding:20px;}table{width:100%;border-collapse:collapse;}th,td{border:1px solid #ddd;padding:8px;text-align:left;}th{background:#f2f2f2;}&lt;\/style>\n        &lt;\/head>&lt;body>&lt;h1>Letterbox Word Combinations&lt;\/h1>\n        &lt;table>&lt;tr>&lt;th>Word 1&lt;\/th>&lt;th>Word 2&lt;\/th>&lt;th>Combined Length&lt;\/th>&lt;\/tr>\n        ${validCombinations.map((&#91;w1,w2]) => `&lt;tr>&lt;td>${w1}&lt;\/td>&lt;td>${w2}&lt;\/td>&lt;td>${w1.length + w2.length}&lt;\/td>&lt;\/tr>`).join('')}\n        &lt;\/table>&lt;\/body>&lt;\/html>`);\n    newTab.document.close();\n})();\n\n<\/code><\/pre>\n\n\n\n<p class=\"\">It works great.  To use this, first copy the code above.  Then set  your browser to display the bookmark bar.  Then right click on the bar and select the &#8220;new bookmark&#8221; item (I am using a chrome base browser).<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img decoding=\"async\" width=\"405\" height=\"293\" data-src=\"https:\/\/robertjwallace.com\/wp-content\/uploads\/2025\/02\/image-2.png\" alt=\"\" class=\"wp-image-6343 lazyload\" data-srcset=\"https:\/\/robertjwallace.com\/wp-content\/uploads\/2025\/02\/image-2.png 405w, https:\/\/robertjwallace.com\/wp-content\/uploads\/2025\/02\/image-2-300x217.png 300w\" data-sizes=\"(max-width: 405px) 100vw, 405px\" src=\"data:image\/svg+xml;base64,PHN2ZyB3aWR0aD0iMSIgaGVpZ2h0PSIxIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciPjwvc3ZnPg==\" style=\"--smush-placeholder-width: 405px; --smush-placeholder-aspect-ratio: 405\/293;\" \/><\/figure>\n\n\n\n<p class=\"\"> Change the title, and then paste the copied code into the address field and click save.<br><\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img decoding=\"async\" width=\"399\" height=\"290\" data-src=\"https:\/\/robertjwallace.com\/wp-content\/uploads\/2025\/02\/image-3.png\" alt=\"\" class=\"wp-image-6344 lazyload\" data-srcset=\"https:\/\/robertjwallace.com\/wp-content\/uploads\/2025\/02\/image-3.png 399w, https:\/\/robertjwallace.com\/wp-content\/uploads\/2025\/02\/image-3-300x218.png 300w\" data-sizes=\"(max-width: 399px) 100vw, 399px\" src=\"data:image\/svg+xml;base64,PHN2ZyB3aWR0aD0iMSIgaGVpZ2h0PSIxIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciPjwvc3ZnPg==\" style=\"--smush-placeholder-width: 399px; --smush-placeholder-aspect-ratio: 399\/290;\" \/><\/figure>\n\n\n\n<p class=\"\">Now when you are playing the game, you can click on this bookmarklet and it will open a new tab with all of the two word solutions to the game.<\/p>\n\n\n\n<p class=\"\">Enjoy.<\/p>","protected":false},"excerpt":{"rendered":"<p>I wrote a bookmarklet that finds a two word solution to the New York Times game &#8220;Letterbox&#8221;. It worked, but for fun I decided to let an AI rewrite it to be faster. Here is the code it came up with, but it did take several tries before it could open a new tab. It &hellip; <\/p>\n<p class=\"link-more\"><a href=\"https:\/\/robertjwallace.com\/es\/new-york-times-game-letterbox-bookmarklet-cheat\/\" class=\"more-link\">Continuar leyendo<span class=\"screen-reader-text\"> &#8220;New York Times game &#8220;Letterbox&#8221; bookmarklet cheat&#8221;<\/span><\/a><\/p>","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"nf_dc_page":"","_eb_attr":"","footnotes":""},"categories":[143],"tags":[],"class_list":["post-6342","post","type-post","status-publish","format-standard","hentry","category-computer-stuff"],"featured_image_src":null,"featured_image_src_square":null,"author_info":{"display_name":"Bob","author_link":"https:\/\/robertjwallace.com\/es\/author\/admin\/"},"_links":{"self":[{"href":"https:\/\/robertjwallace.com\/es\/wp-json\/wp\/v2\/posts\/6342","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/robertjwallace.com\/es\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/robertjwallace.com\/es\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/robertjwallace.com\/es\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/robertjwallace.com\/es\/wp-json\/wp\/v2\/comments?post=6342"}],"version-history":[{"count":2,"href":"https:\/\/robertjwallace.com\/es\/wp-json\/wp\/v2\/posts\/6342\/revisions"}],"predecessor-version":[{"id":6347,"href":"https:\/\/robertjwallace.com\/es\/wp-json\/wp\/v2\/posts\/6342\/revisions\/6347"}],"wp:attachment":[{"href":"https:\/\/robertjwallace.com\/es\/wp-json\/wp\/v2\/media?parent=6342"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/robertjwallace.com\/es\/wp-json\/wp\/v2\/categories?post=6342"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/robertjwallace.com\/es\/wp-json\/wp\/v2\/tags?post=6342"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}