meetforever/GRPO_CL huggingface dataset:
user: Given a set of numbers, return the additive inverse of each. Each positive becomes negatives, and the negatives become positives.

~~~if-not:racket
```
invert([1,2,3,4,5]) == [-1,-2,-3,-4,-5]
invert([1,-2,3,-4,5]) == [-1,2,-3,4,-5]
invert([]) == []
```
~~~

```if:javascript,python,ruby,php,elixir,dart
You can assume that all values are integers. Do not mutate the input array/list.
```

```if:c
### Notes:
- All values are greater than `INT_MIN`
- The input should be modified, not returned.
```
~~~if:racket
```racket
(invert '(1 2 3 4 5))   ; '(-1 -2 -3 -4 -5)
(invert '(1 -2 3 -4 5)) ; '(-1 2 -3 4 -5)
(invert '())            ; '()
```
~~~

Answer: {"fn_name": "invert", "inputs": [[[1, 2, 3, 4, 5]], [[1, -2, 3, -4, 5]], [[]], [[0]]], "outputs": [[[-1, -2, -3, -4, -5]], [[-1, 2, -3, 4, -5]], [[]], [[0]]]}
user: ## Task

You are given three non negative integers `a`, `b` and `n`, and making an infinite sequence just like fibonacci sequence, use the following rules:

- step 1: use `ab` as the initial sequence.
- step 2: calculate the sum of the last two digits of the sequence, and append it to the end of sequence.
- repeat step 2 until you have enough digits

Your task is to complete the function which returns the `n`th digit (0-based) of the sequence.

### Notes:

- `0 <= a, b <= 9`, `0 <= n <= 10^10`
- `16` fixed testcases
- `100` random testcases, testing for correctness of solution
- `100` random testcases, testing for performance of code
- All inputs are valid.
- Pay attention to code performance.


## Examples

For `a = 7, b = 8 and n = 9` the output should be `5`, because the sequence is:
```
78 -> 7815 -> 78156 -> 7815611 -> 78156112 -> 781561123 -> 7815611235 -> ...
``` 

and the 9th digit of the sequence is `5`.

---

For `a = 0, b = 0 and n = 100000000` the output should be `0`, because all the digits in this sequence are `0`.

Answer: {"fn_name": "find", "inputs": [[7, 8, 9], [0, 0, 1000000]], "outputs": [[5], [0]]}
user: # Background

My TV remote control has arrow buttons and an `OK` button.

I can use these to move a "cursor" on a logical screen keyboard to type "words"...

The screen "keyboard" layout looks like this


  #tvkb {
    width : 300px;
    border: 5px solid gray; border-collapse: collapse;
  }
  #tvkb td {
    color : orange;
    background-color : black;
    text-align : right;
    border: 3px solid gray; border-collapse: collapse;
  }


abcde123
fghij456
klmno789
pqrst.@0
uvwxyz_/


# Kata task

How many button presses on my remote are required to type a given `word`?

## Notes

* The cursor always starts on the letter `a` (top left)
* Remember to also press `OK` to "accept" each character.
* Take a direct route from one character to the next
* The cursor does not wrap (e.g. you cannot leave one edge and reappear on the opposite edge)
* A "word" (for the purpose of this Kata) is any sequence of characters available on my virtual "keyboard" 

# Example

word = `codewars`

* c => `a`-`b`-`c`-OK = 3
* o => `c`-`d`-`e`-`j`-`o`-OK = 5
* d => `o`-`j`-`e`-`d`-OK = 4
* e => `d`-`e`-OK = 2
* w => `e`-`j`-`o`-`t`-`y`-`x`-`w`-OK = 7
* a => `w`-`r`-`m`-`h`-`c`-`b`-`a`-OK = 7
* r => `a`-`f`-`k`-`p`-`q`-`r`-OK = 6
* s => `r`-`s`-OK = 2

Answer = 3 + 5 + 4 + 2 + 7 + 7 + 6 + 2 = 36



*Good Luck!
DM.*



