1234 as abcd | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 4

1234 as abcd

If I give input as 23451 it will be convert as bcdea &it will be print in order like12345.......&abcde......

11th Aug 2019, 5:01 AM
๐Ÿ‘€ Sandy๐Ÿ‘€
๐Ÿ‘€  Sandy๐Ÿ‘€ - avatar
9 Answers
+ 7
What language? Your attempts?
11th Aug 2019, 5:23 AM
Hatsy Rei
Hatsy Rei - avatar
+ 6
This is a trivial problem. Basically maintain a list of 10 characters(a-j). Then pass the list of numbers(input) in a for loop so you can get character at index position. Which can be pushed to an array for packing the characters later. #pseudo code str = [a b c d e f g h i j] inp = [4 5 7] for i inp res.push(str[i]) end pack (res) Real code: https://code.sololearn.com/c8yjROpvHSku/ Edit: for zero based index 1 needs to be reduced from input numbers
11th Aug 2019, 9:32 AM
Lord Krishna
Lord Krishna - avatar
+ 4
Sandhya What language are you using to code this?
11th Aug 2019, 5:37 AM
๐Ÿ‘‘ Prometheus ๐Ÿ‡ธ๐Ÿ‡ฌ
๐Ÿ‘‘ Prometheus ๐Ÿ‡ธ๐Ÿ‡ฌ - avatar
+ 3
Hint: Every number maps to only one letter. Use relevant datatypes to help you with this associativity.
11th Aug 2019, 5:23 AM
๐Ÿ‘‘ Prometheus ๐Ÿ‡ธ๐Ÿ‡ฌ
๐Ÿ‘‘ Prometheus ๐Ÿ‡ธ๐Ÿ‡ฌ - avatar
+ 3
In cpp
11th Aug 2019, 5:38 AM
๐Ÿ‘€ Sandy๐Ÿ‘€
๐Ÿ‘€  Sandy๐Ÿ‘€ - avatar
+ 2
Any language
11th Aug 2019, 5:36 AM
๐Ÿ‘€ Sandy๐Ÿ‘€
๐Ÿ‘€  Sandy๐Ÿ‘€ - avatar
+ 2
Sandhya At least specify the language in the Relevant Tags. 'conversion' didn't help deducting your question scope.
11th Aug 2019, 6:11 AM
Ipang
+ 2
If we give input like 1423 it could be converted into adbc &it should be print in order like abcd
11th Aug 2019, 9:42 AM
๐Ÿ‘€ Sandy๐Ÿ‘€
๐Ÿ‘€  Sandy๐Ÿ‘€ - avatar
0
You could initialize an array of chars with size 26+1, 0 position will be empty, first position will contain a .... example: array [1] = 'a';
12th Aug 2019, 9:55 PM
Dimitrios
Dimitrios - avatar