Author Topic: Rebus of Letters  (Read 10608 times)

0 Members and 1 Guest are viewing this topic.

This topic contains a post which is marked as Best Answer. Press here if you would like to see it.

Offline DANILIN

  • Forum Regular
  • Posts: 128
    • View Profile
    • Danilin youtube
Rebus of Letters
« on: August 28, 2020, 05:44:52 am »
Rebus of Letters

My program solves a rebus from letters of form:
UDAR + UDAR = DRAKA

Russian: Punch + Punch = Fight

I'm looking for other options possibly using an array

Code: QB64: [Select]
  1. ' daudar.bas
  2.  
  3. start = TIMER
  4.  
  5. FOR u = 1 TO 9
  6.     FOR d = 1 TO 9
  7.         FOR a = 0 TO 9
  8.             FOR r = 0 TO 9
  9.                 FOR k = 0 TO 9
  10.  
  11. IF u = d THEN 22
  12. IF u = a THEN 33
  13. IF u = r THEN 44
  14. IF u = k THEN 55
  15.  
  16. IF d = a THEN 33
  17. IF d = r THEN 44
  18. IF d = k THEN 55
  19.  
  20. IF a = r THEN 44
  21. IF a = k THEN 55
  22. IF r = k THEN 55
  23.  
  24. udar = 1000*u + 100*d + 10*a + r
  25. draka = d*10000 + r*1000 + a*100 + k*10 + a
  26.  
  27. IF udar + udar = draka THEN PRINT udar, draka
  28.  
  29.                 55 NEXT k
  30.            44 NEXT r
  31.        33 NEXT a
  32.    22 NEXT d
  33. 11 NEXT u
  34.  
  35. finish = TIMER
  36.  
  37. PRINT finish - start
  38.  

Next: combinatorics of letter combinations and formulas

Offer your rebuses
Russia looks world from future. big data is peace data.
https://youtube.com/playlist?list=PLBBTP9oVY7IagpH0g9FNUQ8JqmHwxDDDB
i never recommend anything to anyone and always write only about myself

Offline DANILIN

  • Forum Regular
  • Posts: 128
    • View Profile
    • Danilin youtube
Re: Rebus of Letters
« Reply #1 on: August 28, 2020, 06:33:07 pm »
Solve of rebus UDAR+UDAR=DRAKA through an array of 5 Letters

Letter comparisons via nested Loops

improvement possible: variable number of letters
then nested comparison loops will be universal

Code: QB64: [Select]
  1. ' Russian Rebus Letters from Digitals.bas
  2. NN = 5: DIM a(NN)
  3. FOR u = 1 TO 9: a(1) = u
  4.     FOR d = 1 TO 9: a(2) = d
  5.         FOR a = 0 TO 9: a(3) = a
  6.             FOR r = 0 TO 9: a(4) = r
  7.                 FOR k = 0 TO 9: a(5) = k
  8. FOR xx = 1 TO NN-1
  9.    FOR yy = xx + 1 TO NN
  10.       IF a(xx) = a(yy) THEN GOTO 55
  11. NEXT yy: NEXT xx
  12.              udar = 1000*u + 100*d + 10*a + r
  13.              draka = d*10000 + r*1000 + a*100 + k*10 + a
  14.                   IF udar + udar = draka THEN PRINT udar, draka
« Last Edit: September 02, 2020, 02:01:55 pm by DANILIN »
Russia looks world from future. big data is peace data.
https://youtube.com/playlist?list=PLBBTP9oVY7IagpH0g9FNUQ8JqmHwxDDDB
i never recommend anything to anyone and always write only about myself

Offline bplus

  • Global Moderator
  • Forum Resident
  • Posts: 8053
  • b = b + ...
    • View Profile
Re: Rebus of Letters
« Reply #2 on: August 29, 2020, 05:47:51 pm »
@DANILIN Hardly as clever as yours and allot of tedious work but
ten + two = four  76 ways!

