DO NOT USE THIS TAG. It is in the process of being eliminated. If your question is just about performance, use the [performance] tag.
0
votes
0answers
11 views
Does declaring variables/caching selectors affect performance? [closed]
I'm not sure how jQuery works, but I assume caching selectors like this "hurts" performance as it searched through the DOM?
...
-1
votes
1answer
22 views
Human Readable filesizes
I am re-inventing the wheel and would like to lay down a comprehensive filesizes function. The only issue is that I guess bit-wise operators are more efficient but I'll be darned if I can understand ...
0
votes
1answer
54 views
Optimizing Diwali Lights problem in C
I was trying to solve the Diwali Lights challenge on HackerRank.
Problem Statement
On the eve of Diwali, Hari is decorating his house with a serial light
bulb set. The serial light bulb set ...
4
votes
1answer
220 views
Optimizing critical loop for consuming a byte-buffer
I'm currently developing an Open Source project called sims3py using Python2.7. One overarching goal of the project is to ensure a Pure Python implementation of functions currently available only ...
0
votes
1answer
23 views
More efficient columnar transposition decryption
Below, I have created a rudimentary script to decipher a columnar transposition. I am wondering if there is a more efficient way to determine the number of the rows in a column? Also, is there a way ...
3
votes
2answers
118 views
Optimizing Multiplication Table
I have a class that takes an array of integers and produces a multiplication table.
...
1
vote
0answers
47 views
Minimum amount of edges that needs to be traversed to visit all vertices… or something like that
So I have this problem, where I'm given m connections over n vertices. The vertices are labeled ...
-2
votes
0answers
34 views
Better way to build an object (multiple methods)?
I've inherited a method that populates/builds an object (ReportSchedulesVO rsVO), and is about 300 lines long. At an overhead view, the purpose of the method is to ...
1
vote
1answer
41 views
GCD calculation - A cross of the Euclidean and the Binary algorithm
I was reading Knuth's The Art of Computer Programming - Volume 2 (Seminumerical Algorithms) Third Edition. I saw the two algorithms (A and B). A method (due to V. C. Harris) was mentioned (in page ...
2
votes
1answer
49 views
Building a Simple Menu With Perl
I wrote a Perl script to implement a simple menu where you can call subroutines for each menu option. I created a Menu class that can be used to create new menus and a print method that will start ...
8
votes
3answers
332 views
Two sets came to an intersection
Challenge:
Print set intersections.
Specifications:
Your program should accept as its first argument a path to a filename.
Each line in the file is a test case.
Each test case contain ...
10
votes
2answers
185 views
Calculating holes on a Tetris grid quickly
I have created a Tetris AI which can play Tetris on its own given a set of rules. It places the next piece in every possible way on the board, and calculates which position that gives the fewest ...
3
votes
3answers
112 views
10
votes
4answers
2k views
TicTacToe AI needs optimization
How do I condense this gigantic monster into something more manageable? I heard about command pattern but I can't figure out how to use it. What other solutions are there?
...
4
votes
1answer
66 views
TicTacToe game needs optimizing
I'm new to programming and want to check if I'm using best coding practices in my program.
...
3
votes
0answers
27 views
Optimization for better response time to use in analytics application
We are trying to use NodeJS for analytics. The following code gets the parameter from a URL and dumps it into a flat file. Is there any way to optimize it to get better response time?
...
15
votes
4answers
1k views
Duplicate like a weapon, arrays like heaven
Challenge:
Find the duplicated entry.
Specifications:
Your program should accept as its first argument a path to a filename.
Each line in this file is one test case.
Each line ...
3
votes
1answer
47 views
Efficiency and correctness of my randomized selection algorithm
Instead of picking a random pivot I'm shuffling the array beforehand. Does it count as randomization and is it efficient to shuffle or pick a random pivot and is my implementation pythonic?
Problem
...
4
votes
1answer
105 views
Optimizing code to find maximum XOR in Java
This problem is from HackerRank (not a competition, just for practice)
Basically what you do is take in two integers as a range and then finding the maximum XOR from a pair of integers in that ...
2
votes
2answers
59 views
Commute info entry fragment for Android app
This is a simple app for taking down a user's home and work address, the days of their commute, and the times they go to work and go home. The times and workweek are entered via TimePicker dialogs ...
3
votes
2answers
75 views
Premium palindromic primes
Challenge: Write a program which determines the largest prime palindrome less than 1000.
The answer is 929, and my program correctly finds and prints this, but actually ended up being more complex ...
2
votes
2answers
50 views
Quickly filter an object by keys
I am trying to optimize an object filter function. Given an array of keys, I need to filter an object. I feel that creating a new object each time may degrade performance. Is there a way to mock the ...
0
votes
1answer
74 views
PHP framework building: initializer and object loader classes
I am building a PHP framework and would like to get some feedback on a few different sections of the project. I consider myself still a neophyte in PHP so I would like to ask if I'm going about ...
1
vote
0answers
33 views
Optimize Python script for generating Point Cloud
I'm trying to produce a 3D point cloud from a depth image and some camera intrinsics. The image is 640x480, and is a NumPy array of bytes. The output is a (rows * columns) x 3 array of points.
I've ...
2
votes
1answer
114 views
Dijkstra's algorithm in Python
I was hoping that some more experienced programmers could help me make my implementation of Dijkstra's algorithm more efficient.
So far, I think that the most susceptible part is how I am looping ...
3
votes
0answers
30 views
Optimizing image generation in Perlin noise generator
I've created a simple Perlin noise generator in JavaScript and am trying to find ways to optimize it. It lives inside a webpage and generates an image using nothing more than random number generator ...
1
vote
2answers
51 views
Quicksort algorithm
I have reimplemented the quicksort algorithms that takes a list and sorts it in non-decreasing order:
...
2
votes
4answers
78 views
Coupon collector
This is a coupon collector code to analyze the running time. I need some suggestions on improving the running times of this code. I have used the data structure dictionary, but is there any other data ...
2
votes
1answer
28 views
CREATE Service Call
I'm a relatively new (~6 mos) developer, and I'm hoping for some feedback on my code style/structure. While I'm particularly interested in efficiency and maintainability, I'm open to feedback ...
5
votes
1answer
63 views
Effective use of branch prediction in terrain generator
I am trying to learn how branch optimization works.
For an experiment, I have a recursive fractal terrain generation and I have moved all if statements to binary ...
4
votes
1answer
50 views
Data-checking class supporting letters
I'm starting to learn OOP with PHP, and all I've learned so far is just by searching and reading. So I have this need to check input data for certain things like min of chars, max of chars, spaced or ...
3
votes
3answers
198 views
Determining if a pair exists in a large sorted array
I'm doing practice interview questions from here. Here is the one I am currently on - if you are given a very large sorted int array, then check of there exists a ...
2
votes
3answers
428 views
Finding duplicates in two sorted arrays
This is an interview question from here. Specifically, the second asked for a function that took in two sorted arrays of integers with no duplicate values within a single array and which returned an ...
3
votes
3answers
124 views
Project Euler 35: Circular primes below 1 million
I'm doing another Project Euler problem, number 35, and I need help improving my code speed:
The number, 197, is called a circular prime because all rotations of
the digits: 197, 971, and 719, ...
2
votes
0answers
25 views
One-dimensional convolution using Data.Vector
As part of some code I've written, I needed to perform a 1-D convolution. This convolution ends up happening quite often, so I wanted to optimise it (in some way other than using a FFT, though I could ...
8
votes
3answers
204 views
Breadth-first search for clusters of pixels in a given color range
I am a beginner in programming languages, so I apologise if my code is badly formatted or doesn't make any sense.
My program gets an image and a RGB color range as input and it counts how many pixels ...
-1
votes
1answer
66 views
Merge sort optimization and improvement
How to optimize this merge sort code to make it run faster? And how to call merge_sort function without user input by declaring necessary array in the code?
...
3
votes
1answer
115 views
Wait for System.IO.StreamReader.ReadLineAsync
I want to wait for a line to be read, but only for so long before timing out. This is what I came up with. Is there a better way to do it?
...
2
votes
1answer
53 views
Is this an optimal implementation of merge sort?
I am taking an algorithm course and we are to implement merge sort that handles list of elements with even or odd number of elements and handles duplication, so I wrote this function:
...
3
votes
3answers
152 views
Find intersection of two arrays without duplicates
A = [9, 1, 4, 2, 5] k unique integers
B = [3, 1, 8, 7, 6, 5] n unique integers
Intersection => [1, 5]
Find an algorithm that uses \$O(1)\$ space (the space used by the return variable is not ...
3
votes
1answer
117 views
Check if string can be rearranged into a palindrome
I created a function to test whether a single word string can be a rearranged into a palindrome (doesn't have to be a real word). My logic was if the string has an even number of letters, then each ...
5
votes
3answers
143 views
Bresenhams line algorithm optimization
Based on these guidelines I optimised Bresenhams line algorithm, it now fits for all kinds of line cases like images a, b, c, d, e, f, g, h show in those guidelines.
This is my test.txt input file ...
5
votes
3answers
114 views
Counting letters as quickly as possible
I received a task, of taking a known text file (Linux dictionary), use threads to count the different letters in it, and present the results in an array.
The code doesn't have to be pretty, elegant, ...
3
votes
2answers
124 views
Implementation of Dijkstra's algorithm to find the shortest path in graph
This is my implementation of Dijkstra's algorithm in C++.
Please clarify
Whether the class design is proper or if it needs to be improved.
I am just hard coding the vertex based on the priority of ...
2
votes
1answer
44 views
Books Algorithm Dealing with Square Digit Sums
A little context:
Book has 411 Pages
Read a random number of pages on the first day which is unknown
Number of pages to read next day is the square of the sum of the digits of the page ...
6
votes
4answers
2k views
Swapping two integer numbers with no temporary variable
I tried to swap 2 integer numbers without using an additional variable as a traditional swap.
Is it legal in C++? My VC compiler doesn't complain nor gives any warning about it. If so, how can I ...
8
votes
1answer
161 views
Python-based Git pre-commit hook to manage multiple users/Git identities
A couple of months ago I posted a bash script to manage multiple Git identities as a solution on Stack Overflow but soon found the hook isn't flexible enough.
Thus I decided to rewrite the hook in ...
5
votes
1answer
64 views
2
votes
1answer
38 views
SQL query to order by the difference between FIRST and BEST scores
Can anyone help me optimise this query? I have the following table:
...
2
votes
3answers
136 views
Calculate the square root of the sum of the squares of the prime factors of an input number
This question is related to another one that I have asked here.
I need to find ways to improve the runtime performance of the following piece of C-code.
I want to increase ...