1. Python / Говнокод #24687

    −2

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    11. 11
    12. 12
    13. 13
    14. 14
    15. 15
    16. 16
    17. 17
    18. 18
    19. 19
    20. 20
    21. 21
    22. 22
    def printlen(x):
        print(len(x))
    
    def argslist(x):
        return list(x.args)
    
    def add(value_error, arg):
        raise Exception(*value_error, *arg)
    
    def fibonacci(a, b, x):
        try:
            assert b<x
            printlen(b)
            try:
                add(a,b)
            except Exception as e:
                fibonacci(argslist(e), a, x)
        except AssertionError as e:
            print(e)
    
    threshold = 1000
    fibonacci([[]],[[]],[[]]*threshold)

    Выводит числа Фибоначчи от 1 до threshold.
    Если убрать строку "assert b<x", то python.exe займёт всю оперативку, потому что зачем лимит вложенности исключений?

    Запостил: tungmetla, 30 Августа 2018

    Комментарии (8) RSS

    Добавить комментарий