Code: QB64: [Select]
  1. ' rebus challenge by danilin ref:  https://www.qb64.org/forum/index.php?topic=2961.msg122153#msg122153
  2. _TITLE "Rebus Danilin Challenge" 'b+ 2020-08-29
  3.  
  4. 'try nine + five = seven  > nope
  5. 'try ten + two = four
  6. f = 1
  7. PRINT "Count:", "ten", "+ two", " = four"
  8. FOR t = 5 TO 9
  9.     FOR w = 0 TO 9
  10.         FOR o = 0 TO 9
  11.             FOR e = 0 TO 9
  12.                 FOR n = 0 TO 9
  13.                     FOR u = 0 TO 9
  14.                         FOR r = 0 TO 9
  15.  
  16.                             IF r <> u AND r <> n AND r <> e AND r <> o AND r <> w AND r <> t AND r <> f THEN
  17.                                 IF u <> n AND u <> e AND u <> o AND u <> w AND u <> t AND u <> f THEN
  18.                                     IF n <> e AND n <> o AND n <> w AND n <> t AND n <> f THEN
  19.                                         IF e <> o AND e <> w AND e <> t AND e <> f THEN
  20.                                             IF o <> w AND o <> t AND o <> f THEN
  21.                                                 IF w <> t AND w <> f THEN
  22.                                                     IF t <> f THEN
  23.                                                         ten = 100 * t + 10 * e + n
  24.                                                         two = 100 * t + 10 * w + o
  25.                                                         four = 1000 * f + 100 * o + 10 * u + r
  26.                                                         IF ten + two = four THEN
  27.                                                             count = count + 1
  28.                                                             PRINT count, ten, two, four
  29.                                                             IF count MOD 20 = 0 THEN
  30.                                                                 INPUT "Press enter to contiue... "; w$
  31.                                                                 CLS
  32.                                                                 PRINT "Count:", "ten", "+ two", " = four"
  33.                                                             END IF
  34.                                                         END IF
  35.                                                     END IF
  36.                                                 END IF
  37.                                             END IF
  38.                                         END IF
  39.                                     END IF
  40.                                 END IF
  41.                             END IF
  42.  
  43.                         NEXT
  44.                     NEXT
  45.                 NEXT
  46.             NEXT
  47.         NEXT
  48.     NEXT
  49. PRINT "ten + two = four "; count; " ways!"
  50.  
  51.  

Offline bplus

  • Global Moderator
  • Forum Resident
  • Posts: 8053
  • b = b + ...
    • View Profile
Re: Rebus of Letters
« Reply #3 on: August 30, 2020, 11:11:38 pm »
I got this one off the Internet. This stuff is called Cryptarithm or Alphametic Puzzles. Thanks to Danilin's 2nd program I have a much easier time making sure all the letters are different values.

Here is "send + more = money" written by a program I am writing and testing to solve these suckers.
Code: QB64: [Select]
  1. DIM a(8)
  2. FOR s = 0 TO 9: a(1) = s
  3.     FOR e = 0 TO 9: a(2) = e
  4.         FOR n = 0 TO 9: a(3) = n
  5.             FOR d = 0 TO 9: a(4) = d
  6.                 FOR m = 0 TO 9: a(5) = m
  7.                     FOR o = 0 TO 9: a(6) = o
  8.                         FOR r = 0 TO 9: a(7) = r
  9.                             FOR y = 0 TO 9: a(8) = y
  10.                                 FOR xx = 1 TO 7
  11.                                     FOR yy = xx + 1 TO 8
  12.                                         IF a(xx) = a(yy) THEN GOTO skip
  13.                                     NEXT
  14.                                 NEXT
  15.                                 send = 10 ^ 3 * s + 10 ^ 2 * e + 10 ^ 1 * n + 10 ^ 0 * d
  16.                                 more = 10 ^ 3 * m + 10 ^ 2 * o + 10 ^ 1 * r + 10 ^ 0 * e
  17.                                 money = 10 ^ 4 * m + 10 ^ 3 * o + 10 ^ 2 * n + 10 ^ 1 * e + 10 ^ 0 * y
  18.                                 IF send + more = money THEN
  19.                                     PRINT send, more, money
  20.                                 END IF
  21.                                 skip:
  22.                             NEXT
  23.                         NEXT
  24.                     NEXT
  25.                 NEXT
  26.             NEXT
  27.         NEXT
  28.     NEXT
  29.  

I still have to tell it that letters that start words can't be 0, so this program solves with m = 0 before getting around to m = 1 which has just one solution, the last listed.

Offline bplus

  • Global Moderator
  • Forum Resident
  • Posts: 8053
  • b = b + ...
    • View Profile
