Skip to main content
edited body
Source Link
Makonede
  • 6.6k
  • 20
  • 49

Jelly, 8 bytes

,CÄḤ×ƊS_

Try it online!

-2 bytes thanks to Bubbler

How it works

,CÄḤ×ƊS_ - Main link. Takes a binary list B on the left
 C       - Complement. Flip the bits of B
,        - Pair with B: [B, B']
     Ɗ   - Last 3 links as a monad f([B, B']):
  Ä      -   Cumulative sum of each
   Ḥ     -   Unhalve
     ×    -   Multiply modified B by B and modified B' by B'
      S  - Columnwise sum
       _ - Subtract B, elementwise

Jelly, 8 bytes

,CÄḤ×ƊS_

Try it online!

-2 bytes thanks to Bubbler

How it works

,CÄḤ×ƊS_ - Main link. Takes a binary list B on the left
 C       - Complement. Flip the bits of B
,        - Pair with B: [B, B']
     Ɗ   - Last 3 links as a monad f([B, B']):
  Ä      -   Cumulative sum of each
   Ḥ     -   Unhalve
     ×   -   Multiply modified B by B and modified B' by B'
      S  - Columnwise sum
       _ - Subtract B, elementwise

Jelly, 8 bytes

,CÄḤ×ƊS_

Try it online!

-2 bytes thanks to Bubbler

How it works

,CÄḤ×ƊS_ - Main link. Takes a binary list B on the left
 C       - Complement. Flip the bits of B
,        - Pair with B: [B, B']
     Ɗ   - Last 3 links as a monad f([B, B']):
  Ä      -   Cumulative sum of each
   Ḥ     -   Unhalve
    ×    -   Multiply modified B by B and modified B' by B'
      S  - Columnwise sum
       _ - Subtract B, elementwise
added 1 character in body
Source Link

Jelly, 108 bytes

,CÄḤ’1¦×ƲSCÄḤ×ƊS_

Try it online!Try it online!

-2 bytes thanks to Bubbler

How it works

,CÄḤ’1¦×ƲSCÄḤ×ƊS_ - Main link. Takes a binary list B on the left
 C         - Complement. Flip the bits of B
,          - Pair with B: [B, B']
       Ɗ Ʋ  - Last 43 links as a monad f([B, B']):
  Ä        -   Cumulative sum of each
   Ḥ       -   Unhalve
     ×   -   To the first elementMultiply (modified B):
    ’      - by B and modified DecrementB' eachby elementB'
       × S  -   Multiply modified B by B and modified B' byColumnwise B'sum
         S_ - ColumnwiseSubtract sumB, elementwise

Jelly, 10 bytes

,CÄḤ’1¦×ƲS

Try it online!

How it works

,CÄḤ’1¦×ƲS - Main link. Takes a binary list B on the left
 C         - Complement. Flip the bits of B
,          - Pair with B: [B, B']
        Ʋ  - Last 4 links as a monad f([B, B']):
  Ä        -   Cumulative sum of each
   Ḥ       -   Unhalve
        -   To the first element (modified B):
    ’      -     Decrement each element
       ×   -   Multiply modified B by B and modified B' by B'
         S - Columnwise sum

Jelly, 8 bytes

,CÄḤ×ƊS_

Try it online!

-2 bytes thanks to Bubbler

How it works

,CÄḤ×ƊS_ - Main link. Takes a binary list B on the left
 C       - Complement. Flip the bits of B
,        - Pair with B: [B, B']
     Ɗ   - Last 3 links as a monad f([B, B']):
  Ä      -   Cumulative sum of each
   Ḥ     -   Unhalve
     ×   -   Multiply modified B by B and modified B' by B'
      S  - Columnwise sum
       _ - Subtract B, elementwise
added 13 characters in body
Source Link

Jelly, 1110 bytes

CÄḤ×Ɗ+ÄḤ’×Ʋ,CÄḤ’1¦×ƲS

Try it online!Try it online!

How it works

,CÄḤ’1¦×ƲS - Main link. Takes a binary list B on the left
 C         - Complement. Flip the bits of B
,          - Pair with B: [B, B']
        Ʋ  - Last 4 links as a monad f([B, B']):
  Ä        -   Cumulative sum of each
   Ḥ       -   Unhalve
     1¦    -   To the first element (modified B):
    ’      -     Decrement each element
       ×   -   Multiply modified B by B and modified B' by B'
         S - Columnwise sum

Jelly, 11 bytes

CÄḤ×Ɗ+ÄḤ’×Ʋ

Try it online!

Jelly, 10 bytes

,CÄḤ’1¦×ƲS

Try it online!

How it works

,CÄḤ’1¦×ƲS - Main link. Takes a binary list B on the left
 C         - Complement. Flip the bits of B
,          - Pair with B: [B, B']
        Ʋ  - Last 4 links as a monad f([B, B']):
  Ä        -   Cumulative sum of each
   Ḥ       -   Unhalve
     1¦    -   To the first element (modified B):
    ’      -     Decrement each element
       ×   -   Multiply modified B by B and modified B' by B'
         S - Columnwise sum
Source Link
Loading