From 721396e429e47dc77d8354e84f54e64347e24bce Mon Sep 17 00:00:00 2001 From: divlo Date: Sun, 15 Nov 2020 11:09:44 +0100 Subject: [PATCH] feat(challenge): first non-repeating character --- .../first-non-repeating-character/README.md | 19 +++++++++++ .../input-output.json | 34 +++++++++++++++++++ .../solutions/.gitkeep | 0 3 files changed, 53 insertions(+) create mode 100644 challenges/first-non-repeating-character/README.md create mode 100644 challenges/first-non-repeating-character/input-output.json create mode 100644 challenges/first-non-repeating-character/solutions/.gitkeep diff --git a/challenges/first-non-repeating-character/README.md b/challenges/first-non-repeating-character/README.md new file mode 100644 index 0000000..62c31c7 --- /dev/null +++ b/challenges/first-non-repeating-character/README.md @@ -0,0 +1,19 @@ +# first-non-repeating-character + +Created by [@Divlo](https://github.com/Divlo) on 15 November 2020. + +## Instructions : + +Write a function that takes a string input, and returns the first character that is not repeated anywhere in the string. + +For example, if given the input `'stress'`, the function should return `'t'`, since the letter _t_ only occurs once in the string, and occurs first in the string. + +If a string contains all repeating characters, it should return an empty string (`""`). + +## Source : + +[First non-repeating character - Codewars](https://www.codewars.com/kata/52bc74d4ac05d0945d00054e/) + +## Examples : + +See the `input-output.json` file for examples of input/output. diff --git a/challenges/first-non-repeating-character/input-output.json b/challenges/first-non-repeating-character/input-output.json new file mode 100644 index 0000000..ec49843 --- /dev/null +++ b/challenges/first-non-repeating-character/input-output.json @@ -0,0 +1,34 @@ +[ + { + "input": ["a"], + "output": "a" + }, + { + "input": ["stress"], + "output": "t" + }, + { + "input": ["moonmen"], + "output": "e" + }, + { + "input": [""], + "output": "" + }, + { + "input": ["abba"], + "output": "" + }, + { + "input": ["aa"], + "output": "" + }, + { + "input": ["~><#~><"], + "output": "#" + }, + { + "input": ["hello world, eh?"], + "output": "w" + } +] diff --git a/challenges/first-non-repeating-character/solutions/.gitkeep b/challenges/first-non-repeating-character/solutions/.gitkeep new file mode 100644 index 0000000..e69de29