Программы

Powershell 3 Cmdlets Hackerrank Solution May 2026

-split , ForEach-Object , Write-Output . 5. Example 2: Solve "Plus Minus" (Calculate Ratios) Problem: Given an array of integers, calculate the fractions of positive, negative, and zero values. One-liner using Group-Object and [Math]::Round : $lines = @($input) $n = [int]$lines[0] $arr = $lines[1].Trim() -split ' ' | ForEach-Object [int]$_ $groups = $arr | Group-Object [Math]::Sign($ ) $positive = ($groups | Where-Object $ .Name -eq 1 ).Count / $n $negative = ($groups | Where-Object $ .Name -eq -1 ).Count / $n $zero = ($groups | Where-Object $ .Name -eq 0 ).Count / $n

Group-Object with dynamic script block. 6. Example 3: "Mini-Max Sum" – Cmdlet Pipeline Mastery Problem: Given 5 integers, find the minimum sum of 4 elements and maximum sum of 4 elements. Elegant solution: $lines = @($input) $arr = $lines[0].Trim() -split ' ' | ForEach-Object [int]$_ $total = ($arr | Measure-Object -Sum).Sum $minElem = ($arr | Measure-Object -Minimum).Minimum $maxElem = ($arr | Measure-Object -Maximum).Maximum Write-Output "$($total - $maxElem) $($total - $minElem)" powershell 3 cmdlets hackerrank solution

for ($i = 0; $i -lt $n; $i++) $primary += $matrix[$i][$i] $secondary += $matrix[$i][$n - 1 - $i] -split , ForEach-Object , Write-Output

Получать новости
Статистика сайта

Hits
112687160
32857

Hosts
4977438
247

Visitors
109264863
32724
427

Powershell 3 Cmdlets Hackerrank Solution May 2026

Скачать ZwCAD

ZwCAD 2018 PRO (32/64 Bit. RUS/Eng)




powershell 3 cmdlets hackerrank solution

facebook-logo.png v_k_logo.jpg odnoklassniki_logo.jpg mail_ru_logo.jpg tweeter_logo.jpg