-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Showing
3 changed files
with
69 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
import solution from '.'; | ||
|
||
describe('solution', () => { | ||
it('should join strings based on their length', () => { | ||
expect.assertions(4); | ||
|
||
expect(solution('45', '1')).toStrictEqual('1451'); | ||
expect(solution('13', '200')).toStrictEqual('1320013'); | ||
expect(solution('Soon', 'Me')).toStrictEqual('MeSoonMe'); | ||
expect(solution('U', 'False')).toStrictEqual('UFalseU'); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
function solution(a: string, b: string): string { | ||
return a.length < b.length ? a + b + a : b + a + b; | ||
} | ||
|
||
export default solution; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
# [Short Long Short](https://www.codewars.com/kata/50654ddff44f800200000007) | ||
|
||
Given 2 strings, `a` and `b`, return a string of the form short+long+short, with the shorter string on the outside | ||
and the longer string on the inside. The strings will not be the same length, but they may be empty ( length `0` ). | ||
|
||
For example: | ||
|
||
```javascript | ||
solution('1', '22'); // returns "1221" | ||
solution('22', '1'); // returns "1221" | ||
``` | ||
|
||
```typescript | ||
solution('1', '22'); // returns "1221" | ||
solution('22', '1'); // returns "1221" | ||
``` | ||
|
||
```coffeescript | ||
solution("1", "22") # returns "1221" | ||
solution("22", "1") # returns "1221" | ||
``` | ||
|
||
```ruby | ||
solution("1", "22") # returns "1221" | ||
solution("22", "1") # returns "1221" | ||
``` | ||
|
||
```elixir | ||
solution("1", "22") # returns "1221" | ||
solution("22", "1") # returns "1221" | ||
``` | ||
|
||
```csharp | ||
ShortLongShort.Solution("1", "22"); // returns "1221" | ||
ShortLongShort.Solution("22", "1"); // returns "1221" | ||
``` | ||
|
||
```python | ||
solution("1", "22") # returns "1221" | ||
solution("22", "1") # returns "1221" | ||
``` | ||
|
||
```php | ||
shortLongShort("1", "22") // returns "1221" | ||
shortLongShort("22", "1") // returns "1221" | ||
``` | ||
|
||
--- | ||
|
||
## Tags | ||
|
||
- Algorithms |