Skip to main content
Commonmark migration
Source Link

#CJam, 110 103 bytes

CJam, 110 103 bytes

Pretttttty long. Can be golfed a lot.

q~_,,\f>{_,),5>\f<{:X)\0==X1b_X,.85*<!\.15X,*>!X0=!*\X0=*+&},:,W>U):U+}%{,(},_{{_W=IW=>\1bI1b>!&!},}fI, 

Input is like

[0 1 1 0 0 0 0 0 0 0 0 0 0 0 1 0 1 1 1 1 1 1 1 0 1 0 0 0 0 0] 

Output is the number of phases.

Try it online here

#CJam, 110 103 bytes

Pretttttty long. Can be golfed a lot.

q~_,,\f>{_,),5>\f<{:X)\0==X1b_X,.85*<!\.15X,*>!X0=!*\X0=*+&},:,W>U):U+}%{,(},_{{_W=IW=>\1bI1b>!&!},}fI, 

Input is like

[0 1 1 0 0 0 0 0 0 0 0 0 0 0 1 0 1 1 1 1 1 1 1 0 1 0 0 0 0 0] 

Output is the number of phases.

Try it online here

CJam, 110 103 bytes

Pretttttty long. Can be golfed a lot.

q~_,,\f>{_,),5>\f<{:X)\0==X1b_X,.85*<!\.15X,*>!X0=!*\X0=*+&},:,W>U):U+}%{,(},_{{_W=IW=>\1bI1b>!&!},}fI, 

Input is like

[0 1 1 0 0 0 0 0 0 0 0 0 0 0 1 0 1 1 1 1 1 1 1 0 1 0 0 0 0 0] 

Output is the number of phases.

Try it online here

added 4 characters in body
Source Link
Optimizer
  • 26.6k
  • 7
  • 67
  • 144

#CJam, 110110 103 bytes

Pretttttty long. Can be golfed a lot.

q~_,,\f>{_,),\f<{,4>},{)\0==},5>\f<{:X1b_XX)\0==X1b_X,.85*<!\.15X,*>!X0=!*\X0=*e|*\X0=*+&},:,UW>U):U+-2>}%{,(},_{{_W=IW=>\1bI1b>!&!},}fI, 

Input is like

[0 1 1 0 0 0 0 0 0 0 0 0 0 0 1 0 1 1 1 1 1 1 1 0 1 0 0 0 0 0] 

Output is the number of phases.

Try it online here

#CJam, 110 bytes

Pretttttty long. Can be golfed a lot.

q~_,,\f>{_,),\f<{,4>},{)\0==},{:X1b_X,.85*<!\.15X,*>!X0=!*\X0=*e|},:,U):U+-2>}%{,(},_{{_W=IW=>\1bI1b>!&!},}fI, 

Input is like

[0 1 1 0 0 0 0 0 0 0 0 0 0 0 1 0 1 1 1 1 1 1 1 0 1 0 0 0 0 0] 

Output is the number of phases.

Try it online here

#CJam, 110 103 bytes

Pretttttty long. Can be golfed a lot.

q~_,,\f>{_,),5>\f<{:X)\0==X1b_X,.85*<!\.15X,*>!X0=!*\X0=*+&},:,W>U):U+}%{,(},_{{_W=IW=>\1bI1b>!&!},}fI, 

Input is like

[0 1 1 0 0 0 0 0 0 0 0 0 0 0 1 0 1 1 1 1 1 1 1 0 1 0 0 0 0 0] 

Output is the number of phases.

Try it online here

Source Link
Optimizer
  • 26.6k
  • 7
  • 67
  • 144

#CJam, 110 bytes

Pretttttty long. Can be golfed a lot.

q~_,,\f>{_,),\f<{,4>},{)\0==},{:X1b_X,.85*<!\.15X,*>!X0=!*\X0=*e|},:,U):U+-2>}%{,(},_{{_W=IW=>\1bI1b>!&!},}fI, 

Input is like

[0 1 1 0 0 0 0 0 0 0 0 0 0 0 1 0 1 1 1 1 1 1 1 0 1 0 0 0 0 0] 

Output is the number of phases.

Try it online here