meetforever/GRPO_CL huggingface dataset:
user: # Task
 You have set an alarm for some of the week days.
 
 Days of the week are encoded in binary representation like this:
```
0000001 - Sunday
0000010 - Monday
0000100 - Tuesday
0001000 - Wednesday
0010000 - Thursday
0100000 - Friday 
1000000 - Saturday```
For example, if your alarm is set only for Sunday and Friday, the representation will be `0100001`. 

 Given the current day of the week, your task is to find the day of the week when alarm will ring next time.

# Example

 For `currentDay = 4, availableWeekDays = 42`, the result should be `6`.
 
 ```
currentDay = 4 means the current Day is Wednesday
availableWeekDays = 42 convert to binary is "0101010"
So the next day is 6 (Friday)
```

# Input/Output


 - `[input]` integer `currentDay`
 
 The weekdays range from 1 to 7, 1 is Sunday and 7 is Saturday


 - `[input]` integer `availableWeekDays`
 
 An integer. Days of the week are encoded in its binary representation.


 - `[output]` an integer

 The next day available.

Answer: {"fn_name": "next_day_of_week", "inputs": [[4, 42], [6, 42], [7, 42]], "outputs": [[6], [2], [2]]}
user: In this Kata, you will write a function `doubles` that will remove double string characters that are adjacent to each other.

For example:

`doubles('abbcccdddda') = 'aca'`, because, from left to right:
```Haskell
a) There is only one 'a' on the left hand side, so it stays.
b) The 2 b's disappear because we are removing double characters that are adjacent. 
c) Of the 3 c's, we remove two. We are only removing doubles. 
d) The 4 d's all disappear, because we first remove the first double, and again we remove the second double.
e) There is only one 'a' at the end, so it stays.
```

Two more examples: `doubles('abbbzz') = 'ab'` and `doubles('abba') = ""`. In the second example, when we remove the b's in `'abba'`, the double `a` that results is then removed.

The strings will contain lowercase letters only. More examples in the test cases. 

Good luck!

Answer: {"fn_name": "doubles", "inputs": [["abbbzz"], ["zzzzykkkd"], ["abbcccdddda"], ["vvvvvoiiiiin"], ["rrrmooomqqqqj"], ["xxbnnnnnyaaaaam"], ["qqqqqqnpppgooooonpppppqmmmmmc"], ["qqqqqwwwx"], ["jjjfzzzzzzsddgrrrrru"], ["jjjjjfuuuutgggggqppdaaas"], ["iiiiibllllllyqqqqqbiiiiiituuf"], ["mmmmmmuzzqllllmqqqp"]], "outputs": [["ab"], ["ykd"], ["aca"], ["voin"], ["rmomj"], ["bnyam"], ["npgonpqmc"], ["qwx"], ["jfsgru"], ["jftgqdas"], ["ibyqbtf"], ["uqmqp"]]}
user: ## Task 

Using `n` as a parameter in the function `pattern`, where `n>0`, complete the codes to get the pattern (take the help of examples):

**Note:** There is no newline in the end (after the pattern ends)


### Examples

`pattern(3)` should return `"1\n1*2\n1**3"`, e.g. the following:
```
1
1*2
1**3
```
`pattern(10):` should return the following:
```
1
1*2
1**3
1***4
1****5
1*****6
1******7
1*******8
1********9
1*********10
```

Answer: {"fn_name": "pattern", "inputs": [[3], [7], [20]], "outputs": [["1\n1*2\n1**3"], ["1\n1*2\n1**3\n1***4\n1****5\n1*****6\n1******7"], ["1\n1*2\n1**3\n1***4\n1****5\n1*****6\n1******7\n1*******8\n1********9\n1*********10\n1**********11\n1***********12\n1************13\n1*************14\n1**************15\n1***************16\n1****************17\n1*****************18\n1******************19\n1*******************20"]]}
user: Implement a function/class, which should return an integer if the input string is in one of the formats specified below, or `null/nil/None` otherwise.

