Hot answers tagged

9 votes

Custom asdict method for dataclasses

Don't type() == bytes; use isinstance. More broadly, though, bytes-to-hex conversion doesn't seem like it should be in this ...
Reinderien's user avatar
  • 60.8k
4 votes
Accepted

Optimized Python Solution for Determining if an Array Contains All Possibilities

As you've seen in many of the other solutions, it's pretty feasible to re-frame your original implementation as a generator, and this increases legibility. Add unit tests. I disregard your memory tag ...
Reinderien's user avatar
  • 60.8k
3 votes

Football team match result summary table

Layout Place the class right after the imports. Having the class between other lines of code disrupts the natural flow of the code. You should also add blank lines between the functions. Lint check I ...
toolic's user avatar
  • 1,406
3 votes

Optimized Python Solution for Determining if an Array Contains All Possibilities

A simple algorithm with runtime complexity of O(n) is: ...
Sudix's user avatar
  • 131
3 votes
Accepted

Parsing Java's class file

Your reference is extremely out-of-date; refer to version 21. Luckily the JVM hasn't changed much. Typer seems like overkill for a program that unconditionally accepts one command-line argument. I ...
Reinderien's user avatar
  • 60.8k
2 votes

Blackjack simulator for probability of a dealer bust for each starting card

The code has excellent layout, partitioning into functions, and you gave variables and functions meaningful names, for the most part. Naming Consider a better name for the ...
toolic's user avatar
  • 1,406
2 votes

Friendly probability puzzle solved with simulation

Your code is mostly well laid-out and clear. The only thing I'd suggest working on is naming, you use too many abbreviations and the duel method should have a verb ...
gazoh's user avatar
  • 3,179
2 votes

Euler integration of delay differential equation with circular buffer

Your integration method is not reusable; you need to make it reusable. The parameters are fairly easy to add and hint. For the integrand callable you can use a ...
Reinderien's user avatar
  • 60.8k
2 votes

Friendly probability puzzle solved with simulation

ŃOT AN ANSWER, just a comment: You do not need to solve 'infinite geometric series' once you enclose the geometric sequence into recursion. Case A. The first round, Aaron shoots. – If he hits ...
CiaPan's user avatar
  • 1,561
2 votes
Accepted

Trigger Cloud Function with Eventarc and then extract BigQuery table as csv files

Looks good. optional type annotation This would be a better signature: def move_data(table: str) -> None: It turns out we're really passing in a table name, ...
J_H's user avatar
  • 22.3k
2 votes

Optimized Python Solution for Determining if an Array Contains All Possibilities

This question is tagged memory-optimization. So upon being handed a vector of length N, we wish to compute a boolean with O(1) constant memory complexity, that is, ...
J_H's user avatar
  • 22.3k
2 votes

Optimized Python Solution for Determining if an Array Contains All Possibilities

n goes unused in the function. We can safely elide it. Since it is an array of integers, a type-hint would help the readers and linters: ...
Harith's user avatar
  • 4,115
1 vote

Football team match result summary table

These two lines: ...
Daniel Walker's user avatar
1 vote

Euler integration of delay differential equation with circular buffer

Documentation Add documentation to the top of your file to describe the purpose of your code. Naming Some of your variables have meaningful names, but others are not too descriptive. It is fine to ...
toolic's user avatar
  • 1,406
1 vote
Accepted

Friendly probability puzzle solved with simulation

Overall, it looks excellent: Good partitioning of code into class and functions Good layout and flow of the code Good naming of class, functions and variables Lint check (...
toolic's user avatar
  • 1,406
1 vote

Goal: Writing Effective Unit Tests to Ensure a Datetime Conversion To/From Local-UTC Works

Time and date is a deeply gnarly subject, but parsing and comparing can be fairly straighforward. Also note your above code is very slow because it re-initializes the 'tzf' object repeatedly. That ...
jmullee's user avatar
  • 161

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