Digit sum

Take an integer input, take the digit sum until one digit is left.
123456789->45->9
3264438924656432->71->8

IN

123456789

OUT

9

IN

3264438924656432

OUT

8

IN

86091795777214198982302874082228117380720385924328887730971212579342203308879143943429746338049565724

OUT

7
Login to submit solution


14 symbols perl failed test 3 Wrong answer
8
instead of
7
Sun Feb 22 20:41:54 2015 vakorol
#!/usr/bin/perl -p0
$_=--$_%9+1
14 symbols perl failed test 3 Wrong answer
8
instead of
7
Sun Feb 22 20:42:45 2015 vakorol
#!/usr/bin/perl -p0
$_=--$_%9+1
15 symbols perl failed test 3 Wrong answer
8
instead of
7
Fri Feb 27 05:39:43 2015 bluebear94
#!/usr/bin/perl -p
$_=($_-1)%9+1
15 symbols ruby2.0 failed test 1 Code error

./code:2:in `<main>': undefined method `-' for "123456789":String (NoMethodError)

Fri Feb 27 05:41:10 2015 bluebear94
#!/usr/bin/ruby2.0 -p
$_=($_-1)%9+1
25 symbols perl failed test 3 Wrong answer
4
instead of
7
Fri Feb 27 11:08:45 2015 bluebear94
#!/usr/bin/perl -p0
use bigint;$_=--$_%9+1
62 symbols haskell failed test 1 Code error

code:3:35: Illegal literal in type (use DataKinds to enable): 1

Fri Feb 27 11:12:42 2015 bluebear94
main=do
 s<-readLine
 putStrLn(show$((read s)::Integer-1)%9+1)
67 symbols haskell failed test 1 Code error

code:3:36: Illegal literal in type (use DataKinds to enable): 1

Fri Feb 27 11:13:20 2015 bluebear94
main=do
 s<-readLine
 putStrLn(show$((read s)::Integer -1)`mod`9+1)
68 symbols haskell failed test 1 Code error

code:3:37: Illegal literal in type (use DataKinds to enable): 1

Fri Feb 27 11:13:46 2015 bluebear94
main=do
 s<-readLine
 putStrLn(show$((read s)::Integer - 1)`mod`9+1)
68 symbols haskell failed test 1 Code error

code:3:36: Illegal literal in type (use DataKinds to enable): 1

Fri Feb 27 11:14:03 2015 bluebear94
main=do
 s<- readLine
 putStrLn(show$((read s)::Integer -1)`mod`9+1)
69 symbols haskell failed test 1 Code error

code:3:37: Illegal literal in type (use DataKinds to enable): 1

Fri Feb 27 11:14:19 2015 bluebear94
main=do
 s<- readLine
 putStrLn(show$((read s)::Integer - 1)`mod`9+1)
67 symbols haskell failed test 1 Code error

code:2:5: Not in scope: ‘readLine’ Perhaps you meant one of these: ‘readFile’ (imported from Prelude), ‘readLn’ (imported from Prelude), ‘readList’ (imported from Prelude)

Fri Feb 27 11:16:06 2015 bluebear94
main=do
 s<-readLine
 putStrLn$show$((read s::Integer) - 1)`mod`9+1
63 symbols haskell failed test 1 Code error

code: user error (Prelude.readIO: no parse)

Fri Feb 27 11:16:39 2015 bluebear94
main=do
 s<-readLn
 putStrLn$show$((read s::Integer)-1)`mod`9+1
16 symbols python2 failed test 1 Wrong answer
0
instead of
9
Sun Mar 22 21:12:17 2015 LLcoolNJ
print(input())%9
19 symbols bash failed test 3 Wrong answer
6
instead of
7
Wed Apr 1 04:48:51 2015 MasWag
awk '$0=($1-1)%9+1'
34 symbols perl failed test 1 Wrong answer
0
instead of
9
Fri Apr 24 00:34:40 2015 James Curtis-Smith
($t+=$_)%=9 for split ,<>;print $t
18 symbols ruby2.0 failed test 1 Wrong answer
123456788
instead of
9
Wed May 6 20:42:47 2015 NightFury1
p(gets.to_i-1)&9+1
66 symbols nodejs failed test 1 Code error

net.js:612 throw new TypeError('invalid data'); ^ TypeError: invalid data at Socket.write (net.js:612:11) at Object.<anonymous> (/opt/share/code:1:78) at Module._compile (module.js:456:26) at Object.Module._extensions..js (module.js:474:10) at Module.load (module.js:356:32) at Function.Module._load (module.js:312:12) at Function.Module.runMain (module.js:497:10) at startup (node.js:119:16) at node.js:902:3

Mon May 11 07:13:43 2015 _nderscore
process.stdout.write(require('fs').readFileSync('/dev/stdin')%9+1)
26 symbols python2 failed test 2 Code error

Traceback (most recent call last): File "./code", line 2, in <module> print [9,a][a] IndexError: list index out of range

Mon Oct 12 15:54:47 2015 BogdanShevchenko
a=input()%9
print [9,a][a]
15 symbols perl failed test 3 Wrong answer
8
instead of
7
Thu Nov 19 14:22:05 2015 bugov
#!/usr/bin/perl -p
$_=($_-1)%9+1
57 symbols python3 failed test 1 Wrong answer
45
9
instead of
9
Wed Nov 25 15:43:27 2015 louietyj
x=int(input())
while x>10:x=sum(map(int,str(x)));print(x)

View all solutions