Skip to main content
added 135 characters in body; added 8 characters in body; added 72 characters in body
Source Link
mazzy
  • 7.2k
  • 2
  • 13
  • 23

Powershell, 1614 bytes

Sum array elements. An operator + can work as a unary and binary operator.

+(1,0,2)[$i++%3][$i++] 

Test script:

+(1,0,2)[$i++%3][$i++] $i=0 # or start new powershell session  +(1,0,2)[$i++%3]+[$i++]+(1,0,2)[$i++%3][$i++]  $i=0 # or start new powershell session +(1,0,2)[$i++%3]+[$i++]+(1,0,2)[$i++%3]+[$i++]+(1,0,2)[$i++%3][$i++] 

Note: $i=0 emulates a new session. You can type three times in a new powershell terminal window to start a pure test instead.

Output:

1 1 3 

Powershell, 16 bytes

Sum array elements. An operator + can work as a unary and binary operator.

+(1,0,2)[$i++%3] 

Test script:

+(1,0,2)[$i++%3] +(1,0,2)[$i++%3]+(1,0,2)[$i++%3] +(1,0,2)[$i++%3]+(1,0,2)[$i++%3]+(1,0,2)[$i++%3] 

Output:

1 1 3 

Powershell, 14 bytes

Sum array elements. An operator + can work as a unary and binary operator.

+(1,0,2)[$i++] 

Test script:

+(1,0,2)[$i++] $i=0 # or start new powershell session  +(1,0,2)[$i++]+(1,0,2)[$i++]  $i=0 # or start new powershell session +(1,0,2)[$i++]+(1,0,2)[$i++]+(1,0,2)[$i++] 

Note: $i=0 emulates a new session. You can type three times in a new powershell terminal window to start a pure test instead.

Output:

1 1 3 
Source Link
mazzy
  • 7.2k
  • 2
  • 13
  • 23

Powershell, 16 bytes

Sum array elements. An operator + can work as a unary and binary operator.

+(1,0,2)[$i++%3] 

Test script:

+(1,0,2)[$i++%3] +(1,0,2)[$i++%3]+(1,0,2)[$i++%3] +(1,0,2)[$i++%3]+(1,0,2)[$i++%3]+(1,0,2)[$i++%3] 

Output:

1 1 3