Skip to main content
Commonmark migration
Source Link

#POSIX sh + tr + dc, 27 25 bytes

POSIX sh + tr + dc, 27 25 bytes

dc -e "0d`tr -sc 0-9 +`p"

Converts any run of non-digits (including the terminating newline) to + operator, pushes two zeros onto the stack (in case input begins with non-digit), adds them all and prints the result. There may be an extra zero remaining at bottom of stack, but we don't care about that.

#POSIX sh + tr + dc, 27 25 bytes

dc -e "0d`tr -sc 0-9 +`p"

Converts any run of non-digits (including the terminating newline) to + operator, pushes two zeros onto the stack (in case input begins with non-digit), adds them all and prints the result. There may be an extra zero remaining at bottom of stack, but we don't care about that.

POSIX sh + tr + dc, 27 25 bytes

dc -e "0d`tr -sc 0-9 +`p"

Converts any run of non-digits (including the terminating newline) to + operator, pushes two zeros onto the stack (in case input begins with non-digit), adds them all and prints the result. There may be an extra zero remaining at bottom of stack, but we don't care about that.

'0 0 ' == '0d'
Source Link
Toby Speight
  • 6.3k
  • 1
  • 24
  • 41

#POSIX sh + tr + dc, 2727 25 bytes

dc -e "0 0 `tr"0d`tr -sc 0-9 +`p"

Converts any run of non-digits (including the terminating newline) to + operator, pushes two zeros onto the stack (in case input begins with non-digit), adds them all and prints the result. There may be an extra zero remaining at bottom of stack, but we don't care about that.

#POSIX sh + tr + dc, 27 bytes

dc -e "0 0 `tr -sc 0-9 +`p"

Converts any run of non-digits to + operator, pushes two zeros onto the stack (in case input begins with non-digit), adds them all and prints the result. There may be an extra zero remaining at bottom of stack, but we don't care about that.

#POSIX sh + tr + dc, 27 25 bytes

dc -e "0d`tr -sc 0-9 +`p"

Converts any run of non-digits (including the terminating newline) to + operator, pushes two zeros onto the stack (in case input begins with non-digit), adds them all and prints the result. There may be an extra zero remaining at bottom of stack, but we don't care about that.

Source Link
Toby Speight
  • 6.3k
  • 1
  • 24
  • 41

#POSIX sh + tr + dc, 27 bytes

dc -e "0 0 `tr -sc 0-9 +`p"

Converts any run of non-digits to + operator, pushes two zeros onto the stack (in case input begins with non-digit), adds them all and prints the result. There may be an extra zero remaining at bottom of stack, but we don't care about that.