Hot answers tagged

6 votes

Implementing a --assume-yes/--assume-no command line flag to affect a `input()` based `confirm()` function

Of the three approaches, the first seems best to me. We can do a little better by giving names to the the "assume" versions of the function, and include them in ...
Toby Speight's user avatar
5 votes

Implementing a --assume-yes/--assume-no command line flag to affect a `input()` based `confirm()` function

Don't assign to args within the __main__ guard - it's still global; it needs to be moved to a function. ...
Reinderien's user avatar
  • 58.1k
4 votes

Increment a large integer represented as array of digits

PEP 20 – The Zen of Python To write Pythonic code, I think PEP 20 – The Zen of Python is the great place to start. I think the posted code doesn't do great with respect to these points: Beautiful is ...
janos's user avatar
  • 111k
2 votes

Expirable LRU cache

name A lru_cache with expiry, nice! I like the requirements. Calling it LRUCache seems to invite confusion with the well-known functools decorator, at least during ...
J_H's user avatar
  • 13.8k
1 vote

Find all combinations of two companies grouped by the projects they are tendering for

What are the options to optimize the code You wrote ... for item in items ... dataframe['tender_product'] == item ... and complained that ...
J_H's user avatar
  • 13.8k
1 vote

Implementing a --assume-yes/--assume-no command line flag to affect a `input()` based `confirm()` function

An online search for "python configuration management" will return a slew of libraries and articles proposing solutions related to this topic. Which suggests there isn't a single answer that ...
RootTwo's user avatar
  • 9,825
1 vote

Given a list of digits, construct the largest number divisible by 3

The original solution and the proposed solutions include a step of sorting the list of digits. So technically, they are O(n log n), but the list is at most 9 digits long, so the difference may not be ...
RootTwo's user avatar
  • 9,825
1 vote

Leetcode: 2327. Number of People Aware of a Secret

Your approach may be less efficient due to a recursive design that doesn't account for overlapping subproblems effectively, leading to suboptimal runtime and memory usage. The iterative solution ...
suchislife's user avatar
1 vote

Highly flexible tic-tac-toe terminal game in python

Overall the code is organized well and easy to follow. Here are my main points of feedback: board.py For the coords: tuple ...
Setris's user avatar
  • 1,458

Only top scored, non community-wiki answers of a minimum length are eligible