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.
0
votes
0answers
2 views
Sum of an integer number
Hi guys I'm training myself into Problem Solving. So the question is that in a given integer n you have to sum its elements.
i.e (111) the sum is 3
My solution looks like these:
...
1
vote
1answer
36 views
Check for Balanced Parentheses in JavaScript (correctness, performance, and edge cases)
I just implemented the balanced parentheses problem in JavaScript. For those of you who are new to this problem, a statement of it would be:
Give a string of parentheses (including braces and ...
0
votes
0answers
22 views
Why is my red-black tree slower than std::multimap?
I've written a red-black tree in C as an exercise. The tree works and it is not bad, but it is about 10% slower than std::multimap from libstdc++ which I'm comparing it against. Full code of my ...
3
votes
2answers
31 views
Random playlist builder is slow
I wrote a Python script to scan my music library, randomly select 50 songs, and play them in VLC media player. It works great, just a little slow (takes several seconds to launch).
I know that ...
2
votes
2answers
27 views
Outputs all substrings that are palindromes in a given string, in alphabetical order without repitition
I'm currently trying to find a way to get my program to run more efficiently. If anyone has any ideas on how to optimize my program, i would appreciate it a lot. Also, the output has to display in ...
8
votes
0answers
52 views
Cat fight (with rockets)
My code is attempting to implement FP in an efficient / readable manner into some of my video games. I realize this may be a bit subjective, but I feel there is enough merit / objectivity to be of ...
1
vote
0answers
47 views
-2
votes
0answers
30 views
Producing residues of combinatorics on strings [on hold]
Basically, this code does multiplication of chosen operations.
...
0
votes
0answers
13 views
Reduce the execution and memory consumption - Skip invalid record and avoid execution break for invalid record
Here is the pseudo code used inside a rails controller:
...
5
votes
3answers
90 views
Interpreter programming challenge
I have posted here my working and accepted solution to the intepreter programming challenge (detailed here) for your review. The challenge is as follows:
A certain computer has 10 registers and ...
2
votes
2answers
75 views
Retrieving the nth term of an infinite stream
I recently learned how generators can be infinite in Python. For example, the infinite sequence can be the triangular numbers:
$$1, 3, 6, 10,...$$
...
3
votes
1answer
51 views
Sliding window calculation using R
I have the following function count.ones that takes in a data frame data.l in which the observations have been subdivided into ...
0
votes
0answers
20 views
Link Detection and Addition of Anchor
I have the following code but I am not too happy about the way I replace e-mails with mailto links. Additionally, I am thinking how to conbine the logic of the URLs and E-mails into one Loop.
...
3
votes
0answers
43 views
Science Buddies derived password cracker
I am trying to improve the performance of this password cracking method:
...
3
votes
3answers
100 views
High performance, branchless Intersection testing: sphere-aabb & aabb-aabb
From my tests:
AABB-Sphere: 2954.8 tests per ms.
AABB-AABB: 1087.0 tests per ms.
The sphere test is almost 3 times faster, but the two intersection tests seem to perform about the same number ...
0
votes
1answer
39 views
Sentinel based find with conditional fallback to std::find
I've got bored, so I decided to write a code using ancient knowledge of sentinels.
Sentinel based find
Basically what we do is put value that is needed to find at the end, and then write an endless ...
5
votes
2answers
189 views
Yet Another, Another Prime Generator
Yes, I realize there are many, many, many, many, many, prime generators on the Code Review SE. However, I have been unable to find any using this method for generating primes inside a vector, so I ...
0
votes
1answer
16 views
Haskell insertAt solutions
I was working on Haskell Problem 21:
Insert an element at a given position into a list.
Example:
* (insert-at 'alfa '(a b c d) 2)
(A ALFA B C D)
I have ...
-1
votes
0answers
18 views
How to make a code a distributed one between 10 CPUs? [on hold]
I have this code and I would like to distribute the job between 10 CPUs. I need guidance as how to do this.
...
0
votes
0answers
37 views
Simpler Method for Casting all Numbers
I have the following code:
arbFloat pogson(){
return pow(static_cast<arbFloat>(100), static_cast<arbFloat>(1) / static_cast<arbFloat>(5));
}
...
5
votes
1answer
220 views
Brainfuck compiler with tcc backend
I wrote simple compiler for Brainfuck with tcc backend (dont ask for assembler/assembly code generator!). It's output runs incredibly slow. Even Hello World program takes a LOOONG while to execute. I ...
2
votes
1answer
26 views
VBA - XMLHTTP web scraping
I navigate with IE, do various things, then select all results option from a list and fire on click event. Once all results have been listed, I loop through their URLs, using the following code to ...
3
votes
2answers
146 views
Print all lines of a text file containing the same duplicated word
I'm implementing my very first Go application and I would like to receive an hint on how to make a certain check faster.
I have a huge txt file in which each line ...
2
votes
0answers
29 views
Converting [UInt32] -> [UInt8] -> [[UInt8]]
I am trying to speed up my current implementation of a function that converts [UInt32] to a [UInt8] which in turn is split up ...
3
votes
3answers
126 views
Last five non-zero digits of a factorial in base b
This HackerRank problem (based on Project Euler problem 160) says:
For any \$n\$, let \$f_b(n)\$ be the last five digits before the trailing zeroes in \$n!\$ written in base \$b\$.
For example,...
3
votes
1answer
46 views
Compressing time series by removing repeated samples
I work on a project with time series data. So there are samples (\$y\$), and each sample has a timestamp (\$x\$). The data will be visualized, but often there are time series which contain samples ...
3
votes
1answer
89 views
1
vote
2answers
97 views
Remove duplicates from a sorted array
I have solved the LeetCode Remove Duplicates From Sorted Array problem:
Given a sorted array, remove the duplicates in place such that each element appear only once and return the new length. It ...
1
vote
1answer
33 views
Naive Bayes Classifier in C#
The following is my implementation of Naive Bayes Classifier.
https://github.com/edurazee/NaiveBayesClassifier
I took the source code from here and tried to simplify it.
How can I simplify my code ...
5
votes
1answer
68 views
Temperature converter app
I'm learning Ruby and as an exercise I decided to build this little temperature converter app (C to F, F to C, F to K, etc). Looking back at it, it's pretty much just a bunch of boilerplate code. Any ...
0
votes
0answers
26 views
Optimizing List creation
Using IBM JT400 toolbox, I'm reading records from a DB2 keyed table (it's like reading a ResultSet with ResultSet.next()).
As what I'm building is an higher level ...
1
vote
0answers
29 views
Project Euler #15 in Python
I've wrote the code for Project Euler #15 and it runs amazingly fast. I know I can write it using binomials but I wanted to calculate by brute force as if I do not know Binomials. But I think it must ...
0
votes
2answers
63 views
Is it possible to use switch case for more than one array.indexOf
I have some set of if conditions for a particular array using JavaScript.
activity is the array containing 10-12 items. This ...
2
votes
0answers
41 views
Generating all unique permutations of a string
Here is a plan for generating the permutations of S: For each item x
in S, recursively generate the sequence of permutations of S - x, and
adjoin x to the front of each one. This yields, for each ...
2
votes
0answers
39 views
Slow JavaScript, which adresses deprecated html tags
I have written a JavaScript that can read every defined html element and changes the color for each char inside the selected element.
It works fine for smaller projects / sites, however will be laggy ...
3
votes
2answers
29 views
IMAP Mailbox Daily Average Volume Statistics Generator
Because my job needed something like this, I created a Python script that'll connect to an IMAP server, get all the emails, and then calculate the very rough daily average of emails received to the ...
2
votes
1answer
42 views
Dynamic Array Bags
For one of my assignments, we were asked to create a data structure similar to Bags using dynamic arrays where the order would be important - which I was able to do successfully, that is, the code ...
1
vote
1answer
36 views
Display Tournament League from total Players
I've created function that will display a league competition from the total team numbers.
For example if we have 4 teams it will display (a vs b) vs (c vs d)
and ...
0
votes
1answer
59 views
Checking whether any item in an array has a desired value for a key
I want to check whether or not an object exists in an array given its key (key is not unique).
The object takes the form:
...
4
votes
2answers
134 views
Intersection of N lists, or of an N-d array
I often find myself having to do np.intersect1d() multiple times because I need to find the intersection of a number of list like or array like things. So I ended ...
0
votes
0answers
17 views
Generating a carousel slider
I'm currently using Backbone to generate a carousel slider. In my View, I have an initialize function that looks like this:
<...
2
votes
1answer
82 views
Find the number of K-Complementary pairs in an array
Below is the program to find k-complementary pairs: K = A[i] + A[j];.
...
3
votes
1answer
81 views
Detect if string contains more than 1 period
This function returns true if the string contains zero or one periods, and returns false if the string contains more than one ...
3
votes
1answer
194 views
Storing database references to files/media
This is an extension of this question due to it not covering an important role of my setup that I think needs more attention.
The files are stored on a different server for separation and convenience....
0
votes
0answers
64 views
Generate a table with random numbers
I wrote the following code for generating a table with random numbers and would like to ask if there is any way to optimize/enhance/modularize the JavaScript code, especially the addColumn and the ...
0
votes
0answers
31 views
Performant DB2 queries for aggregation context
I need to improve the following DB2 queries, I understand DB2 is slow by nature and that the infrastructure is not the most ideal but here's my scenario.
I have to go and grab data from ...
2
votes
1answer
48 views
Invert-range operation in a circular vector
I implemented a invert-range operation in a (logical) circular vector. A circular vector is a vector without a logical starting and ending object, or, equivalently, the successive element of the ...
1
vote
0answers
25 views
“Photo Sales App” exercise as homework, and processing multiple checkbox “isChecked” values
I've done this assignment here for my android programming course I'm taking. The exercise requirements were to create a single-activity interface for selecting a 'photo package' to purchase, and to ...
5
votes
3answers
85 views
Upload an image to a folder through a form
I am using this code to upload an image. Please review it and give your feedback regarding performance, security, and quality. This also works in PDO project.
...
1
vote
1answer
64 views
Dijkstra's Algorithm not optimized enough
I was attempting a question on HackerRank-Dijkstra's Shortest Reach 2 and upon submission my programs times out in 3/7 test cases. One of the test cases had 200 nodes and about 2000 connections. Here ...