PowerShell - leap, raindrops, reverse-string, two-fer

This commit is contained in:
Xevion
2021-11-26 02:28:45 -06:00
parent e02f2ceabf
commit 3bd08f4c92
29 changed files with 569 additions and 0 deletions
@@ -0,0 +1,22 @@
{
"blurb": "Reverse a string",
"authors": [
"gyssels"
],
"contributors": [
"kchenery"
],
"files": {
"solution": [
"ReverseString.ps1"
],
"test": [
"ReverseString.tests.ps1"
],
"example": [
".meta/ReverseString.example.ps1"
]
},
"source": "Introductory challenge to reverse an input string",
"source_url": "https://medium.freecodecamp.org/how-to-reverse-a-string-in-javascript-in-3-different-ways-75e4763c68cb"
}
@@ -0,0 +1 @@
{"track":"powershell","exercise":"reverse-string","id":"675925dac0bc4ca59b00bd1f0515381e","url":"https://exercism.org/tracks/powershell/exercises/reverse-string","handle":"Xevion","is_requester":true,"auto_approve":false}
+1
View File
@@ -0,0 +1 @@
1
+33
View File
@@ -0,0 +1,33 @@
# Help
## Running the tests
To run the tests run the command `Invoke-Pester` from within the exercise directory.
## Submitting your solution
You can submit your solution using the `exercism submit ReverseString.ps1` command.
This command will upload your solution to the Exercism website and print the solution page's URL.
It's possible to submit an incomplete solution which allows you to:
- See how others have completed the exercise
- Request help from a mentor
## Need to get help?
If you'd like help solving the exercise, check the following pages:
- The [PowerShell track's documentation](https://exercism.org/docs/tracks/powershell)
- [Exercism's support channel on gitter](https://gitter.im/exercism/support)
- The [Frequently Asked Questions](https://exercism.org/docs/using/faqs)
Should those resources not suffice, you could submit your (incomplete) solution to request mentoring.
To get help if you are having trouble, you can use one of the following resources:
- [Powershell Documentation][powershell docs]
[Add more resources]: TODO
[powershell docs]: https://docs.microsoft.com/en-us/powershell/
+26
View File
@@ -0,0 +1,26 @@
# Reverse String
Welcome to Reverse String on Exercism's PowerShell Track.
If you need help running the tests or submitting your code, check out `HELP.md`.
## Instructions
Reverse a string
For example:
input: "cool"
output: "looc"
## Source
### Created by
- @gyssels
### Contributed to by
- @kchenery
### Based on
Introductory challenge to reverse an input string - https://medium.freecodecamp.org/how-to-reverse-a-string-in-javascript-in-3-different-ways-75e4763c68cb
@@ -0,0 +1,11 @@
Function Get-ReverseString {
[CmdletBinding()]
Param(
[Parameter(Position=1, ValueFromPipeline=$true)]
[string]$Forward
)
$x = $Forward.ToCharArray()
[array]::Reverse($x)
return -join $x
}
@@ -0,0 +1,21 @@
BeforeAll {
. ".\ReverseString.ps1"
}
Describe "Get-ReverseString Tests" {
It "Given <Forward> it outputs <Reverse>" -TestCases @(
@{ Forward = ""; Reverse = "" },
@{ Forward = "PowerShell"; Reverse = "llehSrewoP" },
@{ Forward = "robot"; Reverse = "tobor" },
@{ Forward = "Ramen"; Reverse = "nemaR" },
@{ Forward = "I'm hungry!"; Reverse = "!yrgnuh m'I" },
@{ Forward = "racecar"; Reverse = "racecar" }
) {
Param(
[string]$Forward,
[string]$Reverse
)
Get-ReverseString -Forward $Forward | Should -BeExactly $Reverse
}
}