Series
* TV Remote
* TV Remote (shift and space)
* TV Remote (wrap)
* TV Remote (symbols)

Answer: {"fn_name": "tv_remote", "inputs": [["codewars"], ["does"], ["your"], ["solution"], ["work"], ["for"], ["these"], ["words"], ["mississippi"]], "outputs": [[36], [16], [23], [33], [20], [12], [27], [25], [35]]}
user: In this Kata you are to implement a function that parses a string which is composed from tokens of the form 'n1-n2,n3,n4-n5:n6' where 'nX' is a positive integer. Each token represent a different range:

'n1-n2' represents the range n1 to n2 (inclusive in both ends).
'n3' represents the single integer n3.
'n4-n5:n6' represents the range n4 to n5 (inclusive in both ends) but only includes every other n6 integer.

Notes:
1. The input string doesn't not have to include all the token types.
2. All integers are assumed to be positive.
3. Tokens may be separated by `','`, `', '` or ` , `.

Some examples:

'1-10,14, 20-25:2' -> [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 14, 20, 22, 24]

'5-10' -> [5, 6, 7, 8, 9, 10]

'2' -> [2]

The output should be a list of integers.

Answer: {"fn_name": "range_parser", "inputs": [["1-10,14, 20-25:2"], ["5-10"], ["2"], ["1-10,3"], ["1-10:5"]], "outputs": [[[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 14, 20, 22, 24]], [[5, 6, 7, 8, 9, 10]], [[2]], [[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 3]], [[1, 6]]]}
user: # Situation
You have been hired by a company making electric garage doors. Accidents with the present product line have resulted in numerous damaged cars, broken limbs and several killed pets. Your mission is to write a safer version of their controller software.

# Specification
We always start with a closed door. The remote control has exactly one button, with the following behaviour.

+ If the door is closed, a push starts opening the door, and vice-versa
+ It takes 5 seconds for the door to open or close completely
+ While the door is moving, one push pauses movement, another push resumes movement in the same direction

In order to make the door safer, it has been equiped with resistance-based obstacle detection. When the door detects an obstacle, it must immediately reverse the direction of movement.

# Input
A string where each character represents one second, with the following possible values.

* ```'.'``` No event
* ```'P'``` Button has been pressed
* ```'O'``` Obstacle has been detected (supersedes P)

As an example, ```'..P....'``` means that nothing happens for two seconds, then the button is pressed, then no further events.

# Output
A string where each character represents one second and indicates the position of the door (0 if fully closed and 5 fully open). The door starts moving immediately, hence its position changes at the same second as the event.

# Example
```..P...O.....``` as input should yield
```001234321000``` as output

Answer: {"fn_name": "controller", "inputs": [[""], [".........."], ["P.."], ["P...."], ["P......P......"], ["P.P.."], ["P.P.P...."], [".....P.P........P...."], [".....P......P.P..P...."], ["P.O...."], ["P......P.O...."], ["P..OP..P.."], ["P......P..OP..P..."], ["..P...O....."]], "outputs": [[""], ["0000000000"], ["123"], ["12345"], ["12345554321000"], ["12222"], ["122234555"], ["000001222222222234555"], ["0000012345554333321000"], ["1210000"], ["12345554345555"], ["1232222100"], ["123455543233334555"], ["001234321000"]]}
user: Complete the solution. It should try to retrieve the value of the array at the index provided. If the index is out of the array's max bounds then it should return the default value instead. 

Example:
```Haskell
solution [1..3] 1 1000 `shouldBe` 2
solution [1..5] (10) 1000 `shouldBe` 1000
-- negative values work as long as they are not out of the length bounds
solution [1..3] (-1) 1000 `shouldBe` 3
solution [1..3] (-5) 1000 `shouldBe` 1000
solution [1..3] (-3) 1000 `shouldBe` 1
solution [1..5] (-3) 1000 `shouldBe` 3
-- for Haskell default value will always be a (random) number, not a character.
```

