This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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? ")) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Задача является эквивалентом декартового произведения | |
# Декартово произведение - произведение двух множеств: | |
# произведение множества хи множества Y это набор, | |
# содержащий все упорядоченные пары (x, y), для | |
# которых х принадлежит X, ау принадлежит Ү. | |
# Нам просто нужно расчитать декартово произведение для | |
# каждой набора букв каждого числа. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Будем юзать динамическое программирование - храним мапу суммы элементов до текущего элемента. | |
# Два случая: | |
# 1. Либо подмассив с элементами от начала исходного массива до | |
# текущего элемента имеет сумму элементов равную К. | |
# 2. Либо существует более короткий подмассив (от некоторого | |
# среднего элемента) до этого элемента, и в этом случае разница | |
# между общей суммой до среднего элемента и общей суммой до этого элемента равна k. | |
from collections import defaultdict |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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): |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"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" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) |