All about flooble | fun stuff | Get a free chatterbox | Free JavaScript | Avatars    
perplexus dot info

Home > General
DVR Alphabets (Posted on 2008-09-15) Difficulty: 3 of 5
TiVo's and other DVR's, such as those provided by the Cable TV company, allow searches for programs using an on-screen alphabet that you can move through using up, down, left and right buttons so you can select a letter with the enter button, then go on to select the next letter, etc.

One such alphabetic layout is as follows:

ABCD
EFGH
IJKL
MNOP
QRST
UVWX
YZ

The cursor always starts at A before the first letter of the word is typed. There is no wrap-around, so you can't go from A to Y in one step, nor from X to U in one step, and you can't go down from W or X, or right from Z.

Typing THIRTY using the above layout requires 30 button presses: DDDDRRR=UUU=LLLD=DDR=RR=LLLDD=, here using the = to represent Enter, and initial letters to represent Up, Down, Left, Right.

Suppose a different DVR has a different number of letters in each row. Using that DVR, with more letters per row, the word LOW can be typed in 12 or fewer button presses. On this same DVR, there are three number words (such as EIGHT, EIGHTEEN or EIGHTY, but those are just examples, not the answer) which also require 12 or fewer button presses each.

How many letters are there on a line on this other DVR, and what are the three numbers that can be spelled with 12 or fewer button presses each?

  Submitted by Charlie    
No Rating
Solution: (Hide)
The following table shows how many presses are required to type LOW with the given number of letters per row in the layout:

 5            13
 6            16
 7            15
 8            11
 9            11
10            11
11            11
12            32
13            33
14            34
15            25
16            26
17            27
18            28
19            29
20            30
21            31
22            32
23            25
24            25
25            25
26            25

So only with 8, 9, 10 or 11 letters per row does LOW take 12 or fewer presses, in fact taking 11 presses.

What about the three number words that can be typed with 12 or fewer button presses? The table below shows what number words can be typed with 12 or fewer presses for layouts with from 8 through 11 letters per row:

letters    number         button
   /row   represented     presses
 8            2             12
 
 9            1             11
 9            2             11
 9           10             12
 
10            1             11

11            1             11

Only 9 letters per row allows three number words, ONE, TWO and TEN, to be spelled with 12 or fewer presses.

The program for the first table above:

DECLARE SUB enterNum ()
DECLARE SUB ProcPiece (piece$, MajorPower!)
DATA one,two,three,four,five,six,seven,eight,nine
DATA ten,eleven,twelve,thirteen,fourteen,fifteen,sixteen,seventeen
DATA eighteen,nineteen
DATA twenty,thirty,forty,fifty,sixty,seventy,eighty,ninety
DATA thousand,million,billion,trillion,quadrillion,quintillion,sextillion
DIM SHARED unit$(19), ten$(10), major$(7)
FOR i = 1 TO 19
  READ unit$(i)
NEXT
FOR i = 2 TO 9
  READ ten$(i)
NEXT
FOR i = 1 TO 7
  READ major$(i)
NEXT
DIM SHARED name$, num$


letPerLine = 4
alpha$ = "abcdefghijklmnopqrstuvwxyz"

FOR letPerLine = 5 TO 26
   w$ = "low": GOSUB ctStrokes: PRINT letPerLine, tot
NEXT
PRINT

END

ctStrokes:
  row = 0: col = 0: tot = 0
  FOR i = 1 TO LEN(w$)
    letNo = INSTR(alpha$, MID$(w$, i, 1)) - 1    ' zero based
    IF letNo > 0 THEN
      newRow = letNo \\ letPerLine
      newCol = letNo MOD letPerLine
      dist = ABS(newRow - row) + ABS(newCol - col) + 1
      tot = tot + dist
      row = newRow: col = newCol
    END IF
  NEXT
RETURN

SUB enterNum
 DO
  INPUT "Enter number:", num$
  num$ = LTRIM$(RTRIM$(num$))
  num = 1
  FOR i = 1 TO LEN(num$)
    IF INSTR("0123456789", MID$(num$, i, 1)) = 0 THEN num = 0: EXIT FOR
  NEXT
  IF num = 0 THEN PRINT "Must be numeric."
 LOOP WHILE num = 0
END SUB

SUB ProcPiece (piece$, MajorPower)
  piece = VAL(piece$)
  n$ = ""
  IF piece > 99 THEN
    n$ = unit$(piece \\ 100) + " hundred "
    piece = piece MOD 100
  END IF
  IF piece > 19 THEN
    n$ = n$ + ten$(piece \\ 10)
    piece = piece MOD 10
    IF piece > 0 THEN n$ = n$ + "-":  ELSE n$ = n$ + " "
  END IF
  IF piece > 0 THEN n$ = n$ + unit$(piece) + " "
  IF n$ > "" THEN name$ = n$ + major$(MajorPower) + " " + name$
END SUB

The added code to make the second table above:

FOR letPerLine = 8 TO 11

ctFit = 0
FOR n = 1 TO 150
        num$ = LTRIM$(STR$(n))
        IF num$ = "0" THEN
                name$ = "zero"
        ELSE
                name$ = ""
                MajorPower = 0
                DO
                        l = LEN(num$): IF l > 3 THEN l = 3
                        piece$ = RIGHT$(num$, l)
                        num$ = LEFT$(num$, LEN(num$) - l)
                        CALL ProcPiece(piece$, MajorPower)
                        MajorPower = MajorPower + 1
                LOOP WHILE LEN(num$) > 0
        END IF
        w$ = name$
        GOSUB ctStrokes
        IF tot <= 12 THEN
          ctFit = ctFit + 1
          PRINT letPerLine; n; tot
        END IF
NEXT
IF ctFit > 2 THEN PRINT letPerLine

NEXT letPerLine

Based on "Low numbers" by Susan Denham, Enigma No. 1508, New Scientist, 23 August 2008

Comments: ( You must be logged in to post comments.)
  Subject Author Date
Some ThoughtsPuzzle Thoughts K Sengupta2023-09-11 01:45:27
reply to Dej Mar (1)ed bottemiller2008-09-15 15:39:08
Solutioned bottemiller2008-09-15 15:24:53
SolutionA probable solutionDej Mar2008-09-15 13:44:40
Please log in:
Login:
Password:
Remember me:
Sign up! | Forgot password


Search:
Search body:
Forums (0)
Newest Problems
Random Problem
FAQ | About This Site
Site Statistics
New Comments (15)
Unsolved Problems
Top Rated Problems
This month's top
Most Commented On

Chatterbox:
Copyright © 2002 - 2024 by Animus Pactum Consulting. All rights reserved. Privacy Information