2016 Update

This commit is contained in:
Tina Müller 2016-12-05 22:15:40 +01:00
parent 948b86eafa
commit dcf5d15da3
7965 changed files with 139854 additions and 31002 deletions

View file

@ -0,0 +1,22 @@
function Get-EquilibriumIndex ( $Sequence )
{
$Indexes = 0..($Sequence.Count - 1)
$EqulibriumIndex = @()
ForEach ( $TestIndex in $Indexes )
{
$Left = 0
$Right = 0
ForEach ( $Index in $Indexes )
{
If ( $Index -lt $TestIndex ) { $Left += $Sequence[$Index] }
ElseIf ( $Index -gt $TestIndex ) { $Right += $Sequence[$Index] }
}
If ( $Left -eq $Right )
{
$EqulibriumIndex += $TestIndex
}
}
return $EqulibriumIndex
}

View file

@ -0,0 +1 @@
Get-EquilibriumIndex -7, 1, 5, 2, -4, 3, 0

View file

@ -1,15 +0,0 @@
function equil($arr){
$res=@()
for($i=0;$i -lt $arr.length;$i++){
$left=0;$right=0
for($j=0;$j -lt $arr.length;$j++){
if ($j -lt $i){$left+=$arr[$j]}
if ($j -gt $i){$right+=$arr[$j]}
}
if($left -eq $right){$res+=$i}
}
[String]$res
}
equil -7,1,5,2,-4,3,0