I'm trying to write a program to place students in cars for carpooling to an event. I have the addresses for each student, and can geocode each address to get coordinates (the addresses are close enough that I can simply use euclidean distances between coordinates.) Some of the students have cars and can drives others. How can I efficien...
I had to program a similar problem using goto statements. Now we are asked to rewrite our code without using goto statement. I don't know how to begin doing this program. I paste in the previous program code using the goto.
// Eight Queens problem using one dimesional array and goto statement
#include "stdafx.h"
#include <iostream>...
I am writing a dice game simulator in Python. I represent a roll by using a list containing integers from 1-6. So I might have a roll like this:
[1,2,1,4,5,1]
I need to determine if a roll contains scoring combinations, such as 3 of a kind, 4 of a kind, 2 sets of 3, and straights.
Is there a simple Pythonic way of doing this? I've...
Given this array
int [] myArray = {5,-11,2,3,14,5,-14,2};
I must be able to return 3 because the longest down sequence is 14,5,-14.
What's the fastest way to do this?
PS: Down sequence is a series of non-increasing numbers.
...
As part of my rhythm game that I'm working, I'm allowing users to create and upload custom songs and notecharts. I'm thinking of hashing the song and notecharts to uniquely identify them. Of course, I'd like as few collisions as possible, however, cryptographic strength isn't of much importance here as a wide uniform range. In addition, ...
I have a 15 integer column with 5,000,000 rows in a table. Given a input record containing 15 integers I need to compare the input record with the 5,000,000 record table and obtain all matching rows.
Note1: All integers within a row are unique
Note2: the order of columns matching and the input record is not important.
for example: 1, 1...
Im making a online game, and as in many online games i will need loads of data being transfered via internet, so i need to be able to compress data efficiently.
For instance i want to send from my client to the server my character coordinates.
Edit: yeah bad example, let me change the values...
X coordinate(say -32 to 32).(65 diferent...
I have an interesting conceptual problem, and I'm wondering if anyone can help me quantify it. Basically, I'm playing a set of games... and for each game I know the probability that I will win, the probability that I will tie, and the probability that I will lose (each game will have different probabilities).
At a high level, what I wa...
hello everyone I'm trying to find this algorithm on c++ in net but can't, I found this one
// Best solution
function boolean hasLoop(Node startNode){
Node slowNode = Node fastNode1 = Node fastNode2 = startNode;
while (slowNode && fastNode1 = fastNode2.next() && fastNode2 = fastNode1.next()){
if (slowNode == fastNode1 || slowNode...
We have a set of Documents , each has a set of Features.
Given feature A, we need to know what is the probability of having feature B in the same document.
I thought of building a probability matrix , s.t:
M(i,j) = Probability of having feature B in a document , given that feature A is there.
However , we have an additional requirem...
Am trying to find the latest sub-directory from a parent director.
public static DirectoryInfo GetLatestSubDirectory(string parentDirPath)
As of now the implementation is uses the bubble sort algorithm to find the latest by comparing the creation time.
if (subDirInfo.CreationTimeUtc > latestSubDirInfo.CreationTimeUtc)
Am wonderin...
I'm using a customized version of Hacker News popularity algorithm for my social site (items with a number of likes and comments). The algorithm works perfectly but I don't know how to update item scorings correctly (I'm storing the score in item model as meta data).
Now I'm just updating scores on every new like and comment for items ...
I have a collection of 43 to 50 numbers ranging from 0.133 to 0.005 (but mostly on the small side). I would like to find, if possible, all combinations that have a sum between L and R, which are very close together.*
The brute-force method takes 243 to 250 steps, which isn't feasible. What's a good method to use here?
Edit: The combi...
Search engines and databases allow you to use consecutive string search (such as "this is a test"), which matches this is a test that will match, but won't match test this is a.
I know that some databases have built-in features that allow you to use the same functionality without writing a single line of code (e.g. MySQL's full text sea...
Let's say you are taking a video (with the camera in a steady position) and a bird flies through the view of the camera. It should be possible to do image segmentation and automatically remove this bird from the video.
What are these styles of algorithms called and how are they normally accomplished?
...
In my program I have some cubes (simple, xyz location, xyz size). I want bo be able to take one of these cubes and 'Subtract' another cube from it.
So my question, what is a good generic data structure to represent the resulting 3d object, and what kind of algorithm is used to subtract a 3d solid from another?
...
My actual problem is a bit more general that this, but here is a specific example. In basketball, you calculate free throw percentage as:
Free-Throw Percentage (FT%) = Free-Throws Made (FTM) / Free-Throws Attempted (FTA)
I have two teams, and for each team I have the mean and variance of the team's FTM and FTA, so I can model each as ...
I was asked this question in an interview recently.
There are N numbers, too many to fit into memory. They are split across k database tables (unsorted), each of which can fit into memory. Find the median of all the numbers.
Wasn't quite sure about the answer to this one.
...
has anyone of you ever dealt with job scheduling problems with Java?
I have to work on a resource-constrained project scheduling problem and want to ask for some practical tips. Are there any good libs available for implementing algorithms? What are efficient data structures I should use?
edit:
It seems like i have not explained it rig...
I'm currently debugging my transposition table for a chess variant engine where pieces can be placed (ie. originally not on the board). I need to know how often I'm hitting key collisions. I'm saving the piece list in each table index, along with the usual hash data. My simple solution for determining if two positions are equal is failin...