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

Home > Just Math
Ternary train (Posted on 2014-03-28) Difficulty: 4 of 5
Please restore the 5 by 5 grid containing 10 ternary numbers with no leading zeroes.
The crossword-like definitions follow:


Across:
I. a cube
II. twice a permutable (in base 10) prime
III. divisible by eleven
IV. the number of trees with 10 vertices
V. a square

Down:
1. repdigit in base 12
2. a factorion in base 10
3. a semiprime
4. a square of a prime
5. its cube in base 10 uses only 3 distinct digits

Rem: I have built it bottoms-up. Hope there is only one solution...

No Solution Yet Submitted by Ady TZIDON    
No Rating

Comments: ( Back to comment list | You must be logged in to post comments.)
Solution computer solution | Comment 2 of 3 |

DECLARE SUB factor (num%, s$)
DECLARE FUNCTION fact# (x#)
DECLARE SUB permute (a$)
DECLARE FUNCTION bs12$ (x#)
DECLARE FUNCTION tern$ (x#)
DEFDBL A-Z
DIM prime(164) AS STRING
  DATA    11 , 13 , 17 , 19 , 23 , 29 , 31 , 37 , 41 , 43
  DATA    47 , 53 , 59 , 61 , 67 , 71 , 73 , 79 , 83 , 89
  DATA    97 , 101 , 103 , 107 , 109 , 113 , 127 , 131 , 17 , 139
  DATA    149 , 151 , 157 , 163 , 167 , 173 , 179 , 181 , 191 , 193
  DATA    197 , 199 , 211 , 223 , 227 , 229 , 233 , 239 , 241 , 251
  DATA    257 , 263 , 269 , 271 , 277 , 281 , 283 , 293 , 307 , 311
  DATA    313 , 317 , 331 , 337 , 347 , 349 , 353 , 359 , 367 , 373
  DATA    379 , 383 , 389 , 397 , 401 , 409 , 419 , 421 , 431 , 433
  DATA    439 , 443 , 449 , 457 , 461 , 463 , 467 , 479 , 487 , 491
  DATA    499 , 503 , 509 , 521 , 523 , 541 , 547 , 557 , 563 , 569
  DATA    571 , 577 , 587 , 593 , 599 , 601 , 607 , 613 , 617 , 619
  DATA    631 , 641 , 643 , 647 , 653 , 659 , 661 , 673 , 677 , 683
  DATA    691 , 701 , 709 , 719 , 727 , 733 , 739 , 743 , 751 , 757
  DATA    761 , 769 , 773 , 787 , 797 , 809 , 811 , 821 , 823 , 827
  DATA    829 , 839 , 853 , 857 , 859 , 863 , 877 , 881 , 883 , 887
  DATA    907 , 911 , 919 , 929 , 937 , 941 , 947 , 953 , 967 , 971
  DATA    977 , 983 , 991 , 997

FOR i = 1 TO 164: READ prime(i): NEXT


CLS
low = 3 ^ 4: high = 3 ^ 5 - 1: PRINT low, high
PRINT tern$(low), tern$(high)

PRINT : PRINT "across"

OPEN "terntran.txt" FOR OUTPUT AS #2

PRINT "cube"
FOR n = low TO high
  cr = INT(n ^ (1 / 3) + .5)
  IF cr * cr * cr = n THEN PRINT n; tern$(n); " "; : PRINT #2, tern$(n); " ";
NEXT: PRINT : PRINT : PRINT #2, : PRINT #2,

PRINT "twice perm prime"
FOR n = low TO high
  IF n MOD 2 = 0 THEN
    FOR i = 1 TO 164
      IF VAL(prime(i)) = n / 2 THEN
        good = 0
        a$ = prime(i): h$ = a$
        DO
          FOR j = 1 TO 164
            IF prime(j) = a$ AND VAL(a$) <> n / 2 THEN good = 1: EXIT FOR
          NEXT
          IF good THEN EXIT DO
          permute a$
        LOOP UNTIL a$ = h$
        IF good THEN PRINT n; tern$(n); " "; : PRINT #2, tern$(n); " ";
      END IF
    NEXT
  END IF
NEXT: PRINT : PRINT : PRINT #2, : PRINT #2,

PRINT "div by 11"
FOR n = low TO high
  IF n MOD 11 = 0 THEN PRINT n; tern$(n); " "; : PRINT #2, tern$(n); " ";
NEXT: PRINT : PRINT : PRINT #2, : PRINT #2,

PRINT "trees"
n = 106
PRINT n; tern$(n); " "; : PRINT #2, tern$(n); " ";
PRINT : PRINT : PRINT #2, : PRINT #2,


PRINT "square"
FOR n = low TO high
  sr = INT(SQR(n) + .5)
  IF sr * sr = n THEN PRINT n; tern$(n); " "; : PRINT #2, tern$(n); " ";
NEXT: PRINT : PRINT : PRINT #2, : PRINT #2,


PRINT "--------------"
PRINT #2, "--------------"
PRINT "down"
PRINT "repdigit base 12"

FOR n = low TO high
   x$ = bs12$(n)
   good = 1
   FOR i = 2 TO LEN(x$)
     IF MID$(x$, i, 1) <> LEFT$(x$, 1) THEN good = 0: EXIT FOR
   NEXT
   IF good THEN PRINT n; bs12$(n); " "; tern$(n); " "; : PRINT #2, tern$(n); " ";
NEXT: PRINT : PRINT : PRINT #2, : PRINT #2,

PRINT "factorion base 10"
FOR n = low TO high
   tot = 0
   ns$ = LTRIM$(STR$(n))
   FOR i = 1 TO LEN(ns$)
     tot = tot + fact(VAL(MID$(ns$, i, 1)))
   NEXT
   IF tot = n THEN PRINT n; tern$(n); " "; : PRINT #2, tern$(n); " ";
NEXT: PRINT : PRINT : PRINT #2, : PRINT #2,

PRINT "semiprime"
FOR n = low TO high
  factor INT(n), f$
  ix = INSTR(f$, " ")
  IF ix > 0 THEN
     ix = INSTR(ix + 1, f$, " ")
     IF ix = 0 THEN
          PRINT n; tern$(n); " "; : PRINT #2, tern$(n); " ";
     END IF
  END IF
NEXT: PRINT : PRINT : PRINT #2, : PRINT #2,

PRINT "square of prime"

FOR n = low TO high
  factor INT(n), f$
  ix = INSTR(f$, " ")
  IF ix > 0 THEN
     ix2 = INSTR(ix + 1, f$, " ")
     IF ix2 = 0 THEN
        s1$ = LEFT$(f$, ix - 1)
        s2$ = MID$(f$, ix + 1)
        IF s1$ = s2$ THEN PRINT n; tern$(n); " "; : PRINT #2, tern$(n); " ";
     END IF
  END IF
NEXT: PRINT : PRINT : PRINT #2, : PRINT #2,

FOR n = low TO high
   n3 = n * n * n
   n3s$ = LTRIM$(STR$(n3))
   dct = 1
   FOR i = 2 TO LEN(n3s$)
     IF INSTR(n3s$, MID$(n3s$, i, 1)) = i THEN dct = dct + 1
   NEXT
   IF dct <= 3 THEN
      PRINT n; n3; dct; tern$(n); " "; : PRINT #2, tern$(n); " ";
   END IF
NEXT: PRINT : PRINT : PRINT #2, : PRINT #2,

FUNCTION bs12$ (x)
  s$ = ""
  n = x
  WHILE n > 0
    d = n MOD 12: n = n \ 12
  
    s$ = LTRIM$(MID$("0123456789ab", d + 1, 1)) + s$
  WEND
  bs12$ = s$
END FUNCTION

FUNCTION fact (x)
 f = 1
 FOR i = 2 TO x
     f = f * i
 NEXT
 fact = f
END FUNCTION

DEFINT A-Z
SUB factor (num, s$)
 s$ = "": n = ABS(num): IF n > 0 THEN limit = SQR(n):  ELSE limit = 0
 IF limit <> INT(limit) THEN limit = INT(limit + 1)
 dv = 2: GOSUB DivideIt
 dv = 3: GOSUB DivideIt
 dv = 5: GOSUB DivideIt
 dv = 7
 DO UNTIL dv > limit
   GOSUB DivideIt: dv = dv + 4 '11
   GOSUB DivideIt: dv = dv + 2 '13
   GOSUB DivideIt: dv = dv + 4 '17
   GOSUB DivideIt: dv = dv + 2 '19
   GOSUB DivideIt: dv = dv + 4 '23
   GOSUB DivideIt: dv = dv + 6 '29
   GOSUB DivideIt: dv = dv + 2 '31
   GOSUB DivideIt: dv = dv + 6 '37
   IF INKEY$ = CHR$(27) THEN s$ = CHR$(27): EXIT SUB
 LOOP
 IF n > 1 THEN s$ = s$ + STR$(n)
 s$ = LTRIM$(s$)
 EXIT SUB

DivideIt:
 DO
  q = INT(n / dv)
  IF q * dv = n AND n > 0 THEN
    n = q: s$ = s$ + STR$(dv): IF n > 0 THEN limit = SQR(n):  ELSE limit = 0
    IF limit <> INT(limit) THEN limit = INT(limit + 1)
   ELSE
    EXIT DO
  END IF
 LOOP
 RETURN
END SUB


DEFDBL A-Z
FUNCTION tern$ (x)
  s$ = ""
  n = x
  WHILE n > 0
    d = n MOD 3: n = n \ 3
    s$ = LTRIM$(STR$(d)) + s$
  WEND
  tern$ = s$
END FUNCTION

produces the below possibilities:

Unless otherwise noted, the groups consist of the decimal value followed by the ternary value.

across
cube
 125 11122  216 22000

twice perm prime
 142 12021  146 12102  158 12212  194 21012  214 21221  226 22101

div by 11
 88 10021  99 10200  110 11002  121 11111  132 11220  143 12022  154 12201  165
20010  176 20112  187 20221  198 21100  209 21202  220 22011  231 22120  242
22222

trees
 106 10221

square
 81 10000  100 10201  121 11111  144 12100  169 20021  196 21021  225 22100

--------------
down
repdigit base 12
(groups are base-10, base-12, base-3)
 91 77 10101  104 88 10212  117 99 11100  130 aa 11211  143 bb 12022  157 111
12211

factorion base 10
 145 12101

semiprime
 82 10001  85 10011  86 10012  87 10020  91 10101  93 10110  94 10111  95 10112
 106 10221  111 11010  115 11021  118 11101  119 11102  121 11111  122 11112
 123 11120  129 11210  133 11221  134 11222  141 12020  142 12021  143 12022
 145 12101  146 12102  155 12202  158 12212  159 12220  161 12222  166 20011
 169 20021  177 20120  178 20121  183 20210  185 20212  187 20221  194 21012
 201 21110  202 21111  203 21112  205 21121  206 21122  209 21202  213 21220
 214 21221  215 21222  217 22001  218 22002  219 22010  221 22012  226 22101
 235 22201  237 22210

square of prime
 121 11111  169 20021

cube in base 10 uses 3 distinct digits or fewer:
(groups consist of decimal value, cube, number of dist. digits, ternary rep):
 92  778688  3 10102  100  1000000  2 10201  101  1030301  3 10202  110
 1331000  3 11002  173  5177717  3 20102  192  7077888  3 21010  200  8000000
 2 21102  211  9393931  3 21211


Summary of the ternary values:

across

11122 22000

12021 12102 12212 21012 21221 22101

10021 10200 11002 11111 11220 12022 12201 20010 20112 20221 21100 21202 22011 22120 22222

10221

10000 10201 11111 12100 20021 21021 22100

--------------

down

10101 10212 11100 11211 12022 12211

12101

10001 10011 10012 10020 10101 10110 10111 10112 10221 11010 11021 11101 11102 11111 11112 11120 11210 11221 11222 12020 12021 12022 12101 12102 12202 12212 12220 12222 20011 20021 20120 20121 20210 20212 20221 21012 21110 21111 21112 21121 21122 21202 21220 21221 21222 22001 22002 22010 22012 22101 22201 22210

11111 20021

10102 10201 10202 11002 20102 21010 21102 21211


Obviously the fourth row across is 10221 and then the fourth column down becomes 20021. Similar fittings are made until the square is complete:

1 1 1 2 2  cube = 125 decimal
2 2 1 0 1  twice permutable prime = 226 = 2*113
2 1 2 0 2  div by 11: = 209
1 0 2 2 1  trees w/10 vert. = 106 decimal
1 1 1 1 1  square = 121 decimal

down
12211  repdigit base 12: base-10 157; base-12 111
12101  factorion base 10: 145 = 1! + 4! + 5!
11221  semiprime = 133 decimal = 7*19
20021  square of prime = 169 decimal = 13^2
21211  cube contains only 3 distinct decimal digits: decimal 211^3 = 9393931


  Posted by Charlie on 2014-03-28 14:26:02
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 (2)
Unsolved Problems
Top Rated Problems
This month's top
Most Commented On

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