```python
data = ['a', 'b', 'c']
solution(data, 1, 'd') # should == 'b'
solution(data, 5, 'd') # should == 'd'

# negative values work as long as they aren't out of the length bounds
solution(data, -1, 'd') # should == 'c'
solution(data, -5, 'd') # should == 'd'
```

Answer: {"fn_name": "solution", "inputs": [[[null, null], 0, "a"]], "outputs": [[null]]}
user: The Spelling Bee bees are back...

# How many bees are in the beehive?

* bees can be facing UP, DOWN, LEFT, RIGHT, and now also _diagonally_ up/down/left/right
* bees can share parts of other bees



## Examples

Ex1
```
bee.bee     
.e..e..
.b..eeb
```
_Answer: 5_

Ex2
```
beee..     
eeb.e.
ebee.b
```
_Answer: 7_

Answer: {"fn_name": "how_many_bees", "inputs": [[null]], "outputs": [[0]]}
user: Regular Tic-Tac-Toe is boring.

That's why in this Kata you will be playing  Tic-Tac-Toe in **3D** using a 4 x 4 x 4 matrix!



# Kata Task

Play the game. Work out who wins.

Return a string

* `O wins after  moves`
* `X wins after  moves`
* `No winner`

# Rules

* Player `O` always goes first
* Input `moves` is list/array/tuple of `[x,y,z]` (zero based)
* Each player takes a turn until you find a winner, or there are no moves left
* Four of the same symbols in a row wins
* There may be more moves provided than are necessary to finish the game - that is for you to figure out



Good Luck!
DM

Answer: {"fn_name": "play_OX_3D", "inputs": [[[]]], "outputs": [["No winner"]]}
user: You are given two sorted arrays that contain only integers. Your task is to find a way to merge them into a single one, sorted in **ascending order**. Complete the function `mergeArrays(arr1, arr2)`, where `arr1` and `arr2` are the original sorted arrays.

You don't need to worry about validation, since `arr1` and `arr2` must be arrays with 0 or more Integers. If both `arr1` and `arr2` are empty, then just return an empty array.

**Note:** `arr1` and `arr2` may be sorted in different orders. Also `arr1` and `arr2` may have same integers. Remove duplicated in the returned result.

## Examples

Happy coding!

Answer: {"fn_name": "merge_arrays", "inputs": [[[1, 2, 3, 4], [5, 6, 7, 8]], [[10, 8, 6, 4, 2], [9, 7, 5, 3, 1]], [[-20, 35, 36, 37, 39, 40], [-10, -5, 0, 6, 7, 8, 9, 10, 25, 38, 50, 62]], [[5, 6, 7, 8, 9, 10], [20, 18, 15, 14, 13, 12, 11, 4, 3, 2]], [[45, 30, 20, 15, 12, 5], [9, 10, 18, 25, 35, 50]], [[-8, -3, -2, 4, 5, 6, 7, 15, 42, 90, 134], [216, 102, 74, 32, 8, 2, 0, -9, -13]], [[-100, -27, -8, 5, 23, 56, 124, 325], [-34, -27, 6, 12, 25, 56, 213, 325, 601]], [[18, 7, 2, 0, -22, -46, -103, -293], [-300, -293, -46, -31, -5, 0, 18, 19, 74, 231]], [[105, 73, -4, -73, -201], [-201, -73, -4, 73, 105]]], "outputs": [[[1, 2, 3, 4, 5, 6, 7, 8]], [[1, 2, 3, 4, 5, 6, 7, 8, 9, 10]], [[-20, -10, -5, 0, 6, 7, 8, 9, 10, 25, 35, 36, 37, 38, 39, 40, 50, 62]], [[2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 18, 20]], [[5, 9, 10, 12, 15, 18, 20, 25, 30, 35, 45, 50]], [[-13, -9, -8, -3, -2, 0, 2, 4, 5, 6, 7, 8, 15, 32, 42, 74, 90, 102, 134, 216]], [[-100, -34, -27, -8, 5, 6, 12, 23, 25, 56, 124, 213, 325, 601]], [[-300, -293, -103, -46, -31, -22, -5, 0, 2, 7, 18, 19, 74, 231]], [[-201, -73, -4, 73, 105]]]}
user: Write a function that outputs the transpose of a matrix - a new matrix
where the columns and rows of the original are swapped.

