# Tagged Questions

Optimization is the act of improving a method or design. Optimization usually takes the form of improving the efficiency of an algorithm, or reducing the resources it requires (space in memory, on disk, or amount of network traffic, etc.).

24 views

### AI for an online contest

I'm actually creating an AI for the online contest Vindinium. The fact is that's also an exam for my school because I'm going to have a note with that work. I created an AI based on ants pheromones ...
30 views

### Checking if a directory exists in FTP without relying on exception handling?

I've written a method to check if a directory already exists on an FTP server. The only way I could see to make this work was to return a different result from the method if an exception is thrown - ...
23 views

### Prime Number Sieve Optimization

I've written my own prime number sieve in JavaScript. It loops through numbers 1-100 and puts them in one of two arrays, depending on if it is composite or prime. I was wondering if there are any ...
109 views

### Search algorithm to find a point from a given X value

I implement the following algorithm in order to find a point from a given X value in a sorted list with the same distance between each X values. Here's an example of my list content with a delta of ...
83 views

### Stepping Number Solution Optimization

I have the following problem: The stepping number: A number is called a stepping number if every adjacent digits, except those separated by commas, differ by 1. A stepping number can't be a ...
46 views

### EF GroupBy query optimization

I have this method: ...
65 views

### Calculate possible balances in piggy-bank by weight

I have solved Piggy-Bank problem on SPOJ using dynamic programming. The question asks you to get the minimum value that is possible with given weight ($w$) and one or more coins ($n$) with given ...
18 views

### Python, testing user input speed with random phrase [closed]

This is a plugin for a Jabber/XMPP bot which gives the user a random phrase, and starts a timer in milliseconds, when the user replies with same phrase, the bot replies with the timer. Now these the ...
233 views

### Count cars passing in opposite directions

The problem comes from codility, whose coding problems I'm starting to enjoy as their evaluation criteria really looks at runtime. Task description A non-empty zero-indexed array ...
44 views
+50

### Smoother column resize, page reveal animation

I've been working on this site. The designers original inspiration for the column layout came from this site. I've been trying to get the animation as smooth as possible, to match the smoothness of ...
121 views

### Becoming the greatest tower builder

I am trying to learn how to write proper code in python, and stumbled upon the following problem. Bob is given a set of building blocks b, and a number ...
39 views

### Randomly pick a host from a list, subject to an uptime requirement

I have a POJO as shown below which will have hostname and other attributes. ...
49 views

### Recursively parsing JSON response using GSON

I have a URL which I am executing it and it is returning the below string as a JSON response. I am using GSON to parse JSON. In the below JSON, "resourceId" ...
80 views

### My Google Maps Script

I've written a script with the Google Maps JavaScript API v3. I've ran it through JSHint and everything seems to be valid. I'm wondering if my script has room for improvement. Any suggestions are ...
165 views

### Refactoring a FTPHelper Class

I've written a FTPHelper class to help teach me more about code strucutre. I don't know what I don't know so I would really value feedback on how I can be laying out and thinking about my programming ...
28 views

### Speeding up loop-rich Matlab function to calculate temperature distribution

I would like to speed up this function as much as possible in Matlab. This is part of a bigger simulation project, and as it is one of the most called functions within the simulation, this is crucial. ...
106 views

### Code redundancy issue while feeding dropdownlists

I have a dashboard to manage a learning center system. There are scenarios like admin create learning center and define a classroom in it and then assign some courses in it and assign students to ...
29 views

### 2 4 tree insert function

I'm after creating an insert function for a 2 4 tree in Haskell. I'm just wondering if this is the best way to implement it (especially when handling the Root4s), ...
45 views

### Distribution problem optimization

The situation is this: I have a bunch of servers which are synced so that they all have the same data. Unfortunately, a disaster happened and the servers are all out of sync. My task is to re-sync all ...
91 views

### Better card validity check in JS card game

I am writing a card game in Javascript. The game is played with a 32 card deck. When a card is selected to be played by a user, i do a validity check on the server to check whether it matches the ...
62 views

### 2-opt algorithm for traveling salesman

I wrote a 2-opt algorithm to be used in a program and noticed (using profile) that the 2-opt is eating up a lot of time. I have tried a few things to make it run faster, but I am out of ideas. Any ...
72 views

### Using std::array to implement variadic construction of class with list-of-self as subclass

I have a situation with a base class for whom a container of itself is a subclass. So a Block of Item has various ways in which ...
100 views

### General Game Loop 2.0

Follow up from General Game Loop I have two interfaces. Entity for ticks. Drawable for rendering. Drawable.java ...
74 views

### Cleaning up website code

I am a bit of noob to jQuery so I got this jQuery code what I think can be way faster. Does someone want to help me clean it up? Explaining why you did what would be real nice but not needed. The ...
31 views

