8
votes
3answers
354 views

Finding the largest of a series of numbers being XORed

I'm working on solving a problem involving finding the largest of a series of numbers being XORed. This is the actual problem: Xorq has invented an encryption algorithm which uses bitwise XOR ...
5
votes
4answers
71 views

Optimizing nested loop in run length encoding function

I'm currently working on a tool that needs to decode, modify data, then re-encode that data using the Yaz0 format. Everything has been in a working state, but after running some code analysis on my ...
8
votes
4answers
168 views

Adding two sides of an array

The purpose of the program is to add 2 sides of an array starting from the bottom and top of both ends and to find the lowest difference at equal decrements of iteration. The program functions but ...
7
votes
3answers
148 views

Getting the top 10 stores within a category

I have the following query. I know there's an easier way to do this without the sub queries, or at least optimizing how they're used. I've read about cross joins and using ...
2
votes
0answers
24 views

C code for hash-consing: how could its performance be increased?

I've isolated this function, cons, for hash-consing in C. It is where the bottleneck of my program is. How could its performance be improved? ...
3
votes
1answer
16 views

Bit compressing in JavaScript

I have an bit array var data = []; ... and I have the following function: jsPerf ...
3
votes
1answer
35 views

How to generate valid number of combinations of datacenter and its host id?

I have a list of datacenters, which are dc1, dc2 and dc3. And each datacenter has six ids as ...
5
votes
4answers
372 views
5
votes
4answers
81 views

Stack implementation using only one queue in C

We start with an empty queue. For the push operation we simply insert the value to be pushed into the queue. The pop operation needs some manipulation. When we need to pop from the stack (simulated ...
2
votes
0answers
53 views

Code elimination once it is conditionally dead [closed]

A situation when programming code becomes dead dynamically or conditionally, such as here in this scenario. I don't want my code to be failure victim of branch prediction. ...
5
votes
1answer
77 views

E-commerce product price tracker

I building a very simple price tracker web app. I am using MongoDB with pymongo. The user will enter the URL of the product he wishes to track and the desired amount, when the price goes below this ...
0
votes
0answers
10 views

Need to use floats for performance yet want double-precision calculations [migrated]

MonoGame is an open-source version of Microsoft's XNA. It's a framework for building cross-platform games. It has a number of mathematical types such as Vector and Quaternion. I am a bit baffled by ...
5
votes
0answers
74 views

Merging overlapping/intersecting string vectors

I am trying to merge overlapping/intersecting sets given as a list of string vectors below in R (my actual data set has thousands of such sets). The overlap/intersection is based on the ...
10
votes
3answers
339 views

Optimize a Date and Timespan function

I have a working function that may be optimizable. Currently processing 4 objects gives me 0.0459822 for the elapsed time in seconds - used for testing purposes. ...
2
votes
1answer
80 views

Typeahead Talent Buddy

Problem is Talent Buddy. Your task is to write a function that prints to the standard output (stdout) for each query the user name that matches the query if there are multiple user names ...
2
votes
1answer
70 views

Performance of Codility MaxCounter challenge solution

I'm doing some of the Codility challenges using Ruby. The current challenge is "The MaxCounter," which is described as: Calculate the values of counters after applying all alternating operations: ...
9
votes
1answer
405 views

Chunk Generation Performance in C#

I'm working on a game in C#, this game generate new chunk (infinite) when you move around. If I have > 1000 chunks in my list then it become laggy even though I only load the necessary chunks on my ...
3
votes
0answers
61 views

Python Multiprocessing: Using mutable ctype arrays seems to work, yet I am not seeing significant speed-up. Why?

As a brief introduction, I am student working on a body of code which forms part of my Masters' research - this is my first question on SO. My background is in physics and mathematics, so I will ...
4
votes
1answer
70 views

Ignore exceptions when changing column formula in Excel table

The new table feature on Excel is excellent and you can specify a column formula as well as exceptions on the column. However, if you want to change the column formula, Excel will rewrite the whole ...
4
votes
2answers
67 views

Increasing performance of OpenMP based advection equation solver for Xeon Phi

I am solving linear advection equation in order to learn parallel programming. I am running this code on Xeon Phi co processor. Below is a plot of how it scales up with increasing number of threads. I ...
4
votes
3answers
70 views

String self-similarity

It's a string problem I have been making on Hackerrank. It is executing fine on all test cases except the last two. These last two test case are declaring it "Terminated due to time out". C programs ...
5
votes
3answers
93 views

Calculating the ranks of classmates' exam grades

The questions from hackerearth: Geeko is in worry now because an exam is coming up and he has to know what rank he can get on exams. So he goes back into the the school records and finds the ...
14
votes
6answers
2k views

Sherlock and The Beast

This is my solution to this question from Hackerrank. Given N (<= 100000), find the largest N-digit number such that: The number has only 3 and 5 as its digits. Number of times 3 ...
9
votes
2answers
75 views

Scalability of running commands from user input

Here is some code I have that has been extracted and shrunk down from a project of mine. ...
6
votes
2answers
130 views

Prime Number Speed

I know prime number programs have been beaten to death. I am have been programming for eight years (not that long, but I'm not in my 20s yet and I got a programming job straight out of high school so ...
1
vote
4answers
641 views
2
votes
1answer
38 views

Finding given element in minimum steps from matrix [closed]

A N*N size matrix is entered. The condition is that each element of the matrix is greater than the elements above it and left to it. Or, it can be said that all the elements on the right side and ...
1
vote
1answer
43 views

Trimming exactly two white spaces from string at O(N) [closed]

This is the optimized code I have written for removing/trimming one white space from a given string. I'm required to remove exactly two spaces from the string at the same cost of \$O(N)\$ by ...
4
votes
1answer
310 views

Hackerrank Gem Stones

I am working on some problems on Hackerrank. John has discovered various rocks. Each rock is composed of various elements, and each element is represented by a lowercase Latin letter from 'a' to ...
12
votes
3answers
232 views

Search script code efficiency

Is there a more efficient way to write this? This script will be used heavily and I want to make sure I do not have any memory leaks or speed issues. This script gets an input from a form and ...
6
votes
3answers
114 views

Retrieving data from files in the folder

I am to use VBA code to simply retrieve certain data from all Excel files in certain folder and paste it in working spreadsheet. I am not sure that this is the most efficient (which matters as I would ...
5
votes
4answers
60 views

Number Of Matching Elements In Two Lists

I have many sets of 2 strings. I'm trying to determine the number of matching elements in these 2 strings. The rules are if the strings share a common letter, that's a point, order does matter, but ...
7
votes
0answers
134 views

Recursively using reflection to merge fields

I'm using the Observer pattern to notify my UI that the object they're representing has changed. Also, I'm refreshing this object from the interwebs. Therefore, I'm ending up with two instances ...
5
votes
3answers
108 views

Speed up query to rank team sales by aggregating data from two databases

On my machine it runs in about 60 seconds and about 2-3 minutes live. The criteria needed are: Current month only (from first of month until current day) I need the rank of the currently logged in ...
1
vote
0answers
42 views

Three-machine proportionate flow shop problem with unequal machine

As part of an academic project I wrote a code about dynamic programming that solves the "Three-machine proportionate flow shop problem with unequal machine". My major problem is that the code takes a ...
2
votes
3answers
53 views

Speeding up Project Euler 43 - sub-string divisibility

The number, 1406357289, is a 0 to 9 pandigital number because it is made up of each of the digits 0 to 9 in some order, but it also has a rather interesting sub-string divisibility property. ...
1
vote
3answers
79 views

Efficient Collatz sequence analysis

I'm new to Haskell, and I'm wondering why my programs are so slow compared to other languages. Haskell, 6 seconds (x64, -O2): ...
2
votes
0answers
67 views

Optimization Algorithm: Too much memory consumed

What I have here is an implementation of an optimization algorithm called the covariance matrix adaptation evolutionary strategy. I am using this algorithm to optimize the position of wind turbines ...
8
votes
2answers
181 views

Calculation of an inflation on volume/year

Background I would like to find out if my current solution to the problem described below is "good enough" or if there is an alternative way of achieving it. All I care about is the length (no. of ...
4
votes
1answer
39 views

Hiding and revealing toggle responds very slow

I have a list of 6 items, and each one on click reveals a div that runs 100% wide under the row of list items. The code works, but the div opens very slowly and kind of choppy. Is there anything I can ...
3
votes
1answer
73 views

Navigation bar implementation

I made a navigation bar on the left side of my site. It works perfectly, the only problem is I'm new to jQuery and I think I'm repeating too much code. Is this the case? If it is please help me out. ...
3
votes
3answers
420 views

Bresenham's line algorithm implementation

May there be any performance and/or code standard improvements on the following LineOfSight code? ...
5
votes
1answer
76 views

Using CountDownLatch for blocking the reads if writes are happening

I am trying to implement lock by which I want to avoid reads from happening whenever I am doing a write on my three maps. Requirements: Reads block until all three maps have been set for the first ...
11
votes
3answers
392 views

Text “analyzer” in C++

I have few years of experience with web and I recently started learning C++ and I feel a bit lost, so I would like to ask to for some tips how to improve my code overall. This text summarizer should ...
4
votes
2answers
320 views

Reading a file and storing the contents in an array

This is my code for reading a file with a delimiter. Any suggestions to help improve my code efficiency? I am not satisfied with using array data structure. Can any other data structure be used ...
4
votes
3answers
345 views

32-bit factorial calculator in x86 NASM assembly

This program calculates the factorial of a given positive number. This is how it handles input: if negative, terminate program if 0-2, display input without calculating if greater than or equal to ...
4
votes
2answers
58 views

Page loader function

This is the function which I wrote and am currently using in my project. I want to know if there is a better way to write it: ...
1
vote
1answer
89 views

Codeigniter ActiveRecord Wrapper Model

Can someone help me refactor this to be more optimized? Performance seems to be very optimal, but I think more can be squeezed from it. ...
6
votes
2answers
154 views

Inversion of an array that contains indices

I have an array of length n that contains numbers from 0 to n-1 in random order. I now want to "inverse" this array to one that where index i corresponds to the location of i in the source array. ...