+ 5

Challenge time! : Add 1 to each digit of a number

Write a code which inputs a number from the user and outputs a number which has each digit incremented by 1 Example : 239 Output : 350 (since 9+1=10 with 1 carry) 123-->234 Happy coding! Answers in C++, Java will be prefered though all languages r welcome!

14th Oct 2017, 3:40 PM
Abhishek Tandon
Abhishek Tandon - avatar
9 Réponses
+ 5
heres mine... with STEP-details ## ( input a number ) https://code.sololearn.com/ccFzmlmE48c5/?ref=app
14th Oct 2017, 6:26 PM
sayan chandra
sayan chandra - avatar
+ 21
https://code.sololearn.com/coN4Atqn87kz/?ref=app
14th Oct 2017, 7:17 PM
Worm
Worm - avatar
14th Oct 2017, 7:51 PM
m abrate
m abrate - avatar
14th Oct 2017, 9:42 PM
m abrate
m abrate - avatar
14th Oct 2017, 8:56 PM
m abrate
m abrate - avatar
+ 4
@sayan Nice code! I really appreciate ur effort!
14th Oct 2017, 6:38 PM
Abhishek Tandon
Abhishek Tandon - avatar
+ 2
n+sum([10**i*(-9 if ((n//10**i)%10)==9) else 1) for i in range(log10(n))])
14th Oct 2017, 4:13 PM
VcC
VcC - avatar
+ 2
☺✌thanks number/0
14th Oct 2017, 6:39 PM
sayan chandra
sayan chandra - avatar
+ 2
with carry this is really simple from math import log10 chgc=lambda n:n+(10**int(log10(n)+1)-1)//9 print(chgc(int(input()))) https://code.sololearn.com/c95wsH0nhFZ4/?ref=app
14th Oct 2017, 9:51 PM
VcC
VcC - avatar