Tuesday, 24 November 2015

The crossword that counts itself

I love puzzles. This is described by Alex Bellos at the Guardian.

It helps to write a spreadsheet to solve this.

  1. Set the column widths to be about the same as the height, making them look square.
  2. Draw out the puzzle by highlighting a phrase (there are 12 "phrases"), and formatting: format cells, borders, click outline, OK.
  3. Repeat for each of the other 11 phrases, highlight, Ctrl-Y (repeats the last format command for a new area)
  4. Count the lengths of the rectangles (these are "phrase length"), subtract (3 or 2) to get "word length"
  5. The area inside the blue box is named "puzzle"
  6. The formula (row 20) for "actual" is: = SUMPRODUCT( LEN(puzzle) - LEN( SUBSTITUTE(puzzle,"e","") ))
  7. This formula is copied for the 11 rows below and the letter edited, each time.
  8. The formula for "= target" is: =IF( E20 = F20, "Y", "N")
  9. When they all show "Y", the puzzle is solved.
  10. The sum in cell e32 just tallies the 12 "actual" numbers. It must eventually show 68 when the puzzle is solved
  11. The working between p18 : ae32 allows one to count the number of times each number word is used and tally them (must be = 68 too)
  12. The cells bordered in red are named: number
  13. The "word cells" formula is just: = number * R19
  14. This formula is copied down and across (to the 3 combos). The "3 combos" show the 3 possible combinations of possible words.
  15. The "# letters" fomula is just the length of the number. e.g.: = LEN( AD20 )

This is not so easy to solve using purely coded program, because the rules to narrow down the combinations are not so clear. After you've figured out what constraints must be met it, no doubt, becomes much easier to program.

Tuesday, 10 November 2015

Code spippets - Fsharp

GistBox Clipper

Clipper is the companion Chrome extension to GistBox. It allows users to create Gists from:

  • Example code blocks
  • Highlighted text
  • Any page on the web
Install Chrome Extension
Enter keyboard data, via console, with validation.
/// Read a valid age (between 0 and 150) from key input let readage (person: string) = let mutable continueLooping = true let mutable age = 0 while continueLooping do Console.WriteLine("Enter {0}'s age (between 0 and 150): ", person) let canparse, keyin = Int32.TryParse(Console.ReadLine()) age <- keyin if canparse && age >= 0 && age < 151 then continueLooping <- false age

Code snippets - css

Lists, without indents, with buttons, and over-handing firstline
ul { list-style: disc outside none; margin-left: 0; padding-left: 1em; } ul.circle { list-style-type: circle; } /* for lists within lists */ li { padding-left: 0.5em; }
pre :- with CR wrapping a line
pre { white-space: pre-wrap; /* css-3 */ white-space: -moz-pre-wrap; /* Mozilla, since 1999 */ white-space: -pre-wrap; /* Opera 4-6 */ white-space: -o-pre-wrap; /* Opera 7 */ word-wrap: break-word; /* Internet Explorer 5.5+ */ }