Format:
* Optional `-` or `+`
* Base prefix `0b` (binary), `0x` (hexadecimal), `0o` (octal), or in case of no prefix decimal.
* Digits depending on base

Any extra character (including whitespace) makes the input invalid, in which case you should return `null/nil/None`.

Digits are case insensitive, but base prefix must be lower case.

See the test cases for examples.

Answer: {"fn_name": "to_integer", "inputs": [["123"], ["0x123"], ["0o123"], ["0123"], ["123 "], [" 123"], ["0b1010"], ["+123"], ["-123"], ["0B1010"], ["0b12"], ["-0x123"], ["-0o123"], ["-0123"], ["123\n"], ["\n123"], ["-0b1010"], ["0xDEADbeef"], ["0X123"], ["0O123"], ["0o18"]], "outputs": [[123], [291], [83], [123], [null], [null], [10], [123], [-123], [null], [null], [-291], [-83], [-123], [null], [null], [-10], [3735928559], [null], [null], [null]]}
user: # Task
 The number is considered to be `unlucky` if it does not have digits `4` and `7` and is divisible by `13`. Please count all unlucky numbers not greater than `n`.

# Example

 For `n = 20`, the result should be `2` (numbers `0 and 13`).
 
 For `n = 100`, the result should be `7` (numbers `0, 13, 26, 39, 52, 65, and 91`)
 
# Input/Output


 - `[input]` integer `n`

 `1 ≤ n ≤ 10^8(10^6 in Python)`


 - `[output]` an integer

Answer: {"fn_name": "unlucky_number", "inputs": [[20], [100], [1000], [1000000]], "outputs": [[2], [7], [40], [20182]]}
user: Define a method that accepts 2 strings as parameters. The method returns the first string sorted by the second.

```python
sort_string("foos", "of")       == "oofs"
sort_string("string", "gnirts") == "gnirts"
sort_string("banana", "abn")    == "aaabnn"
```

To elaborate, the second string defines the ordering. It is possible that in the second string characters repeat, so you should remove repeating characters, leaving only the first occurrence.

Any character in the first string that does not appear in the second string should be sorted to the end of the result in original order.

Answer: {"fn_name": "sort_string", "inputs": [["banana", "abn"], ["banana", "xyz"], ["banana", "an"], ["foos", "of"], ["string", "gnirts"], ["banana", "a"], ["bungholio", "aacbuoldiiaoh"], ["fumyarhncujlj", "nsejcwn"]], "outputs": [["aaabnn"], ["banana"], ["aaannb"], ["oofs"], ["gnirts"], ["aaabnn"], ["buoolihng"], ["njjcfumyarhul"]]}
user: Magic The Gathering is a collectible card game that features wizards battling against each other with spells and creature summons. The game itself can be quite complicated to learn. In this series of katas, we'll be solving some of the situations that arise during gameplay. You won't need any prior knowledge of the game to solve these contrived problems, as I will provide you with enough information.

## Creatures

Each creature has a power and toughness. We will represent this in an array. [2, 3] means this creature has a power of 2 and a toughness of 3.

When two creatures square off, they each deal damage equal to their power to each other at the same time. If a creature takes on damage greater than or equal to their toughness, they die.

Examples:

- Creature 1 - [2, 3]
- Creature 2 - [3, 3]
- Creature 3 - [1, 4]
- Creature 4 - [4, 1]

If creature 1 battles creature 2, creature 1 dies, while 2 survives. If creature 3 battles creature 4, they both die, as 3 deals 1 damage to 4, but creature 4 only has a toughness of 1.

Write a function `battle(player1, player2)` that takes in 2 arrays of creatures. Each players' creatures battle each other in order (player1[0] battles the creature in player2[0]) and so on. If one list of creatures is longer than the other, those creatures are considered unblocked, and do not battle.

Your function should return an object (a hash in Ruby) with the keys player1 and player2 that contain the power and toughness of the surviving creatures.

Example:
```
Good luck with your battles!


Check out my other Magic The Gathering katas:


Magic The Gathering #1: Creatures
Magic The Gathering #2: Mana

Answer: {"fn_name": "battle", "inputs": [[[[2, 3], [1, 4]], [[3, 3], [4, 1]]], [[], []], [[[1, 1]], [[1, 1]]], [[[2, 1]], [[2, 1]]], [[[1, 2]], [[1, 2]]], [[[2, 3]], [[3, 2]]], [[[2, 7]], [[3, 5]]], [[[2, 5]], [[6, 6]]], [[[6, 6]], [[2, 5]]], [[], [[1, 1], [2, 2]]], [[[1, 1], [2, 2]], []], [[[1, 3], [3, 5], [4, 6], [5, 2]], [[2, 4], [6, 1], [4, 4], [3, 7], [3, 1]]]], "outputs": [[{"player1": [], "player2": [[3, 3]]}], [{"player1": [], "player2": []}], [{"player1": [], "player2": []}], [{"player1": [], "player2": []}], [{"player1": [[1, 2]], "player2": [[1, 2]]}], [{"player1": [], "player2": []}], [{"player1": [[2, 7]], "player2": [[3, 5]]}], [{"player1": [], "player2": [[6, 6]]}], [{"player1": [[6, 6]], "player2": []}], [{"player1": [], "player2": [[1, 1], [2, 2]]}], [{"player1": [[1, 1], [2, 2]], "player2": []}], [{"player1": [[1, 3], [4, 6]], "player2": [[2, 4], [3, 7], [3, 1]]}]]}
user: We need a function (for commercial purposes) that may perform integer partitions with some constraints.
The function should select how many elements each partition should have.
The function should discard some "forbidden" values in each partition.
So, create ```part_const()```, that receives three arguments.
```part_const((1), (2), (3))```
```
(1) - The integer to be partitioned

(2) - The number of elements that each partition should have

(3) - The "forbidden" element that cannot appear in any partition
```
```part_const()``` should output the amount of different integer partitions with the constraints required.

Let's see some cases:
```python
part_const(10, 3, 2) ------> 4 

/// we may have a total of 8 partitions of three elements (of course, the sum of the elements of each partition should be equal 10) :
[1, 1, 8], [1, 2, 7], [1, 3, 6], [1, 4, 5], [2, 2, 6], [2, 3, 5], [2, 4, 4], [3, 3, 4]

but 2 is the forbidden element, so we have to discard [1, 2, 7], [2, 2, 6], [2, 3, 5] and [2, 4, 4] 

