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

    В номинации:
    За время:
  2. 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)
  3. 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)
  4. 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)
  5. 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)
  6. 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)
  7. Куча / Говнокод #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)
  8. PHP / Говнокод #26087

    −3

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

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

    MAPTbIwKA, 11 Декабря 2019

    Комментарии (52)
  9. 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)
  10. 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)
  11. Java / Говнокод #25998

    +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
    57. 57
    58. 58
    59. 59
    60. 60
    61. 61
    62. 62
    import java.util.Scanner;
    
    public class ComputeTax {
    
    public static void main(String[] args) {
    // Create a Scanner
    Scanner input = new Scanner(System.in);
    
    // Prompt the user to enter filing status
    System.out.print(
        "(0-single filer, 1-married jointly or qualifying widow(er)",
        + "\n2-married separately, 3-head of household)\n" +
        "Enter the filing status: ");
    int status = input.nextInt();
    
    // Prompt the user to enter taxable income
    System.out.print("Enter the taxable income: ");
    double income = input.nextDouble();
    
    // Compute tax
    double tax = 0;
    
    if (status == 0) {// Compute tax for single filers
        if (income <= 8350)
              tax = income * 0.10;
        else if (income <= 33950)
              tax = 8350 * 0.10 + (income - 8350) * 0.15;
        else if (income <= 82250)
              tax = 8350 * 0.10 + (33950 - 8350) * 0.15 +
             (income - 33950) * 0.25;
        else if (income <= 171550)
              tax = 8350 * 0.10 + (33950 - 8350) * 0.15 +
             (82250 - 33950) * 0.25 + (income - 82250) * 0.28;
        else if (income <= 372950)
              tax = 8350 * 0.10 + (33950 - 8350) * 0.15 +
              (82250 - 33950) * 0.25 + (171550 - 82250) * 0.28 +
              (income - 171550) * 0.33;
        else
              tax = 8350 * 0.10 + (33950 - 8350) * 0.15 +
             (82250 - 33950) * 0.25 + (171550 - 82250) * 0.28 +
             (372950 - 171550) * 0.33 + (income - 372950) * 0.35;
    }
    else if (status == 1) {
    // Left as exercise
    // Compute tax for married file jointly or qualifying widow(er)
    }
    else if (status == 2) {
    // Compute tax for married separately
    // Left as exercise
    }
    else if (status == 3) {
    // Compute tax for head of household
    // Left as exercise
    }
    else {
        System.out.println("Error: invalid status");
        System.exit(1);
    }
    // Display the result
    System.out.println("Tax is " + (int)(tax * 100) / 100.0);
    
    }

    Ksyrx, 26 Октября 2019

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