New answers tagged

3 votes

Looking for feedback on a flavour of Radix tree I wrote. This is version 2 of the class original posted on this forum

That's a lot of code! This kind of large code review whould probably include tests to prove that it is working correctly. The complexity here is large enough that I can not spot that kind of thing ...
Martin York's user avatar
2 votes

Creating random music covers using Conways Game of Life algorithm

Advice I - Add missing main(String[]) I suggest you add public static void main(String[] args) { new Cover(); } Advice II - ...
coderodde's user avatar
  • 28.1k
2 votes

Sorting the divisors of a given number

There are a couple of optimisations you can make to your code: Rather than initialise divisors to [1], and then dealing with ...
Nick's user avatar
  • 156
2 votes

Scraping website with Python and Selenium to collect data from dynamic website

Be judicious with the use of comments: # create console handler and set level to info ch = logging.StreamHandler() ch.setLevel(logging.WARNING) This one claims ...
Harith's user avatar
  • 5,657
1 vote

Simple TCP port scanner

If you want to scan thousands of ports per second it must be done using UDP packets instead of TCP, as UDP packets do not need to wait for confirmation that the packet was delivered successfully or ...
Amrita Bithi's user avatar
6 votes
Accepted

Leetcode: Largest Number

Let's pretend that the purpose of LeetCode is to train for the real world. In the real world, you wouldn't call this class Solution; you would want to write your ...
Reinderien's user avatar
10 votes

Simple TCP port scanner

From atoi()'s man page: BUGS errno is not set on error so there is no way to distinguish between 0 as an error and as the ...
Harith's user avatar
  • 5,657
8 votes
Accepted

Simple TCP port scanner

Skipping blocked ports quickly It is possible to reduce the timeout for connect() when trying to connect to unresponsive ports, by setting the ...
G. Sliepen's user avatar
  • 55.5k
2 votes
Accepted

Simple version of NEAT

General thoughts The code is scattered all around the place, which makes reasoning about a bit tedious. Consider placing several classes into a single module, I would suggest one for base network-...
301_Moved_Permanently's user avatar
5 votes
Accepted

Multithreading message queue system

Use wait() with a predicate I recommend that you always pass a predicate to wait() that checks whether the condition you are ...
G. Sliepen's user avatar
  • 55.5k
1 vote

Highly nested bioinformatics processing

In addition to the advice from the other answer, here are some adjustments for you to consider, mainly for coding style. All Perl code should include these lines at the top of the file: ...
toolic's user avatar
  • 3,151
3 votes

Multi Threaded High Performance txt file parsing

One performance idea: Do not use branching (if possible by any trick). It is possible to parse text without branching. Have a look at 1BRC (java code base for inspiration, but there is also C, rust, .....
LvargaDS's user avatar
4 votes

Video transcoding using ffmpeg

Prefer to pass around modern Path over str. Prefer the modern ...
J_H's user avatar
  • 25k
5 votes

Simple version of NEAT

Avoid unnecessary loops/comprehensions Replace this loop: # for i in range(len(inputs)): # self.inputs[i] = inputs[i] with an O(1) assignment: ...
tdy's user avatar
  • 845
0 votes
Accepted

Improving efficiency of database searches under SQLite (SpatiaLite - QGIS)

It took me some time because I had to reassess my approach and revisit my project from the ground up. Additionally, I had to overhaul the databases, which involved revising all the code for database ...
Giene's user avatar
  • 149
3 votes

This is a simple stopwatch cli application with a few options

This looks silly at first: #define ONE_MILLION_NSEC 1000000 #define ONE_BILLION_NSEC 1000000000 But considering that you cannot yet write 1'000'000 in C, this will ...
Cris Luengo's user avatar
  • 5,573
6 votes
Accepted

This is a simple stopwatch cli application with a few options

Check the return value of library functions From the man page: signal() returns the previous value of the signal handler. On failure, it returns SIG_ERR, and errno is set to indicate the error. ...
Harith's user avatar
  • 5,657
3 votes

Creating an O(n) algorithm for an array of integers

This can be solved in O(n) by maintaining a monotonic stack of heights of previous buildings. For each new building, remove all elements from the stack with height not greater than the current element....
Unmitigated's user avatar
2 votes

Creating an O(n) algorithm for an array of integers

My approach, n log n: ...
RippedGeek's user avatar
5 votes

Creating an O(n) algorithm for an array of integers

lint def valid_jumps(N: ... Pep-8 asks that you spell the parameter name in this way: n The problem statement suggested ...
J_H's user avatar
  • 25k
4 votes

Creating an O(n) algorithm for an array of integers

The code layout is good. It is clear from the code that the function accepts a list of integers and returns a list of integers. However, you should add a docstring describing more details about the ...
toolic's user avatar
  • 3,151
2 votes

Get specific lines from a huge text file

In addition to the comments on the question and the other answer, here are some other adjustments for you to consider, mainly for coding style. You could format your header comments as plain old ...
toolic's user avatar
  • 3,151
3 votes

Longest spell to cast from pages of spellbook follow-up

Naming Most of your names are descriptive enough, but I can't, for the life of me, figure out what og stand for… pages or ...
301_Moved_Permanently's user avatar

Top 50 recent answers are included