1. PHP / Говнокод #27132

    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
    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
    <?php
    
    class ModelExtensionModuleAridiusfastorder extends Model {
    	
    	public function deleteOrder($order_id) {
    		
    		$this->db->query("DELETE FROM " . DB_PREFIX . "aridiusfastorder WHERE order_id = '" . (int) $order_id . "'");
    	}
    
    	public function editOrder($order_id, $data) {
    		
    		$this->db->query("UPDATE `" . DB_PREFIX . "aridiusfastorder` SET firstname = '" . $this->db->escape($data['firstname']) . "',status = '" . $this->db->escape($data['status']) . "',email = '" . $this->db->escape($data['email']) . "',comment_manager = '" . $this->db->escape($data['comment_manager']) . "',contact = '" . $data['contact'] . "' WHERE order_id = '" . (int)$order_id . "'");
    	}
    	
    	public function getOrder($order_id) {
    		
    		$query = $this->db->query("SELECT * FROM " . DB_PREFIX . "aridiusfastorder WHERE order_id = '" . (int)$order_id . "'");
    		
    		return $query->row;
    	}
    
    	public function getOrders($data = array()) {
    
    		$sql = "SELECT * FROM " . DB_PREFIX . "aridiusfastorder";
    
    		if (isset($data['filter_order_id']) && !is_null($data['filter_order_id'])) {
    			$sql .= " WHERE order_id = '" . (int) $data['filter_order_id'] . "'";
    		} else {
    			$sql .= " WHERE order_id > '0'";
    		}
    
    		if (!empty($data['filter_contact'])) {
    			$sql .= " AND contact LIKE '%" . $this->db->escape($data['filter_contact']) . "%'";
    		}
    			if (!empty($data['filter_email'])) {
    			$sql .= " AND email LIKE '%" . $this->db->escape($data['filter_email']) . "%'";
    		}
    		if (!empty($data['filter_status'])) {
    			$sql .= " AND status LIKE '%" . $this->db->escape($data['filter_status']) . "%'";
    		}
    		
    		if (!empty($data['filter_firstname'])) {
    			$sql .= " AND firstname LIKE '%" . $this->db->escape($data['filter_firstname']) . "%'";
    		}
    
    		if (!empty($data['filter_product_name'])) {
    			$sql .= " AND product_name LIKE '%" . $this->db->escape($data['filter_product_name']) . "%'";
    		}
    
    		if (!empty($data['filter_date_added'])) {
    			$sql .= " AND DATE(date_added) = DATE('" . $this->db->escape($data['filter_date_added']) . "')";
    		}
    
    		if (!empty($data['filter_total'])) {
    			$sql .= " AND total = '" . (float) $data['filter_total'] . "'";
    		}
    
    		$sort_data = array(
    			'order_id',
    			'status',
    			'email',
    			'contact',
    			'firstname',
    			'product_name',
    			'total',
    			'date_added'
    		);
    
    		if (isset($data['sort']) && in_array($data['sort'], $sort_data)) {
    			$sql .= " ORDER BY " . $data['sort'];
    		} else {
    			$sql .= " ORDER BY order_id";
    		}
    
    		if (isset($data['order']) && ($data['order'] == 'DESC')) {
    			$sql .= " DESC";
    		} else {
    			$sql .= " ASC";
    		}
    
    		if (isset($data['start']) || isset($data['limit'])) {
    			if ($data['start'] < 0) {
    				$data['start'] = 0;
    			}
    
    			if ($data['limit'] < 1) {
    				$data['limit'] = 20;
    			}
    
    			$sql .= " LIMIT " . (int) $data['start'] . "," . (int) $data['limit'];
    		}
    
    		$query = $this->db->query($sql);
    
    		return $query->rows;
    	}
    
    	public function getTotalOrders() {

    rastabumper, 25 Ноября 2020

    Комментарии (14)
  2. C++ / Говнокод #27131

    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
    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
    #include <iostream>
    #include <ctime>
    #include <string>
    #include <random>
    #include <algorithm>
    #include <iomanip> // для ограничения количества вводимых симолов для std::cin
    
    void compUsrWthCmptr(std::string userInput, std::string computerInput)
    {
        std::reverse(userInput.begin(), userInput.end());//  Считаем правильно угаданные позиции
        std::reverse(computerInput.begin(), computerInput.end());
        int guessedPositions{ 0 };
        for (int i = 0; (i < userInput.length()) && (i < computerInput.length()); ++i)
        {
            if (userInput[i] == computerInput[i])
            {
                guessedPositions++;
            }
        }
        std::string::iterator it_userInput;
        std::string::iterator it_computerInput;
        it_userInput = std::unique(userInput.begin(), userInput.end()); // Удаляем повторяющиеся цифры
        userInput.resize(std::distance(userInput.begin(), it_userInput));
        it_computerInput = std::unique(computerInput.begin(), computerInput.end());
        computerInput.resize(std::distance(computerInput.begin(), it_computerInput));
        int guessedDigits{ 0 }; //  Считаем количество правильно угаданных цифр без учета повторяющихся
        for (int i = 0; i < userInput.length(); ++i)
        {
            for (int x = 0; x < computerInput.length(); ++x)
            {
                if (userInput[i] == computerInput[x])
                {
                    guessedDigits++;
                }
            }
        }
        std::cout << "  Угадано: " << guessedDigits << ". Соответствует своим разрядам: " << guessedPositions << std::endl << std::endl;
    };
    void startTheGame()
    {
        int pcsRandomNumber = getRandomNumber(0, 999);      //Загаданое число.
        std::cout << "  Компьютер загадал трехзначное число от 0 до 999!\n" << "  Это: " << pcsRandomNumber << std::endl << std::endl;
        std::string pcNumber{ std::to_string(pcsRandomNumber) };
        bool win = false;
        do
        {
            int usersGuess = getUsersGuess();
            std::string guess{ std::to_string(usersGuess) };
            std::cout << "  Ваш вариант : " << guess << std::endl;
            compUsrWthCmptr(guess, pcNumber);
            if (usersGuess == pcsRandomNumber)
            {
                win = true;
                std::cout << "  *** Вы угадали число " << pcsRandomNumber << "!***\n";
            }
        } while (!win);
    };
    int getUsersGuess()
    {
        while (true) // цикл продолжается до тех пор, пока пользователь не введет корректное значение
        {
            std::cout << "  Введите коректное значение: ";
            int a;
            std::cin >> std::setw(3) >> a;
            if (std::cin.fail()) // если предыдущее извлечение оказалось неудачным,
            {
                std::cin.clear(); // то возвращаем cin в 'обычный' режим работы
                std::cin.ignore(32767, '\n'); // и удаляем значения предыдущего ввода из входного буфера
                std::cout << "  Предыдущее извлечение оказалось неудачным. Попытайтесь еще раз.\n\n";
            }
            else
            {
                if (a >= 1000 || a < 0)
                {
                    std::cin.ignore(32767, '\n'); // удаляем лишние значения
                    std::cout << "  Введенное число вне требуемого диапазонате. Попытайтесь еще раз.\n\n";
                }
                else
                {
                    std::cin.ignore(32767, '\n'); // удаляем лишние значения
                    return a;
                }
            }
        }
    }
    int getRandomNumber(int min, int max)
    {
        return static_cast<int>(rand() % (max - min + 1) + min);
    }
    
    int main()
    {
        setlocale(LC_ALL, "Russian");
        srand(static_cast<unsigned int>(time(0)));
        startTheGame();
        return 0;
    }

    Начинающий говнокодер просит оценить его код. Где/что можно улучшить если возможно. Благодарю
    //Напишите программу реализующую игру «Угадай число».Компьютер загадывает число от 0 до 999 (используйте генерацию случайных чисел),
    //а пользователь угадывает его.На каждом шаге угадывающий делает предположение, а задумавший число — сообщает, сколько цифр из числа угаданы
    //и сколько из угаданных цифр занимают правильные позиции в числе.Например, если задумано число 725 и выдвинуто предположение,
    //что задумано число 523, то угаданы две цифры(5 и 2) и одна из них занимает верную позицию.

    radionnazmiev, 25 Ноября 2020

    Комментарии (29)
  3. JavaScript / Говнокод #27124

    +1

    1. 1
    console.log("Hello, World!");

    https://en.wikipedia.org/wiki/World_Hello_Day

    3_dar, 21 Ноября 2020

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

    +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
    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
    ShipType Ship::getShipTypeByLength(int length)
    {
        switch (length) {
            case 1: return BOAT;
            case 2: return CRUISER;
            case 3: return DESTROYER;
            case 4: return BATTLESHIP;
            case 5: return AIRCRAFT_CARRIER;
    
            default:
                std::cout << "No ship meets the given length: " << length << std::endl;
                return ERROR_SHIP;
        }
    }
    
    int Ship::getShipLengthByType(ShipType type)
    {
        switch (type) {
            case BOAT: return 1;
            case CRUISER: return 2;
            case DESTROYER: return 3;
            case BATTLESHIP: return 4;
            case AIRCRAFT_CARRIER: return 5;
    
            default:
                std::cout << "No ship meets the given type: " << type << std::endl;
                return 0;
        }
    }
    
    int Ship::getShipAmountByType(ShipType type)
    {
        switch (type) {
            case BOAT: return 4;
            case CRUISER: return 3;
            case DESTROYER: return 2;
            case BATTLESHIP: return 1;
            case AIRCRAFT_CARRIER: return 1;
    
            default:
                std::cout << "No ship meets the given type: " << type << std::endl;
                return 0;
        }
    }
    
    Coordinates Ship::getFirstBlockCoordinatesByShipData(int x, int y, int length, Orientation orientation)
    {
        Coordinates result;
        if (orientation == HORIZONTAL) {
            result.x = x - (length / 2);
            result.y = y;
        } else {
            result.x = x;
            result.y = y - (length / 2);
        }
        return result;
    }
    
    Coordinates Ship::getLastBlockCoordinatesByShipData(int x, int y, int length, Orientation orientation)
    {
        Coordinates result;
        if (orientation == HORIZONTAL) {
            result.x = x + (length / 2) + (length % 2) - 1;
            result.y = y;
        } else {
            result.x = x;
            result.y = y + (length / 2) + (length % 2) - 1;
        }
        return result;
    }

    Вот некоторые полезные функции из игры «Морской Бой», которую я зачем-то написал.

    oaoaoammm, 21 Ноября 2020

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

    +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
    #include <iostream>
    using namespace std;
    
    int del(int s)
    {
    	int k = 0;
    	for (int i = 1;i <= 20;i++)
    	{
    		if (s % i == 0)
    		{
    			k++;
    		};
    
    	};
    	return k == 20;
    
    }
    
    int main()
    {
    	unsigned long int q = 1;
    	for (int i = 1;i <= 20;i++)
    	{
    		q = q*i;
    	}
    	for (int i=1;i<=q;i++)
    	{
    		if (del(i))
    		{
    			cout << i;
    			break;
    		}
    	}
    	return 0;
    }

    2520 - самое маленькое число, которое делится без остатка на все числа от 1 до 10.

    Какое самое маленькое число делится нацело на все числа от 1 до 20?

    Что за неоптимизированное говно я сейчас сделал.........

    NikEral7, 19 Ноября 2020

    Комментарии (467)
  6. Куча / Говнокод #27119

    0

    1. 1
    https://journal.tinkoff.ru/diary-quality-manager-moscow-950k/

    OCETuHCKuu_nemyx, 19 Ноября 2020

    Комментарии (38)
  7. Куча / Говнокод #27118

    0

    1. 1
    Mi sidim v servernoy!

    Vse kto nas chitaet! Mi sidim v servernoy, v zaperty, mobillnyi ne beret! Pozovonite na ohrany po telefony на okrany 762-23-96 i skagite chtobi nas vypustili!

    3vservernoy, 19 Ноября 2020

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

    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
    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
    #Я новичок в питоне, учусь буквально 2 недели. Это моя первая программа - типа банкомат, 
    #которую показал для примера учитель в очень упрощенном варианте, а я уже заинтересовался этим и стал улучшать её. 
    
    x=input('Чтобы зарегистрироваться, введите логин.\n' )
    y=input('Придумайте пароль.\n')
    login=x
    password=y
    print('Вы успешно зарегистрировались!')
    print('__________________________________________________________________________________________________________________')
    print('__________________________________________________________________________________________________________________')
    print('Войдите в систему, чтобы получить доступ ко всем функциям.')
    log=(input("Введите логин:\n"))
    pas=(input("Введите пароль:\n"))
    if((log==login)and(pas == password)):
    	balance=0
    	print('__________________________________________________________________________________________________________________')
    	print('__________________________________________________________________________________________________________________')
    	print("Вход выполнен успешно! У вас на счету",balance,"р.")
    	while 1:
    		print('__________________________________________________________________________________________________________________')
    		print('__________________________________________________________________________________________________________________')
    		print("Введите 1, чтобы пополнить счет, 2, чтобы снять, 3, чтобы выйти из аккаунта, и 4, чтобы узнать состояние счета.")
    		s=int(input('(Далее - Enter.)\n'))
    		if(s==1):
    			sum=int(input("На сколько вы хотите пополнить счет? (Далее - Enter.)\n"))
    			balance=balance+sum
    			print("Операция проведена успешно! На Вашем счету",balance,'р.')
    		if(s==2):
    			print("Сколько вы желаете снять со счета?")
    			sum=int(input('(Далее - Enter.)\n'))
    			if (sum>balance):
    				print('__________________________________________________________________________________________________________________')
    				print('__________________________________________________________________________________________________________________')
    				print("На счете недостаточно средств. Попробуйте ввести меньшее значение.")
    			else:
    				balance=balance-sum
    				print("Средства сняты со счета. Остаток:",balance,"р.")
    		if(s==3):
    			print('__________________________________________________________________________________________________________________')
    			print('__________________________________________________________________________________________________________________')
    			print('Вы вышли из аккаунта.') 
    			raise SystemExit
    		if(s==4):
    			print('__________________________________________________________________________________________________________________')
    			print('__________________________________________________________________________________________________________________')
    			print('На вашем счету',balance,'р.')
    if((log!= login)or(pas!= password)):
    	count=4
    	while ((log!=login)or(pas!=password)):
    		count=count-1
    		print("Неправильно введён логин или пароль. Осталось попыток входа:", count)
    		log=(input("Введите логин:\n"))
    		pas=(input("Введите пароль:\n"))	
    		if ((count < 2)and((log!=login)or(pas!=password))):
    			print('Вход заблокирован в связи с ошибкой при входе.')
    			break
    if ((log ==login)and(pas==password)):
    	
    	balance=0
    	print('__________________________________________________________________________________________________________________')
    	print('__________________________________________________________________________________________________________________')
    	print("Вход выполнен успешно! У вас на счету",balance,"р.")
    	while ((balance > -1)):
    		print('__________________________________________________________________________________________________________________')
    		print('__________________________________________________________________________________________________________________')
    		print('Введите 1, чтобы пополнить счет, 2, чтобы снять, 3, чтобы выйти из аккаунта, и 4, для того чтобы узнать состояние счета.')
    		s=int(input('(Далее - Enter.)\n'))
    		if(s==1):
    			sum=int(input("На сколько вы хотите пополнить счет?\n"))
    			balance=balance+sum
    			print("Операция проведена успешно! На Вашем счету",balance,'р.')
    		if(s==2):
    			print("Сколько вы желаете снять со счета?")
    			sum=int(input('(Далее - Enter.)\n'))
    			if (sum>balance):
    				print("На счете недостаточно средств. Попробуйте ввести меньшее значение.")
    			else:
    				balance=balance-sum
    				print("Средства сняты со счета. Остаток:",balance,"р.")
    		if(s==3):
    			print('__________________________________________________________________________________________________________________')
    			print('__________________________________________________________________________________________________________________')
    			print('Вы вышли из аккаунта.')
    			raise SystemExit
    		if(s==4):
    			print('__________________________________________________________________________________________________________________')
    			print('__________________________________________________________________________________________________________________')
    			print('На вашем счету',balance,'р.')

    govnokoder7, 18 Ноября 2020

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

    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
    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
    Fixpoint mint_add0 {N} (i k : Fin.t N) te_i te' t0 vec
                 (Ht : MInt nonCommRel N k vec (te' :: t0))
                 (Hik : k < i)
                 (Hcomm0 : trace_elems_commute te_i te')
                 {struct Ht} :
          exists t' : list TE,
              MInt nonCommRel N k (vec_append i te_i vec) (te' :: t') /\
              Permutation trace_elems_commute (te_i :: te' :: t0) (te' :: t').
        Proof with eauto.
          (* Welcome to the hell proof! *)
          remember (te' :: t0) as t_.
          destruct Ht as [k
                         |k j vec te_k t Hij Ht
                         |k j vec te_k te_j t Hij Hcomm Ht
                         ];
            [discriminate
            |replace te' with te_k in * by congruence; clear Heqt_..
            ].
          2:{ destruct (trace_elems_commute_dec te_i te_j).
              - apply mint_add0 with (te_i := te_i) (i := i) in Ht; [|lia|assumption].
                destruct Ht as [t' [Ht' Hperm']].
                exists (te_j :: t'). split.
                + swap_vec_append.
                  eapply mint_cons2...
                + apply permut_cons with (a := te_k) in Hperm'.
                  eapply permut_trans...
                  now apply permut_head'.
              - exists (te_i :: te_j :: t). split.
                + swap_vec_append.
                  apply mint_cons1 with (j0 := i); [lia|].
                  apply mint_cons2 with (j0 := j); [lia|auto..].
                + now apply permut_head'.
          }
          { inversion_ Ht.
            - exists [te_i]. split.
              + swap_vec_append.
                apply mint_cons1 with (j0 := i); [lia|].
                apply mint_cons1 with (j0 := i); [lia|].
                constructor.
              + now apply permut_head'.
            - rename te into te_j.
              destruct (PeanoNat.Nat.lt_ge_cases j i).
              2:{ exists (te_i :: te_j :: t1). split.
                  - swap_vec_append.
                    apply mint_cons1 with (j1 := i); [lia|].
                    apply mint_cons1 with (j1 := j); [lia|assumption].
                  - now apply permut_head'.
              }
              { destruct (trace_elems_commute_dec te_i te_j) as [Hte_ij|Hte_ij].
                - apply mint_add0 with (i := i) (te_i := te_i) in Ht; [|lia|assumption].
                  destruct Ht as [t' [Ht' Hperm']].
                  exists (te_j :: t'). split.
                  + swap_vec_append.
                    eapply mint_cons1...
                  + apply permut_cons with (a := te_k) in Hperm'.
                    now apply permut_head.
                - exists (te_i :: te_j :: t1). split.
                  + swap_vec_append.
                    apply mint_cons1 with (j1 := i); [lia|].
                    apply mint_cons2 with (j1 := j); [lia|assumption..].
                  + apply permut_head; [assumption|constructor].
              }
            - rename j0 into i0. cbn in H0.
              destruct (PeanoNat.Nat.lt_ge_cases j i).
              2:{ exists (te_i :: te_i0 :: te_j :: t1). split.
                  + swap_vec_append.
                    apply mint_cons1 with (j0 := i); [lia|].
                    apply mint_cons1 with (j0 := j); [lia|assumption].
                  + now apply permut_head'.
              }
              { destruct (trace_elems_commute_dec te_i te_i0).
                - apply mint_add0 with (i := i) (te_i := te_i) in Ht; [|lia|assumption].
                  destruct Ht as [t' [Ht' Hperm']].
                  exists (te_i0 :: t'). split.
                  + swap_vec_append.
                    eapply mint_cons1...
                  + apply permut_cons with (a := te_k) in Hperm'.
                    now apply permut_head.
                - exists (te_i :: te_i0 :: te_j :: t1). split.
                  + swap_vec_append.
                    apply mint_cons1 with (j0 := i); [lia|].
                    apply mint_cons2 with (j0 := j); [lia|assumption..].
                  + apply permut_head.
                    * assumption.
                    * constructor.
              }
          }
        Qed.

    Мой magnum opus. Часть доказательства про выкидывание из рассмотрения коммутирующих системных вызовов.

    CHayT, 17 Ноября 2020

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

    +1

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    DeliveryTruck t when t.GrossWeightClass switch
    {
        < 3000 => 10.00m - 2.00m,
        >= 3000 and <= 5000 => 10.00m,
        > 5000 => 10.00m + 5.00m,
    }

    С каждой новой версией C# всё меньше похож на C# и всё больше на Perl.

    Vindicar, 14 Ноября 2020

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