Skip to main content
golfed 2 bytes
Source Link
ETHproductions
  • 50.1k
  • 6
  • 94
  • 240

Japt, 7 66 4 bytes

å+ x

Try it online!

Explanation

å+ x    Implicit: input = digit list
å+      Cumulative reduce by addition. Gives the sum of each prefix.
   x    Sum.

Old solution:

å+ ¬¬x

Try it online!

Explanation

å+ ¬¬x   Implicit: input = string
å+       Cumulative reduce by concatenation. Gives the list of prefixes.
   ¬     Join into a single string of digits.
    ¬    Split back into digits.
     x   Sum.
         Implicit: output result of last expression

Japt, 7 6 bytes

å+ ¬¬x

Try it online!

Explanation

å+ ¬¬x   Implicit: input = string
å+       Cumulative reduce by concatenation. Gives the list of prefixes.
   ¬     Join into a single string of digits.
    ¬    Split back into digits.
     x   Sum.
         Implicit: output result of last expression

Japt, 7 6 4 bytes

å+ x

Try it online!

Explanation

å+ x    Implicit: input = digit list
å+      Cumulative reduce by addition. Gives the sum of each prefix.
   x    Sum.

Old solution:

å+ ¬¬x

Try it online!

Explanation

å+ ¬¬x   Implicit: input = string
å+       Cumulative reduce by concatenation. Gives the list of prefixes.
   ¬     Join into a single string of digits.
    ¬    Split back into digits.
     x   Sum.
         Implicit: output result of last expression
golfed a byte
Source Link
ETHproductions
  • 50.1k
  • 6
  • 94
  • 240

Japt, 77 6 bytes

å+ x_¬x¬¬x

Try it online!Try it online!

Explanation

å+ ¬¬x   Implicit: input = string
å+       Cumulative reduce by concatenation. Gives the list of prefixes.
   ¬     Join into a single string of digits.
    ¬    Split back into digits.
     x   Sum.
         Implicit: output result of last expression

Japt, 7 bytes

å+ x_¬x

Try it online!

Japt, 7 6 bytes

å+ ¬¬x

Try it online!

Explanation

å+ ¬¬x   Implicit: input = string
å+       Cumulative reduce by concatenation. Gives the list of prefixes.
   ¬     Join into a single string of digits.
    ¬    Split back into digits.
     x   Sum.
         Implicit: output result of last expression
Source Link
ETHproductions
  • 50.1k
  • 6
  • 94
  • 240

Japt, 7 bytes

å+ x_¬x

Try it online!