1. Лучший говнокод

    В номинации:
    За время:
  2. JavaScript / Говнокод #27550

    +1

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    11. 11
    12. 12
    function main() {
        let user = {
            firstName: "John",
            sayHi() {
                print(`Hello, ${this.firstName}!`);
            },
        };
    
        user.sayHi();
    
        print("done.");
    }

    как тебе такое Илон Маск?

    ASD_77, 06 Августа 2021

    Комментарии (110)
  3. Куча / Говнокод #27547

    +1

    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
    Ltac destruct_mint_ H := 
       match type of H with
          (MInt_ _ ?z ?t) =>
          lazymatch goal with
            |- ?GOAL =>
            refine (match H in (MInt_ _ z0 t0) return (z = z0 -> t = t0 -> GOAL) with
                    | mint_nil    _  =>
                      fun Heq_z Heq_tt_ =>
                        ltac:(destruct_mint_common Heq_tt_ Heq_z H)
                    | mint_cons   _ te rest l      r   t H =>
                      fun Heq_z Heq_tt_ =>
                        ltac:(destruct_mint_common Heq_tt_ Heq_z H)
                    | mint_cons_l _ te rest l r z t Hz H  =>
                      fun Heq_z Heq_tt_ =>
                        ltac:(destruct_mint_common Heq_tt_ Heq_z H)
                    | mint_cons_r _ te te' rest l r z t Hz Hcomm H =>
                      fun Heq_z Heq_tt_ =>
                        ltac:(destruct_mint_common Heq_tt_ Heq_z H)
                    end (eq_refl z) (eq_refl t))
          end
        end.

    Наебавшись с inversion в механизированным доказательстве, закрыл я очи.

    CHayT, 04 Августа 2021

    Комментарии (23)
  4. JavaScript / Говнокод #27546

    +1

    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
    function main() {
        let { aa, bb } = { aa: 10, bb: 20 };
        print(aa + bb);
    
        let {
            aa,
            bb: { q, r },
        } = { aa: 10, bb: { q: 1, r: 2 } };
        assert(aa == 10, "{}");
        assert(q == 1, "{}");
        assert(r == 2, "{}");
    
        let { x, y } = new ObjF(1, "foo");
        assert(x == 1, "{}");
        assert(y == "foo", "{}");
    
        print("done.");
    }

    Добрый вечер дорогие неопределившиеся... или заблудшие... вот я тут вам новую фичу притарабанил .. называет деконстракт :)

    ASD_77, 04 Августа 2021

    Комментарии (94)
  5. Куча / Говнокод #-27539

    +1

    1. 1
    Именно поэтому я за «PHP» #4

    #1: https://govnokod.ru/26462 https://govnokod.xyz/_26462
    #2: https://govnokod.ru/26827 https://govnokod.xyz/_26827
    #3: https://govnokod.ru/26832 https://govnokod.xyz/_26832

    nepeKamHblu_nemyx, 28 Июля 2021

    Комментарии (9875)
  6. JavaScript / Говнокод #27538

    +1

    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
    namespace Ifaces {
        interface IFoo {
            foo(): number;
        }
    }
    
    class Cls1 implements Ifaces.IFoo
    {
    	foo(): number
    	{
    		print("Hello");
    		return 1;
    	}
    }
    
    function main()
    {
    	const cls1 = new Cls1();
    	cls1.foo();
    
    	const ifoo: Ifaces.IFoo = cls1;
    	ifoo.foo();
    }

    Алилуя. я вам интерфейсы принес... узрите теперь дампик

    ASD_77, 27 Июля 2021

    Комментарии (28)
  7. C++ / Говнокод #27536

    +1

    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
    class Solution {
    public:
        std::vector<std::vector<int>> diagonalSort(std::vector<std::vector<int>> & mat) {
            if (!mat.size()) return mat;
            
            const size_t rl = mat[0].size();
            const size_t cl = mat.size();
            
            sort(mat, rl, cl, 0, 0);
            for (size_t i = 1; i < rl; ++i) {
                sort(mat, rl, cl, 0, i);
            }
            for (size_t i = 1; i < cl; ++i) {
                sort(mat, rl, cl, i, 0);
            }
            
            return mat;
        }
    private:
        void sort(std::vector<std::vector<int>> & mat, size_t rl, size_t cl, size_t i, size_t j) {
            const size_t len = std::min(rl - j, cl - i);
            const size_t endj = j + len;
            const size_t endi = i + len;
            std::sort(diag_iter<false>{&mat, i, j}, diag_iter<false>{&mat, endi, endj});
        }
        
        template <bool isConst>
        class diag_iter {
            std::vector<std::vector<int>> *base;
            size_t i, j;
            using T = int;
        public:
            using iterator_category = std::forward_iterator_tag;
            using difference_type   = std::ptrdiff_t;
            using value_type        = T;
            using pointer           = T*;
            using reference         = typename std::conditional<isConst, const T&, T&>::type;
            diag_iter(std::vector<std::vector<int>> *base, size_t i, size_t j) : base(base), i(i), j(j) { }
            diag_iter(const diag_iter&) = default;
            diag_iter& operator=(const diag_iter&) = default;
            ~diag_iter() = default;
            reference operator*() const { return (*base)[i][j]; }
            diag_iter& operator++() { i++; j++; return *this; }
            friend bool operator== (const diag_iter& a, const diag_iter& b) { return a.i == b.i && a.j == b.j; };
            friend bool operator!= (const diag_iter& a, const diag_iter& b) { return !(a == b); };
            pointer operator->() const { return &(this->operator*()); }
            diag_iter operator++(int) { diag_iter tmp = *this; ++(*this); return tmp; }
            diag_iter() = default;
            diag_iter& operator--() { i--; j--; return *this; }
            diag_iter operator--(int) { diag_iter tmp = *this; --(*this); return tmp; }
            diag_iter& operator+=(difference_type n) { i += n; j += n; return *this; }
            friend diag_iter operator+(diag_iter it, difference_type n) { return it += n; }
            diag_iter& operator-=(difference_type n) { i -= n; j -= n; return *this; }
            diag_iter operator-(difference_type n) const { return diag_iter(*this) -= n; }
            friend difference_type operator-(const diag_iter& a, const diag_iter& b) { return (b.j * b.base->size() + b.i) - (a.j * a.base->size() + a.i); }
            reference operator[](difference_type n) const { return *(*this + n); }
            friend bool operator<(const diag_iter& a, const diag_iter& b) { return b - a > 0; }
            friend bool operator>(const diag_iter& a, const diag_iter& b) { return b < a; }
            friend bool operator>=(const diag_iter& a, const diag_iter& b) { return !(a < b); }
            friend bool operator<=(const diag_iter& a, const diag_iter& b) { return !(a > b); }
        };
    };

    https://leetcode.com/problems/sort-the-matrix-diagonally/

    Сортировка через итераторы оказалась примерно в три раза медленнее, чем через копирование в вектор, сортировку его и копирование обратно.

    grillow1337, 25 Июля 2021

    Комментарии (18)
  8. C++ / Говнокод #27533

    +1

    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
    #include <iostream>
    #include <functional>
    
    #define STD_FUNCTION(a, ...) typeof( a (*) __VA_ARGS__ )
    
    template<typename T>
    T do_op_t(T a, T b, STD_FUNCTION(T,(T,T)) op)
    {
      return op(a,b);
    }
    
    template
    <
    
      typename T,
    
      STD_FUNCTION(
        T,
        (
          T,T,
          STD_FUNCTION(
            T,
            (T,T)
          )
        )
      ) F1,
    
      STD_FUNCTION(
        T,
        (T,T)
      ) F2
    
    >
    T do_op_spec(T a, T b)
    {
      return F1(a, b, F2);
    }
    
    int add(int a, int b) { return a + b; }
    
    int mul(int a, int b) { return a * b; }
    
    std::function<int(int,int)> fnc = \
      do_op_spec\
      <
        int,
        do_op_t<int>,
        add
      >;
    
    int main()
    {
      std::cout << do_op_t<int>(9, 9, add) << "\n";
      std::cout << do_op_t<int>(9, 9, mul) << "\n";
      std::cout << do_op_spec<int, do_op_t<int>,add>(9,9)  << "\n";
      std::cout << do_op_spec<int, do_op_t<int>,mul>(9,9)  << "\n";
      std::cout << fnc(9,9) << "\n";
    }

    Какая крестопараша )))

    j123123, 23 Июля 2021

    Комментарии (95)
  9. C# / Говнокод #27532

    +1

    1. 1
    Dictionary<Tuple<MapOfRestoredOwnership, bool, bool, bool>, IDictionary<PropertySqlGeography, IEnumerable<LandConsolidationData>>> villages

    Parameter for function...

    bugotrep, 21 Июля 2021

    Комментарии (11)
  10. Go / Говнокод #27530

    +1

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    8. 8
    9. 9
    func (c *Client) DeleteFile(filename string) {
    	_, err := s3.New(c.session).DeleteObject(&s3.DeleteObjectInput{
    		Bucket: aws.String(c.bucket),
    		Key:    aws.String(filename),
    	})
    	if err != nil {
    		return
    	}
    }

    Ошибочка обработана

    Vitanaki, 21 Июля 2021

    Комментарии (77)
  11. JavaScript / Говнокод #27519

    +1

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    /* В отдельном файле */
    function Skif_Email(auth,em) {
    	em = em.substring(3,em.length-3);
    	auth = auth.substring(4,auth.length-4);
    	document.write('<a href="mailto:',em,'" title="Защищён от спам-роботов">',auth,'</a>');
    }
    
    /* На странице */
    
    <script type="text/javascript">Skif_Email('[email protected]', '[email protected]');</script>

    Какая защита )))

    HEu3BECTHblu_nemyx, 16 Июля 2021

    Комментарии (59)