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. Си / Говнокод #24496

    +5

    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
    void sort3(uint32_t a[static 3])
    {
      //                   0     1     2     3     4     5     6     7     8
      uint32_t tmp[9] = {a[0], a[1], a[2], a[0], a[1], a[0], a[2], a[1], a[0]};
      uint8_t bits = (a[0] <= a[1]) | ((a[1] <= a[2]) << 1) | ((a[0] <= a[2]) << 2);
      static const uint8_t b[] =
      {
        [0b000] = 6,
        [0b001] = 2,
        [0b010] = 1,
        [0b101] = 5,
        [0b110] = 4,
        [0b111] = 0,
      };
      memcpy(a, tmp+b[bits], 3*sizeof(uint32_t));
    }

    Новая инновационная сортировка на 3 элемента без if-ов
    https://wandbox.org/permlink/pTLXgxKKQuaiVCxb

    j123123, 15 Июля 2018

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