Created
January 2, 2014 08:26
-
-
Save anonymous/8216399 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function solve726_2 ([int]$n){ | |
$a = 0..$n | |
$b = $a | % -begin{$acc=0} {$acc += $_; $acc} | |
$r0 = $n | |
for($l = 0; $l -lt $n; $l++){ | |
for($r = $l+1; $r -le $n; $r++){ | |
$x = $n - ($b[$r] - $b[$l]) | |
if(0 -gt $x){ break } | |
if(0 -eq $x){ ,$a[($l+1)..$r]; break } | |
} | |
} | |
} | |
solve726_2 2014 | % {$_ -join ","} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment