# Scenario 

*You're saying good-bye your best friend* , **_See you next happy year_** . 

**_Happy Year_** *is the year with only distinct digits* , (e.g) **_2018_**

___
# Task

**_Given_** a year, **_Find_** **_The next happy year_** or **_The closest year You'll see your best friend_**      ![!alt](https://i.imgur.com/mdX8dJP.png) ![!alt](https://i.imgur.com/mdX8dJP.png)

___
# Notes

* **_Year_** Of Course always **_Positive_** .
* **_Have no fear_** , *It is guaranteed that the answer exists* . 
* **_It's not necessary_** *that the year passed to the function is Happy one* .   
* **_Input Year with in range_** *(1000  ≤  y  ≤  9000)*

____
# Input >> Output Examples:

```
nextHappyYear (7712) ==> return (7801)
```

## **_Explanation_**:

As the **_Next closest year with only distinct digits is_**  *7801* . 
___

```
nextHappyYear (8989) ==> return (9012)
```

## **_Explanation_**:

As the **_Next closest year with only distinct digits is_**  *9012* . 
___

```
nextHappyYear (1001) ==> return (1023)
```

## **_Explanation_**:

As the **_Next closest year with only distinct digits is_**  *1023* .
___
___
___

# [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

Difficulty: introductory

Starter code:

def next_happy_year(year):
	

Solutions:
def next_happy_year(year):
    year += 1
    
    while len(set(str(year))) != 4:
        year += 1
    
    return year

def next_happy_year(year):
    for n in range(year+1, 9999):
        if len(set(str(n))) == 4:
            return n

def next_happy_year(year):
    while True:
        year+=1
        if len(str(year)) == len(set(str(year))):
            return year

def next_happy_year(year):
    return year + 1 if len(set(str(year + 1))) == 4 else next_happy_year(year + 1)


# 😉😉

def next_happy_year(year):
    y = year + 1
    while len(str(y)) != len(set(str(y))):
        y += 1
    return y

def next_happy_year(year):
    while True:
        year+=1
        if len(set(c for c in str(year))) == len(str(year)):
            return year

def next_happy_year(year):
    return  next(y for y in range(year+1, 9877) if len(set(str(y))) == 4)

def next_happy_year(year):
    while True:
        year += 1
        if len(str(year)) == len(set(str(year))): break
    return year # cant believe this works

import re

def next_happy_year(year):
    return year + 1 if re.match(r'(?:([0-9])(?!.*\1)){4}', str(year + 1)) else next_happy_year(year + 1)