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

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

    +31.1

    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
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="ru">
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
        <title>Govnokod.ru  — Накласть говнокод</title>
        <meta name="keywords" content="говнокод, смешной код, быдлокод, быдлокодеры, индусы, для программистов, про программистов, индусский код, записки программиста, говно, говнокод на php, mysql, perl" />
        <meta name="description" content="Сборник говнокода на различных языках программирования" />
        <link rel="stylesheet" type="text/css" href="/templates/css/style.css" />
            <link rel="stylesheet" type="text/css" href="/templates/css/add.css" />
        <script type="text/javascript">
        <!--
        var SITE_PATH = '';
        //-->
        </script>
        <script type="text/javascript" src="/templates/external.php?type=js&files=prototype.js,govnokod.js"></script>
    </head>
    <body>
        <div class="header">
            <a href="/">
                <img src="/templates/images/logo.png" alt="Говнокод.Ру" title="Да, это говно!" />
                Govnokod.ru
            </a>
        </div>
        <div class="add-govno">
            <a href="http://govnokod.ru/add"><img src="/templates/images/icon-plus.png" alt="" /></a>
            <a href="http://govnokod.ru/add">Накласть говнокод</a>
        </div>
        <ul class="menu">
            <li class="active"><a href="http://govnokod.ru">Говнокод</a></li>
                </ul>
        <div style="clear:both"></div>
        <ul class="sub-menu">
            <li class="left"> </li>
        	<li><a href="#">Новый</a></li>
        	<li><a href="#">Лучший</a></li>
        	<li class="right"> </li>
        </ul>
    
        <div style="clear: both;"></div>
    
        
    
    
    
        <table class="rblock">
            <tr>
                <td style="width:20px"><img src="/templates/images/rblock-left-top.png" alt="" /></td>
                <td class="empty"> </td><td style="width:20px"><img src="/templates/images/rblock-right-top.png" alt="" /></td>
            </tr>
            <tr class="content">
                <td> </td>
                <td>
                    <h1>Накласть говнокод</h1>
                                    <form action="http://govnokod.ru/add" method="post">
                        <table width="100%" border="0" cellpadding="5" cellspacing="0">
                            <tr>
                                <td style="vertical-align: top; width: 20%;"><label for="form_category_id">Язык: <span style="color: red;">*</span></label></td>
                                <td style="width: 80%;"><select id="form_category_id" name="category_id">
    <option selected="selected" style="font-weight: bold;" value=""> </option>
    <option value="1">PHP</option>
    <option value="2">JavaScript</option>
    <option value="3">MySQL</option>
    <option value="4">PERL</option>
    <option value="5">Python</option>
    </select></td>
                            </tr>
                            <tr>
                                <td style="vertical-align: top;"><label for="form_description">Описание:</label></td>
                                <td><textarea cols="50" id="form_description" name="description" rows="4"></textarea></td>
                            </tr>
                            <tr>
                                <td> </td>
                                <td> </td>
                            </tr>
                            <tr>
                                <td style="vertical-align: top;"><label for="form_text">Код: <span style="color: red;">*</span></label></td>
                                <td>
                                    <div id="codeSaveContainer" class="codeInput">
                                        <table cellpadding="0" cellspacing="0" style="width: 100%;">
                                            <tr>
                                                <td style="vertical-align: top; width: 5%;">
                                                    <div id="nums" class="linenumbers"></div>
                                                </td>
                                                <td style="vertical-align: top; width: 95%;">
                                                                                                    <textarea class="codeArea" cols="50" id="codeArea" name="text" onkeyup="numbering(this);" rows="1" value="
    
    
    
    
    " wrap="off">
    
    
    
    
    </textarea>
                                                </td>
                                            </tr>
                                        </table>
                                    </div>
                                </td>

    типичный говнокод

    guest, 27 Ноября 2008

    Комментарии (24)
  3. Си / Говнокод #28798

    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
    struct node
    {
        void *data;
    
        struct node *head;
        struct node *tail;
    };
    struct list
    {
        int size;
    
        struct node *head;
        struct node *tail;
    
        void *(*alloc_node)(size_t);
        void *(*alloc_data)(size_t);
        void (*free_node)(void *);
        void (*free_data)(void *);
    };
    
    typedef struct node node_t;
    typedef struct list list_t;
    
    void list_init(list_t *list)
    {
        list->size = 0;
    
        list->head = (node_t*)list;
        list->tail = (node_t*)list;
    
        list->alloc_node = &malloc;
        list->alloc_data = &malloc;
        list->free_node = &free;
        list->free_data = &free;
    }
    void list_link(struct node *head, struct node *tail)
    {
        head->tail = tail;
        tail->head = head;
    }
    void *push_head(list_t *list, node_t *head, size_t size)
    {
        node_t *node = list->alloc_node(sizeof(node_t));
        void   *data = list->alloc_data(size);
    
        node->data = data;
        list_link(node, head->tail);
        list_link(head, node);
    
        list->size++;
        return data;
    }
    void *push_tail(list_t *list, node_t *tail, size_t size)
    {
        node_t *node = list->alloc_node(sizeof(node_t));
        void   *data = list->alloc_data(size);
    
        node->data = data;
        list_link(tail->head, node);
        list_link(node, tail);
    
        list->size++;
        return data;
    }
    void pop(list_t *list, node_t *node)
    {
        list_link(node->head, node->tail);
        list->size--;
    
        void *data = node->data;
    
        list->free_node(node);
        list->free_data(data);
    }
    void print(struct list *list)
    {
        printf("\n====\n");
    
        printf("size: %ld \n", list->size);
    
        int i = 0;
    
        for(node_t *node = list->head; node != list; node = node->head)
        {
            printf("index: %ld number: %ld \n", i, *(int*)(node->data));
            i++;
        }
    }
    
    struct list lst;
    
        list_init(&lst);
    
        print(&lst);
    
        void *data;
        data = push_tail(&lst, lst.tail, 4);
        *(int*)data = 1;

    итак скажите про название функций про то каких функций не хватает + alloc и free поля не трогать это мне нужно ТОЛЬКО НЕ советуйте перейти на с++ и использовать чтото другое(std::list)

    CodeTux, 16 Июня 2023

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

    −9

    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
    govnokod.*##div.entry-comments div.entry-comment-wrapper:has(p.entry-info > strong.entry-author a[href$="/25947"])
    
    govnokod.*##div.entry-comments div.entry-comment-wrapper:has(p.entry-info > strong.entry-author a[href$="/26133"])
    govnokod.*##div.entry-comments div.entry-comment-wrapper:has(p.entry-info > strong.entry-author a[href$="/26134"])
    govnokod.*##div.entry-comments div.entry-comment-wrapper:has(p.entry-info > strong.entry-author a[href$="/26135"])
    govnokod.*##div.entry-comments div.entry-comment-wrapper:has(p.entry-info > strong.entry-author a[href$="/26137"])
    
    govnokod.*##div.entry-comments div.entry-comment-wrapper:has(p.entry-info > strong.entry-author a[href$="/67335"])
    
    govnokod.*##div.entry-comments div.entry-comment-wrapper:has(p.entry-info > strong.entry-author a[href$="/68057"])
    govnokod.*##div.entry-comments div.entry-comment-wrapper:has(p.entry-info > strong.entry-author a[href$="/68069"])
    
    govnokod.*##div.entry-comments div.entry-comment-wrapper:has(p.entry-info > strong.entry-author a[href$="/68120"])
    
    govnokod.*##div.entry-comments div.entry-comment-wrapper:has(p.entry-info > strong.entry-author a[href$="/68134"])
    govnokod.*##div.entry-comments div.entry-comment-wrapper:has(p.entry-info > strong.entry-author a[href$="/68139"])
    
    govnokod.*##div.entry-comments div.entry-comment-wrapper:has(p.entry-info > strong.entry-author a[href$="/68240"])
    govnokod.*##div.entry-comments div.entry-comment-wrapper:has(p.entry-info > strong.entry-author a[href$="/68257"])
    govnokod.*##div.entry-comments div.entry-comment-wrapper:has(p.entry-info > strong.entry-author a[href$="/68261"])
    
    govnokod.*##div.entry-comments div.entry-comment-wrapper:has(p.entry-info > strong.entry-author a[href$="/68335"])
    
    govnokod.*##div.entry-comments div.entry-comment-wrapper:has(p.entry-info > strong.entry-author a[href$="/68367"])
    govnokod.*##div.entry-comments div.entry-comment-wrapper:has(p.entry-info > strong.entry-author a[href$="/68368"])
    govnokod.*##div.entry-comments div.entry-comment-wrapper:has(p.entry-info > strong.entry-author a[href$="/68369"])
    govnokod.*##div.entry-comments div.entry-comment-wrapper:has(p.entry-info > strong.entry-author a[href$="/68371"])
    govnokod.*##div.entry-comments div.entry-comment-wrapper:has(p.entry-info > strong.entry-author a[href$="/68372"])
    govnokod.*##div.entry-comments div.entry-comment-wrapper:has(p.entry-info > strong.entry-author a[href$="/68373"])

    o6AMa_4MO, 27 Февраля 2023

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

    −1

    1. 1
    2. 2
    3. 3
    4. 4
    public bool IsTrueOrFalse(string value)
            {
                return (value.ToString().Length == 4  value.ToString().ToLower()=="true") ? true : (value.ToString().Length == 5  value.ToString().ToLower() == "false") ? false : true;
            }

    techlead_seneor_228, 21 Апреля 2022

    Комментарии (23)
  6. Си / Говнокод #28054

    −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
    typedef enum {
      FILE_NONE, FILE_C, FILE_ASM, FILE_OBJ, FILE_AR, FILE_DSO,
    } FileType;
    
    StringArray include_paths;
    bool opt_fcommon = true;
    bool opt_fpic;
    
    static FileType opt_x;
    static StringArray opt_include;
    static bool opt_E;
    static bool opt_M;
    static bool opt_MD;
    static bool opt_MMD;
    static bool opt_MP;
    static bool opt_S;
    static bool opt_c;
    static bool opt_cc1;
    static bool opt_hash_hash_hash;
    static bool opt_static;
    static bool opt_shared;
    static char *opt_MF;
    static char *opt_MT;
    static char *opt_o;
    
    static StringArray ld_extra_args;
    static StringArray std_include_paths;
    
    char *base_file;
    static char *output_file;
    
    static StringArray input_paths;
    static StringArray tmpfiles;

    благо поиск по проекту работает

    kcalbCube, 25 Февраля 2022

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

    0

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    function main() {
        let arr = [1, 2, 3];
    
        for (const v of arr.map(x => x + 1)) print(v);
    
        print("done.");
    }

    Для тех кто не понял предыдущий пример.. я упростил для вас :)

    ASD_77, 11 Февраля 2022

    Комментарии (23)
  8. Куча / Говнокод #28000

    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
    %% Note: set and unset are not thread-safe.
    -spec set(key(), value()) -> ok.
    set(Key, Value) ->
        case ets:lookup(?status_tab, Key) of
            [{_, {set, _OldValue}}] ->
                ets:insert(?status_tab, {Key, {set, Value}});
            [{_, {unset, Pid}}] ->
                MRef = monitor(process, Pid),
                Pid ! {set, Value},
                receive
                    {'DOWN', MRef, _, _, _} -> ok
                end;
            [] ->
                case ets:insert_new(?status_tab, {Key, {set, Value}}) of
                    true  ->
                        ok;
                    false ->
                        set(Key, Value)
                end
        end,
        ok.
    
    -spec unset(key()) -> ok.
    unset(Key) ->
        case ets:lookup(?status_tab, Key) of
            [{_, {set, _OldValue}}] -> ets:delete(?status_tab, Key);
            _                       -> ok
        end,
        ok.
    
    -spec read(key()) -> value().
    read(Key) ->
        case read_or_wait(Key) of
            {set, Value} ->
                Value;
            {wait, MRef} ->
                receive
                    {'DOWN', MRef, _, _, {cvar_set, Value}} ->
                        Value;
                    {'DOWN', MRef, _, _, noproc} ->
                        read(Key)
                end
        end.
    
    -spec read_or_wait(key()) -> {set, value()} | {wait, reference()}.
    read_or_wait(Key) ->
        case ets:lookup(?status_tab, Key) of
            [] ->
                {Pid, MRef} = spawn_monitor(?MODULE, waker_entrypoint, [Key, self()]),
                receive
                    {Pid, proceed} ->
                        {wait, MRef};
                    {'DOWN', MRef, _, _, Reason} ->
                        cvar_retry = Reason,
                        read_or_wait(Key)
                end;
            [{_, {set, Val}}] ->
                {set, Val};
            [{_, {unset, Pid}}] ->
                {wait, monitor(process, Pid)}
        end.
    
    -spec waker_entrypoint(key(), pid()) -> no_return().
    waker_entrypoint(Key, Parent) ->
        case ets_insert_new({Key, {unset, self()}}) of
            false ->
                exit(cvar_retry);
            true ->
                Parent ! {self(), proceed},
                receive
                    {set, Value} ->
                        ets_insert({Key, {set, Value}}),
                        exit({cvar_set, Value})
                end
        end.

    CHayT, 08 Февраля 2022

    Комментарии (23)
  9. Python / Говнокод #27866

    −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
    #!/usr/bin/python
      
      import sys
      
      cache = {}
      
      def count(start, end):
          if start < end:
              if start not in cache:
                  cache[start] = count(start + 1, end) + count(start * 2, end) + count(start ** 2, end)
              return cache[start]
          elif start == end:
              return 1
          else:
              return 0
    
      print(count(int(sys.argv[1]), int(sys.argv[2])))

    Подсчитать количество путей из a в b с помощью прибавления единицы, умножения на 2 и возведения в квадрат

    Чем формально ограничены возможности преобразовать рекурсию в хвостовую? Вот такое ведь не преобразовать?

    vistefan, 11 Декабря 2021

    Комментарии (23)
  10. Java / Говнокод #27664

    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
    import java.util.Arrays;
    import java.util.Optional;
    
    public class AntiVirus{
      
      private int scanIntensity = 0;
      
      //this method is ready for you.
      public void setScanIntensity(int level){
        scanIntensity = level;
      }
      
      //write this method.
      public String scanFile(File file,VirusDB database){
        String[] signature = database.getSignatures(scanIntensity);
        String fileData = file.getData().toLowerCase();
        
         Optional<String> res = Arrays.stream(signature)
             .map(s -> s.toLowerCase())
             .filter(fileData::contains).findAny();
        
         String scan = " is safe";
        
         if(res.isPresent()) {
            System.out.println(res.get());
            System.out.println("scan: " + scan);
            scan = " is not safe";
            System.out.println("scan after: " + scan);
         }
        
        return file.getName() + scan;
      }
    }

    Не понимаю, почему не работает.

    Задача
    https://www.codewars.com/kata/5b13027eedd62c5216000001

    Test Results:
    AVTest
    checkRandomFiles
    Log
    dos
    scan: is safe
    scan after: is not safe
    dos
    scan: is safe
    scan after: is not safe
    dos
    scan: is safe
    scan after: is not safe
    dos
    scan: is safe
    scan after: is not safe
    dos
    scan: is safe
    scan after: is not safe
    dos
    scan: is safe
    scan after: is not safe
    dos
    scan: is safe
    scan after: is not safe
    dos
    scan: is safe
    scan after: is not safe
    dos
    scan: is safe
    scan after: is not safe
    expected:<f4wpzFoQD is [not ]safe> but was:<f4wpzFoQD is []safe>
    Stack Trace
    Completed in 476ms
    checkSameFilesWithDifferentIntensitySett ings
    Log
    virus
    scan: is safe
    scan after: is not safe
    expected:<file1 is [not ]safe> but was:<file1 is []safe>
    Stack Trace
    Completed in 1ms
    Completed in 496ms

    imrnccc, 14 Сентября 2021

    Комментарии (23)
  11. Куча / Говнокод #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)