diff --git a/lesson2.4_1.py b/lesson2.4_1.py new file mode 100644 index 0000000..593b698 --- /dev/null +++ b/lesson2.4_1.py @@ -0,0 +1,8 @@ +'''****** Задание ******** + *Таблица умножения. +''' +size = int(input()) +for row in range(1, size + 1): + for col in range(1, size + 1): + print(row * col, end=" ") + print() \ No newline at end of file diff --git a/lesson2.4_10.py b/lesson2.4_10.py new file mode 100644 index 0000000..5623038 --- /dev/null +++ b/lesson2.4_10.py @@ -0,0 +1,8 @@ +'''****** Задание ******** + *Мы делили апельсин. +''' +for a in range(1, (b := int(input())) - 1): + if a == 1: + print('А Б В') + for c in range(1, b - a): + print(f'{a} {c} {b - a - c}') \ No newline at end of file diff --git a/lesson2.4_11.py b/lesson2.4_11.py new file mode 100644 index 0000000..52f33c6 --- /dev/null +++ b/lesson2.4_11.py @@ -0,0 +1,17 @@ +'''****** Задание ******** + *Простая задача 3.0. +''' +count = 0 +for i in range(int(input())): + j = 2 + if (n := int(input())) > 1: + count += 1 + if n == 2: + count += 1 + while n % j: + if j > n ** 0.5: + break + j += 1 + else: + count -= 1 +print(count) \ No newline at end of file diff --git a/lesson2.4_12.py b/lesson2.4_12.py new file mode 100644 index 0000000..68a8722 --- /dev/null +++ b/lesson2.4_12.py @@ -0,0 +1,11 @@ +'''****** Задание ******** + *Числовой прямоугольник. +''' +m, n = int(input()), int(input()) +width = len(str(m * n)) +for i in range(1, m + 1): + for j in range(n * (i - 1) + 1, n * i + 1): + if j == n * i: + print(str(j).rjust(width, ' ')) + else: + print(str(j).rjust(width, ' '), end=' ') \ No newline at end of file diff --git a/lesson2.4_13.py b/lesson2.4_13.py new file mode 100644 index 0000000..40edbf0 --- /dev/null +++ b/lesson2.4_13.py @@ -0,0 +1,11 @@ +'''****** Задание ******** + *Числовой прямоугольник 2.0. +''' +m, n = int(input()), int(input()) +width = len(str(m * n)) +for i in range(1, m + 1): + for j in range(i, i + m * (n - 1) + 1, m): + if j == i + m * (n - 1): + print(str(j).rjust(width, ' ')) + else: + print(str(j).rjust(width, ' '), end=' ') \ No newline at end of file diff --git a/lesson2.4_14.py b/lesson2.4_14.py new file mode 100644 index 0000000..7851efc --- /dev/null +++ b/lesson2.4_14.py @@ -0,0 +1,18 @@ +'''****** Задание ******** + *Числовая змейка. +''' +m, n = int(input()), int(input()) +width = len(str(m * n)) +for i in range(1, m + 1): + if i % 2: + for j in range(n * (i - 1) + 1, n * i + 1): + if j == n * i: + print(str(j).rjust(width, ' ')) + else: + print(str(j).rjust(width, ' '), end=' ') + else: + for j in range(n * i, n * (i - 1), -1): + if j == n * (i - 1) + 1: + print(str(j).rjust(width, ' ')) + else: + print(str(j).rjust(width, ' '), end=' ') \ No newline at end of file diff --git a/lesson2.4_15.py b/lesson2.4_15.py new file mode 100644 index 0000000..7cdd296 --- /dev/null +++ b/lesson2.4_15.py @@ -0,0 +1,15 @@ +'''****** Задание ******** + *Числовая змейка 2.0. +''' +m, n = int(input()), int(input()) +width = len(str(m * n)) +for i in range(1, m + 1): + for j in range(n): + if not j % 2 and j != n - 1: + print(str(i + 2 * m * (j // 2)).rjust(width, ' '), end=' ') + elif not j % 2 and j == n - 1: + print(str(i + 2 * m * (j // 2)).rjust(width, ' ')) + elif j % 2 and j != n - 1: + print(str(2 * m * (j // 2 + 1) - (i - 1)).rjust(width, ' '), end=' ') + else: + print(str(2 * m * (j // 2 + 1) - (i - 1)).rjust(width, ' ')) \ No newline at end of file diff --git a/lesson2.4_16.py b/lesson2.4_16.py new file mode 100644 index 0000000..b5879b2 --- /dev/null +++ b/lesson2.4_16.py @@ -0,0 +1,12 @@ +'''****** Задание ******** + *Редизайн таблицы умножения. +''' +m, n = int(input()), int(input()) +for i in range(1, m + 1): + for j in range(1, m + 1): + if j != m: + print(f'{(str(i * j) + " " if n % 2 else str(i * j)).center(n)}|', end='') + else: + print(f'{(str(i * j) + " " if n % 2 else str(i * j)).center(n)}') + if i * j != m * m: + print(f'{"-"* ((n + 1) * m - 1)}') \ No newline at end of file diff --git a/lesson2.4_17.py b/lesson2.4_17.py new file mode 100644 index 0000000..2f21d45 --- /dev/null +++ b/lesson2.4_17.py @@ -0,0 +1,8 @@ +'''****** Задание ******** + *А роза упала на лапу Азора 3.0. +''' +count = 0 +for _ in range(int(input())): + if (n := input()) == n[::-1]: + count += 1 +print(count) \ No newline at end of file diff --git a/lesson2.4_18.py b/lesson2.4_18.py new file mode 100644 index 0000000..298250f --- /dev/null +++ b/lesson2.4_18.py @@ -0,0 +1,17 @@ +'''****** Задание ******** + *Новогоднее настроение 2.0. +''' +m, lengths = '', [0] +for j in range(1, (x := int(input())) + 1): + m += str(j) + ' ' + if j in (sum(range(i)) for i in range(j + 2)): + lengths.append(len(m) - 1) + m = '' +lengths.append(len(m) - 1) +n = 1 +for z in range(1, x + 1): + if z - 1 in (sum(range(i)) for i in range(z + 2)): + print(f"{' ' * ((max(lengths) - lengths[n]) // 2)}{z}", end=' ' if z != 1 else '\n') + n += 1 + else: + print(z, end='\n' if z in (sum(range(i)) for i in range(z + 2)) else ' ') \ No newline at end of file diff --git a/lesson2.4_19.py b/lesson2.4_19.py new file mode 100644 index 0000000..c86bde8 --- /dev/null +++ b/lesson2.4_19.py @@ -0,0 +1,9 @@ +'''****** Задание ******** + *Числовой квадрат. +''' +n = int(input()) +m = len(str((n + 1) // 2)) +for i in range(n): + for j in range(n): + print(f'{min(i + 1, j + 1, n - i, n - j):>{m}}', end=' ') + print() \ No newline at end of file diff --git a/lesson2.4_2.py b/lesson2.4_2.py new file mode 100644 index 0000000..2b37ea7 --- /dev/null +++ b/lesson2.4_2.py @@ -0,0 +1,7 @@ +'''****** Задание ******** + *Не таблица умножения. +''' +size = int(input()) +for second in range(1, size + 1): + for first in range(1, size + 1): + print(f'{first} * {second} = {first * second}') \ No newline at end of file diff --git a/lesson2.4_20.py b/lesson2.4_20.py new file mode 100644 index 0000000..2a24add --- /dev/null +++ b/lesson2.4_20.py @@ -0,0 +1,16 @@ +'''****** Задание ******** + *Математическая выгода. +''' +number = int(input()) +best_value = 0 +best_base = 0 +for base in range(10, 1, -1): + summa = 0 + num = number + while num > 0: + summa += (num % base) + num //= base + if summa >= best_value: + best_value = summa + best_base = base +print(best_base) \ No newline at end of file diff --git a/lesson2.4_3.py b/lesson2.4_3.py new file mode 100644 index 0000000..d5bb42f --- /dev/null +++ b/lesson2.4_3.py @@ -0,0 +1,14 @@ +'''****** Задание ******** + *Новогоднее настроение. +''' +count = int(input()) +num = 1 +row = 2 +print(num) +while num < count: + for i in range(1, row + 1): + if num + i <= count: + print(num + i, end=" ") + row += 1 + print() + num = num + row - 1 diff --git a/lesson2.4_4.py b/lesson2.4_4.py new file mode 100644 index 0000000..f4a7c9a --- /dev/null +++ b/lesson2.4_4.py @@ -0,0 +1,7 @@ +'''****** Задание ******** + *Суммарная сумма. +''' +summ = 0 +for _ in range(int(input())): + summ += sum(map(int, list(input()))) +print(summ) \ No newline at end of file diff --git a/lesson2.4_5.py b/lesson2.4_5.py new file mode 100644 index 0000000..10e5aa9 --- /dev/null +++ b/lesson2.4_5.py @@ -0,0 +1,12 @@ +'''****** Задание ******** + *Зайка — 5. +''' +counter, temp = 0, 0 +for _ in range(int(input())): + while (x := input()) != 'ВСЁ': + if x == 'зайка': + temp += 1 + if temp: + counter += 1 + temp = 0 +print(counter) \ No newline at end of file diff --git a/lesson2.4_6.py b/lesson2.4_6.py new file mode 100644 index 0000000..2ba3056 --- /dev/null +++ b/lesson2.4_6.py @@ -0,0 +1,9 @@ +'''****** Задание ******** + *НОД 2.0. +''' +n, a = int(input()), int(input()) +for _ in range(n - 1): + b = int(input()) + while b: + a, b = b, a % b +print(a) \ No newline at end of file diff --git a/lesson2.4_7.py b/lesson2.4_7.py new file mode 100644 index 0000000..620f3d9 --- /dev/null +++ b/lesson2.4_7.py @@ -0,0 +1,7 @@ +'''****** Задание ******** + *На старт! Внимание! Марш! +''' +for i in range(int(input())): + for j in range(3 + i, 0, -1): + print(f'До старта {j} секунд(ы)') + print(f'Старт {i + 1}!!!') \ No newline at end of file diff --git a/lesson2.4_8.py b/lesson2.4_8.py new file mode 100644 index 0000000..490ad29 --- /dev/null +++ b/lesson2.4_8.py @@ -0,0 +1,9 @@ +'''****** Задание ******** + *Максимальная сумма. +''' +name, summ = '', 0 +for _ in range(int(input())): + temp_name, temp_summ = input(), sum(map(int, input())) + if temp_summ >= summ: + name, summ = temp_name, temp_summ +print(name) \ No newline at end of file diff --git a/lesson2.4_9.py b/lesson2.4_9.py new file mode 100644 index 0000000..9aa5945 --- /dev/null +++ b/lesson2.4_9.py @@ -0,0 +1,7 @@ +'''****** Задание ******** + *Большое число. +''' +number = '' +for _ in range(int(input())): + number += max(input()) +print(number) \ No newline at end of file