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

    В номинации:
    За время:
  2. Куча / Говнокод #-27380

    +1

    1. 1
    Просто оффтоп #18

    #1: https://govnokod.ru/20162 https://govnokod.xyz/_20162
    #2: https://govnokod.ru/25329 https://govnokod.xyz/_25329
    #3: https://govnokod.ru/25415 https://govnokod.xyz/_25415
    #4: (vanished) https://govnokod.xyz/_25472
    #5: https://govnokod.ru/25693 https://govnokod.xyz/_25693
    #6: (vanished) https://govnokod.xyz/_26649
    #7: https://govnokod.ru/26672 https://govnokod.xyz/_26672
    #8: https://govnokod.ru/26924 https://govnokod.xyz/_26924
    #9: https://govnokod.ru/27072 https://govnokod.xyz/_27072
    #10: https://govnokod.ru/27086 https://govnokod.xyz/_27086
    #11: https://govnokod.ru/27122 https://govnokod.xyz/_27122
    #12: https://govnokod.ru/27153 https://govnokod.xyz/_27153
    #13: https://govnokod.ru/27159 https://govnokod.xyz/_27159
    #14: https://govnokod.ru/27200 https://govnokod.xyz/_27200
    #15: https://govnokod.ru/27237 https://govnokod.xyz/_27237
    #16: https://govnokod.ru/27282 https://govnokod.xyz/_27282
    #17: https://govnokod.ru/27319 https://govnokod.xyz/_27319

    nepeKamHblu_nemyx, 28 Апреля 2021

    Комментарии (6734)
  3. Куча / Говнокод #27379

    +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
    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
    (set-logic UF)
    ; https://smtlib.cs.uiowa.edu/logics.shtml
    ; UF for the extension allowing free sort and function symbols 
    
    (set-option :produce-proofs true)
    
    (declare-sort M_wff)
    
    
    ; AND2
    (declare-fun M_a2 (M_wff M_wff) M_wff)
    
    ; AND3
    (declare-fun M_a3 (M_wff M_wff M_wff) M_wff)
    
    
    
    ; (AND2 a b) <=> (AND2 b a)
    
    (assert 
      (forall ( (a M_wff) (b M_wff) )
        (=
          (M_a2 a b)
          (M_a2 b a)
        )
      )
    )
    
    
    
    ; (AND2 a a) <=> a
    
    (assert 
      (forall ( (a M_wff) )
        (=
          (M_a2 a a)
          a
        )
      )
    )
    
    
    
    ; (AND2 a (AND2 b c)) <=> (AND3 a b c)
    
    (assert 
      (forall ( (a M_wff) (b M_wff) (c M_wff) )
        (=
          (M_a2 a (M_a2 b c))
          (M_a3 a b c)
        )
      )
    )
    
    
    
    ; (AND3 a b c) <=> (AND3 b a c)
    
    (assert
      (forall ( (a M_wff) (b M_wff) (c M_wff) )
        (=
          (M_a3 a b c)
          (M_a3 b a c)
        )
      )
    )
    
    
    
    ; IMPL - implication
    (declare-fun M_impl (M_wff M_wff) M_wff)
    
    
    
    ; http://us.metamath.org/ileuni/ax-1.html
    ; Axiom Simp
    ; (IMPL a (IMPL b a)) <=> (AND2 a b)
    
    (assert
      (forall ( (a M_wff) (b M_wff) )
        (=
          (M_impl a (M_impl b a))
          (M_a2 a b)
        )
      )
    )
    
    ...

    Весь код не влазит.

    https://rise4fun.com/Z3/GnfIH
    https://paste.debian.net/hidden/38ef8493/ (запасная ссылка)

    Переписывал Metamath на язык из SMT солверов https://smtlib.cs.uiowa.edu/language.shtml
    Z3 даже умеет доказывать какую-то питушню там.

    j123123, 28 Апреля 2021

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

    +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
    %% This function is needed as a hack to guide dialyzer into inferring
    %% the correct types.
    -spec id(A) -> A.
    id(A) ->
      A.
    
    %% Где-то в header'е....
    
    -define(deftarget(RECIPE), {RECIPE, fun my_module:id/1}).
    
    %% A horrible, horrible hack to make Dialyzer infer right type of the promise return value
    -define(want(TARGET),
            (fun() ->
                 case TARGET of
                   {_, ___IAmSorryYouHaveToSeeThisWorkaroundForDialyzer} ->
                     ___IAmSorryYouHaveToSeeThisWorkaroundForDialyzer(my_module:want(TARGET))
                 end
             end)()).

    Пути статический типизации в Erlang неисповедимы.

    CHayT, 26 Апреля 2021

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

    +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
    // Update is called once per frame
        void Update () {
            if (!isWin && !isFail && !isPaused)
            {
                if (timeForUnhit > 0) //Для состояния восстановления игрока
                {
                    timeForUnhit -= Time.deltaTime;
                    //LevelGenerate.Instance.player.GetComponent<SpriteRenderer>().sprite = hitPlayer;
                }
                else if (timeForInvc > 0)
                //Для состояния непобедимости игрока
                {
                    timeForInvc -= Time.deltaTime;
                    //LevelGenerate.Instance.player.GetComponent<SpriteRenderer>().sprite = invcPlayer;
                }
    
                else
                {
                    //LevelGenerate.Instance.player.GetComponent<SpriteRenderer>().sprite = player;
                    LevelGenerate.Instance.player.GetComponent<Animator>().CrossFade(animNames[0], 0);
                    if (invc)
                    {
                        
                        MusicManager.Instance.gameObject.GetComponent<AudioSource>().clip = MusicManager.Instance.music[1];
                        MusicManager.Instance.gameObject.GetComponent<AudioSource>().Play();
                    }
                    invc = false;
                    
                }
            }
    
            i = LevelGenerate.Instance.playerY;
            j = LevelGenerate.Instance.playerX;
            
            if (!isWin && !isFail) //Если уровень не завершен
            {
                collideEnemy(); //Обнаружение столкновения с врагом
                collectItem(); //Обнаружения столкновения с собираемым предметом
                genNthOrdColls(2); //Генерация предметов n-ого порядка после сбора предметов (n-1)-ого
                genNthOrdColls(3);
                genNthOrdColls(4);
    
                if (colls[0] == 0 && colls[1] == 0 && colls[2] == 0 && colls[3] == 0 && LevelGenerate.Instance.resLoaded) isWin = true; //Если все предметы собраны, то уровень завершен с прохождением
            }
    
            if (isWin && animationSet == 0) //Меняем спрайт игрока при завершении уровня
            {
                //LevelGenerate.Instance.player.GetComponent<SpriteRenderer>().sprite = winPlayer;
                LevelGenerate.Instance.player.GetComponent<Animator>().CrossFade(animNames[1], 0);
                animationSet++;
                delayTime = 1.5f;
                MusicManager.Instance.gameObject.GetComponent<AudioSource>().mute = true;
                SoundManager.Instance.gameObject.GetComponent<AudioSource>().clip = SoundManager.Instance.sounds[0];
                SoundManager.Instance.gameObject.GetComponent<AudioSource>().Play();
            }
    
            if (isWin && delayTime <= 0)
            {
                //path = Application.dataPath + "\\Levels\\SaveData1";
    
                /*if (Application.platform == RuntimePlatform.WindowsEditor)
                {
                    path = Application.dataPath;
                    path = Path.Combine(path, "Levels");
                }
                else if (Application.platform == RuntimePlatform.Android)
                    path = Application.persistentDataPath;
                
                path = Path.Combine(path, "SaveData1");
                fs = new FileStream(path, FileMode.Open);
                bw = new BinaryWriter(fs);*/
                levelNum = (byte)(Convert.ToByte(LevelGenerate.Instance.levelFile.Substring(5)) - 1);
                levelNum++;
                if (PlayerPrefs.GetInt("maxLevel") == levelNum)
                {
    
    
                    
                    PlayerPrefs.SetInt("maxLevel", (int)levelNum);
                    PlayerPrefs.Save();
                }
                PlayerPrefs.SetInt("level", (int)levelNum);
    
                /*bw.Write(levelNum);
                
                bw.Write("Level" + (levelNum+1).ToString());
                bw.Close();
                fs.Close();*/
                SceneManager.LoadScene("Win");
            } else if (delayTime > 0)
            {
                delayTime -= Time.deltaTime;
            }
            if (isFail && delayTime <= 0)
            {
                //path = Application.dataPath + "\\Levels\\SaveData1";
                /*if (Application.platform == RuntimePlatform.WindowsEditor)
                {
                    path = Application.dataPath;
                    path = Path.Combine(path, "Levels");

    ```
    }
    else if (Application.platform == RuntimePlatform.Android)
    path = Application.persistentDataPath;

    path = Path.Combine(path, "SaveData1");
    fs = new FileStream(path, FileMode.Open);
    bw = new BinaryWriter(fs);

    fs.Seek(1, SeekOrigin.Begin);
    bw.Write(LevelGenerate.Instance.levelFil e);
    bw.Close();
    fs.Close();*/
    PlayerPrefs.SetString("levelFile", LevelGenerate.Instance.levelFile);
    PlayerPrefs.Save();
    SceneManager.LoadScene("Fail");
    } else if (delayTime > 0)
    {
    delayTime -= Time.deltaTime;
    }
    }
    ```

    Самый страшный метод из EventManager-а (модуль который отвечал за все события в игре - коллизию с врагом, таймаут непобедимости и пр.).

    JaneBurt, 24 Апреля 2021

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

    +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
    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
    99. 99
    //Генерация уровня из файла
        void mapGenerate()
        {
            
            float x = 0.72f, y = -0.72f; //Координаты игрового объекта
            byte i = 0, j = 0; //Цифровые координаты игрвоого объекта
    
            while (y >= -5.76f)
            {
                while (x <= 5.76f)
                {
                    
                        
                    if (map[i, j] % 8 == 1) //Если игровой объект - точка спавна игрока
                    {
                        player.transform.position = new Vector3(x, y, 0);
                        playerX = j;
                        playerY = i;
                    }
                    else if (map[i, j] % 8 == 5) //Если игровой объект - точка спавна врага
                    {
                        enemy.transform.position = new Vector3(x, y, 0);
                        enemyX = j;
                        enemyY = i;
                        //print("Enemy: " + enemyX + " " + enemyY);
                    } else if(map[i, j] % 8 == 6) //Если игровой объект - собираемый предмет
                    {
                        EventManager.Instance.colls[0]++; //Увеличивается количество собираемых монет на уровне
                        mapObj[i, j] = Instantiate(entities[map[i, j] % 8], new Vector3(x, y, 0), Quaternion.identity);
                    }
    
                    else if (map[i,j] % 8 != 0) { //Для остальных игровых объектов
                        mapObj[i,j] = Instantiate(entities[map[i, j] % 8], new Vector3(x, y, 0), Quaternion.identity);
                    }
                    x += 0.72f;
                    j++;
                }
                y -= 0.72f;
                x = 0.72f;
                j = 0;
                i++;
            }
        } 
    
        //Считывание данных об уровне
        void readLevelFile()
        {
            string path = "";
            FileStream fs = null;
            BinaryReader br = null;
            
            if (Application.platform == RuntimePlatform.WindowsEditor)
            {
                path = Application.dataPath;
                path = Path.Combine(path, "Levels");
                path = Path.Combine(path, levelFile);
                fs = new FileStream(path, FileMode.Open);
                br = new BinaryReader(fs);
                head = br.ReadBytes(8); //Чтение заголовка файла
                for (int i = 0; i < 8; i++)
                {
                    for (int j = 0; j < 8; j++)
                    {
                        map[i, j] = br.ReadByte(); //Чтение кода игрового объекта
                    }
                }
    
    
    
                br.Close();
                fs.Close();
            } else if (Application.platform == RuntimePlatform.Android)
            {
                
                byte[] file = null;
                
                    path = "jar:file://"+ Application.dataPath + "!/assets/Levels/"+levelFile;
                    www = new WWW(path);
                while (!www.isDone) { }
                    if (!string.IsNullOrEmpty(www.error))
                    {
                        Debug.LogError("Can't read");
                    }
                    file = www.bytes;
    
                    for (int i = 0; i < 8; i++)
                    {
                        head[i] = file[i];
                    }
                    for (int i = 0; i < 8; i++)
                    {
                        for (int j = 0; j < 8; j++)
                        {
                            map[i, j] = file[j + i * 8 + 8]; //Чтение кода игрового объекта
                        }
                    }
    
                www.Dispose();
            }

    Из кода собственной аркады на Unity 2017-ого года. Неоправданные байто*бские оптимизации, взаимодействие между модулями через десяток глобалов, магические константы не зафиксированные в именах кода, куча хардкода. И ето из модуля для генерации уровня. В модуле для управления событиями код страшнее.

    JaneBurt, 24 Апреля 2021

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

    +1

    1. 1
    there are java.io.FileNotFoundException and java.nio.file.NoSuchFileException . Both are subclasses of IOException, neither of them is a subclass of the opposite.

    DypHuu_niBEHb, 20 Апреля 2021

    Комментарии (10)
  8. C# / Говнокод #27366

    +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
    private List<CellControl[]> ComposeLines(List<CellControl[]> vertical, List<CellControl[]> horizontal)
            {
                List<CellControl[]> result = new List<CellControl[]>();
    
                foreach (var vLine in vertical)
                {
                    var cellsCount = vLine.Length;
                    List<CellControl[]> linesToCompose = new List<CellControl[]>();
                    foreach (var vCell in vLine)
                    {
                        foreach (var hLine in horizontal)
                        {
                            foreach (var hCell in hLine)
                            {
                                if (hCell.X == vCell.X && hCell.Y == vCell.Y)
                                {
                                    linesToCompose.Add(hLine);
                                    cellsCount += hLine.Length;
                                    break;
                                }
                            }
    
                            if (linesToCompose.Count == 0)
                            {
                                result.Add(hLine);
                            }
                        }
                    }
    
                    if (linesToCompose.Count == 0)
                    {
                        result.Add(vLine);
                    }
                    else
                    {
                        linesToCompose.Add(vLine);
                        var newLine = new CellControl[cellsCount];
                        var i = 0;
                        foreach (var line in linesToCompose)
                        {
                            foreach (var cellControl in line)
                            {
                                newLine[i] = cellControl;
    
                                cellControl.Selected = true;
                                i++;
                            }
                        }
                        
                        result.Add(newLine);
                    }
                }
                
                return result;
            }

    mdd-inbox, 20 Апреля 2021

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

    +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
    import cowsay
    cowsay.cow('Hello World')
    
    
      ___________
    < Hello World >
      ===========
                    \
                     \
                       ^__^
                       (oo)\_______
                       (__)\       )\/\
                           ||----w |
                           ||     ||

    3_dar, 15 Апреля 2021

    Комментарии (244)
  10. Куча / Говнокод #27353

    +1

    1. 1
    Питушня #15

    #1: https://govnokod.ru/26692 https://govnokod.xyz/_26692
    #2: https://govnokod.ru/26891 https://govnokod.xyz/_26891
    #3: https://govnokod.ru/26893 https://govnokod.xyz/_26893
    #4: https://govnokod.ru/26935 https://govnokod.xyz/_26935
    #5: (vanished) https://govnokod.xyz/_26954
    #6: (vanished) https://govnokod.xyz/_26956
    #7: https://govnokod.ru/26964 https://govnokod.xyz/_26964
    #8: https://govnokod.ru/26966 https://govnokod.xyz/_26966
    #9: https://govnokod.ru/27017 https://govnokod.xyz/_27017
    #10: https://govnokod.ru/27045 https://govnokod.xyz/_27045
    #11: https://govnokod.ru/27058 https://govnokod.xyz/_27058
    #12: https://govnokod.ru/27182 https://govnokod.xyz/_27182
    #13: https://govnokod.ru/27260 https://govnokod.xyz/_27260
    #14: https://govnokod.ru/27343 https://govnokod.xyz/_27343

    nepeKamHblu_nemyx, 11 Апреля 2021

    Комментарии (2532)
  11. Куча / Говнокод #27352

    +1

    1. 1
    11 апреля - всемирный день анимешника

    Всех поздравляем!!!

    OCETuHCKuu_nemyx, 11 Апреля 2021

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