Some information about task TWOFIVE There are over 700 million valid words. Therfore, in computing the number that corresponds to a word, we must avoid explicitly counting every lexicographically preceding word. The key observation is that the number of valid words consistent within an assignment of the first k letters of the alphabet (i.e. A .. letter[k]) to a set of locations depends on the locations occupied by these letters, but not on which letter is assigned to each location. For example, the number of valid words consistent with the letters A..G in either of the configurations below is the same: Configuration 1: A B E F C G D Configuration 2: A D F G B E C This is enough to permit a dynammic programming approach to succeed in the permitted time. Indeed, we have an "untuned" 8 millisecond solution. 20 test cases were given as 10 pairs. The first of each pair gives a word, from which we are to compute the number, while the second asks for the inverse computation. As a consequence, brute forse does work for small numbers and their inverses. The data consisted of: 3 and its inverse, "ABCDEFGHIJKLMNOPQRSVTUWXY"; 20 and its inverse; 1 000 000 and its inverse; the maximum number (701149020) and its inverse; and seven other essentially random nine digit values. Case T N ---- - --------- 1 W 20 2 N 20 3 W 3 4 N 3 5 W 701149020 Last word in the lexicon 6 N 701149020 7 W 1000000 8 N 1000000 9 W 350574511 10 N 350574511 11 W 106407948 12 N 106407948 13 W 100000000 14 N 100000000 15 W 299925684 16 N 299925684 17 W 699509817 18 N 699509817 19 W 660689109 20 N 660689109 where T = kind of case (W or N) N = ordinal number