Re: Rebus of Letters
« Reply #4 on: August 30, 2020, 11:51:03 pm »
I added _TITLE, fixed the 1st letter problem, added a header to the Solution and the test program send more money gets written and runs perfect.

Code: QB64: [Select]
  1. _TITLE "send more money Solver.bas" ' written by Cryptarithm Program Writer.bas b+ 2020-08-30
  2. DIM a(8)
  3. FOR s = 1 TO 9: a(1) = s
  4.     FOR e = 0 TO 9: a(2) = e
  5.         FOR n = 0 TO 9: a(3) = n
  6.             FOR d = 0 TO 9: a(4) = d
  7.                 FOR m = 1 TO 9: a(5) = m
  8.                     FOR o = 0 TO 9: a(6) = o
  9.                         FOR r = 0 TO 9: a(7) = r
  10.                             FOR y = 0 TO 9: a(8) = y
  11.                                 FOR xx = 1 TO 7
  12.                                     FOR yy = xx + 1 TO 8
  13.                                         IF a(xx) = a(yy) THEN GOTO skip
  14.                                     NEXT
  15.                                 NEXT
  16.                                 send = 10 ^ 3 * s + 10 ^ 2 * e + 10 ^ 1 * n + 10 ^ 0 * d
  17.                                 more = 10 ^ 3 * m + 10 ^ 2 * o + 10 ^ 1 * r + 10 ^ 0 * e
  18.                                 money = 10 ^ 4 * m + 10 ^ 3 * o + 10 ^ 2 * n + 10 ^ 1 * e + 10 ^ 0 * y
  19.                                 IF send + more = money THEN
  20.                                     PRINT " send", " more", " money"
  21.                                     PRINT send, more, money
  22.                                 END IF
  23.                                 skip:
  24.                             NEXT
  25.                         NEXT
  26.                     NEXT
  27.                 NEXT
  28.             NEXT
  29.         NEXT
  30.     NEXT
  31.  

Next try input of the 3 words to write the program, so the program writer can write a program to solve for the 3 words.
« Last Edit: August 30, 2020, 11:53:28 pm by bplus »

Offline _vince

  • Seasoned Forum Regular
  • Posts: 422
    • View Profile
Re: Rebus of Letters
« Reply #5 on: August 30, 2020, 11:52:24 pm »
are you substituting digits for letters?

Offline bplus

  • Global Moderator
  • Forum Resident
  • Posts: 8053
  • b = b + ...
    • View Profile
Re: Rebus of Letters
« Reply #6 on: August 30, 2020, 11:57:47 pm »

are you substituting digits for letters?

We are finding the digits for each letter to make the "equation" work. What digits make send + more = money
send + more = money
9567 + 1085 = 10652

m's, o's, e's all match up to same number

Offline bplus

  • Global Moderator
  • Forum Resident
  • Posts: 8053
  • b = b + ...
    • View Profile
Re: Rebus of Letters
« Reply #7 on: August 31, 2020, 12:10:26 am »
Yeah, no problem with inputting words :) me + me = bee
Code: QB64: [Select]
  1. _TITLE "me me bee Solver.bas" ' written by Cryptarithm Program Writer.bas b+ 2020-08-30
  2. DIM a(3)
  3. FOR m = 1 TO 9: a(1) = m
  4.     FOR e = 0 TO 9: a(2) = e
  5.         FOR b = 1 TO 9: a(3) = b
  6.             FOR xx = 1 TO 2
  7.                 FOR yy = xx + 1 TO 3
  8.                     IF a(xx) = a(yy) THEN GOTO skip
  9.                 NEXT
  10.             NEXT
  11.             me = 10 ^ 1 * m + 10 ^ 0 * e
  12.             me = 10 ^ 1 * m + 10 ^ 0 * e
  13.             bee = 10 ^ 2 * b + 10 ^ 1 * e + 10 ^ 0 * e
  14.             IF me + me = bee THEN
  15.                 PRINT " me", " me", " bee"
  16.                 PRINT me, me, bee
  17.             END IF
  18.             skip:
  19.         NEXT
  20.     NEXT
  21.  

 
me + me = bee.PNG

« Last Edit: August 31, 2020, 12:27:48 am by bplus »

Offline bplus

  • Global Moderator
  • Forum Resident
  • Posts: 8053
  • b = b + ...
    • View Profile
