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

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

    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
    // https://github.com/microsoft/Windows-driver-samples/blob/d3ec258921cfcef7b053b5a2c866330d43dd3f03/filesys/fastfat/dumpsup.c#L35
    
    #define DumpLabel(Label,Width) {                                          \
        size_t i, LastPeriod=0;                                                \
        CHAR _Str[20];                                                        \
        for(i=0;i<2;i++) { _Str[i] = UCHAR_SP;}                               \
        for(i=0;i<strlen(#Label);i++) {if (#Label[i] == '.') LastPeriod = i;} \
        strncpy(&_Str[2],&#Label[LastPeriod],Width);                          \
        for(i=strlen(_Str);i<Width;i++) {_Str[i] = UCHAR_SP;}                 \
        _Str[Width] = '\0';                                                   \
        DbgPrint("%s", _Str);                                                  \
    }
    
    #define DumpField(Field) {                                         \
        if ((FatDumpCurrentColumn + 18 + 9 + 9) > 80) {DumpNewLine();} \
        FatDumpCurrentColumn += 18 + 9 + 9;                            \
        DumpLabel(Field,18);                                           \
        DbgPrint(":%p", Ptr->Field);                                  \
        DbgPrint("         ");                                          \
    }
    
    #define DumpListEntry(Links) {                                     \
        if ((FatDumpCurrentColumn + 18 + 9 + 9) > 80) {DumpNewLine();} \
        FatDumpCurrentColumn += 18 + 9 + 9;                            \
        DumpLabel(Links,18);                                           \
        DbgPrint(":%p", Ptr->Links.Flink);                            \
        DbgPrint(":%p", Ptr->Links.Blink);                            \
    }
    
    #define DumpName(Field,Width) {                                    \
        ULONG i;                                                       \
        CHAR _String[256];                                             \
        if ((FatDumpCurrentColumn + 18 + Width) > 80) {DumpNewLine();} \
        FatDumpCurrentColumn += 18 + Width;                            \
        DumpLabel(Field,18);                                           \
        for(i=0;i<Width;i++) {_String[i] = (CHAR)Ptr->Field[i];}             \
        _String[Width] = '\0';                                         \
        DbgPrint("%s", _String);                                        \
    }
    
    #define TestForNull(Name) {                                 \
        if (Ptr == NULL) {                                      \
            DbgPrint("%s - Cannot dump a NULL pointer\n", Name); \
            return;                                             \
        }                                                       \
    }

    Макроговно от мекомягких для отладки файловой системы FAT

    j123123, 22 Ноября 2021

    Комментарии (199)
  3. Perl / Говнокод #4478

    −118

    1. 1
    return (($publish && $filename ne '--') ? 1 : 0);

    Особенно умиляют скобочки

    krushi, 29 Октября 2010

    Комментарии (199)
  4. Python / Говнокод #26459

    0

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    8. 8
    import nacl
    from nacl.signing import VerifyKey
    from nacl.encoding import HexEncoder
    
    
    v = VerifyKey('c328dd78deb171f38ed6a6d7ff6f55a2f84fa75f1aca4d544beec00c6c882dbe', encoder=HexEncoder)
    v.verify('ed23a4dab9aea504c74df88818e665cacbc98a258214d48b0be5491b7fae47b1ded7bba07be43286c60fa5e570fa4d2be12afc5a307be0703a9303402873a60761646d696e4067636f64652e7370616365', encoder=HexEncoder)
    # b'[email protected]'

    gost, 29 Февраля 2020

    Комментарии (198)
  5. Си / Говнокод #26027

    +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
    31. 31
    32. 32
    33. 33
    34. 34
    35. 35
    36. 36
    37. 37
    38. 38
    #include <stdio.h>
    #include <inttypes.h>
    #include <string.h>
    
    // endian dependend
    #define PUT3(a,b,c) (((uint64_t)a<<8*0) | ((uint64_t)b<<8*1) | ((uint64_t)c<<8*2))
    
    void testswitch(uint64_t x)
    {
      switch (x) 
      { 
        case PUT3('a','b','c'): printf("abc\n"); 
          break; 
        case PUT3('d','e','f'): printf("def\n"); 
          break; 
        case PUT3('g','h','i'): printf("ghi\n"); 
          break; 
        default: printf("Choice other than abc, def and ghi\n"); 
          break;   
       }
    }
    
    int main() 
    { 
       uint64_t x = 0;
       char a[] = "abc";
       memcpy(&x, a, sizeof(a)-1);
       testswitch(x);
    
       char b[] = "def";
       memcpy(&x, b, sizeof(a)-1);
       testswitch(x);
    
       char c[] = "ghi";
       memcpy(&x, c, sizeof(a)-1);
       testswitch(x);
       return 0; 
    }

    switch для строк!

    Перечитывал несвежие говнокоды, где я выкладывал творчество вконтактоолимпиадников https://govnokod.ru/23170#comment388376

    j123123, 12 Ноября 2019

    Комментарии (198)
  6. Swift / Говнокод #25197

    0

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    scheduler.queue.async { [weak self] in
                guard let weakself = self else {
                    return
                }
                
                let locations = weakself.interactor

    kyzmitch, 16 Декабря 2018

    Комментарии (198)
  7. Java / Говнокод #23761

    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
    import java.util.Scanner;
    public class MasInd {
        public static void main (String[] args) {
            Scanner sc = new Scanner(System.in);
            System.out.println("Введите массу тела в килограммах");
            double m = sc.nextDouble();
            System.out.println("Введите рост в метрах");
            double r = sc.nextDouble();
            double i = m/(r*r);
            System.out.println("Индекс массы тела = " + i);
            if (i>=18.5 & i<25) {
                System.out.println("Норма");
            }
            if (i>=25 & i<30) {
                System.out.println("Предожирение");
            }
            if (i>=30) {
                System.out.println("Ожирение");
            }
            if (i<18.5) {
                System.out.println("Дефицит массы тела");
            }
        }
    }

    Определитель индекса массы тела.
    У меня, кстати, индекс - 22.47 (норма).

    SewerSurfer, 13 Февраля 2018

    Комментарии (198)
  8. Python / Говнокод #18267

    −267

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    import execjs
    
    js = '{"1": "2", "3": [4,5]}'
    
    default = execjs.get()
    print default.eval(js)

    Раз уже астрологи объявили неделю ебанутого парсенья json.

    3_14dar, 02 Июня 2015

    Комментарии (198)
  9. Куча / Говнокод #16162

    +89

    1. 1
    (1 until n) flatMap (i => (1 until i) filter (j => isPrime(i+j)) map (j => (i, j)))

    Скала говна.

    LispGovno, 13 Июня 2014

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

    +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
    for (size_t i = 0; i < 4; ++i) {
        __m128 x0 = _mm_loadu_ps((const float*)blocks[0] + i * 4);
        __m128 x1 = _mm_loadu_ps((const float*)blocks[1] + i * 4);
        __m128 x2 = _mm_loadu_ps((const float*)blocks[2] + i * 4);
        __m128 x3 = _mm_loadu_ps((const float*)blocks[3] + i * 4);
     
        __m128 t0 = _mm_unpacklo_ps(x0, x1);
        __m128 t1 = _mm_unpackhi_ps(x0, x1);
        __m128 t2 = _mm_unpacklo_ps(x2, x3);
        __m128 t3 = _mm_unpackhi_ps(x2, x3);
     
        x[i * 4 + 0] = _mm_castps_si128(_mm_movelh_ps(t0, t2));
        x[i * 4 + 1] = _mm_castps_si128(_mm_movehl_ps(t2, t0));
        x[i * 4 + 2] = _mm_castps_si128(_mm_movelh_ps(t1, t3));
        x[i * 4 + 3] = _mm_castps_si128(_mm_movehl_ps(t3, t1));
    }

    4х MD5

    https://ideone.com/a8YcZ8

    bormand, 12 Сентября 2021

    Комментарии (197)
  11. Lua / Говнокод #25987

    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
    local money = 0
    local auto_money = 0
    local auto_money_lvl = 0
    local auto_money_buy = 50
    local bonus_money_lvl = 0
    local bonus_money_buy = 35
    local json_pip = require("json")
    local bacg = display.newRect(0,0,1080,1920)
    local button = display.newRect(160,190,175,175)
    button:setFillColor(0,0.4,0.3)
    local button_auto = display.newRect(70,400,111,111)
    button_auto:setFillColor(0,0.4,0.3)
    local button_bonus = display.newRect(250,400,111,111)
    button_bonus:setFillColor(0,0.4,0.3)
    local text = display.newText("Click", 161, 190, "consolas", 30)
    text:setFillColor(1,1,1)
    local text1 = display.newText("Money:", 64, -19, "consolas", 30)
    text1:setFillColor(0,0.1,0.8)
    local text2 = display.newText(money, 200, -16, "consolas", 30)
    text2:setFillColor(0,0.1,0.8)
    local text3 = display.newText("Auto", 70, 370, "consolas", 30)
    text3:setFillColor(1,1,1)
    local text4 = display.newText("click", 70, 400, "consolas", 30)
    text4:setFillColor(1,1,1)
    local text5 = display.newText(auto_money_buy, 70, 437, "consolas", 30)
    text5:setFillColor(1,1,1)
    local text6 = display.newText("Bonus", 250, 370, "consolas", 30)
    text6:setFillColor(1,1,1)
    local text7 = display.newText("click", 250, 400, "consolas", 30)
    text7:setFillColor(1,1,1)
    local text8 = display.newText(bonus_money_buy, 250, 437, "consolas", 30)
    text8:setFillColor(1,1,1)
    ocal button_shadow = display.newRect(160,280,175,10)
    button_shadow:setFillColor(0,0.3,0.4)
    local button_shadow_auto = display.newRect(70,460,111,10)
    button_shadow_auto:setFillColor(0,0.3,0.4)
    local button_shadow_bonus = display.newRect(250,460,111,10)
    button_shadow_bonus:setFillColor(0,0.3,0.4)
    local copyright = display.newText("KernelCoreSW 2018-2019", 163, 490, "consolas", 23)
    copyright:setFillColor(0,0.1,0.8)
    local function flapBird (event)
      if(event.phase == "began") then
       ---lvl
       if(bonus_money_lvl == 0) then
         money = money + 1
        end
        if(bonus_money_lvl == 1) then
         money = money + 2
        end
    --И еще такого говнаролла штук 10
    text2.text = money
    end
    local function flapBird_bonus (event)
      if(event.phase == "began") then
        if(money >= bonus_money_buy) then
         money = money - bonus_money_buy
         bonus_money_buy = bonus_money_buy * 3
         bonus_money_lvl = bonus_money_lvl + 1
        end
        text2.text = money
        text8.text = bonus_money_buy
      end
    end
    local function onUpdate (args)
    
        if(auto_money > 40) then
      auto_money = 0
        end    
        ---------levels
        if(auto_money_lvl == 1) then
      if(auto_money == 40) then
       money = money + 1
       text2.text = money
      end
        end
        ---------levels end и еще такого говна штук 10
        auto_money = auto_money + 1
    end
    local function load_settings(fileName)
        local path = system.pathForFile(fileName, system.ResourceDirectory)
        local contents = ""
        local myTable = {}
        local file = io.open(path, "r")
        if(file) then
      contents = file:read("*a")
      myTable = json.decode(contents)
      io.close(file)
      return myTable
        end
        return nil
    end
    local settings = loadSettings("settings.json")
    if(settings) then
        money = settings.money
        auto_money = settings.auto_money
        auto_money_buy = settings.auto_money_buy
        auto_money_lvl = settings.auto_money_lvl
        bonus_money_lvl = settings.bonus_money_lvl
        bonus_money_buy = settings.bonus_money_buy
    end

    button:addEventListener("touch", flapBird)
    button_auto:addEventListener("touch", flapBird_auto)
    button_bonus:addEventListener("touch", flapBird_bonus)
    Runtime:addEventListener("enterFrame", onUpdate)

    Гейдев.

    3oJIoTou_xyu, 23 Октября 2019

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