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

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

    −10.5

    1. 1
    this.SelectedDate = this.SelectedDate;

    Проверяем дату на корректность...

    guest, 10 Декабря 2008

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

    +52.3

    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
    //разметка матрицы
    
     while ((founded==1)&&(mat[nx][ny]<=0)) {
      founded=0;
      iii=y-i;
      while (((i==0)&&(iii==y))||((iii<=y+i))){
       ii=x-i;
       while ((ii<=x+i)){
    	if ((mat[ii][iii]==i)&&((ii<70)&&(ii>=0))&&((iii<70)&&(iii>=0))) {
    	 bii=ii;
    	 biii=iii;
    	 if ((mat[bii+1][biii]==-1)&&(bii+1<70)&&(bii+1>=0)) {
    	  mat[bii+1][biii]=i+1;
    	  founded=1;
    	 }
    	 if ((mat[bii-1][biii]==-1)&&(bii-1<70)&&(bii-1>=0)) {
    	  mat[bii-1][biii]=i+1;
    	  founded=1;
    	 }
    	 if ((mat[bii][biii+1]==-1)&&(biii+1<70)&&(biii+1>=0)) {
    	  mat[bii][biii+1]=i+1;
    	  founded=1;
    	 }
    	 if ((mat[bii][biii-1]==-1)&&(biii-1<70)&&(biii-1>=0)) {
    	  mat[bii][biii-1]=i+1;
    	  founded=1;
    	 }
    	}
    	ii++;
       }
       iii++;
      }
      i++;
     }
     if (mat[nx][ny]>=0) {
      if ((nx==40)&&(ny==57)) {
       nx=nx;
      }
      ik=i;
    
      ii=nx;
      iii=ny;
      //поиск пути
    
      while (ik>1) {
       if ((mat[ii-1][iii]==ik-1)&&(ii-1<70)&&(ii-1>=0)) {
    	ii--;
    	mat[ii][iii]=-3;
       }
       if ((mat[ii][iii-1]==ik-1)&&(iii-1<70)&&(iii-1>=0)) {
    	iii--;
    	mat[ii][iii]=-3;
       }
       if ((mat[ii+1][iii]==ik-1)&&(ii+1<70)&&(ii+1>=0)) {
    	ii++;
    	mat[ii][iii]=-3;
       }
    
       if ((mat[ii][iii+1]==ik-1)&&(iii+1<70)&&(iii+1>=0)) {
    	iii++;
    	mat[ii][iii]=-3;
       }
       ik--;
      }
       ax=ii*10+5;
       ay=iii*10+5;
      //out_to_file(mat,"d:\\out.txt");
      i++;
       ii=0;
       iii=0;
       while ((iii>-1)&&(iii<70)){
    	ii=0;
    	while ((ii>-1)&&(ii<70)){
    	 if ((mat[ii][iii]>-1)||(mat[ii][iii]==-3)) {
    	  mat[ii][iii]=-1;
    	 }
    	 ii++;
    	}
    	iii++;
       }
      nx=ax;
      ny=ay;
     } else ...
     }

    Разметка матрицы, Поиск Пути.

    guest, 08 Декабря 2008

    Комментарии (9)
  4. Java / Говнокод #57

    +24

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    8. 8
    /**
      * Getter for billbackAdjustmentType 
      *
      * @return the billbackAdjustmentType instance
      */
    public BillbackAdjustmentType getBillbackAdjustmentType() {
        return billbackAdjustmentType != null ? billbackAdjustmentType : BillbackAdjustmentType.PlusBillbackAdjustment;
    }

    ...и попробуй такое найди под дебагом :)

    guest, 04 Декабря 2008

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

    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
    #include <iostream>
    #include <type_traits>
    #include <mutex>
    #include <string>
    #include <memory>
    #include <vector>
    #include <chrono>
    
    void bad_function(void* data) {
       ///  НИКОГДА ТАК НЕ ПИШИ
        if (data) {
            std::cout << *(std::string*)data << "\n";
        }
    }
    
    template<typename T = std::string,
             typename Alloc = std::allocator<T>,
             typename = std::enable_if_t<std::is_constructible_v<T, const char*>>,
             typename Clock = std::chrono::high_resolution_clock,
             typename TimePoint = typename Clock::time_point>
    class GoodFunctionImpl {
    private:
        static std::recursive_mutex mtx_;
        Alloc alloc_;
        std::vector<T, Alloc> buffer_;
        std::string context_;
        TimePoint init_time_;
        
        template<typename U>
        using is_valid_type = std::conjunction<
            std::is_same<std::decay_t<U>, T>,
            std::is_constructible<T, U>
        >;
        
        void internal_log(const std::string& msg) {
            buffer_.push_back(T(msg.c_str()));
        }
        
    public:
        GoodFunctionImpl() : init_time_(Clock::now()) {
            internal_log("GoodFunctionImpl initialized");
        }
        
        template<typename U,
                 typename = std::enable_if_t<is_valid_type<U>::value>>
        decltype(auto) execute(U&& input) {
            std::lock_guard<std::recursive_mutex> lock(mtx_);
            
            internal_log("Processing started");
            
            T processed = std::forward<U>(input);
            
            auto duration = Clock::now() - init_time_;
            auto duration_ms = std::chrono::duration_cast<
                std::chrono::milliseconds>(duration).count();
            
            std::cout << processed << " (runtime: " 
                      << duration_ms << "ms)\n";
            
            internal_log("Processing completed");
            
            return processed;
        }
        
        size_t get_buffer_size() const { return buffer_.size(); }
    };
    
    template<typename T, typename Alloc, typename, typename Clock, typename TimePoint>
    std::recursive_mutex GoodFunctionImpl<T, Alloc, Clock, TimePoint>::mtx_;
    
    void good_function(const std::string& input) {
        // Пиши ВОТ ТАК
        // так делают все
        // это стабильно и надежно
        // так надо
        GoodFunctionImpl<> impl;
        auto result = impl.execute(input);
        
        std::cout << "Buffer entries: " 
                  << impl.get_buffer_size() << "\n";
    }

    lisp-worst-code, 06 Декабря 2025

    Комментарии (8)
  6. PHP / Говнокод #29168

    +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
    23. 23
    24. 24
    25. 25
    26. 26
    27. 27
    28. 28
    29. 29
    30. 30
    <?php
    function hsum($a, $b, $p) {
        $hs = $a ^ $b;
        $hp = $a & $b;
        $p <<= 1;
        return [$hs ^ $p, $hp | ($hs & $p)];
    }
    
    function hsum_rec($a, $b, $p) {
        list($s, $newp) = hsum($a, $b, $p);
        if ($newp == $p) {
            return [$s, $newp];
        } else {
            return hsum_rec($a, $b, $newp);
        }
    }
    
    function sum2($a, $b) {
        list($s, $p) = hsum_rec($a, $b, 0);
        return $s;
    }
    
    for($i = 0; $i < 16; $i++) {
        for($j = 0; $j < 16; $j++) {
            if(sum2($i,$j) != $i + $j) {
                $k = sum2($i,$j);
                echo "Error: $i, $j, $k\n";
            }
        }
    }

    Программа складывает два целых числа.

    Myxa, 08 Августа 2025

    Комментарии (8)
  7. Си / Говнокод #29130

    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
    #include <stdio.h>
    
    int bts(unsigned int n, int bitN) {
        return n & (1 << bitN);
    }
    
    int main() {
        volatile char *p_lacoon;
        unsigned char res = 0;
        
        p_lacoon = ((unsigned )p_lacoon | 01 << 1);
        res |= bts(p_lacoon, 0) | bts(p_lacoon, 1);
    
        p_lacoon = ((unsigned )p_lacoon | 01 & ~!~0);
        p_lacoon = ((unsigned )p_lacoon | 01 << 1 << 0);
        res |= 4 << (bts(p_lacoon, 0) | bts(p_lacoon, 1) ^ 3);
    
        p_lacoon = ((int)p_lacoon | 01 & ~0xFE | 00);
        p_lacoon = ((int)p_lacoon | 01 << 1);
        res |= ~!0xFF << (bts(p_lacoon, 0) | 6 ^ 0x29b);
        res |= ~!0xFC << (bts(p_lacoon, 1) | 4 ^ 0x29c);
        res |= ~!0xF0 << 5;
    
        p_lacoon = (int)p_lacoon >> 01 >> 001 << 001 << 01;
    
        printf("%x, %X %s\n", p_lacoon, (res & 001) ? res-1 : res, "*****. Challenge everything.");
    }

    Предтерминальная стадия мозгфускации.
    Из собеса в подразделение AMD: продемонстрировать варианты хранения при недостатке памяти.
    Работает в GCC, ICC, Clang только -O0.
    Кто хочет разобраться - welcome https://godbolt.org/z/hd4eYeM1Y

    OdduOne, 09 Мая 2025

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

    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
    // https://github.com/ggml-org/llama.cpp/blob/f4c3dd5daa3a79f713813cf1aabdc5886071061d/examples/simple/simple.cpp#L23
    
        // parse command line arguments
    
        {
            int i = 1;
            for (; i < argc; i++) {
                if (strcmp(argv[i], "-m") == 0) {
                    if (i + 1 < argc) {
                        model_path = argv[++i];
                    } else {
                        print_usage(argc, argv);
                        return 1;
                    }
                } else if (strcmp(argv[i], "-n") == 0) {
                    if (i + 1 < argc) {
                        try {
                            n_predict = std::stoi(argv[++i]);
                        } catch (...) {
                            print_usage(argc, argv);
                            return 1;
                        }
                    } else {
                        print_usage(argc, argv);
                        return 1;
                    }
                } else if (strcmp(argv[i], "-ngl") == 0) {
                    if (i + 1 < argc) {
                        try {
                            ngl = std::stoi(argv[++i]);
                        } catch (...) {
                            print_usage(argc, argv);
                            return 1;
                        }
                    } else {
                        print_usage(argc, argv);
                        return 1;
                    }
                } else {
                    // prompt starts here
                    break;
                }
            }
            if (model_path.empty()) {
                print_usage(argc, argv);
                return 1;
            }
            if (i < argc) {
                prompt = argv[i++];
                for (; i < argc; i++) {
                    prompt += " ";
                    prompt += argv[i];
                }
            }
        }

    Парсинг аргументов командной строки

    j123123, 16 Марта 2025

    Комментарии (8)
  9. Java / Говнокод #29063

    0

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    8. 8
    public static String getJoinedHeaderTypes(List<String> types, String delimiter) {
            if (!types.isEmpty() && types.size() > 1) {
                return String.join(delimiter, types);
            } else if (types.size() == 1) {
                return types.stream().findFirst().get();
            }
            return "";
        }

    Когда тебе рассказали, что есть стримы...

    nekkiy, 03 Декабря 2024

    Комментарии (8)
  10. Си / Говнокод #28871

    0

    1. 001
    2. 002
    3. 003
    4. 004
    5. 005
    6. 006
    7. 007
    8. 008
    9. 009
    10. 010
    11. 011
    12. 012
    13. 013
    14. 014
    15. 015
    16. 016
    17. 017
    18. 018
    19. 019
    20. 020
    21. 021
    22. 022
    23. 023
    24. 024
    25. 025
    26. 026
    27. 027
    28. 028
    29. 029
    30. 030
    31. 031
    32. 032
    33. 033
    34. 034
    35. 035
    36. 036
    37. 037
    38. 038
    39. 039
    40. 040
    41. 041
    42. 042
    43. 043
    44. 044
    45. 045
    46. 046
    47. 047
    48. 048
    49. 049
    50. 050
    51. 051
    52. 052
    53. 053
    54. 054
    55. 055
    56. 056
    57. 057
    58. 058
    59. 059
    60. 060
    61. 061
    62. 062
    63. 063
    64. 064
    65. 065
    66. 066
    67. 067
    68. 068
    69. 069
    70. 070
    71. 071
    72. 072
    73. 073
    74. 074
    75. 075
    76. 076
    77. 077
    78. 078
    79. 079
    80. 080
    81. 081
    82. 082
    83. 083
    84. 084
    85. 085
    86. 086
    87. 087
    88. 088
    89. 089
    90. 090
    91. 091
    92. 092
    93. 093
    94. 094
    95. 095
    96. 096
    97. 097
    98. 098
    99. 099
    100. 100
    fclose(cfPtr);
    
      while ((mem[operand] > -9999) && (mem[operand] < 9999) && sign != 1) {
    
        ins_rgr = (mem[ins_cnt]);
    
        op_code = (ins_rgr / 100);
        operand = (ins_rgr % 100);
        // printf("op_code = %d   operand = %d  acc = %d\n", op_code, operand , acc
        // );
        //    dump(mem);
    
        switch (op_code) {
    
        case HALT:
          sign = 1;
          break;
    
        case READ:
          printf("? read ");
    
          scanf("%d", &buf);
          mem[operand] = buf;
    
          ins_cnt++;
          break;
    
        case WRITE:
          printf("%d\n", mem[operand]);
          ins_cnt++;
          break;
    
        case LOAD:
    
          acc = mem[operand];
          ins_cnt++;
          break;
    
        case STORE:
    
          mem[operand] = acc;
          ins_cnt++;
          break;
    
        case ADD:
    
          acc += mem[operand];
          ins_cnt++;
          break;
    
        case SUBSTRACT:
    
          acc -= mem[operand];
          ins_cnt++;
    
          break;
    
        case DIVIDE:
    
          acc /= mem[operand];
          ins_cnt++;
          break;
    
        case MUL:
    
          acc *= mem[operand];
          ins_cnt++;
          break;
    
        case POW:
          acc = pow(acc, mem[operand]);
          ins_cnt++;
          break;
    
        case MOD:
          acc = fmod(acc, mem[operand]);
          ins_cnt++;
          break;
    
        case NEWLINE:
          puts(" ");
          ins_cnt++;
          break;
    
        case BRANCH:
        case BRANCHZERO:
        case BRANCHNEG:
       
          branch(&ins_cnt, acc, operand, op_code);
    
          break;
    
         
        }
      }
    
      dump(mem);
      dump_file(mem);
      puts(" ");
    }

    Демотрон 2
    Читалка для кода симплтрона

    gne4do, 02 Октября 2023

    Комментарии (8)
  11. PHP / Говнокод #28830

    0

    1. 1
    За "PHP".

    DECAHTHblu_nemyx, 02 Августа 2023

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