Re: Rebus of Letters
« Reply #8 on: August 31, 2020, 12:20:14 am »
This one is supposed to be a Rebus too:
time time lucky  (third time's a charm)
It has a ton of solutions.
Code: QB64: [Select]
  1. _TITLE "time time lucky Solver.bas" ' written by Cryptarithm Program Writer.bas b+ 2020-08-30
  2. DIM a(9)
  3. FOR t = 1 TO 9: a(1) = t
  4.     FOR i = 0 TO 9: a(2) = i
  5.         FOR m = 0 TO 9: a(3) = m
  6.             FOR e = 0 TO 9: a(4) = e
  7.                 FOR l = 1 TO 9: a(5) = l
  8.                     FOR u = 0 TO 9: a(6) = u
  9.                         FOR c = 0 TO 9: a(7) = c
  10.                             FOR k = 0 TO 9: a(8) = k
  11.                                 FOR y = 0 TO 9: a(9) = y
  12.                                     FOR xx = 1 TO 8
  13.                                         FOR yy = xx + 1 TO 9
  14.                                             IF a(xx) = a(yy) THEN GOTO skip
  15.                                         NEXT
  16.                                     NEXT
  17.                                     time = 10 ^ 3 * t + 10 ^ 2 * i + 10 ^ 1 * m + 10 ^ 0 * e
  18.                                     time = 10 ^ 3 * t + 10 ^ 2 * i + 10 ^ 1 * m + 10 ^ 0 * e
  19.                                     lucky = 10 ^ 4 * l + 10 ^ 3 * u + 10 ^ 2 * c + 10 ^ 1 * k + 10 ^ 0 * y
  20.                                     IF time + time = lucky THEN
  21.                                         PRINT " time", " time", " lucky"
  22.                                         PRINT time, time, lucky
  23.                                     END IF
  24.                                     skip:
  25.                                 NEXT
  26.                             NEXT
  27.                         NEXT
  28.                     NEXT
  29.                 NEXT
  30.             NEXT
  31.         NEXT
  32.     NEXT
  33.  

Offline bplus

  • Global Moderator
  • Forum Resident
  • Posts: 8053
  • b = b + ...
    • View Profile
Re: Rebus of Letters
« Reply #9 on: August 31, 2020, 12:24:01 am »
Here is a totally appropriate one, nice   ;-) runs fast one solution.
Code: QB64: [Select]
  1. _TITLE "USA USSR PEACE Solver.bas" ' written by Cryptarithm Program Writer.bas b+ 2020-08-30
  2. DIM a(7)
  3. FOR U = 1 TO 9: a(1) = U
  4.     FOR S = 0 TO 9: a(2) = S
  5.         FOR A = 0 TO 9: a(3) = A
  6.             FOR R = 0 TO 9: a(4) = R
  7.                 FOR P = 1 TO 9: a(5) = P
  8.                     FOR E = 0 TO 9: a(6) = E
  9.                         FOR C = 0 TO 9: a(7) = C
  10.                             FOR xx = 1 TO 6
  11.                                 FOR yy = xx + 1 TO 7
  12.                                     IF a(xx) = a(yy) THEN GOTO skip
  13.                                 NEXT
  14.                             NEXT
  15.                             USA = 10 ^ 2 * U + 10 ^ 1 * S + 10 ^ 0 * A
  16.                             USSR = 10 ^ 3 * U + 10 ^ 2 * S + 10 ^ 1 * S + 10 ^ 0 * R
  17.                             PEACE = 10 ^ 4 * P + 10 ^ 3 * E + 10 ^ 2 * A + 10 ^ 1 * C + 10 ^ 0 * E
  18.                             IF USA + USSR = PEACE THEN
  19.                                 PRINT " USA", " USSR", " PEACE"
  20.                                 PRINT USA, USSR, PEACE
  21.                             END IF
  22.                             skip:
  23.                         NEXT
  24.                     NEXT
  25.                 NEXT
  26.             NEXT
  27.         NEXT
  28.     NEXT
  29.  

Next up, do one that can add more than 2 words.
« Last Edit: August 31, 2020, 12:26:28 am by bplus »

Offline bplus

  • Global Moderator
  • Forum Resident
  • Posts: 8053
  • b = b + ...
    • View Profile
