Tagged Questions
Performance is a subset of Optimization: performance is the goal when you want the execution time of your program or routine to be optimal.
3
votes
0answers
31 views
Josephus permutation
This problem is taken from the book Introduction to Algorithms, Third Edition
By Thomas H. Cormen, Charles E. Leiserson, Ronald L. Rivest and Clifford Stein:
We define the Josephus problem as ...
4
votes
0answers
29 views
Shortest path navigation across a grid using Best First Search
The code below is an implementation of the Best First Search algorithm for navigation of the shortest path across a 2D NxN matrix. As a heuristic for the search I use the standard distance formula. ...
-8
votes
0answers
28 views
What are the Possible Flaws in my Program and Suggestion For Optimization [on hold]
Here is my code, It's Java Script,
...
3
votes
1answer
39 views
Portably generate uniformly random floats from mt19937 output
My goal is to generate a sequence of random float from a seeded random generator. The sequence should be the same on any machine / any compiler -- this rules out ...
3
votes
5answers
108 views
-4
votes
0answers
32 views
Loading a huge number of images in the View [on hold]
I have to just load huge number(1 million) of images in a view.
My app is fetching the images from api call using background jobs but my app is getting very slower when I load the view it is taking ...
2
votes
1answer
44 views
Querying the Google ads API
I have a method which relies heavily on object supplied by third party APIs. Below is my working code, is there any scope of improvement?
...
5
votes
0answers
36 views
Copy files mentioned in an Excel sheet
Please help me in reducing the time complexity of this code as it is taking a long time to read its Excel input.
...
2
votes
1answer
50 views
Printing longest sequence of zeroes
I am doing a coding exercise in codility and I came across this question:
A binary gap within a positive integer N is any maximal sequence of
consecutive zeros that is surrounded by ones at both ...
2
votes
2answers
90 views
Functions to merge dictionaries with a comparison
I have several functions for merging some dictionaries but over time I created a more general function that would make all these others obsolete if it weren't slower.
I have the specialized (and ...
0
votes
0answers
31 views
Permuted index generator (second version)
I have implemented a second program that produces a permuted index; here is my first solution.
As advised in one of the answers, I split my program into two classes.
Could anyone tell me if I did ...
3
votes
3answers
337 views
Optimizing timeline generation
I have a bunch of processes that are being executed on different virtual machines. All of those processes have a StartDate, ...
5
votes
3answers
141 views
Nondeduplicating mutual membership testing
Python sets are magical things. Mutable, deduplicating data stores with handy operator overloads for &, ...
6
votes
2answers
76 views
Recursive directory copy program
A little while ago, I had to write a little C# application to recover my HDD data (full context on this question)
To answer my problem I developed a console application which job was to recursively ...
4
votes
3answers
197 views
Using Enum to Handle String literals
I have a java component that was using a lot of string literals that I need to make comparisons on and return booleans based on these comparisons.
In order to make the code more robust I externalized ...
-1
votes
1answer
22 views
Managing game entity data [on hold]
I am making a 3D game and I'm focused on performance.
I'm making a entity class.
...
2
votes
1answer
51 views
196-Algorithm Program
Attempting to see whether using 196 as a respectively in my program will have a result or not, I made a simple function to test it. Now the 196-Algorithm requires ...
1
vote
0answers
33 views
Progressively split and map a large, line-based string
Goal
I have a large string (~10MB in ~400k lines). I want to "efficiently" split it on a delimiter and map the resulting sets of lines. Efficiently is defined as something that is fast (wall time), ...
0
votes
0answers
22 views
Checking if a 3D point is outside of a trapezoid
I have recently written if a 3D point is within a specified trapezoid. It does it by checking 3 different planes of the trapezoid. I place the relevant 2 coordinates from the 3D point into the current ...
6
votes
3answers
308 views
Rotation of elements in an array
We had to write a program that would perform rotation of elements in an array. The array size was entered by user, so it had to be in a sense, dynamic.
Rotation or Circular Shifting
Initial Array: ...
2
votes
1answer
26 views
Optimize performance of flatten function in python
I have to flatten a large number (>300k) dicts to write them to a csv file.
Example:
...
2
votes
2answers
42 views
Java web scraping robots
I am developing application that goes through 2 websites and gets all the articles, but my code is identical in most parts, is there a way to optimize this code actually :/ (TL and DN are the naming ...
4
votes
2answers
111 views
Counting primes less than n
The following code was written to be a submission to this challenge on PPCG.
It uses this algorithm, the Meissal-Lehmer method. I follow the Wikipedia entry pretty naively, except I tried to memoize ...
3
votes
1answer
39 views
SICP - exercise 1.11 - tree recursion
From SICP
Exercise 1.11: A function \$f\$ is defined by the rule that:
\$f(n) = n\$ if \$n < 3\$, and
\$f(n) = f(n-1)+2f(n-2)+3f(n-3)\$ if \$n >= 3\$.
Write a procedure ...
14
votes
4answers
538 views
Generating formatted multiplication tables in C++
I am self studying C++ from Robert Lafore's OOP in C++. I am solving the first exercise questions of chapter-3 loop and decisions. I've written three different codes using different approaches. I want ...
4
votes
3answers
68 views
Extracting sleep quality scores from periodic readings
How can I optimize the next function to work faster? The function must prepare a list to put in a CSV file. The list must contain values of average percentage of sleep per minute counted from ...
5
votes
2answers
74 views
Document term matrix in Clojure
This is my very first foray into Clojure (I'm normally a Python-pushing data-type). I'm trying to create a simple term-document matrix as a vector of vectors, out of a vector of strings.
For those ...
3
votes
0answers
32 views
Median filter for large mask
I'm trying to implement the fast median filter developed by T.S.Huang (HUANG, T.S. 1981. Two-Dimensional Signal Processing II: Transforms
and Median Filters. Berlin: Springer-Verlag, pp. 209-211.).
...
1
vote
0answers
33 views
Update method using timer in WinForms Poker app
I have a WinForms Poker app that needs to update some stuff and im doing this by using a timer:
...
2
votes
1answer
75 views
Poker app in C#
I am developing a poker application using C#. It is almost done, and I'm looking for improvements. One of the things I wonder is whether I should change my method that checks if the player has a ...
3
votes
1answer
62 views
Python 4 Players Snake Game
I would really like to hear out some suggestions as well as general response to the code I've written for 4 players snake game. It's my first time using pygame module, as well as trying to design a ...
4
votes
2answers
51 views
1D shock tube problem written in Fortran
I have written a simple Euler solver for the 1D shock tube problem. Eventually, I plan to extend this code to solve the full 3D compressible Navier-Stokes equations. Therefore, I want to start with ...
6
votes
4answers
819 views
4
votes
2answers
41 views
Storing disassembled data in a structured way
I want to store the information returned by the dis function of the dis module in a structured way, using a dict, associating the mnemonics of each code of a line to the correspondent line number.
...
2
votes
2answers
79 views
My spaceship is slow to explode after being hit by the asteroid
I am making a game for my computer science class. My professor's requirements are:
Write a Processing program that draws a triangle in the middle of the window.
Rotate the triangle when the left and ...
3
votes
2answers
345 views
Web dashboard using many REST API requests
I have created REST API in codeigniter. REST sever created in codeigniter 3.0 and REST client created codeigniter 2.x.x.
I have wrote simple code for login. After login client created dashboard ...
1
vote
2answers
68 views
Concatenate three 16-bit integers in one 64-bit integer with C++
I am looking for an elegant alternative of the following code where wordXX contains always 16 bits:
...
5
votes
2answers
364 views
Beginner word-guessing game
I have the following code.
Aim is to guess a four letter string. Each letter can be tried four times. If the letter cannot be guessed, we go to the next letter until the fourth letter is reached.
I ...
3
votes
1answer
100 views
Joining huge CSV files and splitting the result into batches
I've got ~20GB of data about the same subject, concatenated from small files of 16kB, each produced by different measurement equipment. They share some headers (on the example: B, D & E) and they ...
3
votes
1answer
46 views
Multiplying square matrix with C pthreads (POSIX threads)
I'm a student, and I'm trying to make the product of two square matrix with some threads in the soup. I've already worked on some fast single-threaded product (with some cache-friendly tricks), and ...
1
vote
1answer
70 views
Reading input fast in Java for competitive programming
I have been solving problems on Timus Online Judge. In the beginning, I didn't worry much about I/O operations, so I just took some code from the internet and focused more on the logic. But after ...
4
votes
1answer
68 views
Looping through Files in a Folder
I have this simple looping macro, but I can't seem how to figure out how to make it run faster. I tried including more update = false statements as well as well as ...
6
votes
3answers
181 views
Base converting with strings from bases 1 to 36 to bases 1 to 36
I'm writing a fastest-code challenge over at PPCG relating to base conversion of bases 1 to 36, and as a part of the process for writing the competition, I decided to write my own program for it. This ...
2
votes
2answers
171 views
+50
Parsing JSON in one go
I need to parse a simple JSON string (flat JSON, no hierarchy) for keys and values, and there is a system constraint that I cannot use any built-in JSON library and can only read a string once due to ...
3
votes
2answers
49 views
Optimzation removeClass() and addClass()
I am trying to simplify and optimize these line of codes.
This is a jQuery function controls a <div> to expand up or expand down.
This is my coding ...
4
votes
1answer
42 views
Construct binary tree from inorder and postorder traversal
The problem is taken from here. The tree is guaranteed not to have duplicate elements.
My questions is, instead of creating new arrays leftInOrder, ...
5
votes
1answer
94 views
How to lose plants and aggravate people
Courtesy of a few posts around here I've discovered HackerRank. Poisonous Plants is one of their challenges.
Of course, skip the following if you'd like to try it yourself.
Challenge:
There are ...
-1
votes
1answer
54 views
Operations on a vector
I have the following class which is used for operations on a vector. The vector stores the following struct which has 3 enums and 1 boolean.
Info represents a computer node. Nodes communicate with ...
1
vote
1answer
50 views
Transforming a list into a dictionary
I have a simple list and want to filter it by a specific key. But I guess my for loop solution is not an efficient way. I'm searching an other way or one best practice.
...
1
vote
0answers
47 views
Vectorising orthogonal-triangular decomposition for 3D matrix
I am trying to optimise the computation time of my code (for the second time after a first optimisation that gives very good results). Currently, this code is very time-consuming depending on the size ...