Pyth, 18 bytes
L?SIb0hys%L2>Bb1
y
-2 thanks to @Erik the Outgolfer.
The script has two line: the first one defines a function y, the second line calls y with the implicit Q (evaluated stdin) argument.
L?SIb0hys%L2>Bb1
L function y(b)
? if...
SIb the Invariant b == sumsort(b) holds
0 return 0
h otherwise increment...
y ...the return of a recursive call with:
B the current argument "bifurcated", an array of:
b - the original argument
> 1 - same with the head popped off
L map...
% 2 ...take only every 2nd value in each array
s and concat them back together
Pyth, 18 bytes
L?SIb0hys%L2>Bb1
y
-2 thanks to @Erik the Outgolfer.
The script has two line: the first one defines a function y, the second line calls y with the implicit Q (evaluated stdin) argument.
L?SIb0hys%L2>Bb1
L function y(b)
? if...
SIb the Invariant b == sum(b) holds
0 return 0
h otherwise increment...
y ...the return of a recursive call with:
B the current argument "bifurcated", an array of:
b - the original argument
> 1 - same with the head popped off
L map...
% 2 ...take only every 2nd value in each array
s and concat them back together
Pyth, 18 bytes
L?SIb0hys%L2>Bb1
y
-2 thanks to @Erik the Outgolfer.
The script has two line: the first one defines a function y, the second line calls y with the implicit Q (evaluated stdin) argument.
L?SIb0hys%L2>Bb1
L function y(b)
? if...
SIb the Invariant b == sort(b) holds
0 return 0
h otherwise increment...
y ...the return of a recursive call with:
B the current argument "bifurcated", an array of:
b - the original argument
> 1 - same with the head popped off
L map...
% 2 ...take only every 2nd value in each array
s and concat them back together
Pyth, 18 bytes
L?SIb0hys%L2>Bb1
y
-2 thanks to @Erik the Outgolfer.
The script has two line: the first one defines a function y, the second line calls y with the implicit Q (evaluated stdin) argument.
L?SIb0hys%L2>Bb1
L function y(b)
? if...
SIb the Invariant b == sum(b) holds
0 return 0
h otherwise increment...
y ...the return of a recursive call with:
B the current argument "bifurcated", an array of:
b - the original argument
> 1 - same with the head popped off
L map...
% 2 ...take only every 2nd value in each array
s and concat them back together
Pyth, 18 bytes
L?SIb0hys%L2>Bb1
y
-2 thanks to @Erik the Outgolfer.
The script has two line: the first one defines a function y, the second line calls y with the implicit Q (evaluated stdin) argument.
L?SIb0hys%L2>Bb1
L function y(b)
? if...
SIb the Invariant b == sum(b) holds
0 return 0
h otherwise increment...
y ...the return of a recursive call with:
B the current argument "bifurcated", an array of:
b - the original argument
> 1 - same with the head popped off
L map...
% 2 ...take only every 2nd value in each array
s and concat them back together