This kata is based on a [variation](https://www.codewars.com/kata/happy-numbers-5) of *Happy Numbers* by TySlothrop. It is advisable to complete it first to grasp the idea and then move on to this one.
___
Hello, my dear friend, and welcome to another *Happy Numbers* kata! What? You're not interested in them anymore? They are all the same? But what if I say that this one is a *performance version*...  
___
# Your task:
Write a function `performant_numbers` which takes a number `n` as an argument and returns a list of all *happy numbers* from `1` to `n` inclusive. For example:
```
performant_numbers(10)   =>  [1, 7, 10]
performant_numbers(50)   =>  [1, 7, 10, 13, 19, 23, 28, 31, 32, 44, 49]
performant_numbers(100)  =>  [1, 7, 10, 13, 19, 23, 28, 31, 32, 44, 49, 68, 70, 79, 82, 86, 91, 94, 97, 100]
```
# Test suite:
* `5000` tests with number `n` being up to `300000`
* The reference solution takes around `4.9` seconds to calculate the result
* you are not allowed to hardcode the sequence: you'll have to compute it (max length of the code: 1700 characters)
___
Will you take up the challenge?
from bisect import bisect

def happy_numbers(n):
    happy_list = []
    happy = {1}
    unhappy = set()
    for k in range(1, n+1):
        i = k
        seen = set()
        while True:
            if i in happy:
                happy_list.append(k)
                happy |= seen
                break
            elif i in unhappy or i in seen:
                unhappy |= seen
                break
            seen.add(i)
            i = sum(int(d)**2 for d in str(i))
    return happy_list

happy_list = happy_numbers(300000)

def performant_numbers(n):
    i = bisect(happy_list, n)
    return happy_list[:i]
from bisect import bisect

def happy_numbers(n):
    happy_list = []
    happy = {1}
    unhappy = set()
    for k in range(1, n+1):
        i = k
        seen = set()
        while True:
            if i in happy:
                happy_list.append(k)
                happy |= seen
                break
            elif i in unhappy or i in seen:
                unhappy |= seen
                break
            seen.add(i)
            i = sum(int(d)**2 for d in str(i))
    return happy_list

happy_list = happy_numbers(300000)

def performant_numbers(n):
    i = bisect(happy_list, n)
    return happy_list[:i]