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

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

    +133

    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
    #include<stdio.h>
    int main()
    {
    	int a;
    	printf("Vvedite svoy vozrast (0-200 let)");
    	scanf("%d",&a);
    	if ((a==11)||(a==12)||(a==13)||(a==14)){printf("mne %d let",a); return 0;}
    	if ((a==111)||(a==112)||(a==113)||(a==114)){printf("mne %d let",a); return 0;}
    	if (a%10==1){printf("mne %d god",a); return 0;}
    	if (a%10==2){printf("mne %d goda",a); return 0;}
    	if (a%10==3){printf("mne %d goda",a); return 0;}
    	if (a%10==4){printf("mne %d goda",a); return 0;}
    	if ((a%10==0)||(a%10==5)||(a%10==6)||(a%10==7)||(a%10==8)||(a%10==9)){printf("mne %d let",a); return 0;}
    	return 0;
    }

    Программа выводит год/года/лет. То есть возраст синтаксически правильно. Вопрос. Это как-нибудь можно написать покороче? Это считается говнокодом?

    ForEveR, 09 Июня 2010

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

    +126

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    public partial class Form1 : Form
        {
            string str;
            int количество;
            public Form1(string str, int количество)
            {
                InitializeComponent();
                str = this.str;
                количество = this.количество;
            }

    Классный конструктор, ничего не скажешь.
    А потом сидишь и удивляешься, почему же у тебя пустая строка и количество не прописалось...

    alexanika, 28 Мая 2010

    Комментарии (53)
  4. C# / Говнокод #27553

    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
    static public (int, int) FirstPosition(int figure, int rotate)
            {
                int x = 0;
                int y = 0;
                if ((figure == 1) && (rotate == 1)) { x = 6; y = 2; }
                if ((figure == 1) && (rotate == 2)) { x = 6; y = 3; }
                if ((figure == 2) && (rotate == 1)) { x = 6; y = 2; }
                if ((figure == 2) && (rotate == 2)) { x = 6; y = 3; }
                if ((figure == 3) && (rotate == 1)) { x = 6; y = 2; }
                if ((figure == 3) && (rotate == 2)) { x = 6; y = 3; }
                if ((figure == 4) && (rotate == 1)) { x = 6; y = 2; }
                if ((figure == 4) && (rotate == 2)) { x = 6; y = 2; }
                if ((figure == 4) && (rotate == 3)) { x = 6; y = 2; }
                if ((figure == 4) && (rotate == 4)) { x = 6; y = 3; }
                if ((figure == 5) && (rotate == 1)) { x = 6; y = 2; }
                if ((figure == 5) && (rotate == 2)) { x = 6; y = 3; }
                if ((figure == 5) && (rotate == 3)) { x = 6; y = 2; }
                if ((figure == 5) && (rotate == 4)) { x = 6; y = 2; }
                if ((figure == 6) && (rotate == 1)) { x = 6; y = 3; }
                if ((figure == 6) && (rotate == 2)) { x = 6; y = 2; }
                if ((figure == 6) && (rotate == 3)) { x = 6; y = 2; }
                if ((figure == 6) && (rotate == 4)) { x = 6; y = 2; }
                if ((figure == 7) && (rotate == 1)) { x = 6; y = 3; }
                return (x, y);
            }                           //НАЧАЛЬНАЯ ПОЗИЦИЯ ЦЕНТРА ФИГУРЫ
            static public int[,] Position(int figure, int rotate, int[,] a, int x, int y)
            {
                if ((figure == 1) && (rotate == 1)) { a[x, y - 2] = 1; a[x, y - 1] = 1; a[x, y] = 1; a[x, y + 1] = 1; }
                if ((figure == 1) && (rotate == 2)) { a[x - 1, y] = 1; a[x, y] = 1; a[x + 1, y] = 1; a[x + 2, y] = 1; }
                if ((figure == 2) && (rotate == 1)) { a[x - 1, y - 1] = 1; a[x - 1, y] = 1; a[x, y] = 1; a[x, y + 1] = 1; }
                if ((figure == 2) && (rotate == 2)) { a[x - 1, y] = 1; a[x, y] = 1; a[x, y - 1] = 1; a[x + 1, y - 1] = 1; }
                if ((figure == 3) && (rotate == 1)) { a[x + 1, y - 1] = 1; a[x + 1, y] = 1; a[x, y] = 1; a[x, y + 1] = 1; }
                if ((figure == 3) && (rotate == 2)) { a[x - 1, y - 1] = 1; a[x, y - 1] = 1; a[x, y] = 1; a[x + 1, y] = 1; }
                if ((figure == 4) && (rotate == 1)) { a[x, y - 1] = 1; a[x, y] = 1; a[x, y + 1] = 1; a[x + 1, y + 1] = 1; }
                if ((figure == 4) && (rotate == 2)) { a[x + 1, y] = 1; a[x, y] = 1; a[x - 1, y] = 1; a[x - 1, y + 1] = 1; }
                if ((figure == 4) && (rotate == 3)) { a[x - 1, y - 1] = 1; a[x, y - 1] = 1; a[x, y] = 1; a[x, y + 1] = 1; }
                if ((figure == 4) && (rotate == 4)) { a[x - 1, y] = 1; a[x, y] = 1; a[x + 1, y] = 1; a[x + 1, y - 1] = 1; }
                if ((figure == 5) && (rotate == 1)) { a[x, y - 1] = 1; a[x, y] = 1; a[x, y + 1] = 1; a[x - 1, y + 1] = 1; }
                if ((figure == 5) && (rotate == 2)) { a[x - 1, y - 1] = 1; a[x - 1, y] = 1; a[x, y] = 1; a[x + 1, y] = 1; }
                if ((figure == 5) && (rotate == 3)) { a[x + 1, y - 1] = 1; a[x, y - 1] = 1; a[x, y] = 1; a[x, y + 1] = 1; }
                if ((figure == 5) && (rotate == 4)) { a[x - 1, y] = 1; a[x, y] = 1; a[x + 1, y] = 1; a[x + 1, y + 1] = 1; }
                if ((figure == 6) && (rotate == 1)) { a[x, y] = 1; a[x, y - 1] = 1; a[x - 1, y] = 1; a[x + 1, y] = 1; }
                if ((figure == 6) && (rotate == 2)) { a[x, y - 1] = 1; a[x + 1, y] = 1; a[x, y + 1] = 1; a[x, y] = 1; }
                if ((figure == 6) && (rotate == 3)) { a[x - 1, y] = 1; a[x, y + 1] = 1; a[x + 1, y] = 1; a[x, y] = 1; }
                if ((figure == 6) && (rotate == 4)) { a[x, y - 1] = 1; a[x - 1, y] = 1; a[x, y + 1] = 1; a[x, y] = 1; }
                if ((figure == 7) && (rotate == 1)) { a[x, y] = 1; a[x + 1, y] = 1; a[x + 1, y - 1] = 1; a[x, y - 1] = 1; }
                return (a);
            }             //ПОСТРОЕНИЕ ФИГУРЫ ОТНОСИТЕЛЬНО ЕЁ ЦЕНТРА

    Поворот тетрисных фигур

    VladimirM4K, 08 Августа 2021

    Комментарии (52)
  5. Python / Говнокод #27419

    +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
    from enum import Enum
    from dataclasses import dataclass
    
    class Pathfind:
        __init__ = lambda self, maxmoves=9999: exec(f'self.maxmoves={maxmoves}')
        def pathfind(self, cells):
            i, found, ecords, path = 0, False, (0,0), list()
            while(not found):
                a = self.getbyval(cells, i)
                for n in [j for sub in [self.filterneighbors(self.getneighbors(cells, x[0], x[1])) for x in a] for j in sub]:
                    cells[n.ccoords[1]][n.ccoords[0]].value = i+1 if cells[n.ccoords[1]][n.ccoords[0]].value>(i+1) else cells[n.ccoords[1]][n.ccoords[0]].value
                    if cells[n.ccoords[1]][n.ccoords[0]].ctype == CellType.END: found, ecords = True, (n.ccoords[1],n.ccoords[0])
                if i<self.maxmoves: i+=1
                else: return False
            found, cpath = False, ecords
            while(not found):
                path.append(cpath)
                if cpath == self.getbyval(cells, 0)[0]: return path
                cell = list(filter(None, ([x if x.value==cells[cpath[0]][cpath[1]].value-1 else None for x in self.filterneighbors(self.getneighbors(cells, cpath[0], cpath[1]))])))[0]
                cpath = (cell.ccoords[1],cell.ccoords[0])
                
        listtocells = lambda self, lst: [[Cell(CellType(lst[y][x]), (x,y), 0 if lst[y][x]==2 else self.maxmoves) for x in range(len(lst[y]))] for y in range(len(lst))]
        getbyval = lambda self, cells, val: [(x, y) for x in range(len(cells)) for y in range(len(cells[x])) if cells[x][y].value == val]
        getneighbors = lambda self, cells, x, y: list(filter(None, [cells[x-1][y] if x>0 else None,cells[x+1][y] if x<len(cells)-1 else None,cells[x][y-1] if y>0 else None,cells[x][y+1] if y<len(cells[x])-1 else None]))
        filterneighbors = lambda self, cells: list(filter(lambda cell: False if (cell is None) or cell.ctype==CellType.WALL else True, cells))
    
    class CellType(Enum):
    	AIR, WALL, START, END = 0, 1, 2, 3
    
    @dataclass
    class Cell:
        ctype: CellType = CellType.AIR
        ccoords: tuple = (0,0)
        value: int = 0

    Максимально уёбищная реализация волнового алгоритма.

    Gehennom, 11 Мая 2021

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

    −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
    $(".mobile-filter__footer-popular-btn").on("click",function(e){
    e.preventDefault(),
    $("#header-mobile").addClass("blue"),
    $(this).addClass("active"),
    $("#filter-aside-mobile-category-popular").addClass("active")
    });
    $("#filter-aside-mobile-category-popular .catalog-mobile-menu__close").on("click",function(e){
    e.preventDefault(),
    $("#header-mobile").removeClass("blue"),
    $(".mobile-filter__footer-popular-btn").removeClass("active"),
    $("#filter-aside-mobile-category-popular").removeClass("active")
    })

    sdf

    snegoviktlt, 12 Ноября 2020

    Комментарии (52)
  7. PHP / Говнокод #27035

    0

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    // https://vk.com/login?u=2&to=YWxfZmVlZC5waHA-
    $ echo YWxfZmVlZC5waHA- | base64 -d
    al_feed.phpbase64: invalid input
    
    $ echo -n al_feed.php | base64
    YWxfZmVlZC5waHA=

    Олимпиадники даже base64 умудрились пропатчить

    Fike, 17 Октября 2020

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

    +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
    39. 39
    40. 40
    41. 41
    Definition uilv_add_trivial {N} te (t : list TE) (traces : Traces N)
                 i j (Ht : MInt_ trace_elems_don't_commute j true traces t)
                 s s' (Hls : LongStep s (te :: t) s')
                 (Htriv : trivial_add i j traces) :
        MInt_ trace_elems_don't_commute i true (push_te traces i te) (te :: t).
      Proof with autorewrite with vector; eauto with vector; try vec_forall_eq_contradiction.
        unfold push_te.
        unfold trivial_add in Htriv.
        destruct (Fin.eq_dec i j) as [Hij|Hij].
        (* [i=j], solving by constructor: *)
        { subst.
          unfold trivial_add.
          eapply mint_keep with (rest := traces[@j])...
        }
        remember traces[@j] as t2_.
        destruct t2_ as [|te2 t2]; subst.
        { inversion Ht as [vec Hvec|? ? ? ? ? Hj Hcont|? ? ? ? ? ? Hjj0 Hswitch Hj Hcont];
            subst.
          - eapply mint_keep with (prog := true)...
            eapply mint_nil...
          - rewrite Hj in Heqt2_.
            discriminate.
        }
        remember traces[@i] as t1_.
        destruct t1_ as [|te1 t1]; subst.
        (* [te] is the last element in i-th trace: *)
        { eapply mint_keep with (rest := []) (prog := false)...
          inversion Ht as [vec Hvec|? ? ? ? ? Hj Hcont|? ? ? ? ? ? Hjj0 Hswitch Hj Hcont];
            subst...
          rewrite Heqt1_ in *.
          eapply mint_switch...
          rewrite <-Heqt1_...
        }
        destruct Htriv as [|[Hij' Hcomm]]; [contradiction Hij|idtac].
        eapply mint_keep with (rest := te1 :: t1) (prog := false)...
        rewrite Heqt1_, Vec.replace_id.
        inversion Ht as [vec Hvec|? ? ? ? ? Hj Hcont|? ? ? ? ? ? Hjj0 Hswitch Hj Hcont]; subst...
        replace te0 with te2 in * by congruence.
        eapply mint_switch...
        rewrite <-Heqt1_...
      Defined.

    Кто сказал, что хуже C++ темплейтов ничего уже нет? Вы ничего не понимаете в метушне. Это говно разворачивается в 12000 строк, например.

    CHayT, 20 Августа 2020

    Комментарии (52)
  9. PHP / Говнокод #26087

    −3

    1. 1
    2. 2
    Официальный тред для обсуждения способов высера видеоизображения на телеящик.
    Один калмент -- один способ

    Официальный тред для обсуждения способов высера видеоизображения на телеящик.
    Один калмент -- один способ

    MAPTbIwKA, 11 Декабря 2019

    Комментарии (52)
  10. PHP / Говнокод #26056

    +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
    <?php
    
    $img = imagecreatefromgif('http://web.archive.org/web/20070419044913im_/upyachka.ru/img/kot/16.gif');
    
    $w = imagesx($img);
    $h = imagesy($img);
    
    $symbols = array(' ', '▀', '▄', '█');
    
    for($y = 0; $y < floor($w/2); ++$y) {
        for($x = 0; $x < $w; ++$x) {
            $color1 = imagecolorat($img, $x, 2*$y);
            $color2 = imagecolorat($img, $x, 2*$y+1);
            $bit1 = intval(($color1 & 0xff) > 0x80);
            $bit2 = intval(($color2 & 0xff) > 0x80);
            echo $symbols[$bit1 + ($bit2 << 1)];
        }
        echo PHP_EOL;
    }

    XYPO3BO3, 28 Ноября 2019

    Комментарии (52)
  11. Python / Говнокод #26010

    +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
    x = 0; y = 0
     
    def gcd(a, b):
    #{
        global x, y
        if (a == 0):
        #{
            x = 0; y = 1;
            return b;
        #}
        d = gcd(b%a, a);
        t = x
        x = y - (b // a) * x;
        y = t;
        return d;
    #}
     
    #int main()
    #{
    #ios_base::sync_with_stdio(0); in.tie(0);
    #I n, p, w, d, dd, ww;
    #in >> n >> p >> w >> d;
    n, p, w, d = map(int, input().split())
    gc = gcd(d, w);
    dd = x; ww = y
    g = w * d // gc;
    if (p % gc):
        print(-1); exit(0)
    dd *= p // gc;
    ww *= p // gc;
    if (ww < 0):
    #{
        di = (-ww + g // w - 1) // (g // w);
        ww += g // w * di;
        dd -= g // d * di;
        if (dd < 0):
            print(-1); exit(0)
    #}
    elif (dd < 0):
    #{
        di = (-dd + g // d - 1) // (g // d);
        dd += g // d * di;
        ww -= g // w * di;
        if (dd < 0):
            print(-1); exit(0)
    #}
    if (ww < 0 or dd < 0):
        print(-1); exit(0)
    di = dd // (g // d);
    dd -= g // d * di;
    ww += g // w * di;
    if (ww + dd <= n):
        print(ww, dd, n - ww - dd)
    else:
        print(-1);
    #}

    Когда на соревновании по спортивному программированию пишешь код на C++ и внезапно понимаешь, что int64_t тебе недостаточно.

    fyodor95, 04 Ноября 2019

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