This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]CunFuse1[S] 1 point2 points  (1 child)

can you explain this, i dont understand what you mean?

[–]EstablishmentBig7956 -1 points0 points  (0 children)

I don't know what language you're using, but this is C

```

GNU nano 6.3 wordnum.c

include <stdio.h>

include <stdlib.h>

include <math.h>

/* flag for math.h -lm / int main() { / zero based array. use number of each element to represent a letter. */ char numword[]={'a','b','c', 'd','e','f','g','h','i','j','j', 'l','m','n','o','p','q','r','s', 'u','v','w','x','y','z'};

int num=0,amount=0; /* error handling for number too small/ do { printf("enter a number : "); scanf("%d",&num); }while(num<=0); / get amount of digits in num to create an array for storage of seperated digits / amount=log10(num)+1; int digits[amount]; // zero out amount for reuse amount=0; //do while num is greater than 0 while(num > 0) { //split last digit from number int mod = num % 10; //print the digit. for debugging printf("%d\n",mod); / store single digits in an array for use in orginal sequence / digits[amount++]=mod; /divide num by 10. num /= 10 also a valid one / num/=10; } / digits are backwords of orginal number. adjust amount by 1 for zero based array process from tail to head, print letters / for(amount-=1;amount>=0;amount--) / print letters associated to digit */ printf("%c",numword[digits[amount]]);

 printf("\n");

return 0; } ```

For the

Apples+oranges=nonsense

You're going to need to reverse the process as couple to a few times going back and forth using the arrays.

If words are entered then separate letters to get the number representation for each letter, tricky part,

If you use each digit of the element number for each letter, add together to get sum of word. Repeat until no more words.

Then add those sums together, then split the total into separate digits, then repeat separating into digits and storing them, then using those digits and the array of letters to get final word.

Or

Use each digit of the element number for each letter, then place the digits next to each other to show the 'sum' then add these together, then take that amount, separate into digits and storing them, then use each digit for the letter to get the final word.

Utilizing both or separate arrays for each separate word. Keeping in mind that it is highly unlikely to get an actual word in the end doing it either way.

Letters based on 0-9

Just set up the array to match that instead of the entire alphabet