## Posts

### The only number whose Scrabble score equals itself is TWELVE

When Heather and I were playing Scrabble recently, one of us played TWELVE and were amused to observe that it scored 12 (it wasn't played on any premium squares). Scoring other numbers in our heads (ONE, TWO, THREE, etc.) we couldn't find any others that worked like this, and so we wondered if it was the only such number. I started by writing a script which generated the written form of a number (1=ONE, 2=TWO, 666=SIX HUNDRED AND SIXTY SIX) and then added a function which calculated the Scrabble score for the word(s) . I ignored spaces and didn't consider premium squares or the maximum size of a scrabble board. I then used these to test the first few hundred thousand numbers, and found that the only match was TWELVE. I also found that the highest scoring number with n digits was the number made up purely of 6s. So 6 is the highest scoring 1 digit number, 66 is the highest scoring 2 digit number, etc. There were other numbers that scored as much (e.g. 65 scores as much

### Javascript function to convert a number into the English written format (1=ONE, 2=TWO, etc.)

This takes any positive integer number (up to 10^66-1) and returns the English written format (in upper case) for that number. So 1 -> ONE, 666 -> SIX HUNDRED AND SIXTY SIX. f unction inWords(num) {   var a = ["","ONE","TWO","THREE","FOUR","FIVE","SIX","SEVEN","EIGHT","NINE","TEN","ELEVEN","TWELVE","THIRTEEN","FOURTEEN","FIFTEEN","SIXTEEN","SEVENTEEN","EIGHTEEN","NINETEEN "];   var b = ["","","TWENTY","THIRTY","FORTY","FIFTY","SIXTY","SEVENTY","EIGHTY","NINETY"];   var c = ["THOUSAND","MILLION","BILLION","TRILLION","QUADRILLION","QUINTILLION","SEXTILLION","SEPTILLION","OCTILLION","NONILL

### Javascript function to calculate the Scrabble score for a word

This takes any string of characters and totals up how much it would be worth in Scrabble. It ignores any spaces or other non alphabet characters. It doesn't factor in any premium letter or word squares, and it doesn't care if you provide more letters than could possibly fit on a real Scrabble board. function scrabbleScore(word) {   var scores = [1,3,3,2,1,4,2,4,1,8,5,1,3,1,1,3,10,1,1,1,1,4,4,8,4,10];   var score = 0;   word = word.toUpperCase();   for (var i=0; i<word.length; i++) {     var n = word.charCodeAt(i) - 65;     if (n<0 || n>25) continue;     score += scores[n];   }   return score; }