Skip to content

Initial course version#1

Merged
Polina (polinak1r) merged 9 commits into
mainfrom
polina/initial_version_v2
May 22, 2026
Merged

Initial course version#1
Polina (polinak1r) merged 9 commits into
mainfrom
polina/initial_version_v2

Conversation

@polinak1r

Copy link
Copy Markdown
Contributor

This PR contains a first complete version of the course with a brief introduction.

  • All tasks have been added and are now present in the course structure
  • All placeholders have been filled in and checked for correctness
  • Both unit tests and hidden tests run correctly for all tasks

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Perhaps these comments apply to other tasks as well.
Roman Kovalev (@KovalevRoma) pay attention to it too

@@ -0,0 +1,33 @@
def points_cover_naive(starts, ends, points):

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

from bisect import bisect_left, bisect_right
from sys import stdin

Imports are missing



if __name__ == '__main__':
data = list(map(int, stdin.read().split()))

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Am I correct in understanding that stdin.read() will keep reading as long as there is data to read, and if I run this in an IDE (click run button) and enter data manually, the input will never finish?

@@ -0,0 +1,44 @@
def partition3_naive(values):
for c in product(range(3), repeat=len(values)):

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

NameError: name 'product' is not defined

Comment thread L03/T04/lcm.py

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Traceback (most recent call last):
  File "/Users/Konstantin.Chaika/PycharmProjects/algorithmic-toolbox-python/L03/T04/tests/tests.py", line 12, in test_random_pairs
    self.assertEqual(a * b // math.gcd(a, b), lcm(a, b), msg=f"Wrong answer for a={a}, b={b}")
                                              ^^^^^^^^^
  File "/Users/Konstantin.Chaika/PycharmProjects/algorithmic-toolbox-python/L03/T04/lcm.py", line 12, in lcm
    assert 1 <= a <= 2 * 10 ** 9 and 1 <= b <= 2 * 10 ** 9
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
AssertionError

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

image

@kochaika Konstantin Chaika (kochaika) Apr 22, 2026

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe assert inside the lcm function is not a thing we should use here
Or at least do not call it from tests with invalid inputs

@KovalevRoma

Copy link
Copy Markdown

Environment

  • OS: Windows 11 / Ubuntu 22.04
  • IDE: PyCharm 2026.1.1
  • Python 3.10, Python 3.13

Issues

1. Overall potential issue:

In all tasks, the algorithmic complexity is not actually being tested. As a result, naive solutions pass all tests. This should be fixed. This is especially important for tasks where asymptotic optimization is explicitly required: L05/T02, L05/T04.

2. L02/T02 (Maximum Pairwise Product)

  • The task title appears twice in the description.
  • The solution in the course differs from the one in solution:
    • solution uses an O(n log n) approach (sorting)
    • the original solution works in O(n):
      a = 0
      b = 0
      for i in range(len(numbers)):
          if numbers[i] > a:
              b = a
              a = numbers[i]
          elif numbers[i] > b:
              b = numbers[i]
      return a * b
  • This does not affect correctness for small inputs, but there are no large tests where the difference is noticeable. When a student opens "peek solution", this inconsistency may be confusing.

3. L03/T01 (Fibonacci Number)

  • The task title is duplicated in the description.

4. L04/T03 (Maximum Value of the Loot)

  • The task title is duplicated in the description.

Notes:

L03/T02 (Last Digit of Fibonacci Number)

  • The peek solution is not optimal in terms of memory usage.
  • It would be better to adapt the solution from L03/T01 using O(1) memory:
    previous, current = current, (previous + current) % 10
  • Since this is an algorithms course, the peek solution should demonstrate an optimal approach.

Comment thread L04/T03/task.md Outdated

After entering the input, send EOF:
- `Ctrl + Z`, then `Enter` for **Windows**
- `Ctrl + D` for **macOS** or **Linux**

@kochaika Konstantin Chaika (kochaika) May 4, 2026

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ctrl + D does not work on MacOS when app is run inside the IDE. With green triangle button click
But it do work in the terminal

When app is run inside the IDE Cmd + D works...
¯\_(ツ)_/¯

Comment thread course-info.yaml Outdated
Comment on lines +10 to +13
vendor:
name: JetBrains
email: support@jetbrains.com
url: https://www.jetbrains.com/

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Need to be removed: Sasha will publish it from his own vendor!

@polinak1r Polina (polinak1r) merged commit 5a931f2 into main May 22, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants