mirror of
https://github.com/Xevion/exercism.git
synced 2026-01-31 10:24:15 -06:00
PowerShell - leap, raindrops, reverse-string, two-fer
This commit is contained in:
@@ -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}
|
||||
@@ -0,0 +1 @@
|
||||
1
|
||||
@@ -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/
|
||||
@@ -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
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user