Skip to main content
added 44 characters in body
Source Link
Justin Mariner
  • 5k
  • 1
  • 13
  • 18

Japt, 88 6 bytes

-2 bytes thanks to @ETHproductions

ò¦ ®ì2Ãxxì2

Try it online!Try it online!

Explanation

Implicit input: [1, 1, 1, -1, -1, -1, -1, 1, 1]

ò¦

Partition input array (ò) between different (¦) elements:
[[1, 1, 1], [-1, -1, -1, -1], [1, 1]]

®ì2ì2

Map each partition (®) to itself parsed as an array of base-2 digits (ì): [7, -15, 3]

Ãxx

End mapping (Ã) andGet the sum (x) of the resulting array: -5

Japt, 8 bytes

ò¦ ®ì2Ãx

Try it online!

Explanation

Implicit input: [1, 1, 1, -1, -1, -1, -1, 1, 1]

ò¦

Partition input array (ò) between different (¦) elements:
[[1, 1, 1], [-1, -1, -1, -1], [1, 1]]

®ì2

Map each partition (®) to itself parsed as an array of base-2 digits (ì): [7, -15, 3]

Ãx

End mapping (Ã) and sum (x): -5

Japt, 8 6 bytes

-2 bytes thanks to @ETHproductions

ò¦ xì2

Try it online!

Explanation

Implicit input: [1, 1, 1, -1, -1, -1, -1, 1, 1]

ò¦

Partition input array (ò) between different (¦) elements:
[[1, 1, 1], [-1, -1, -1, -1], [1, 1]]

ì2

Map each partition to itself parsed as an array of base-2 digits (ì): [7, -15, 3]

x

Get the sum (x) of the resulting array: -5

added 498 characters in body
Source Link
Justin Mariner
  • 5k
  • 1
  • 13
  • 18

Japt, 118 bytes

ò¦ ®m<<Ãc x®ì2Ãx

Try it online!Try it online!

Explanation

Implicit input: [1, 1, 1, -1, -1, -1, -1, 1, 1]

ò¦

Partition input array (ò) between different (¦) elements:
[[1, 1, 1], [-1, -1, -1, -1], [1, 1]]

®m®ì2

Map each partition to itself (®) with each element mapped to itself parsed as an array of base-2 digits (mì)...

<<

The element, left-shifted over by the current index.
: [[1, 2, 4], [-1, -2, -4[7, -8], [115, 2]]3]

Ãc xÃx

End mapping (Ã), flatten array (c), and sum (x).
[1, 2, 4, -1, -2, -4, -8, 1, 2] =>: -5

Japt, 11 bytes

ò¦ ®m<<Ãc x

Try it online!

Explanation

Implicit input: [1, 1, 1, -1, -1, -1, -1, 1, 1]

ò¦

Partition input array (ò) between different (¦) elements:
[[1, 1, 1], [-1, -1, -1, -1], [1, 1]]

®m

Map each partition to itself (®) with each element mapped to (m)...

<<

The element, left-shifted over by the current index.
[[1, 2, 4], [-1, -2, -4, -8], [1, 2]]

Ãc x

End mapping (Ã), flatten array (c), and sum (x).
[1, 2, 4, -1, -2, -4, -8, 1, 2] => -5

Japt, 8 bytes

ò¦ ®ì2Ãx

Try it online!

Explanation

Implicit input: [1, 1, 1, -1, -1, -1, -1, 1, 1]

ò¦

Partition input array (ò) between different (¦) elements:
[[1, 1, 1], [-1, -1, -1, -1], [1, 1]]

®ì2

Map each partition (®) to itself parsed as an array of base-2 digits (ì): [7, -15, 3]

Ãx

End mapping (Ã) and sum (x): -5

added 498 characters in body
Source Link
Justin Mariner
  • 5k
  • 1
  • 13
  • 18

Japt, 11 bytes

ò¦ ®m<<Ãc x

Try it online!

Explanation

Implicit input: [1, 1, 1, -1, -1, -1, -1, 1, 1]

ò¦

Partition input array (ò) between different (¦) elements:
[[1, 1, 1], [-1, -1, -1, -1], [1, 1]]

®m

Map each partition to itself (®) with each element mapped to (m)...

<<

The element, left-shifted over by the current index.
[[1, 2, 4], [-1, -2, -4, -8], [1, 2]]

Ãc x

End mapping (Ã), flatten array (c), and sum (x).
[1, 2, 4, -1, -2, -4, -8, 1, 2] => -5

Japt, 11 bytes

ò¦ ®m<<Ãc x

Try it online!

Japt, 11 bytes

ò¦ ®m<<Ãc x

Try it online!

Explanation

Implicit input: [1, 1, 1, -1, -1, -1, -1, 1, 1]

ò¦

Partition input array (ò) between different (¦) elements:
[[1, 1, 1], [-1, -1, -1, -1], [1, 1]]

®m

Map each partition to itself (®) with each element mapped to (m)...

<<

The element, left-shifted over by the current index.
[[1, 2, 4], [-1, -2, -4, -8], [1, 2]]

Ãc x

End mapping (Ã), flatten array (c), and sum (x).
[1, 2, 4, -1, -2, -4, -8, 1, 2] => -5

Source Link
Justin Mariner
  • 5k
  • 1
  • 13
  • 18
Loading