↑ Software ↑


wbc - WordBrain Count

wbc counts the total number of possible chains of N cells that can be formed on an X-by-Y rectangular grid. At each of the X*Y positions in the grid, wbc determines how many N-length chains can be constructed beginning at that position.

The program was inspired by MAG Interactive's WordBrain game for phones and tablets. Alphabetic tiles spelling certain words are jumbled on a square playing board. Adjacent tiles must be connected in sequence to spell out a word. For example, "BRAIN" is formed by starting at a "B", sliding to an adjacent "R", sliding to an "A" adjacent to the "R", and sliding to an "I" and "N" in turn. Adjacent tiles can be connected up, down, left, right, and diagonally. A tile already used in a word cannot be reused. When a word is formed, its tiles disappear from the board and the tiles above drop down to fill the space. The player is only given the lengths of the words to be found, although hints can be used to reveal actual letters in the words.

The game is fun and I got pretty far, I think well into the 7x7 games. However, the need sometimes to find two-letter words became tedious: at each of the 49 positions, try all of the possible two letter words. It was frustrating and I eventually moved on to other games.

Since then, I've always wondered how many possible two-letter words there are on a full 7x7 board. So, a few years later, I wrote wbc. The program does make a couple of assumptions. First, the board is full, which is only true before any words are formed. Second, a chain of N arbitrary tiles always forms a word. Obviously, this is not the case in the game: you must form valid words. wbc, on the other hand, will count "THE" beginning at the "T", "HET" beginning at the "H", and "EHT" beginning at "E".

As it turns out, there are 312 possible two-letter words in a 7x7 puzzle. Here are the counts for all the possible lengths in a 3x4 puzzle (with a tweak in the formatting!):

    % wbc -board 3x4 1-13
    Board: 3x4   Length: 1    # of possible words:    12
    Board: 3x4   Length: 2    # of possible words:    58
    Board: 3x4   Length: 3    # of possible words:   256
    Board: 3x4   Length: 4    # of possible words:   946
    Board: 3x4   Length: 5    # of possible words:  2952
    Board: 3x4   Length: 6    # of possible words:  7808
    Board: 3x4   Length: 7    # of possible words: 17348
    Board: 3x4   Length: 8    # of possible words: 31604
    Board: 3x4   Length: 9    # of possible words: 45424
    Board: 3x4   Length: 10   # of possible words: 47312
    Board: 3x4   Length: 11   # of possible words: 30848
    Board: 3x4   Length: 12   # of possible words:  9356
    Board: 3x4   Length: 13   # of possible words:     0

I initially thought it might be possible to populate a board with two alternating letters which spelled a word both forward and backword, and thus give a board which achieved the maximum number of two-letter words. (I was wrong!) I implemented the "-two" option to generate all possible two-letter combinations in which one and only one letter is a vowel. Pairs are generated in which the second of a pair is the first in reverse. For example:

    ab  ba
    ac  ca
    ad  da
    af  fa
    on  no

"On" and "no" were the only "true" word pair, not counting slightly slangy words such as "ah"/"ha", "am"/"ma", etc. When I actually wrote a board down on paper with alternating "N"s and "O"s, however, I saw my mistake. If you begin each row with the same letter, "N" or "O", then you can't form vertical words because they're the same letters. If you alternate the beginning letter of each row, then you can't form diagonal words for the same reason. Oh, well ...

    N O N O           N O N O
    N O N O    vs.    O N O N
    N O N O           N O N O


% wbc [-debug] [-help]
      [-board rows[xcolumns]]


turns debug on.
prints out a help message.
-board rows[xcolumns]
specifies the dimensions of the rectangular board. If the number of columns is not specified, the board is square. The default board size is 7x7.
generates pairs of two-letter words and their reverse.
specifies the chain length or a range of chain lengths. The default length is 2. If a range is specified, the counts for each length are separately calculated and printed.

Alex Measday  /  E-mail