Skip to main content

New answers tagged

2votes

Slow SQL query with nested subquery

The inner select has a max to much. I think that is meant to do less time conversions, or such. But it clashes with group by. ...
Joop Eggen's user avatar
3votes
Accepted

Solution to the N Queens Puzzle in the PicoBlaze assembly language

Glad to learn that you got the correct result, but 3 hours is still a long time for this, I think. Luckily, there are lots of opportunities for optimizing this program. A lot of copying is going on ...
Sep Roland's user avatar
2votes

Simulation of a mechanical arm

1. Encapsulate your “nearest-neighbor” logic You repeat the same block of code six times: ...
Ahamad's user avatar
2votes

Finding Special Parts in a Word

In such code, one should look for rules, smart logic. Here we have sequences x² and xyⁿx. (As already said in an earlier answer, with n = 0 one covers the first sequence.) The logic here is detecting ...
Joop Eggen's user avatar
4votes

Finding Special Parts in a Word

...
TorbenPutkonen's user avatar
4votes

Finding Special Parts in a Word

The "length 2" rule is unnecessary, just ignore it and read the "length ≥ 3" rule as "length ≥ 2" instead. You can simplify your code accordingly, removing the ...
Robert's user avatar
-2votes

Finding Special Parts in a Word

To reduce time complexity, we can avoid redundant substring operations and take advantage of string patterns. This strategy aims to solve the problem efficiently, with a time complexity closer to O(n²)...
Somesh Diwan's user avatar
1vote

Butter side up?

When working with Mathematica, performance optimization is crucial for handling complex computations efficiently. One key improvement is using FindRoot instead of NSolve for numerical problems. ...
Unknown Enigma's user avatar
15votes
Accepted

CUDA Mandelbrot Kernel

Small issues Avoid doing calculations that the CPU can do. For example, let the CPU calculate scale_factor and pass it in as an argument. Then you also don't need <...
G. Sliepen's user avatar
1vote

Divide a set into subset with some constraints

Your implementation has extremely severe superlinear time blowup. Comparing your implementation to one I'll describe momentarily, here are some rudimentary benchmark comparisons: ...
Reinderien's user avatar
1vote

Divide a set into subset with some constraints

Here are some minor coding style suggestions. They are not likely to improve performance. Documentation Add a docstring for the min_count function to describe its ...
toolic's user avatar
  • 11.1k
2votes

Lotto simulator in Python

Documentation The PEP 8 style guide recommends adding docstrings for functions. You should also add a docstring to the top of the code to summarize its purpose. For example: ...
toolic's user avatar
  • 11.1k
3votes
Accepted

SIFT Keypoint Detection for Image in C++

Avoid repeating yourself Code duplication increases the maintenance burden and the chance of introducing bugs. Try to avoid it as much as possible. For exampe, in ...
G. Sliepen's user avatar
1vote

Simple chess engine

This is impossible to read: ...
Cris Luengo's user avatar
3votes

Simple chess engine

Constants Use underscore characters to make large numeric literals easier to read and understand. For example, change: 0xFF000000000000 to: ...
toolic's user avatar
  • 11.1k
2votes

Fibonacci Sequence Generator generates 1 million numbers

One of my big learning in programming was that the most elegant is not always the fastest. If you need to frequently calculate big Fibonacci numbers, the fastest way is probably to hard code some of ...
Máté Juhász's user avatar
1vote

Random forest code algorithm

Documentation The PEP 8 style guide recommends adding docstrings for files and functions. For example, for the data_load.py file, since "data" is a ...
toolic's user avatar
  • 11.1k
3votes
Accepted

LeetCode Number 416: Partition Equal Subset Sum

Performance Since your primary concern is mem/runtime, let's address this first. Your algorithm appears correct, but is missing one small optimization: laziness. You always traverse both branches to <...
STerliakov's user avatar
2votes

Binance.Net getting historical data from start date to end date loop optimization

Whale's Secret ScriptApiLib allows you to do get candlesticks without implementing it yourself. The library takes into accounts these implementation details like that the most you can get in one ...
MartyIX's user avatar
10votes

Fibonacci Sequence Generator generates 1 million numbers

Iteration variable The most obvious change is that the iteration variable itself doesn't need to be a BigInteger. A simple int, ...
Matthieu M.'s user avatar
10votes

Fibonacci Sequence Generator generates 1 million numbers

Caveat: I don't work with C# (or with its BigInteger facilities) meaning this "answer" is speculative, noting the use of 3 variables and several transfer operations during each of a million ...
Fe2O3's user avatar
  • 4,657
2votes

LeetCode Number 416: Partition Equal Subset Sum

The following only applies to your code (with the find method), not the dfs LeetCode example. I can not think of a way to ...
toolic's user avatar
  • 11.1k
5votes
Accepted

Julias Set fractal timelapse

Use a vector math library You can almost halve the number of lines of code if you use a vector math library. These allow you to avoid calculating x and y coordinates separately, and instead provide ...
G. Sliepen's user avatar
9votes

How to implement an AVL tree efficient enough in Haskell?

As I said in a comment, I can't verify that your program as written uses 40MB - your profiling data and my own runs of your program show 3MB, in the same range as the C++ performance you refer to. ...
amalloy's user avatar
3votes
Accepted

Efficiently simulating a control sequence

I really need to make it as fast as possible. Does anybody have any suggestions/tips/tricks to speed up this code? Make a test harness Form test code that rates the performance and precision ...
chux's user avatar
  • 35.7k
2votes

2D line-of-sight recalculation code causes lag whenever a door is opened

restartable calculation Together, this is 52ms, which means there is a visible lag of 4 frames whenever a door opens. Relax what the definition of "correct" is. Animate the door, gradually ...
J_H's user avatar
  • 38.9k
3votes

Store special deals, like 3 for 2

Note This question was posted 5+ years ago. Using Python 2 today is not recommended. However, it can still be reviewed. There are 2 major things here that stand out, the calculation and the printing ...
Mast's user avatar
  • 13.7k

Top 50 recent answers are included

close