Skip to content

Instantly share code, notes, and snippets.

@LabtechConsulting
Created December 3, 2016 23:26
Show Gist options
  • Save LabtechConsulting/f94b25c60a192c0af06150b25b3c51ad to your computer and use it in GitHub Desktop.
Save LabtechConsulting/f94b25c60a192c0af06150b25b3c51ad to your computer and use it in GitHub Desktop.
$List = (Invoke-WebRequest 'https://gist.githubusercontent.com/LabtechConsulting/15114472e85f3b8a666dc0a404916772/raw/1458df8ca91f4db6518ec95c3bec91e922ebac09/new_gist_file_0').Content
function Sort-List {
param(
$List
)
begin{
$Temp1 = @()
$Temp2 = @()
$Temp3 = @()
$Temp4 = @()
$TempVar = @()
$NewList = @()
$NewArray2 = @()
$List = $List -split '[\r\n]'
}
process{
foreach($item in $List){
$NewList += $item -split ' ' | where {$_}
}
$NewList | foreach {$i=1} {if ($i++ %3){$Temp1 += $_}else{$Temp2 += $_}}
$Temp1 | foreach {$i=1} {if ($i++ %2){$Temp3 += $_}else{$Temp4 += $_}}
$NewArray = $Temp3 + $Temp4 + $Temp2
$Count = 0
foreach($item in $NewArray){
$count ++
$TempVar = "$TempVar $item"
if($Count -eq 3){
$NewArray2 += $TempVar
$TempVar = @()
$Count = 0
}
}
}
end{$NewArray2}
}
function Count-Triangles {
Param(
$List
)
$Triangle = 0
foreach($Item in $List){
$Sides = ($item -split ' ' | where {$_}).trim()
[int]$Hypotenuse = ($Sides | measure -Maximum).maximum
if((($Sides | measure -Sum).sum - $Hypotenuse) -gt $Hypotenuse){$Triangle ++}
}
Write-Output $Triangle
}
Count-Triangles $($List -split '[\r\n]' | where{$_})
$List = Sort-List $List
Count-Triangles $List
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment