Skip to main content
The 2024 Developer Survey results are live! See the results
25 votes
Accepted

Remove points in a straight line

A look at the second plot in the post shows that something has gone wrong. There are four points in a line here: This shouldn't be possible, since "points that create a straight line when plotted" ...
Gareth Rees's user avatar
  • 49.6k
14 votes
Accepted

Sorting algorithm visualizer in C++ and SDL2

In all, this is a nice program. In particular, it compiled and ran (almost) flawlessly on Linux, so keep up the good work on portability! Here are some things that may help you improve your program. ...
Edward's user avatar
  • 66.5k
11 votes

Remove points in a straight line

You can use Ramer Douglas Peuker algorithm. RDP takes a curve and eliminates points that are close to straight lines. It is distance based. Starting with the two endpoints, it forms a line and picks ...
wooooooooosh's user avatar
10 votes
Accepted

Speech Recognition Part 1: Generate Training Data

I have to admit that I have no idea what the purpose of the code is (never worked with speech recognition) but I know a little bit Python so I can give some advise on the code itself. Performance ...
MSeifert's user avatar
  • 740
10 votes
Accepted

An ASCII histogram of a die rolled n times

The roll function generates a random sequence of integers. The loop body shows me that you know how to seed a pseudo-RNG with a true source of randomness but you're ...
Indiana Kernick's user avatar
9 votes
Accepted

Chart showing the Percentage of Answered CR questions

When I ran your script and started digging through the dom, I noticed that Apr 21 12:00 AM was missing -- I wonder why that was. Anyhow, I wanted to encourage ...
mickmackusa's user avatar
  • 8,674
9 votes

Reverse Engineering Data Files (Binary Visualization)

It seems the program overwrites pixels each time it processes a chunk this means wasting 2*MAP_SIZE*...
Pignotto's user avatar
  • 191
8 votes

Reverse Engineering Data Files (Binary Visualization)

I will be mostly focusing on performance. All benchmarks are done using the time commands on an 2018 MacBook Air (8GiB) using a 32MiB PDF file. I will be computing ...
Rish's user avatar
  • 2,361
7 votes
Accepted

Plotting polynomial roots with density

Keeping all else untouched, this gives a 1000x performance boost: ...
mvds's user avatar
  • 276
7 votes

Speech Recognition Part 1: Generate Training Data

PyAudio doesn't seem to have a with interface, however you should add that interface to your class. PEP 343 explains why it was added to Python, but it mostly comes ...
Peilonrayz's user avatar
  • 43.4k
7 votes
Accepted

Displaying programming languages on a timeline

First of all, congratulations, the result looks really good and that's a lot of work for an exercise! I particularly like how you frequently used standard algorithms. That is also quite a lot of code ...
papagaga's user avatar
  • 5,757
6 votes
Accepted

D3js: transition from stacked bar chart to bar chart with different datasets

Before dealing with the "enter", "update" and "exit" pattern, which is specific to D3, I'd like to address some general issues first. Do not mix jQuery and D3: this mix is normally unnecessary. Not ...
Gerardo Furtado's user avatar
6 votes
Accepted

Genetic Sequence Visualizer - Generating large images

Parser Your parser has a bug in line 62: raw = ''.join([n for n in file.readlines() if not n.startswith('>')]).replace('\n', "").lower() will ...
FirefoxMetzger's user avatar
6 votes

Query to plot a histogram of song ratings

It would be better to use GROUP by in your SQL. By this way you will get rid of long SQL query. ...
Unnamed's user avatar
  • 61
5 votes
Accepted

Drawing a regression line with a timeseries

You don't need dfc, dfc.sort_index() and dfc.sort_values(time_col_str) both make a copy of ...
Peilonrayz's user avatar
  • 43.4k
5 votes
Accepted

Reading and processing histograms stored in ROOT files

Given both the documentation of Python 3 contextlib or contextlib2, I’d say your usage is pretty standard for the tools at play. However, there is something bothering me a bit in your code: ...
301_Moved_Permanently's user avatar
5 votes
Accepted

Plotting an input curve and its FFT using gnuplot in C++

Firstly, does the program give correct results? If so, how do you know? Without going into extensive unit testing, checking your results against a Matlab prototype/your Python implementation is ...
ternonlerwen's user avatar
5 votes
Accepted

Showing two d3.js charts on the same page

I don't see anything wrong with the approach you're using, which is changing the variables' names and writing the code as a whole piece. The reason for that is simple: you have two fundamentally ...
Gerardo Furtado's user avatar
5 votes
Accepted

Predator-prey simulation

Shebang #!/opt/anaconda3/bin/python This is suspicious. Usually you should just #!/usr/bin/env python and make sure that ...
Reinderien's user avatar
  • 62.8k
5 votes
Accepted

Draw a 2d graph using slashes

Some simple things: top and length could probably have better names (Top of what? Length of what?), maybe ...
JeffUK's user avatar
  • 273
5 votes

Compute and plot a 2D vector field with radial symmetry in Python

Is there a suitable plotting function allowing to avoid to compute and store the two potentially large arrays u and v, and ...
tdy's user avatar
  • 1,824
5 votes

Reverse Engineering Data Files (Binary Visualization)

Very interesting approach to create a pattern for reverse engineering. I remember a similar plot (3D actually) done to the timespan between two heartbeats. The normal plot looked like a cigar-shaped ...
uli's user avatar
  • 1,705
4 votes

Data Explorer query that makes bar graphs

I'll answer your main questions: Can I refactor it so that the list of when like then statements occurs only once? (Preferably without complicating the code too much.) Yes, but not at the expense of ...
rene's user avatar
  • 305
4 votes

Git Insert Delete Graph

Overview It is great that you: Used strict and warnings Leveraged other people's code by using the CPAN modules Used comments ...
toolic's user avatar
  • 4,012
4 votes

Plotting polynomial roots with density

Use what C++ provides If you use the C++ versions of the headers: ...
Toby Speight's user avatar
  • 77.3k
4 votes

Remove points in a straight line

This is not really a code review, but an alternative approach to solving your problem. I did my doctoral thesis on bicriterion fitting of polylines to noisy data series. The two criteria are the ...
Ben Voigt's user avatar
  • 852
4 votes
Accepted

Python genetic sequence visualizer

You should make your array class behave a bit more like a Python list. It would be nice if there was a nice representation of it, if you could ...
Graipher's user avatar
  • 41k
4 votes

Plotting a GPS track

Don’t write using namespace std;. You can, however, in a CPP file (not H file) or inside a function put individual ...
JDługosz's user avatar
  • 11.4k
4 votes
Accepted

This is a sorting algorithm visualization program

Welcome to CodeReview, your program is advanced for high school. I have some suggestions for you: private int delay = GUIComponents.delaySlider.getValue() * 1000; ...
dariosicily's user avatar
  • 3,971

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