Initial data commit
This commit is contained in:
parent
72d218235f
commit
f23f22d71c
199087 changed files with 3378941 additions and 0 deletions
21
Task/Nth/PowerShell/nth-1.psh
Normal file
21
Task/Nth/PowerShell/nth-1.psh
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
function nth($inp){
|
||||
$suffix = "th"
|
||||
|
||||
switch($inp % 100){
|
||||
11{$suffix="th"}
|
||||
12{$suffix="th"}
|
||||
13{$suffix="th"}
|
||||
default{
|
||||
switch($inp % 10){
|
||||
1{$suffix="st"}
|
||||
2{$suffix="nd"}
|
||||
3{$suffix="rd"}
|
||||
}
|
||||
}
|
||||
}
|
||||
return "$inp$suffix "
|
||||
}
|
||||
|
||||
0..25 | %{Write-host -nonewline (nth "$_")};""
|
||||
250..265 | %{Write-host -nonewline (nth "$_")};""
|
||||
1000..1025 | %{Write-host -nonewline (nth "$_")};""
|
||||
23
Task/Nth/PowerShell/nth-2.psh
Normal file
23
Task/Nth/PowerShell/nth-2.psh
Normal file
|
|
@ -0,0 +1,23 @@
|
|||
function Get-Nth ([int]$Number)
|
||||
{
|
||||
$suffix = "th"
|
||||
|
||||
switch ($Number % 100){
|
||||
11 {$suffix = "th"}
|
||||
12 {$suffix = "th"}
|
||||
13 {$suffix = "th"}
|
||||
default {
|
||||
switch ($Number % 10){
|
||||
1 {$suffix = "st"}
|
||||
2 {$suffix = "nd"}
|
||||
3 {$suffix = "rd"}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
"$Number$suffix"
|
||||
}
|
||||
|
||||
1..25 | ForEach-Object {Get-Nth $_} | Format-Wide {$_} -Column 5 -Force
|
||||
251..265 | ForEach-Object {Get-Nth $_} | Format-Wide {$_} -Column 5 -Force
|
||||
1001..1025 | ForEach-Object {Get-Nth $_} | Format-Wide {$_} -Column 5 -Force
|
||||
Loading…
Add table
Add a link
Reference in a new issue