### Most efficient way to get columns where one is minimum

I have a table with 3 columns in the format below: WebcastChannelId, WebcastEventId, SortSequence 1 , 2 , 1 1 , 5 , 2 1 , 3 , 3 2 , 7 , 2 2 , 8 , 1 I would like to get the values for the ...
252 views

### Set theory clock code

I wrote some JS to power an HTML/CSS "set theory" clock, and I'd like to share what I have so far and ask if anyone can suggest improvements. Specifically, I'm wondering: Should I bother checking ...
336 views

### Changing element visibility based on multiple checkbox states

I am writing a script in JavaScript & HTML and have some optimization problems. In the for, loop I check a variable named ...
60 views

### Permutation of phone numbers starting at button x, ending at button y, and z numbers long

I am trying find the total number of permutations possible with a given x, y, and z. x is the initial number, y is the final number, and z is the total number of buttons pressed. I am supposed to ...
315 views

In main: ...
23 views

### Refactoring conditions in text parsing method

I am writing a generic text parser and have come up with the following text parsing algorithm, which works fine. I'm wondering how to refactor the following method to make it easily understandable and ...
240 views

### General Game Loop

I have two interfaces. Entity for updates. Drawable for rendering. They both have two interface methods. One that is called every frame, one every second. ...
50 views

### Natural merge sort in Java - follow-up

See the previous iteration: Natural merge sort in Java Arrays.java ...
26 views

### Compare strings by custom sort order

Each letter represent a category. Example the group with "M" Code is greater Than "I" and "C" group. "F" is the higher group Here is what I did but I wonder if there is a better way to do it. ...
113 views

### Harmonic analysis of time series applied to arrays

I've developed some code in Python to apply a harmonic analysis of timeseries (for satellite imagery data). It's based on this, but then I would like to optimize the performance. So instead of a ...
1k views

### How to make this StringToCollections method more generic?

I am new to C# and I have a big functions that receives the following arguments (Package inPackage, string materialIDs, string functionIDs, string companyIDs). ...
29 views

### SharePoint and JSON output project - where can I do better?

I'm working on a project that reads a series of SharePoint lists and outputs them into JSON file(s) which will later be uploaded via FTP to use on a website. I'm aware that there's a lot I could be ...
59 views

### Number database using binary trees

I recently got interested in Go and wrote a database server which uses a binary tree for data storage for fun. As I have no prior experience in Go, I'd like to gather a bit feedback on my code and ...
69 views

### Natural merge sort in Java

Natural merge sort is a modification of merge sort that sacrifices O(N) to actually build a list of "runs" that may be defined as monotonically increasing or strictly decreasing contiguous ...
995 views

### Happy Number Program

I wrote this program, to determine if any given number is happy, and would like to know of any improvements that can be made to make it better. I have tested it, but whether or not it works perfectly ...
54 views

### Simple alphabet scrambler — usage of vectors

I am currently learning C++, using this book: C++ Primer, 5th Edition. I made this program to help me understand the usage of vectors in C++. I have prior programming experience (mainly Python), and ...
55 views

### Optimizing insertion sort for small amounts of data

I'm building a hybrid sort, and for that I need a fast and adaptive sort ideal for small sizes (< 65 elements). Insertion sort immediately comes to mind, and I've been tinkering with different ...
243 views

### Compute (x+yCx)%mod

I want to compute, as quickly as possible, $$\dfrac{(x+y)!}{x!y!} \mod m$$ with $x,y \le 10^6$ and a prime $m=10^9+7$ (called mod in my code). My current ...
213 views

### Game of Life Neighbour count optimization

This is a working Neighbours method. Is there any way to make this simpler and concise? ...
87 views

### Game of Life with exceptional Neighbours

As it currently stands the code works fine. Is there a way to optimize the code in the class Neighbours? What I have done was to copy the code for each of the ...
67 views

### Algorithmic simplification of Miller Columns

Background Unsatisfied with existing implementations of Miller Columns (used to edit hierarchical data), I decided to re-invent the wheel. Problem Most of the existing implementations are too ...
53 views

### Fetching applications, clients, and departments related to a ticket

I have a CouchDB view with the following view/reduce function. After working over 2 hours on it, I have a result I am happy with, but I believe there is a lot of ...
57 views

### Drawing sets of boxes to display contents of arrays

This code draws two sets of 9 boxes on the screen to display the contents of two arrays. How can I speed up, shorten and make the code more efficient? ...
66 views

### Base64 encoder optimization

Base64 is a widely used encoding mechanism to allow arbitrary binary content to be transferred as printable text. This program is designed to take binary file as input and produce a Base64-encoded ...