Skip to content

Commit

Permalink
feat: "Vowel one"
Browse files Browse the repository at this point in the history
Add "Vowel one" kata
  • Loading branch information
marcobiedermann committed Jun 27, 2023
1 parent 47c44a1 commit 70d03ac
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 0 deletions.
9 changes: 9 additions & 0 deletions kata/7 kyu/vowel-one/index.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import { describe, expect, it } from 'vitest';
import vowelOne from '.';

describe('vowelOne', () => {
it('should replace vowels with `1` and non-vowels with `0`', () => {
expect(vowelOne('vowelOne')).toEqual('01010101');
expect(vowelOne('123, arou')).toEqual('000001011');
});
});
7 changes: 7 additions & 0 deletions kata/7 kyu/vowel-one/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
function vowelOne(s: string): string {
return s.replace(/([aeiou])|./gi, (_, vowel) => {
return vowel ? '1' : '0';
});
}

export default vowelOne;
28 changes: 28 additions & 0 deletions kata/7 kyu/vowel-one/readme.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# [Vowel one](https://www.codewars.com/kata/580751a40b5a777a200000a1)

### vowelOne

Write a function that takes a string and outputs a strings of 1's and 0's where vowels become 1's and non-vowels become 0's.

All non-vowels including non alpha characters (spaces,commas etc.) should be included.

Examples:

```haskell
vowelOne "abceios" -- "1001110"

vowelOne "aeiou, abc" -- "1111100100"
```

```javascript
vowelOne('abceios'); // "1001110"

vowelOne('aeiou, abc'); // "1111100100"
```

---

## Tags

- Fundamentals
- Strings

0 comments on commit 70d03ac

Please sign in to comment.