Re: Rebus of Letters
« Reply #10 on: August 31, 2020, 03:19:37 am »
Here is latest from updated program writer, adding 4 words letters to equal the fith words letters!
Code: QB64: [Select]
  1. _TITLE "one nine twenty fifty eighty Solver.bas" ' written by Cryptarithm Program Writer +.bas b+ 2020-08-31
  2. DIM a(10)
  3. FOR e = 1 TO 9: a(1) = e
  4.     FOR i = 0 TO 9: a(2) = i
  5.         FOR g = 0 TO 9: a(3) = g
  6.             FOR h = 0 TO 9: a(4) = h
  7.                 FOR t = 1 TO 9: a(5) = t
  8.                     FOR y = 0 TO 9: a(6) = y
  9.                         FOR f = 1 TO 9: a(7) = f
  10.                             FOR w = 0 TO 9: a(8) = w
  11.                                 FOR n = 1 TO 9: a(9) = n
  12.                                     FOR o = 1 TO 9: a(10) = o
  13.                                         FOR xx = 1 TO 9
  14.                                             FOR yy = xx + 1 TO 10
  15.                                                 IF a(xx) = a(yy) THEN GOTO skip
  16.                                             NEXT
  17.                                         NEXT
  18.                                         one = 10 ^ 2 * o + 10 ^ 1 * n + 10 ^ 0 * e
  19.                                         nine = 10 ^ 3 * n + 10 ^ 2 * i + 10 ^ 1 * n + 10 ^ 0 * e
  20.                                         twenty = 10 ^ 5 * t + 10 ^ 4 * w + 10 ^ 3 * e + 10 ^ 2 * n + 10 ^ 1 * t + 10 ^ 0 * y
  21.                                         fifty = 10 ^ 4 * f + 10 ^ 3 * i + 10 ^ 2 * f + 10 ^ 1 * t + 10 ^ 0 * y
  22.                                         eighty = 10 ^ 5 * e + 10 ^ 4 * i + 10 ^ 3 * g + 10 ^ 2 * h + 10 ^ 1 * t + 10 ^ 0 * y
  23.                                         IF one + nine + twenty + fifty = eighty THEN
  24.                                             PRINT " one", "+nine", "+twenty", "+fifty", "=eighty"
  25.                                             PRINT one, nine, twenty, fifty, eighty
  26.                                             PRINT: PRINT "  Press any to end..."
  27.                                             SLEEP
  28.                                             END
  29.                                         END IF
  30.                                         skip:
  31.                                     NEXT
  32.                                 NEXT
  33.                             NEXT
  34.                         NEXT
  35.                     NEXT
  36.                 NEXT
  37.             NEXT
  38.         NEXT
  39.     NEXT
  40. PRINT " Run is done, goodbye!"
  41.  

 
one nine twenty fifty eighty.PNG


Offline bplus

  • Global Moderator
  • Forum Resident
  • Posts: 8053
  • b = b + ...
    • View Profile
Re: Rebus of Letters
« Reply #11 on: August 31, 2020, 02:54:28 pm »
Hey @DANILIN

I guess you like my progress, are you ready for different math operations? How about yourself? Have you formalized an approach to doing these things?

Offline bplus

  • Global Moderator
  • Forum Resident
  • Posts: 8053
  • b = b + ...
    • View Profile
Re: Rebus of Letters
« Reply #12 on: August 31, 2020, 04:26:41 pm »
I knew this stuff looked familiar, we did this one at JB years ago!
Code: QB64: [Select]
  1. _TITLE "noon moon soon june Solver.bas" ' written by Cryptarithm Program Writer +.bas b+ 2020-08-31
  2. DIM a(7)
  3. FOR j = 1 TO 9: a(1) = j
  4.     FOR u = 0 TO 9: a(2) = u
  5.         FOR n = 1 TO 9: a(3) = n
  6.             FOR e = 0 TO 9: a(4) = e
  7.                 FOR s = 1 TO 9: a(5) = s
  8.                     FOR o = 0 TO 9: a(6) = o
  9.                         FOR m = 1 TO 9: a(7) = m
  10.                             FOR xx = 1 TO 6
  11.                                 FOR yy = xx + 1 TO 7
  12.                                     IF a(xx) = a(yy) THEN GOTO skip
  13.                                 NEXT
  14.                             NEXT
  15.                             noon = 10 ^ 3 * n + 10 ^ 2 * o + 10 ^ 1 * o + 10 ^ 0 * n
  16.                             moon = 10 ^ 3 * m + 10 ^ 2 * o + 10 ^ 1 * o + 10 ^ 0 * n
  17.                             soon = 10 ^ 3 * s + 10 ^ 2 * o + 10 ^ 1 * o + 10 ^ 0 * n
  18.                             june = 10 ^ 3 * j + 10 ^ 2 * u + 10 ^ 1 * n + 10 ^ 0 * e
  19.                             IF noon + moon + soon = june THEN
  20.                                 PRINT " noon", "+moon", "+soon", "=june"
  21.                                 PRINT noon, moon, soon, june
  22.                                 PRINT: PRINT "  Press any to end..."
  23.                                 SLEEP
  24.                                 END
  25.                             END IF
  26.                             skip:
  27.                         NEXT
  28.                     NEXT
  29.                 NEXT
  30.             NEXT
  31.         NEXT
  32.     NEXT
  33. PRINT " Run is done, goodbye!"
  34.  

Found some lovely Multiplication Puzzles :) 1 OK Division and 2 Subtraction puzzles.

Offline bplus

  • Global Moderator
  • Forum Resident
  • Posts: 8053
  • b = b + ...
    • View Profile
Re: Rebus of Letters
« Reply #13 on: August 31, 2020, 10:29:43 pm »
Yes subtraction working:
Code: QB64: [Select]
  1. _TITLE "research sources careless Solver.bas" ' written by Cryptarithm Program Writer ASMD.bas b+ 2020-08-31
  2. DIM a(9)
  3. FOR c = 1 TO 9: a(1) = c
  4.     FOR a = 0 TO 9: a(2) = a
  5.         FOR r = 1 TO 9: a(3) = r
  6.             FOR e = 0 TO 9: a(4) = e
  7.                 FOR l = 0 TO 9: a(5) = l
  8.                     FOR s = 1 TO 9: a(6) = s
  9.                         FOR o = 0 TO 9: a(7) = o
  10.                             FOR u = 0 TO 9: a(8) = u
  11.                                 FOR h = 0 TO 9: a(9) = h
  12.                                     FOR xx = 1 TO 8
  13.                                         FOR yy = xx + 1 TO 9
  14.                                             IF a(xx) = a(yy) THEN GOTO skip
  15.                                         NEXT
  16.                                     NEXT
  17.                                     research = 10 ^ 7 * r + 10 ^ 6 * e + 10 ^ 5 * s + 10 ^ 4 * e + 10 ^ 3 * a + 10 ^ 2 * r + 10 ^ 1 * c + 10 ^ 0 * h
  18.                                     sources = 10 ^ 6 * s + 10 ^ 5 * o + 10 ^ 4 * u + 10 ^ 3 * r + 10 ^ 2 * c + 10 ^ 1 * e + 10 ^ 0 * s
  19.                                     careless = 10 ^ 7 * c + 10 ^ 6 * a + 10 ^ 5 * r + 10 ^ 4 * e + 10 ^ 3 * l + 10 ^ 2 * e + 10 ^ 1 * s + 10 ^ 0 * s
  20.                                     IF research - sources = careless THEN
  21.                                         PRINT " research", "-sources", "=careless"
  22.                                         PRINT research, sources, careless
  23.                                         PRINT: PRINT "  Press any to end..."
  24.                                         SLEEP
  25.                                         END
  26.                                     END IF
  27.                                     skip:
  28.                                 NEXT
  29.                             NEXT
  30.                         NEXT
  31.                     NEXT
  32.                 NEXT
  33.             NEXT
  34.         NEXT
  35.     NEXT
  36. PRINT " Run is done, goodbye!"

I think this is the one where I had to add:
Code: QB64: [Select]
line to the programs because the e notation popped up in the answer.


Multiplication for the little there was to try:
Code: QB64: [Select]
  1. _TITLE "hip hip hurray Solver.bas" ' written by Cryptarithm Program Writer ASMD.bas b+ 2020-08-31
  2. DIM a(7)
  3. FOR h = 1 TO 9: a(1) = h
  4.     FOR u = 0 TO 9: a(2) = u
  5.         FOR r = 0 TO 9: a(3) = r
  6.             FOR a = 0 TO 9: a(4) = a
  7.                 FOR y = 0 TO 9: a(5) = y
  8.                     FOR i = 0 TO 9: a(6) = i
  9.                         FOR p = 0 TO 9: a(7) = p
  10.                             FOR xx = 1 TO 6
  11.                                 FOR yy = xx + 1 TO 7
  12.                                     IF a(xx) = a(yy) THEN GOTO skip
  13.                                 NEXT
  14.                             NEXT
  15.                             hip = 10 ^ 2 * h + 10 ^ 1 * i + 10 ^ 0 * p
  16.                             hip = 10 ^ 2 * h + 10 ^ 1 * i + 10 ^ 0 * p
  17.                             hurray = 10 ^ 5 * h + 10 ^ 4 * u + 10 ^ 3 * r + 10 ^ 2 * r + 10 ^ 1 * a + 10 ^ 0 * y
  18.                             IF hip * hip = hurray THEN
  19.                                 PRINT " hip", "*hip", "=hurray"
  20.                                 PRINT hip, hip, hurray
  21.                                 PRINT: PRINT "  Press any to end..."
  22.                                 SLEEP
  23.                                 END
  24.                             END IF
  25.                             skip:
  26.                         NEXT
  27.                     NEXT
  28.                 NEXT
  29.             NEXT
  30.         NEXT
  31.     NEXT
  32. PRINT " Run is done, goodbye!"
  33.  
And some division:
Code: QB64: [Select]
  1. _TITLE "riding red hood Solver.bas" ' written by Cryptarithm Program Writer ASMD.bas b+ 2020-08-31
  2. DIM a(8)
  3. FOR h = 1 TO 9: a(1) = h
  4.     FOR o = 0 TO 9: a(2) = o
  5.         FOR d = 0 TO 9: a(3) = d
  6.             FOR r = 1 TO 9: a(4) = r
  7.                 FOR e = 0 TO 9: a(5) = e
  8.                     FOR i = 0 TO 9: a(6) = i
  9.                         FOR n = 0 TO 9: a(7) = n
  10.                             FOR g = 0 TO 9: a(8) = g
  11.                                 FOR xx = 1 TO 7
  12.                                     FOR yy = xx + 1 TO 8
  13.                                         IF a(xx) = a(yy) THEN GOTO skip
  14.                                     NEXT
  15.                                 NEXT
  16.                                 riding = 10 ^ 5 * r + 10 ^ 4 * i + 10 ^ 3 * d + 10 ^ 2 * i + 10 ^ 1 * n + 10 ^ 0 * g
  17.                                 red = 10 ^ 2 * r + 10 ^ 1 * e + 10 ^ 0 * d
  18.                                 hood = 10 ^ 3 * h + 10 ^ 2 * o + 10 ^ 1 * o + 10 ^ 0 * d
  19.                                 IF riding \ red = hood THEN
  20.                                     PRINT " riding", "\red", "=hood"
  21.                                     PRINT riding, red, hood
  22.                                     PRINT: PRINT "  Press any to end..."
  23.                                     SLEEP
  24.                                     END
  25.                                 END IF
  26.                                 skip:
  27.                             NEXT
  28.                         NEXT
  29.                     NEXT
  30.                 NEXT
  31.             NEXT
  32.         NEXT
  33.     NEXT
  34. PRINT " Run is done, goodbye!"
  35.  

Alas the really cool division: ANTARTICA \ AMERICA = ASIA failed to find a solution.

Offline DANILIN

  • Forum Regular
  • Posts: 128
    • View Profile
    • Danilin youtube
Re: Rebus of Letters
« Reply #14 on: September 01, 2020, 09:37:54 am »
improvement possible: variable number of letters
then nested comparison loops will be universal

Code: QB64: [Select]
  1. NN=5
  2. dim a(NN)
  3. ...
  4. FOR xx = 1 TO NN-1
  5.    FOR yy = xx + 1 TO NN
  6.       IF a(xx) = a(yy) THEN GOTO skip
Russia looks world from future. big data is peace data.
https://youtube.com/playlist?list=PLBBTP9oVY7IagpH0g9FNUQ8JqmHwxDDDB
i never recommend anything to anyone and always write only about myself