Skip to content

Instantly share code, notes, and snippets.

Created January 2, 2014 08:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save anonymous/8216229 to your computer and use it in GitHub Desktop.
Save anonymous/8216229 to your computer and use it in GitHub Desktop.
function solve726 ([int]$n){
$a = 0..$n
$b = $a | % -begin{$acc=0} {$acc += $_; $acc}
for($l = 0; $l -lt $n; $l++){
for($r = $n; $r -gt $l; $r--){
$x = $n - ($b[$r] - $b[$l])
if(0 -eq $x){ ,$a[($l+1)..$r]; break }
if(0 -lt $x){ break }
}
}
}
solve726 2014 | % {$_ -join ","}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment