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
|
Поиск
Новости
13.04.2026
АВС-4 2026.4 от 13.04.2026 г.
20.03.2026
SANA 2026.3 от 20.03.2026 г.
18.12.2025
АККОРД 2025.1 от 18.12.2025 г.
21.02.2025
ZWCAD 2025
14.02.2025
СРД Средний и текущий ремонт, содержание автодорог
23.01.2025
LIRA-FEM 2025
13.01.2025
АВС-ПИР KZ 2025.1 от 13.01.2025 г. Статьи
|