1. Haskell / Говнокод #29195

    0

    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
    23. 23
    24. 24
    25. 25
    26. 26
    27. 27
    28. 28
    29. 29
    30. 30
    31. 31
    32. 32
    33. 33
    34. 34
    35. 35
    36. 36
    37. 37
    38. 38
    39. 39
    40. 40
    41. 41
    42. 42
    43. 43
    44. 44
    45. 45
    46. 46
    47. 47
    48. 48
    49. 49
    50. 50
    51. 51
    52. 52
    53. 53
    54. 54
    55. 55
    56. 56
    57. 57
    58. 58
    59. 59
    60. 60
    61. 61
    62. 62
    63. 63
    64. 64
    65. 65
    66. 66
    67. 67
    68. 68
    69. 69
    70. 70
    71. 71
    72. 72
    73. 73
    74. 74
    75. 75
    76. 76
    77. 77
    78. 78
    79. 79
    80. 80
    81. 81
    82. 82
    83. 83
    84. 84
    85. 85
    86. 86
    87. 87
    88. 88
    89. 89
    90. 90
    91. 91
    92. 92
    93. 93
    94. 94
    95. 95
    96. 96
    97. 97
    98. 98
    99. 99
    (defun cdr2 (list) ;; faster that cdr on 30%
      (let* ((haskell (sb-sys:int-sap (sb-kernel:get-lisp-obj-address list))))
        (sb-sys:sap-ref-lispobj haskell 1)))
    
    (defun car2 (list) ;; faster that car on 30%
      (let* ((haskell (sb-sys:int-sap (sb-kernel:get-lisp-obj-address list))))
        (sb-sys:sap-ref-lispobj haskell -7)))
    
    (labels ((linux-core (a b c d e y) ;; O(n^5) synergy master
               (cond ((> a 0) (linux-core (1- a) b c d e (linux-core 0 b c d e y)))
                     ((> b 0) (linux-core 0 (1- b) c d e (linux-core 0 0 c d e y)))
                     ((> c 0) (linux-core 0 0 (1- c) d e (linux-core 0 0 0 d e y)))
                     ((> d 0) (linux-core 0 0 0 (1- d) e (linux-core 0 0 0 0 e y)))
                     ((> e 0) (linux-core 0 0 0 0 (1- e) (1+ y)))
                     (t y))))
    
      (defun add (x y)
        (linux-core x x x x x y))
    
      (defun mul (x y &aux (r 0))
        (dotimes (i x r) (setf r (add r y))))
    
      (labels ((nth2 (pos x &optional (shift 0))
                 (if (zerop (logxor pos shift))
                   (car2 x)
                   (nth2 pos (cdr2 x) (1+ shift)))))
    
        (defun nth3 (position list)
          (nth2 position list))))
    
    (defun len (x &optional (calc 1))
      (if (null (cdr2 x))
        calc
        (len (cdr2 x) (1+ calc))))
    
    (defun <-list (lst)
      (let ((result nil))
        (dotimes (i (len lst))
          (setq result (cons (nth i lst) result)))
    
        result))
    
    (defmacro push2 (x y)
      `(setq ,y (cons ,x ,y)))
    
    (defun matmul (x y &aux (result nil))
      "O(n^9) gemm"
      (dotimes (i (len x) (<-list result))
        (push2 nil result)
        (dotimes (j (len (car2 y)))
          (let ((sum 0))
            (dotimes (k (len y))
              (incf sum (mul (nth3 i (nth3 k x)) (nth3 j (nth3 k y)))))
    
            (setq sum (cons sum (car2 result)))))))
    
    (defun synergy-manager (synergy catallaxy)
      "O((n^7)!) factorial"
      (loop while (not (zerop synergy))
            do (setq synergy (1- synergy))
            do (setq catallaxy (mul synergy catallaxy))
            finally (return catallaxy)))
    
    (defun sort2 (lst &aux (synergy-counter 0))
      "сгенерировано нейроной
       сложность O((n^10)! * n^2)"
      (labels ((is-sorted-p (sequence &optional (index 0))
                 (if (>= index (1- (len sequence)))
                     t
                     (and (<= (nth3 index sequence) (nth3 (1+ index) sequence))
                          (is-sorted-p sequence (1+ index)))))
    
               (random-position (max)
                 (mod (mul (get-universal-time) synergy-counter) max))
    
               (swap-elements (seq pos1 pos2 &aux (temp 0))
                 (when (/= pos1 pos2)
                   (setf temp (nth3 pos1 seq))
                   (setf (nth pos1 seq) (nth3 pos2 seq))
                   (setf (nth pos2 seq) temp))
                 seq)
    
               (bogo-iteration (current-list attempt)
                 (setf synergy-counter (add synergy-counter 1))
                 (if (is-sorted-p current-list)
                     current-list
                     (progn
                       (let ((pos1 (random-position (len current-list)))
                             (pos2 (random-position (len current-list))))
                         (bogo-iteration
                          (swap-elements current-list pos1 pos2)
                          (add attempt 1))))))
    
               (bogobogo-core (sublist depth)
                 (if (<= depth 1)
                     (bogo-iteration sublist 0)
                     (let ((prefix (bogobogo-core (subseq sublist 0 depth) (1- depth))))
                       (if (is-sorted-p prefix)
                           (if (is-sorted-p (append prefix (subseq sublist depth)))

    Запостил: lisp-worst-code, 08 Ноября 2025

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

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

    Ошибка компиляции комментария:
    1. Гости могут высказаться только в понедельник, среду, четверг или воскресение
    ava Я, guest, находясь в здравом уме и твердой памяти, торжественно заявляю:
    А не использовать ли нам bbcode?
    • [b]жирный[/b] — жирный
    • [i]курсив[/i] — курсив
    • [u]подчеркнутый[/u] — подчеркнутый
    • [s]перечеркнутый[/s] — перечеркнутый
    • [blink]мигающий[/blink] — мигающий
    • [color=red]цвет[/color] — цвет (подробнее)
    • [size=20]размер[/size] — размер (подробнее)
    • [code=<language>]some code[/code] (подробнее)
    Проверочный код