-
-
Save Windows81/3137f8d1b59504fab65a7a2c2da9570d to your computer and use it in GitHub Desktop.
Run this on your web browser on the Corncob page (http://www.mieliestronk.com/corncob_lowercase.txt) to get a list of anagrams for the word 'Undertale'.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| //Enter text string here. | |
| s='undertale' | |
| let d={} | |
| let l=s.length | |
| for(let c of s.split(''))d[c]=~~d[c]+1 | |
| let w=document.body.innerText.split('\n').map(v=>{ | |
| a={} | |
| let i=0 | |
| for(let c of v.split('')) | |
| if(!d[c])return | |
| else a[c]=~~a[c]+1,i++ | |
| return[v,i,a] | |
| }).filter(v=>v) | |
| function f(d,l,s){ | |
| if(!l)return[[]] | |
| else if(l<0)return[] | |
| let t=[] | |
| for(let[v,i,a]of w){ | |
| if(!i)continue | |
| let h={} | |
| for(let i in d) | |
| if(!h)break | |
| else if((h[i]=d[i]-~~a[i])<0)h=null | |
| if(h) | |
| for(let b of f(h,l-i,v)) | |
| t.push([v,...b]) | |
| } | |
| return t | |
| } | |
| let r=f(d,l,s) | |
| console.log(r) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment