Numerology

31 views
Skip to first unread message

Fuad Omari

unread,
Feb 27, 2023, 9:35:49 AM2/27/23
to The Ring Programming Language

i want to do some numerology
https://en.wikipedia.org/wiki/Numerology
like in old days .getting a text then extract its letters one by one converting it to upper case, then getting its ascii then subtract 64 (so 'A' ascii is 1 'Z' is 26)
i don't want these numbers but suppose it refers to array from 1 tp 26 which contains the values of letters i want.
look the code
if there is another way to do that thank you
load "stdlibcore.ring"
txt = "RED GREEN BLUE YELLOW"
txt = TRIMALL(txt)
total = 0
//values of choice to alphabet chars
abc = [5, 4, 6, 11, 8, 24, 22, 1, 25, 12, 21, 15, 2, 17, 23, 9, 13, 18, 26, 20, 7, 19, 16, 3, 14, 10]
for i = 1 to len(txt)
oneChar = txt[i]
oneCharVal = ascii(oneChar)-64
total = total + abc[oneCharVal]
see oneCharVal see "__" see abc[oneCharVal] +nl
next
? "======="
? "       " +total

numerology.ring
Message has been deleted
Message has been deleted

Bert Mariani

unread,
Feb 27, 2023, 4:53:05 PM2/27/23
to The Ring Programming Language
Hi Faud

Try this modification
Ring Index starts at 1, not 0

load "stdlibcore.ring"
txt = "RED GREEN BLUE YELLOW"
txt = TRIMALL(txt)
total = 0
//values of choice to alphabet chars
abc     = [0, 5, 4, 6, 11, 8, 24, 22, 1, 25, 12, 21, 15, 2, 17, 23, 9, 13, 18, 26, 20, 7, 19, 16, 3, 14, 10]
letters = [" ","A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z"]

for i = 1 to len(txt)
  oneChar    = txt[i]
  oneCharVal = ascii(oneChar)-64
  total      = total + abc[oneCharVal +1]
  see "Pos: "+ oneCharVal +" => Nbr: "+ abc[oneCharVal+1] +" => Let: "+ letters[oneCharVal+1] +nl

next
? "======="
? "       " +total

=====================

Pos: 18 => Nbr: 18 => Let: R
Pos: 5 => Nbr: 8 => Let: E
Pos: 4 => Nbr: 11 => Let: D
Pos: 7 => Nbr: 22 => Let: G
Pos: 18 => Nbr: 18 => Let: R
Pos: 5 => Nbr: 8 => Let: E
Pos: 5 => Nbr: 8 => Let: E
Pos: 14 => Nbr: 17 => Let: N
Pos: 2 => Nbr: 4 => Let: B
Pos: 12 => Nbr: 15 => Let: L
Pos: 21 => Nbr: 7 => Let: U
Pos: 5 => Nbr: 8 => Let: E
Pos: 25 => Nbr: 14 => Let: Y
Pos: 5 => Nbr: 8 => Let: E
Pos: 12 => Nbr: 15 => Let: L
Pos: 12 => Nbr: 15 => Let: L
Pos: 15 => Nbr: 23 => Let: O
Pos: 23 => Nbr: 16 => Let: W
=======
       235
Message has been deleted

Fuad Omari

unread,
Feb 28, 2023, 1:44:15 AM2/28/23
to The Ring Programming Language
Thanks Bert for the variations ,i was using the algorithm with powerbasic long time ago , but fortunately i have discovered ring which have open horizons and more versatile
Reply all
Reply to author
Forward
0 new messages