For example, the transpose of:
  
    | 1 2 3 |
    | 4 5 6 |

is

    | 1 4 |
    | 2 5 |
    | 3 6 |

The input to your function will be an array of matrix rows. You can
assume that each row has the same length, and that the height and
width of the matrix are both positive.

Answer: {"fn_name": "transpose", "inputs": [[[[1]]], [[[1, 2, 3]]], [[[1, 2, 3], [4, 5, 6], [7, 8, 9]]], [[[1, 0, 0], [0, 1, 0], [0, 0, 1], [0, 1, 0], [1, 0, 0]]]], "outputs": [[[[1]]], [[[1], [2], [3]]], [[[1, 4, 7], [2, 5, 8], [3, 6, 9]]], [[[1, 0, 0, 0, 1], [0, 1, 0, 1, 0], [0, 0, 1, 0, 0]]]]}
user: # Task
 In the Land Of Chess, bishops don't really like each other. In fact, when two bishops happen to stand on the same diagonal, they immediately rush towards the opposite ends of that same diagonal.

 Given the initial positions (in chess notation) of two bishops, `bishop1` and `bishop2`, calculate their future positions. Keep in mind that bishops won't move unless they see each other along the same diagonal.

# Example

 For `bishop1 = "d7" and bishop2 = "f5"`, the output should be `["c8", "h3"]`.

 ![](https://codefightsuserpics.s3.amazonaws.com/tasks/bishopDiagonal/img/ex_1.jpg?_tm=1473766087137)

 For `bishop1 = "d8" and bishop2 = "b5"`, the output should be `["b5", "d8"]`.

 The bishops don't belong to the same diagonal, so they don't move.

 ![](https://codefightsuserpics.s3.amazonaws.com/tasks/bishopDiagonal/img/ex_2.jpg?_tm=1473766087425)

# Input/Output


 - `[input]` string `bishop1`

    Coordinates of the first bishop in chess notation.


 - `[input]` string `bishop2`

    Coordinates of the second bishop in the same notation.


 - `[output]` a string array

    Coordinates of the bishops in lexicographical order after they check the diagonals they stand on.

Answer: {"fn_name": "bishop_diagonal", "inputs": [["d7", "f5"], ["d8", "b5"], ["a1", "h8"], ["g3", "e1"], ["b4", "e7"]], "outputs": [[["c8", "h3"]], [["b5", "d8"]], [["a1", "h8"]], [["e1", "h4"]], [["a3", "f8"]]]}
user: Write a function that takes a number or a string and gives back the number of **permutations without repetitions** that can generated using all of its element.; more on permutations [here](https://en.wikipedia.org/wiki/Permutation).

For example, starting with:
```
1
45
115
"abc"
```

You could respectively generate:
```
1
45,54
115,151,511
"abc","acb","bac","bca","cab","cba"
```

So you should have, in turn:
```python
perms(1)==1
perms(45)==2
perms(115)==3
perms("abc")==6
```

Answer: {"fn_name": "perms", "inputs": [[2], [25], [342], [1397], [76853], ["a"], ["ab"], ["abc"], [737], [66666]], "outputs": [[1], [2], [6], [24], [120], [1], [2], [6], [3], [1]]}
user: Write

```python
function combine()
```

that combines arrays by alternatingly taking elements passed to it.

E.g

```python
combine(['a', 'b', 'c'], [1, 2, 3]) == ['a', 1, 'b', 2, 'c', 3]
combine(['a', 'b', 'c'], [1, 2, 3, 4, 5]) == ['a', 1, 'b', 2, 'c', 3, 4, 5]
combine(['a', 'b', 'c'], [1, 2, 3, 4, 5], [6, 7], [8]) == ['a', 1, 6, 8, 'b', 2, 7, 'c', 3, 4, 5]
```

Arrays can have different lengths.

Answer: {"fn_name": "combine", "inputs": [[["a", "b", "c"], [1, 2, 3]], [["a", "b", "c"], [1, 2, 3, 4, 5]], [["a", "b", "c"], [1, 2, 3, 4, 5], [6, 7], [8]], [[{"a": 1}, {"b": 2}], [1, 2]], [[{"a": 2, "b": 1}, {"a": 1, "b": 2}], [1, 2, 3, 4], [5, 6], [7]]], "outputs": [[["a", 1, "b", 2, "c", 3]], [["a", 1, "b", 2, "c", 3, 4, 5]], [["a", 1, 6, 8, "b", 2, 7, "c", 3, 4, 5]], [[{"a": 1}, 1, {"b": 2}, 2]], [[{"a": 2, "b": 1}, 1, 5, 7, {"a": 1, "b": 2}, 2, 6, 3, 4]]]}
user: In this kata you need to write a function that will receive two strings (```n1``` and ```n2```), each representing an integer as a binary number. A third parameter will be provided (```o```) as a string representing one of the following operators: add, subtract, multiply.

Your task is to write the calculate function so that it will perform the arithmetic and the result returned should be a string representing the binary result.

Examples:
```
1 + 1 === 10
10 + 10 === 100
```

Negative binary numbers are usually preceded by several 1's. For this kata, negative numbers can be represented with the negative symbol at the beginning of the string.

Examples of negatives:
```
1 - 10 === -1
10 - 100 === -10
```

Answer: {"fn_name": "calculate", "inputs": [["1", "1", "add"], ["1", "1", "subtract"], ["1", "1", "multiply"], ["10", "10", "multiply"], ["100", "10", "subtract"]], "outputs": [["10"], ["0"], ["1"], ["100"], ["10"]]}
user: To pass the series of gates guarded by the owls, Kenneth needs to present them each with a highly realistic portrait of one.  Unfortunately, he is absolutely rubbish at drawing, and needs some code to return a brand new portrait with a moment's notice.

All owl heads look like this:

    ''0v0''

Such beautiful eyes!
However, they differ in their plumage, which is always symmetrical, eg.:

       VVHVAV''0v0''VAVHVV

or
 
    YYAYAH8XH''0v0''HX8HAYAYY

So Kenneth needs a method that will take a garble of text generated by mashing at his keyboard (numbers and letters, but he knows how to avoid punctuation etc.) for a bit and give him a symmetrical owl with a lovely little face, with a truly symmetrical plumage made of uppercase letters and numbers.

(To be clear, the acceptable characters for the plumage are 8,W,T,Y,U,I,O,A,H,X,V and M.)

Answer: {"fn_name": "owl_pic", "inputs": [["xwe"], ["kuawd6r8q27y87t93r76352475437"], ["t6ggggggggWw"], ["xweWXo"]], "outputs": [["XW''0v0''WX"], ["UAW8Y8T''0v0''T8Y8WAU"], ["TWW''0v0''WWT"], ["XWWXO''0v0''OXWWX"]]}
user: Write an algorithm that takes an array and moves all of the zeros to the end, preserving the order of the other elements.

```python
move_zeros([False,1,0,1,2,0,1,3,"a"]) # returns[False,1,1,2,1,3,"a",0,0]
```

Answer: {"fn_name": "move_zeros", "inputs": [[[1, 2, 0, 1, 0, 1, 0, 3, 0, 1]], [[9, 0.0, 0, 9, 1, 2, 0, 1, 0, 1, 0.0, 3, 0, 1, 9, 0, 0, 0, 0, 9]], [["a", 0, 0, "b", "c", "d", 0, 1, 0, 1, 0, 3, 0, 1, 9, 0, 0, 0, 0, 9]], [["a", 0, 0, "b", null, "c", "d", 0, 1, false, 0, 1, 0, 3, [], 0, 1, 9, 0, 0, {}, 0, 0, 9]], [[0, 1, null, 2, false, 1, 0]], [["a", "b"]], [["a"]], [[0, 0]], [[0]], [[]]], "outputs": [[[1, 2, 1, 1, 3, 1, 0, 0, 0, 0]], [[9, 9, 1, 2, 1, 1, 3, 1, 9, 9, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]], [["a", "b", "c", "d", 1, 1, 3, 1, 9, 9, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]], [["a", "b", null, "c", "d", 1, false, 1, 3, [], 1, 9, {}, 9, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]], [[1, null, 2, false, 1, 0, 0]], [["a", "b"]], [["a"]], [[0, 0]], [[0]], [[]]]}
user: The Mormons are trying to find new followers and in order to do that they embark on missions.

Each time they go on a mission, every Mormons converts a fixed number of people (reach) into followers. This continues and every freshly converted Mormon as well as every original Mormon go on another mission and convert the same fixed number of people each. The process continues until they reach a predefined target number of followers (input into the model).

Converted Mormons are unique so that there's no duplication amongst them.

Create a function Mormons(startingNumber, reach, target) that calculates how many missions Mormons need to embark on, in order to reach their target. While each correct solution will pass, for more fun try to make a recursive function.

All model inputs are valid positive integers.

Answer: {"fn_name": "mormons", "inputs": [[40, 2, 120], [40, 2, 121]], "outputs": [[1], [2]]}
user: An **anagram** is the result of rearranging the letters of a word to produce a new word.

**Note:** anagrams are case insensitive

Complete the function to return `true` if the two arguments given are anagrams of each other; return `false` otherwise.


## Examples

* `"foefet"` is an anagram of `"toffee"`

* `"Buckethead"` is an anagram of `"DeathCubeK"`

Answer: {"fn_name": "is_anagram", "inputs": [["foefet", "toffee"], ["Buckethead", "DeathCubeK"], ["Twoo", "WooT"], ["dumble", "bumble"], ["ound", "round"], ["apple", "pale"]], "outputs": [[true], [true], [true], [false], [false], [false]]}
user: The Ackermann function is a famous function that played a big role in computability theory as the first example of a total computable function that is not primitive recursive.

Since then the function has been a bit simplified but is still of good use. Due to its definition in terms of extremely deep recursion it can be used as a benchmark of a compiler's ability to optimize recursion. 

The goal of this kata is to code a function which will be given two inputs, m and n, and will return the Ackermann number A(m,n) defined by:

```
A(m,n) = n+1                          if m=0  
A(m,n) = A(m-1,1)                     if m>0 , n=0
A(m,n) = A(m-1,A(m,n-1))              if m,n > 0
```

m,n should be non-negative integers, the function should return null (Javascript), None (Python), or nil (Ruby) for other type, non-integer and negative numbers. In C, input is restricted to integer type.

Answer: {"fn_name": "Ackermann", "inputs": [[1, 1], [4, 0], [3, 3]], "outputs": [[3], [13], [61]]}
user: A palindrome is a word, phrase, number, or other sequence of characters which reads the same backward as forward. Examples of numerical palindromes are: 

2332
110011
54322345

For this kata, single digit numbers will not be considered numerical palindromes. 

For a given number ```num```, write a function to test if the number contains a numerical palindrome or not and return a boolean (true if it does and false if does not). Return "Not valid" if the input is not an integer or is less than 0. 

Note: Palindromes should be found without permutating ```num```. 

```
palindrome(5) => false
palindrome(1221) => true
palindrome(141221001) => true
palindrome(1215) => true 
palindrome(1294) => false 
palindrome("109982") => "Not valid"
```

Answer: {"fn_name": "palindrome", "inputs": [[868], [1321], [1215], [2], [123322367], [1551], [13598], ["ACCDDCCA"], ["1551"], [-4505], [22.22]], "outputs": [[true], [false], [true], [false], [true], [true], [false], ["Not valid"], ["Not valid"], ["Not valid"], ["Not valid"]]}
user: # Task
 If string has more than one neighboring dashes(e.g. --) replace they with one dash(-). 
 
 Dashes are considered neighbors even if there is some whitespace **between** them.

# Example

 For `str = "we-are- - - code----warriors.-"`
 
 The result should be `"we-are- code-warriors.-"`
 
# Input/Output


 - `[input]` string `str`
 
 
 - `[output]` a string

Answer: {"fn_name": "replace_dashes_as_one", "inputs": [["we-are- - - code----warriors.-"], ["a---b- - -c"], ["a------"], ["Lorem - ipsum- - - dolor sit amet, consectetur adipiscing elit. Praesent tristique lectus non erat dapibus tincidunt. Integer non nibh fermentum, cursus-diam -------pharetra, mattis--risus.-------"]], "outputs": [["we-are- code-warriors.-"], ["a-b-c"], ["a-"], ["Lorem - ipsum- dolor sit amet, consectetur adipiscing elit. Praesent tristique lectus non erat dapibus tincidunt. Integer non nibh fermentum, cursus-diam -pharetra, mattis-risus.-"]]}
user: ## Task

Complete the function that receives an array of strings (`arr`) as an argument and returns all the valid Roman numerals.

Basic Roman numerals are denoted as:

```
I: 1, V: 5, X: 10, L: 50, C: 100, D: 500, M: 1000
```

For the purposes of this kata we will consider valid only the numbers in range 0 - 5000 (both exclusive) since numbers >= 5000 were written in a different way (you had to place a heavy bar over the numeral that meant it was multiplied with 1000).

There are other ways of tackling this problem but the easiest is probably writing a Regular Expression.

### Let's break the problem down:

To match a set of characters `/[1-9]/`(single digits) you should take into consideration the Roman numbers `I, II, III, IV, V, VI, VII, VIII, IX`. This could be done by testing with `/IX|IV|V?I{0,3}/`. This part `/I{0,3}/` matches `I, II or III` but we have a `V` appearing 0 or 1 times because of the `?` so `/V?I{0,3}/` would match `I,II,III,V,VI,VII or VIII`. However there is one flaw with this. Do you see it? It is the fact that it would also match an empty string `""` because of the {0,3}. In order to pass the tests you will have to **filter out the empty strings** as well. So the entire part matches `I to IX`(inclusive) but what about larger digits?

Use the same logic for the digit in the tens place and the hundreds place. Be sure to wrap each part (units, tens, hundreds, thousands) in a pair of braces `(IX|IV|V?I{0,3})` and for the digit in the thousands place the logic is pretty straight forward, you just have to match `M` 0 to 4 times (since 5000 is not included). Wrap everything up with `^` and `$` to make sure you match the entire string (^ matches from the beginning of the string, while $ denotes the end, meaning there is nothing after that sign.

## Examples

```
["I", "IIV", "IVI", "IX", "XII", "MCD"] ==> ["I", "IX", "XII", "MCD"]

["MMMMCMXCIX", "MMDCXLIV", "MMCIX", "CLD", "LCD"]) ==> ["MMMMCMXCIX", "MMDCXLIV", "MMCIX"]
```

Good luck!

Answer: {"fn_name": "valid_romans", "inputs": [[["MMMCDLXVL", "MDLXXXVI", "DCLXII", "MMMMCLL", "MMDCCCLXXXIVCD"]], [["MMMMCCCXXXII", "MMDCCCXXVCD", "MMCCCXLV", "DCCLXVIIICD", "MMMMCXII"]], [["DCCLIVI", "MDCCXXXVVI", "MDLXXVI", "MDVIL", "MCCLXIII"]], [["DV", "", "CLVIII", "MDCCCXXCD", "MDCLXVI", "MMMDCCCLXXXVI"]], [["MMCDXVIII", "", "MMMCCXXXIV", "MMMMDCLXXXI", "MMMCMXIL", "MMMMCLXI"]]], "outputs": [[["MDLXXXVI", "DCLXII"]], [["MMMMCCCXXXII", "MMCCCXLV", "MMMMCXII"]], [["MDLXXVI", "MCCLXIII"]], [["DV", "CLVIII", "MDCLXVI", "MMMDCCCLXXXVI"]], [["MMCDXVIII", "MMMCCXXXIV", "MMMMDCLXXXI", "MMMMCLXI"]]]}