So the obtained partitions of three elements without having 2 in them are:
[1, 1, 8], [1, 3, 6], [1, 4, 5] and [3, 3, 4] (4 partitions)///
```

```part_const()``` should have a particular feature:

 if we introduce ```0``` as the forbidden element, we will obtain the total amount of partitions with the constrained number of elements.

In fact, 
```python
part_const(10, 3, 0) ------> 8 # The same eight partitions that we saw above.
```

Enjoy it and happy coding!!

Answer: {"fn_name": "part_const", "inputs": [[10, 3, 2], [10, 3, 0], [10, 4, 1], [10, 5, 3], [15, 5, 3], [15, 5, 4], [15, 3, 3]], "outputs": [[4], [8], [2], [4], [15], [19], [13]]}
user: As the title suggests, this is the hard-core version of  another neat kata.

The task is simple to explain: simply sum all the numbers from the first parameter being the beginning to the second parameter being the upper limit (possibly included), going in steps expressed by the third parameter:

```python
sequence_sum(2, 2, 2) # 2
sequence_sum(2, 6, 2) # 12 (= 2 + 4 + 6)
sequence_sum(1, 5, 1) # (= 1 + 2 + 3 + 4 + 5)
sequence_sum(1, 5, 3) # 5 (= 1 + 4)
```

If it is an impossible sequence (with the beginning being larger the end and a positive step or the other way around), just return `0`. See the provided test cases for further examples :)

**Note:** differing from the other base kata, much larger ranges are going to be tested, so you should hope to get your algo optimized and to avoid brute-forcing your way through the solution.

Answer: {"fn_name": "sequence_sum", "inputs": [[2, 6, 2], [1, 5, 1], [1, 5, 3], [-1, -5, -3], [16, 15, 3], [-24, -2, 22], [-2, 4, 658], [780, 6851543, 5], [9383, 71418, 2], [20, 673388797, 5]], "outputs": [[12], [15], [5], [-5], [0], [-26], [-2], [4694363402480], [1253127200], [45345247259849570]]}
user: Write a method that takes a string as an argument and groups the number of time each character appears in the string as a hash sorted by the highest number of occurrences.

The characters should be sorted alphabetically e.g:

```python
get_char_count("cba") == {1: ["a", "b", "c"]}
```

You should ignore spaces, special characters and count uppercase letters as lowercase ones.

For example: 
```python
get_char_count("Mississippi")           ==  {4: ["i", "s"], 2: ["p"], 1: ["m"]}
get_char_count("Hello. Hello? HELLO!")  ==  {6: ["l"], 3: ["e", "h", "o"]}
get_char_count("aaa...bb...c!")         ==  {3: ["a"], 2: ["b"], 1: ["c"]}
get_char_count("abc123")                ==  {1: ["1", "2", "3", "a", "b", "c"]}
get_char_count("aaabbbccc")             ==  {3: ["a", "b", "c"]}
```

Answer: {"fn_name": "get_char_count", "inputs": [["Get me the bacon!"], ["Codewars is bacon"], ["France is also bacon"], ["AaAAaAAabB!B!B3b23jdc"], [""], ["!!!@@@"], ["Mississippi"], ["Hello. Hello? HELLO!"], ["aaa...bb...c!"], ["abc123"], ["aaabbbccc"]], "outputs": [[{"3": ["e"], "2": ["t"], "1": ["a", "b", "c", "g", "h", "m", "n", "o"]}], [{"2": ["a", "c", "o", "s"], "1": ["b", "d", "e", "i", "n", "r", "w"]}], [{"3": ["a"], "2": ["c", "n", "o", "s"], "1": ["b", "e", "f", "i", "l", "r"]}], [{"8": ["a"], "5": ["b"], "2": ["3"], "1": ["2", "c", "d", "j"]}], [{}], [{}], [{"4": ["i", "s"], "2": ["p"], "1": ["m"]}], [{"6": ["l"], "3": ["e", "h", "o"]}], [{"3": ["a"], "2": ["b"], "1": ["c"]}], [{"1": ["1", "2", "3", "a", "b", "c"]}], [{"3": ["a", "b", "c"]}]]}
user: # Definition

**_Extra perfect number_** *is the number that* **_first_** and **_last_** *bits* are **_set bits_**.

____

# Task

**_Given_**  *a positive integer*   `N` ,  **_Return_** the **_extra perfect numbers_** *in range from*  `1`  to  `N` .
____

# Warm-up (Highly recommended)

# [Playing With Numbers Series](https://www.codewars.com/collections/playing-with-numbers)
___

# Notes 


* **_Number_** *passed is always*  **_Positive_** .

* **_Returned array/list_** should *contain the extra perfect numbers in ascending order*  **from lowest to highest**
___

# Input >> Output Examples

```
extraPerfect(3)  ==>  return {1,3}
```
## **_Explanation_**:

# (1)10 =(1)2

**First** and **last** bits as **_set bits_**.

# (3)10 = (11)2

**First** and **last** bits as **_set bits_**.
___

```
extraPerfect(7)  ==>  return {1,3,5,7}
```

## **_Explanation_**:

# (5)10 = (101)2

**First** and **last** bits as **_set bits_**.

# (7)10 = (111)2

**First** and **last** bits as **_set bits_**.
___
___
___

# [Playing with Numbers Series](https://www.codewars.com/collections/playing-with-numbers)

# [Playing With Lists/Arrays Series](https://www.codewars.com/collections/playing-with-lists-slash-arrays)

# [For More Enjoyable Katas](http://www.codewars.com/users/MrZizoScream/authored)
___

## ALL translations are welcomed

## Enjoy Learning !!
# Zizou

Answer: {"fn_name": "extra_perfect", "inputs": [[3], [5], [7], [28], [39]], "outputs": [[[1, 3]], [[1, 3, 5]], [[1, 3, 5, 7]], [[1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27]], [[1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39]]]}
user: Create a program that will take in a string as input and, if there are duplicates of more than two alphabetical characters in the string, returns the string with all the extra characters in a bracket.

For example, the input "aaaabbcdefffffffg" should return  "aa[aa]bbcdeff[fffff]g" 

Please also ensure that the input is a string, and return "Please enter a valid string" if it is not.

Answer: {"fn_name": "string_parse", "inputs": [["aaaabbcdefffffffg"], [3], ["boopdedoop"], ["helloookat"], [true], [""], ["aAAabbcdeffFfFffg"], ["aAAabbcdeFFFffffg"], [{}], [[5.3]]], "outputs": [["aa[aa]bbcdeff[fffff]g"], ["Please enter a valid string"], ["boopdedoop"], ["helloo[o]kat"], ["Please enter a valid string"], [""], ["aAAabbcdeffFfFffg"], ["aAAabbcdeFF[F]ff[ff]g"], ["Please enter a valid string"], ["Please enter a valid string"]]}
user: This kata requires you to convert minutes (`int`) to hours and minutes in the format `hh:mm` (`string`).

If the input is `0` or negative value, then you should return `"00:00"`

**Hint:** use the modulo operation to solve this challenge. The modulo operation simply returns the remainder after a division. For example the remainder of 5 / 2 is 1, so 5 modulo 2 is 1.


## Example

If the input is `78`, then you should return `"01:18"`, because 78 minutes converts to 1 hour and 18 minutes.


Good luck! :D

Answer: {"fn_name": "time_convert", "inputs": [[0], [-6], [8], [32], [75], [63], [134], [180], [970], [565757]], "outputs": [["00:00"], ["00:00"], ["00:08"], ["00:32"], ["01:15"], ["01:03"], ["02:14"], ["03:00"], ["16:10"], ["9429:17"]]}
user: Don't Drink the Water

Given a two-dimensional array representation of a glass of mixed liquids, sort the array such that the liquids appear in the glass based on their density. (Lower density floats to the top) The width of the glass will not change from top to bottom.

```
======================
|   Density Chart    |
======================
| Honey   | H | 1.36 |
| Water   | W | 1.00 |
| Alcohol | A | 0.87 |
| Oil     | O | 0.80 |
----------------------

[                            [
 ['H', 'H', 'W', 'O'],        ['O','O','O','O']
 ['W', 'W', 'O', 'W'],  =>    ['W','W','W','W']
 ['H', 'H', 'O', 'O']         ['H','H','H','H']
 ]                           ]
 
 ```
 
 The glass representation may be larger or smaller. If a liquid doesn't fill a row, it floats to the top and to the left.

Answer: {"fn_name": "separate_liquids", "inputs": [[[["H", "H", "W", "O"], ["W", "W", "O", "W"], ["H", "H", "O", "O"]]], [[["A", "A", "O", "H"], ["A", "H", "W", "O"], ["W", "W", "A", "W"], ["H", "H", "O", "O"]]], [[["A", "H", "W", "O"]]], [[["A"], ["H"], ["W"], ["O"]]], [[]]], "outputs": [[[["O", "O", "O", "O"], ["W", "W", "W", "W"], ["H", "H", "H", "H"]]], [[["O", "O", "O", "O"], ["A", "A", "A", "A"], ["W", "W", "W", "W"], ["H", "H", "H", "H"]]], [[["O", "A", "W", "H"]]], [[["O"], ["A"], ["W"], ["H"]]], [[]]]}
user: # Task

The game starts with `n` people standing in a circle. The presenter counts `m` people starting with the first one, and gives `1` coin to each of them. The rest of the players receive `2` coins each. After that, the last person who received `1` coin leaves the circle, giving everything he had to the next participant (who will also be considered "the first in the circle" in the next round). This process continues until only 1 person remains.

Determine the `number` of this person and how many `coins` he has at the end of the game.

The result should be a pair of values in the format: `[person, coins]`.

## Example:

```
n = 8, m = 3

