7
votes
3answers
107 views

Compare string with wildcard string

I have the following function to compare a string with a wildcard string (containing ? and *), as C# doesn't seem to have a builtin function to do it. ...
3
votes
2answers
314 views

Check winner in a Tic Tac Toe game

I have the below code to check for a winner in a Tic Tac Toe game. I'm wondering if this is a good approach, and if there is a better way of doing this (maybe by monitoring the state of the board). ...
1
vote
1answer
45 views

Robots files generation - simplifying foreach code

I'm trying to figure out if there's a way I can simplify this code which is used to generate a robots.txt file with numerous rules. Different files/folders are separated in separate arrays because ...
5
votes
1answer
87 views

Is there a more elegant solution than this spaghetti code without completely revamping the whole page?

I use 'GROUP_CONCAT' to get comma separated lists of a person's educational background. Included in those lists are the type of degree, major, issuing establishment, and year received. ...
7
votes
2answers
325 views

Merge some child values back into the parent multidimensional array

This is a wonky PHP function I came up with to merge some select values from child arrays into the original. It could really use some help simplifying / making it more elegant. Is there a built-in ...
3
votes
1answer
87 views

Display PHP Menu Stored in an Array and Looped

I'm creating a PHP website for a non-profit. They have some restrictions (no MySQL or pre-installed CMS) so I'm creating a CSS menu displayed by an unordered list where all of the elements are stored ...
6
votes
2answers
4k views

Read an input text file and store the tokens in 2 different arrays

I am very new to Java so please ignore if there are obvious mistakes. If my question seems redundant then please guide me towards the correct link. However, I have surfed enough in order to find the ...
19
votes
6answers
5k views

Guessing a unique 4 random digits number

I've created a simple game, in which the user needs to guess 4 digits number between 0-9, generated randomly using Random() Each of the 4 digits are different from ...
5
votes
1answer
106 views

Optimising Funny Marbles

Problem statement is at http://www.codechef.com/DEC13/problems/MARBLEGF Lira is given array A, which contains elements between 1000 and 2000. Three types of queries can be performed on this ...
3
votes
3answers
114 views
19
votes
6answers
1k views

How can I make this mess of Java for-loops faster?

I'm trying to find all the 3, 4, 5, and 6 letter words given 6 letters. I am finding them by comparing every combination of the 6 letters to an ArrayList of words ...
1
vote
1answer
90 views

Is there any better way to fetch two tables in one statement or query?

The 'Do' method is for prepared statements and returns (by fetchall()). I am also using two looping statements. Is there any better way to fetch two tables in one statement or query? If not, what ...
1
vote
1answer
113 views
3
votes
1answer
51 views

Code to find the proper index comparing 3 values for max one

I have an algorithm and the idea is to move over an array choosing as index the index of the neighboring cell that has the max value. I.e. if array[i + 1][j + 1] has the largest value among the 3 ...
1
vote
1answer
217 views

C arrays and loops optimization

I am writing a program for learning purposes that takes an input of a file structured similarly to: ...
4
votes
1answer
240 views

Optimizing Python / Numpy Code

So I'm implementing a version of the mean shift image processing algorithm for color segmentation in python/numpy. I've written a pure numpy version of the actual mean shifting per pixel (which I ...
2
votes
2answers
80 views

Request for help to tidy up code involving arrays and loops

I posted the following code on here a few days ago: ...
5
votes
1answer
3k views

Java 2d array nested loops

Okay, So I have this method I made that searches a 2d array of user input column length and row length comprised of integers. The method is suppose to find 4 alike numbers in rows, columns, and both ...
1
vote
1answer
191 views
1
vote
1answer
275 views

Downsampling boundaries of a 2D array

I have a linearized 2D array u (block_height * block_width) containing the values of a physical quantity over a regular 2D mesh. ...
2
votes
1answer
1k views

Better method to loop through arrays in VBA

I supplied the following code as an answer to this question on SO, but I was wondering if there was a better way to write out all those array loops. (i.e. perhaps using a Collection/Dictionary?) It ...
1
vote
3answers
664 views

Optimize Array.indexOf

How can I optimize checking a value in recursion before operating on it? I'm using Array.indexOf (this is Javascript) ...
4
votes
2answers
613 views

Splitting an array of numbers into all possible combinations

This takes an array of numbers then splits it into all possible combinations of the number array of size 4 then in another array puts the leftovers. As I want to take the difference in averages of ...