GSM Ôîðóì - GSMForum.SU  

Âåðíóòüñÿ   GSM Ôîðóì - GSMForum.SU > Ôîðóìû ïîääåðæêè îáîðóäîâàíèÿ > Ïðîãðàììàòîðû îò Z3X > Z3x Easy-Jtag

Z3x Easy-Jtag Ôîðóì ïîääåðæêè ïðîãðàììàòîðà Z3x Easy-Jtag Box

 
 
Îïöèè òåìû Îöåíèòü òåìó

# PowerShell 3+ Template $inputFile = ".\data.csv" $requiredYears = 2 $topN = 3 Import-Csv $inputFile | Where-Object [int]$ .YearsOfExperience -ge $requiredYears | Sort-Object [int]$ .Salary -Descending | Select-Object -First $topN | Group-Object Department | Select-Object @Name="Department"; Expression=$ .Name, @Name="AverageSalary"; Expression= [math]::Round(($ .Group | Sort-Object Department

$data = Import-Csv .\employees.csv Filters objects based on a condition.

| Select-Object Department, @Name="AverageSalary"; Expression= Measure-Object Salary -Average).Average Let's assume the CSV file employees.csv looks like this:

Department AverageSalary ---------- ------------- Finance 100000 IT 85000 The challenge will silently test you on: Case 1: Fewer than 3 eligible employees If only 2 employees have >=2 years experience, your Select-Object -First 3 will return just 2, and Group-Object still works fine. Case 2: One department with multiple top earners If all top 3 are from IT, grouping will show only one row for IT with average salary of those 3. Case 3: Empty dataset If no employee has >=2 years experience, Where-Object outputs $null , and the rest of the pipeline should fail gracefully. HackerRank expects:

$data | Where-Object $_.YearsOfExperience -ge 2 Sorts by one or more properties.

$avgSalary = $grouped.Group | Measure-Object Salary -Average Creates new columns on-the-fly.

Import-Csv .\employees.csv | Where-Object $_.YearsOfExperience -ge 2 | Sort-Object Salary -Descending | Select-Object -First 3 | Group-Object Department | Select-Object @N="Department";E=$_.Name, @N="AverageSalary";E= [math]::Round(($_.Group | Sort-Object Department | Format-Table -AutoSize

$data | Select-Object *, @N="SalaryInt";E=[int]$_.Salary | Sort-Object SalaryInt -Desc Better yet, cast during filtering:

Powershell 3 Cmdlets Hackerrank Solution May 2026

# PowerShell 3+ Template $inputFile = ".\data.csv" $requiredYears = 2 $topN = 3 Import-Csv $inputFile | Where-Object [int]$ .YearsOfExperience -ge $requiredYears | Sort-Object [int]$ .Salary -Descending | Select-Object -First $topN | Group-Object Department | Select-Object @Name="Department"; Expression=$ .Name, @Name="AverageSalary"; Expression= [math]::Round(($ .Group | Sort-Object Department

$data = Import-Csv .\employees.csv Filters objects based on a condition.

| Select-Object Department, @Name="AverageSalary"; Expression= Measure-Object Salary -Average).Average Let's assume the CSV file employees.csv looks like this: powershell 3 cmdlets hackerrank solution

Department AverageSalary ---------- ------------- Finance 100000 IT 85000 The challenge will silently test you on: Case 1: Fewer than 3 eligible employees If only 2 employees have >=2 years experience, your Select-Object -First 3 will return just 2, and Group-Object still works fine. Case 2: One department with multiple top earners If all top 3 are from IT, grouping will show only one row for IT with average salary of those 3. Case 3: Empty dataset If no employee has >=2 years experience, Where-Object outputs $null , and the rest of the pipeline should fail gracefully. HackerRank expects:

$data | Where-Object $_.YearsOfExperience -ge 2 Sorts by one or more properties. # PowerShell 3+ Template $inputFile = "

$avgSalary = $grouped.Group | Measure-Object Salary -Average Creates new columns on-the-fly.

Import-Csv .\employees.csv | Where-Object $_.YearsOfExperience -ge 2 | Sort-Object Salary -Descending | Select-Object -First 3 | Group-Object Department | Select-Object @N="Department";E=$_.Name, @N="AverageSalary";E= [math]::Round(($_.Group | Sort-Object Department | Format-Table -AutoSize Case 3: Empty dataset If no employee has

$data | Select-Object *, @N="SalaryInt";E=[int]$_.Salary | Sort-Object SalaryInt -Desc Better yet, cast during filtering:


Powered by vBulletin®
Copyright ©2000 - 2026, Jelsoft Enterprises Ltd. Ïåðåâîä: zCarot