+ 11

🍇🍇CHALLENGE🍉🍉. IT'S ALL ABOUT BASES. Objective: 👉 Write aprogram, that convert a number in a certain base to another base

FORMAT : 👉Your program should take three input : ☝The number to be converted ✌ The base of the number to be converted 👌The base to which you wish your number to be converted to. Example : number : 2E base : 16 tobase: 5 Output =141 ---- number: 3245 base: 6 tobase: 9 Output = 1022 LIMITATIONS : 👉Don't use module/built function that converts, example bin(),hex() Here's mine: https://code.sololearn.com/cRFGPQn2VEts/?ref=app The first 10 correct codes will reposted by me and get best answer mark. DO IT

23rd Nov 2017, 8:49 AM
Justine Ogaraku
Justine Ogaraku - avatar
10 Respuestas
23rd Nov 2017, 7:56 PM
LukArToDo
LukArToDo - avatar
+ 10
@Justine Hahaha 👍 There will be codes in other languages, be patient... 😉
23rd Nov 2017, 8:25 PM
LukArToDo
LukArToDo - avatar
+ 8
Hmmmm..... What's happening here, two correct Java code. I'm envious of Java already 😂.
23rd Nov 2017, 8:16 PM
Justine Ogaraku
Justine Ogaraku - avatar
+ 7
@Vadim hmmmmmm...... I'll be expecting it 😁
24th Nov 2017, 6:08 AM
Justine Ogaraku
Justine Ogaraku - avatar
+ 6
My try.. OOP style, creates base objects and can perform some operations.. feel free to test and implement any operator overloading! Hope you enjoy it! https://code.sololearn.com/cLlqQ5bQ0Ztt/?ref=app
26th Nov 2017, 3:57 PM
AZTECCO
AZTECCO - avatar
+ 4
Since Java is positioned as a cross-platform language, I did not go through an easy way of 10 + c - 'a'. Because I did not expect the letters in the code table to go in a row. https://code.sololearn.com/csm9e4p4r307/?ref=app
23rd Nov 2017, 1:50 PM
Вадим Сухотин (Vadim Sukhotin)
Вадим Сухотин (Vadim Sukhotin) - avatar
+ 4
@Justine. I'll try to translate my code into C##. Patience...
23rd Nov 2017, 8:46 PM
Вадим Сухотин (Vadim Sukhotin)
Вадим Сухотин (Vadim Sukhotin) - avatar
+ 3
Here I and in C# was trained. https://code.sololearn.com/cg4HK8PyxrHy
24th Nov 2017, 6:19 PM
Вадим Сухотин (Vadim Sukhotin)
Вадим Сухотин (Vadim Sukhotin) - avatar
+ 2
Hmmm... what happens past base 36 when all numbers/letters get used up?
24th Nov 2017, 11:15 AM
blackcat1111
blackcat1111 - avatar
+ 1
Here's my try in Python, https://code.sololearn.com/cmPzpa1CAH9O/ The code logic is pretty much up to line 28, everything else's basically making use of it. Samples are randomly generated as user input in SL is annoying. Also, literals and integers' signedness is not taken into account at all, but such addition to the code should be trivial. By the way @Justine, your code accepts invalid input with regards to the submitted source base. As in, if we input the string '1Z' and its source base as 14, it continues execution generating erroneous output, like 49 if the output base is 10, when in reality the character 'Z' is out of the base 14 range. Mine, on the other hand, raises a "ValueError('substring not found')" exception (by the `str.index` method) since I also slice my `BASE36` string to the according base parameter (line 21), which I deliberately let propagate as it's enough to signal out of base-range literals. (Sorry for the TL;DR wall of text :) )
25th Nov 2017, 4:41 AM
Edgar Garrido
Edgar Garrido - avatar