Skip to content

Instantly share code, notes, and snippets.

View xmichael446's full-sized avatar

Michael xmichael446

View GitHub Profile
Apologies for the confusion earlier. Let's recalculate the quantities of the three products to ensure the total price is $500 and you can buy exactly 100 units.
Let's assume the quantities of Product A, Product B, and Product C are represented by variables x, y, and z, respectively. We need to find the values of x, y, and z that satisfy the following conditions:
1. x + y + z = 100 (total number of units)
2. 50x + 10y + z = 500 (total cost)
To solve these equations, we can use trial and error or employ a systematic approach. In this case, let's use a systematic approach:
Start with x = 0 and y = 0, and calculate z based on the second equation:
@xmichael446
xmichael446 / main.rs
Last active November 14, 2022 09:41
Fish simulation in rust
use std::{thread, time::Duration};
use std::fmt::Formatter;
use rand::Rng;
const INITIAL_FISH_AMOUNT: u32 = 20;
const LIFETIME_CONSTRAINTS: (u32, u32) = (10, 50);
#[derive(PartialEq, Clone)]
enum Gender {
#include <bits/stdc++.h>
using namespace std;
vector<long long> d(501, 0);
void rec(long long n, int k) {
for (int i = 1; i < 500; ++i) {
if (n % i == 0) {
if (d[i] == 0 || d[i] > n) {
d[i] = n;
import random
class Player:
def __init__(self, name):
self.name = name
self.score = 0
def guess(self):
return int(input(f"{self.name}, what is your guess? "))
@xmichael446
xmichael446 / keypad.py
Last active June 16, 2021 12:09
Unilecs Solutions
# Задача является эквивалентом декартового произведения
# Декартово произведение - произведение двух множеств:
# произведение множества хи множества Y это набор,
# содержащий все упорядоченные пары (x, y), для
# которых х принадлежит X, ау принадлежит Ү.
# Нам просто нужно расчитать декартово произведение для
# каждой набора букв каждого числа.
# Будем юзать динамическое программирование - храним мапу суммы элементов до текущего элемента.
# Два случая:
# 1. Либо подмассив с элементами от начала исходного массива до
# текущего элемента имеет сумму элементов равную К.
# 2. Либо существует более короткий подмассив (от некоторого
# среднего элемента) до этого элемента, и в этом случае разница
# между общей суммой до среднего элемента и общей суммой до этого элемента равна k.
from collections import defaultdict
bool isValid(vector<vector<int>>& matrix, int x, int y, int val) {
for (int j = 0; j < 9; j++) {
if (matrix[x][j] == val) return false;
}
for (int i = 0; i < 9; i++) {
if (matrix[i][y] == val) return false;
}
int smi = x / 3 * 3;
@xmichael446
xmichael446 / fish.py
Created September 20, 2020 17:24
Fish emulation
import random
import time
import names
import sqlite3
connection = sqlite3.connect('test.db')
cursor = connection.cursor()
class Fish:
def __init__(self, id, aquarium_id, name, dead, mother, father, lifetime, gender, age):
{
"products": [
{
"id": "A0",
"name": "arduino nano",
"price": 40,
"available": 10,
"short_info": "Arduino Nano - Arduino platalar oilasiga mansub bir kontroller. Atmega328p-u mikrokontrollerida, 8 yoki 16hz chastotada ishlaydi",
"entire_info": "https://website.org/arduino_nano",
"image_url": "https://user-images.githubusercontent.com/64916997/84414070-e6435e00-ac2a-11ea-97e2-da4d3b0cf81a.jpg"
@xmichael446
xmichael446 / bot.py
Last active June 20, 2020 12:21
Transformers Education Bot
import json
import logging
from aiogram import Bot, Dispatcher, executor, types
TOKEN = '1170507053:AAEV4pYWfIerISpthd2ULz9-_36SyeCkPi0'
logging.basicConfig(level=logging.INFO)
bot = Bot(token=TOKEN)
dp = Dispatcher(bot)