Skip to main content
deleted 189 characters in body
Source Link
plannapus
  • 9k
  • 22
  • 47

R, 35 characters 35 characters (sum of 3086) 26 bytes (sum of 30862305)

sum(as.real(charToRawutf8ToInt(readline())))

Not particularly inventive, apart maybe from the coercion to a numerical form using as.real instead of the more natural as.integer. charToRaw really does all the work. readline() is one character longer than scan(,"") but scan split the input on spaces by default.

Usage:

> sum(as.real(charToRawutf8ToInt(readline())))
Hello World!
[1] 1085
> sum(as.real(charToRawutf8ToInt(readline())))
sum(as.real(charToRawutf8ToInt(readline())))
[1] 30862305
> sum(as.real(charToRawutf8ToInt(readline())))
q/%8hnp>T%y?'wNb\},9krW &D9']K$n;l.3O+tE*$*._B^s!@k\&Cl:EO1zo8sVxEvBxCock_I+2o6 yeX*0Xq:tS^f)!!7=!tk9K<6#/E`ks(D'$z$\6Ac+MT&[s[]_Y(`<g%"w%cW'`c&q)D$0#C$QGf>?A$iawvc,}`9!('`c&q)D$0#C$QGf>?A$iawvc,}`9!(
[1] 14835

R, 35 characters (sum of 3086)

sum(as.real(charToRaw(readline())))

Not particularly inventive, apart maybe from the coercion to a numerical form using as.real instead of the more natural as.integer. charToRaw really does all the work. readline() is one character longer than scan(,"") but scan split the input on spaces by default.

Usage:

> sum(as.real(charToRaw(readline())))
Hello World!
[1] 1085
> sum(as.real(charToRaw(readline())))
sum(as.real(charToRaw(readline())))
[1] 3086
> sum(as.real(charToRaw(readline())))
q/%8hnp>T%y?'wNb\},9krW &D9']K$n;l.3O+tE*$*._B^s!@k\&Cl:EO1zo8sVxEvBxCock_I+2o6 yeX*0Xq:tS^f)!!7=!tk9K<6#/E`ks(D'$z$\6Ac+MT&[s[]_Y(`<g%"w%cW'`c&q)D$0#C$QGf>?A$iawvc,}`9!('`c&q)D$0#C$QGf>?A$iawvc,}`9!(
[1] 14835

R, 35 characters (sum of 3086) 26 bytes (sum of 2305)

sum(utf8ToInt(readline()))

readline() is one character longer than scan(,"") but scan split the input on spaces by default.

Usage:

> sum(utf8ToInt(readline()))
Hello World!
[1] 1085
> sum(utf8ToInt(readline()))
sum(utf8ToInt(readline()))
[1] 2305
> sum(utf8ToInt(readline()))
q/%8hnp>T%y?'wNb\},9krW &D9']K$n;l.3O+tE*$*._B^s!@k\&Cl:EO1zo8sVxEvBxCock_I+2o6 yeX*0Xq:tS^f)!!7=!tk9K<6#/E`ks(D'$z$\6Ac+MT&[s[]_Y(`<g%"w%cW'`c&q)D$0#C$QGf>?A$iawvc,}`9!('`c&q)D$0#C$QGf>?A$iawvc,}`9!(
[1] 14835
Source Link
plannapus
  • 9k
  • 22
  • 47

R, 35 characters (sum of 3086)

sum(as.real(charToRaw(readline())))

Not particularly inventive, apart maybe from the coercion to a numerical form using as.real instead of the more natural as.integer. charToRaw really does all the work. readline() is one character longer than scan(,"") but scan split the input on spaces by default.

Usage:

> sum(as.real(charToRaw(readline())))
Hello World!
[1] 1085
> sum(as.real(charToRaw(readline())))
sum(as.real(charToRaw(readline())))
[1] 3086
> sum(as.real(charToRaw(readline())))
q/%8hnp>T%y?'wNb\},9krW &D9']K$n;l.3O+tE*$*._B^s!@k\&Cl:EO1zo8sVxEvBxCock_I+2o6 yeX*0Xq:tS^f)!!7=!tk9K<6#/E`ks(D'$z$\6Ac+MT&[s[]_Y(`<g%"w%cW'`c&q)D$0#C$QGf>?A$iawvc,}`9!('`c&q)D$0#C$QGf>?A$iawvc,}`9!(
[1] 14835