People
1 2 3      1 2 ∙      1 2 ∙      ∙ 2 ∙       ∙  2 ∙       ∙ ∙  ∙       ∙ ∙  ∙
8   4  =>  8   4  =>  8   4  =>  8   4  =>   8    4  =>   8    4  =>   ∙    4  =>  7
7 6 5      7 6 5      7 ∙ 5      7 ∙ 5       7  ∙ ∙       7 ∙  ∙       7 ∙  ∙

Coins
0 0 0      1 1 ∙      3 3 ∙      ∙ 9 ∙       ∙ 10 ∙       ∙ ∙  ∙       ∙ ∙  ∙   
0   0  =>  2   3  =>  4   4  =>  5   6  =>   7    7  =>   8   20  =>   ∙   30  =>  51
0 0 0      2 2 2      7 ∙ 3      8 ∙ 5      16 ∙  ∙      17 ∙  ∙      18 ∙  ∙ 
```

## Notes:

* The presenter can do several full circles during one counting.
* In this case, the same person will receive `1` coin multiple times, i.e. no matter how many people are left in the circle, at least `m` coins will always be distributed among the participants during the round.
* If a person had already received `1` coin (possibly multiple times), he won't receive any additional `2` coins **at once(!)** during that round.
* People are counted starting with `1`.
* `m` can be **bigger** than `n` at start

Answer: {"fn_name": "find_last", "inputs": [[5, 1], [8, 3], [75, 34], [82, 49], [73, 38], [86, 71], [61, 17], [42, 38], [29, 5], [64, 49], [61, 20], [88, 52]], "outputs": [[[5, 24]], [[7, 51]], [[35, 4238]], [[48, 5091]], [[61, 3996]], [[10, 6275]], [[26, 3000]], [[12, 1578]], [[28, 740]], [[43, 3327]], [[32, 2922]], [[59, 5856]]]}
user: Let's pretend your company just hired your friend from college and paid you a referral bonus. Awesome! To celebrate, you're taking your team out to the terrible dive bar next door and using the referral bonus to buy, and build, the largest three-dimensional beer can pyramid you can. And then probably drink those beers, because let's pretend it's Friday too. 

A beer can pyramid will square the number of cans in each level - 1 can in the top level, 4 in the second, 9 in the next, 16, 25... 

Complete the beeramid function to return the number of **complete** levels of a beer can pyramid you can make, given the parameters of: 

1) your referral bonus, and

2) the price of a beer can

For example:

Answer: {"fn_name": "beeramid", "inputs": [[9, 2], [10, 2], [11, 2], [21, 1.5], [454, 5], [455, 5], [4, 4], [3, 4], [0, 4], [-1, 4]], "outputs": [[1], [2], [2], [3], [5], [6], [1], [0], [0], [0]]}
user: Switch/Case - Bug Fixing #6

Oh no! Timmy's evalObject function doesn't work. He uses Switch/Cases to evaluate the given properties of an object, can you fix timmy's function?

Answer: {"fn_name": "eval_object", "inputs": [[{"a": 1, "b": 1, "operation": "+"}], [{"a": 1, "b": 1, "operation": "-"}], [{"a": 1, "b": 1, "operation": "/"}], [{"a": 1, "b": 1, "operation": "*"}], [{"a": 1, "b": 1, "operation": "%"}], [{"a": 1, "b": 1, "operation": "**"}]], "outputs": [[2], [0], [1], [1], [0], [1]]}
user: Your task is to determine how many files of the copy queue you will be able to save into your Hard Disk Drive. The files must be saved in the order they appear in the queue. 

### Input:

* Array of file sizes `(0 <= s <= 100)`
* Capacity of the HD `(0 <= c <= 500)`

### Output:

* Number of files that can be fully saved in the HD. 

### Examples:

```
save([4,4,4,3,3], 12) -> 3
# 4+4+4 <= 12, but 4+4+4+3 > 12
```

```
save([4,4,4,3,3], 11) -> 2
# 4+4 <= 11, but 4+4+4 > 11
```

Do not expect any negative or invalid inputs.

Answer: {"fn_name": "save", "inputs": [[[4, 4, 4, 3, 3], 12], [[4, 4, 4, 3, 3], 11], [[4, 8, 15, 16, 23, 42], 108], [[13], 13], [[1, 2, 3, 4], 250], [[100], 500], [[11, 13, 15, 17, 19], 8], [[45], 12]], "outputs": [[3], [2], [6], [1], [4], [1], [0], [0]]}
user: Given an array of positive integers, replace every element with the least greater element to its right.
 If there is no greater element to its right, replace it with -1. For instance, given the array 
 
 `[8, 58, 71, 18, 31, 32, 63, 92, 43, 3, 91, 93, 25, 80, 28]`,
 
 the desired output is 
 
 `[18, 63, 80, 25, 32, 43, 80, 93, 80, 25, 93, -1, 28, -1, -1]`.

Your task is to create a function "arrayManip()" that takes in an array as its argument, manipulates the array as described above, then return the resulting array.

Note: Return a new array, rather than modifying the passed array.

Answer: {"fn_name": "array_manip", "inputs": [[[8, 58, 71, 18, 31, 32, 63, 92, 43, 3, 91, 93, 25, 80, 28]], [[2, 4, 18, 16, 7, 3, 9, 13, 18, 10]]], "outputs": [[[18, 63, 80, 25, 32, 43, 80, 93, 80, 25, 93, -1, 28, -1, -1]], [[3, 7, -1, 18, 9, 9, 10, 18, -1, -1]]]}
user: Find the longest substring within a string that contains at most 2 unique characters.

```
substring("a") => "a"
substring("aaa") => "aaa"
substring("abacd") => "aba"
substring("abacddcd") => "cddcd"
substring("cefageaacceaccacca") => "accacca"
```

This function will take alphanumeric characters as input.

In cases where there could be more than one correct answer, the first string occurrence should be used. For example, substring('abc') should return 'ab' instead of 'bc'.

Although there are O(N^2) solutions to this problem, you should try to solve this problem in O(N) time. Tests may pass for O(N^2) solutions but, this is not guaranteed.

This question is much harder than some of the other substring questions. It's easy to think that you have a solution and then get hung up on the implementation.

Answer: {"fn_name": "substring", "inputs": [[""], ["a"], ["aa"], ["aaa"], ["ab"], ["aba"], ["abc"], ["abcba"], ["bbacc"], ["ccddeeff"], ["bbacddddcdd"], ["abcddeejabbedsajaajjaajjajajajjajjaaacedajajaj"], ["aaaaaaaaaaaaaaaaaaaabbbbbbbbbbbbbbbbbbbbccccccccccccccccccccddddddddddddddddddddeeeeeeeeeeeeeeeeeeeeffffffffffffffffffffgggggggggggggggggggghhhhhhhhhhhhhhhhhhhhiiiiiiiiiiiiiiiiiiiijjjjjjjjjjjjjjjjjjjjkkkkkkkkkkkkkkkkkkkkllllllllllllllllllllmmmmmmmmmmmmmmmmmmmmnnnnnnnnnnnnnnnnnnnnooooooooooooooooooooppppppppppppppppppppqqqqqqqqqqqqqqqqqqqqrrrrrrrrrrrrrrrrrrrrssssssssssssssssssssttttttttttttttttttttuuuuuuuuuuuuuuuuuuuuvvvvvvvvvvvvvvvvvvvvwwwwwwwwwwwwwwwwwwwwxxxxxxxxxxxxxxxxxxxxyyyyyyyyyyyyyyyyyyyyzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz"]], "outputs": [[""], ["a"], ["aa"], ["aaa"], ["ab"], ["aba"], ["ab"], ["bcb"], ["bba"], ["ccdd"], ["cddddcdd"], ["ajaajjaajjajajajjajjaaa"], ["yyyyyyyyyyyyyyyyyyyyzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz"]]}