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
1answer
32 views
Sieve of Eratosthenes Primes Efficiency
I'm fairly new to Java and was trying to make a program thats generates the primes from 2 - 100. I originally had a design of my own making but it was fairly inefficient so I did some research and ...
4
votes
2answers
39 views
Two string comparison
I wrote a function that finds the difference between two strings. This only works given that the difference is continuous.
Beyond doubt this already exists, I am recreating this for educational ...
1
vote
1answer
46 views
3
votes
1answer
40 views
Alternating Direction Method of Multipliers
This is a python implementation of the Alternating Direction Method of Multipliers - a method of constrained optimisation that is used widely in statistics (http://stanford.edu/~boyd/admm.html).
...
1
vote
2answers
59 views
Solving for equilibrium index in an array
I did a sample on Codility and finished the test task.
The problem description is very short:
The equilibrium index of a sequence is an index such that the sum of elements at lower indexes is ...
1
vote
1answer
59 views
Determining if two strings are anagrams
Two strings are said to be anagrams of each other if the letters of
one string may be rearranged to make the other string. For example,
the words 'elvis' and 'lives' are anagrams.
In this ...
1
vote
1answer
28 views
Scraping and using JSON data from thousands of files in a directory
I have a few thousand json files containing order histories sitting in a directory from one of our systems. Since customers can opt in to receive marketing I'm opening each json file and then ...
2
votes
2answers
39 views
Iterate over large amount of words in Python
I wrote a program that should check a dictionary that contains about 50000 other dictionaries. In those dictionaries, one of the keys has a list of words as value. Now, I iterate over those words, ...
4
votes
2answers
31 views
Speeding Up BufferedWriter
Are there any possible speed improvements I can make to the following method. It takes a JDBC ResultSet and breaks it into several CSV files:
...
4
votes
1answer
19 views
DuckyScript precompiler for Arduino Leonardo
I've made a python program to convert DuckyScript code to Arduino code for Leonardo boards. Below you can find both the project files and a sample script.
...
2
votes
2answers
47 views
Mnenomic Password Generator
I have this code that creates unique passwords using the first letter of each word from the file. Before each password is created (written to a file) it is compared to all passwords that are currently ...
1
vote
0answers
25 views
Downloading html documents from the web takes too much time
In this project i'm working on, I need to extract articles text from their original html document. This class, HtmlConnection, recieves the URL of the article, and ...
2
votes
3answers
165 views
Remove repetitive strings from a given sentence efficiently
I recently gave a test on HackerRank:
Given a string, return the most concise string that can be formed from it.
For example:
...
2
votes
3answers
57 views
Creating a tuple from a CSV file
I have written code that reads in a CSV file and creates a tuple from all the items in a group. The group ID is in column 1 of the table and the item name is in column 2. The actual datafile is ~500M ...
2
votes
1answer
43 views
Optimize program to test for divisibility of numbers 3.0
This is a follow up on my previous question.
JS1's answer suggested that I should use a precomputed table containing all permutations of the lowest valid number for each number between 1 and MAX. It ...
3
votes
1answer
44 views
Finding most common contiguous sub-lists in an array of lists
Objective: Given a set of sequences ( eg: step1->step2->step3, step1->step3->step5) ) arranged in an array of lists, count the number of times every contiguous sub-lists occur
Where I need your help:
...
4
votes
1answer
81 views
Read Twitter users from a text file
I have this code for reading Twitter users from a text file represented by integers in the format "int (space) int", where the first int is the ID of
the user doing ...
3
votes
1answer
58 views
Testing for divisibility of numbers - follow-up
(Here is the follow up question)
I had another go at trying to speed up my program described in my previous question.
JS1's answer was particulary helpful and now my code is only about 20% slower ...
2
votes
3answers
72 views
List comprehension method
I have developed some Python code which revolves around two custom classes - a 'Library' class (Lib) which contains a Python list of several objects based on a 'Cas' class. I've not posted the code ...
0
votes
1answer
49 views
Simple neural-network simulation in C++ (Round 3)
As I mentioned at the end of my Round 2 answer, I've needed to expand my code in order to produce faithfully the data needed for Figure 1 of this paper.
Unfortunately, the updates have made my script ...
2
votes
2answers
422 views
Efficient algorithm for counting frequency of a numbers in intervals
I need to build a bar graph that illustrate a distribution of pseudorandom numbers that determined by linear congruential method
$$X_n+1 = (a X_n + c) \mod m$$
$$U = X/m$$
on the interval [0,1]
...
2
votes
1answer
64 views
Inversion count via divide and conquer
I'm happy to hear thoughts and ideas on structure/performance/testing/whatever and multi-threading, which I haven't gotten into yet with Python.
Full code here. Assignment file and a test file ...
2
votes
1answer
30 views
node.js CPU issue
Me and my friend are making a node.js game, and we have been testing cpu, but after profiling this process called zlib is sucking most of the CPU/RAM
3 clients connected to a game is fine, but when ...
6
votes
1answer
66 views
Simple Multi-Dimensional Array Class in C++11
The following code implements a simple multi-dimensional array class (hyper_array::array).
I modeled most (if not all) the feature on the ...
5
votes
2answers
113 views
Find the next prime number — flow control of nested `for` loops
This code works perfectly, but it bothers me. Having a labeled, nested for loop, with a true condition, a ...
3
votes
1answer
61 views
Using LINQ to perform a LEFT OUTER JOIN in 2 DataTables (Multiples criteria)
I know that exists a lot of solutions about how to create an OUTER JOIN between two DataTables.
I created the following code in ...
8
votes
4answers
384 views
Simple GCD utility in Java
I previously discussed the performance concerns about different GCD algorithms. I wrote a simple Java class that implements the Binary GCD algorithm. It is a really tiny class that has only two ...
3
votes
1answer
112 views
Simple neural-network simulation in C++ (Round 2)
Intro
Yesterday I posted this question. Since then, I've updated my code to incorporate these suggestions. I've also removed the dependence on C++11. Finally, I've made the following changes that ...
-3
votes
0answers
30 views
optimize python3 code in competitive programming [closed]
the following codes from python3 and C++ do the same job
...
2
votes
0answers
52 views
JavaScript library for material design toasts (notifications)
This question is a follow-up question to this one.
I wrote a small JavaScript library for material design toasts (notifications). I'd like to know what are my mistakes and how can I correct them? ...
2
votes
1answer
35 views
4
votes
1answer
42 views
Find values in list which sum to a given value within tolerance
This is really a follow on from a question I asked earlier this year on Stack Overflow. I received a great answer to the following problem:
I'm trying to code up something simple and pythonic to ...
3
votes
1answer
44 views
Grouping two sets of data
The following method retrieves a list of users and the subscriptions for each user, from my database. That said, it works, but it runs pretty dang slow. I'd like to improve the speed on it. Currently, ...
2
votes
0answers
42 views
Compute the box covering on a graph using CPython
Edit:
My initial idea was to use numpy to solve efficiently this problem but after trying without results, someone comment on stackoverflow:
"Numpy can speed things up a lot IF your problem is ...
1
vote
2answers
50 views
Database migration script
I'm working on a database migration script written in python, which will take data from a MySQL database and insert them into a PostgreSQL database with a different Schema (different table structures, ...
2
votes
2answers
76 views
Program to test for divisibility of numbers
(EDIT: here is the follow up qusetion)
Using this program to test for the smallest number where its permutations or itself is divisible by 10 or less numbers is twice as slow as the fastest program I ...
4
votes
2answers
80 views
Sort array of Numbers with some values always first
The first number will be dynamically selected and remaining array should be sorted ascending
...
1
vote
1answer
31 views
Find permutation of a specified lexicographic rank
This is one result of my work on Project Euler to learn Java. I'm interested in how well this conforms to best practices as well as any recommendations on efficiency. (I'm pretty sure this code is a ...
0
votes
2answers
42 views
Program to calculate smallest number with permutations divisible by a set of numbers
(EDIT: here is the follow up question)
I have written a small program in C to calculate the smallest number where any of its permutations or the number itself is divisible by a set of given numbers. ...
2
votes
2answers
33 views
Counting finite abelian groups
I wrote this code for this code golfing challenge on the CGPP sister site. It wouldn't really be a competitive entry because I had to write all the functions from scratch. (I didn't even golf anything ...
3
votes
2answers
249 views
Project Euler #42 - Triangle Numbers
Here is the Euler problem referenced, it says:
The n\$^{th}\$ term of the sequence of triangle numbers is given by, t\$_n\$ =
½n(n+1); so the first ten triangle numbers are:
1, 3, 6, 10, ...
5
votes
0answers
66 views
Speeding up Python depth-first search in large graph
I'm building a Markov text poetry generator. The main method, which is attached below, performs a depth-first search through the Markov chain, which is implemented as a NetworkX digraph of Word ...
6
votes
3answers
617 views
Find total number of phone numbers formed by the movement of Knight and Bishop on keypad
I recently gave a test on HackerRank, and submitted my answer for the following question. I passed all the test cases but company told me that the answer is not efficient, and they are not moving ...
2
votes
1answer
28 views
Determine the number of factors of a large numbers efficiently
I am trying to determine the number of factors of a large number efficiently. I have written this function but how can it be improved upon?
...
1
vote
1answer
40 views
Array search algorithms: performance comparison
I'm making a program that compares multi-key sequential search and Interpolation search in a sorted array by the number of array accesses for my assignment.
...
3
votes
2answers
41 views
Correct 4 bytes out of 65K to match a crc32 checksum
I have a corrupted png image. I checked and the crc32 checksum of the first chunk (size ~65k) does not match with the one I get. I am sure of this.
Also, I have ...
1
vote
0answers
27 views
Penalized logistic ridge regression
This code takes a really long time. Can anyone help to make it faster?
This code is for the penalized logistic regression that we should to chose \$\lambda\$ in regularization to control the trade ...
3
votes
1answer
40 views
Converting polar coordinates to Cartesian coordinates
I have a functional script that converts polar coordinates to Cartesian coordinates and then matches a value in a separate array to the coordinates. It works well, but I find that it takes a long time ...
1
vote
2answers
56 views
Generate all available numbers for pattern, shuffle and save to multiple files
I've build simple application that allows me to generate all numbers that have desired length and start with prefix.
For example if I specify 12 as prefix and set ...
1
vote
1answer
33 views
For loop step including last value
I've got the following code. I want to loop through my dataset (which is a matrix) in steps of let's say 50.000 and perform biglm on it.
...