Everyone knows of the cracker barrel triangle peg solitare game. You take one peg and jump it over another into an empty hole and the goal is to have only one peg left. In my code for the game board object I have a function sCpeg(int a, int b) which
When I run my code my out put is this ----jGRASP exec: java AgeClientFL Enter birth day: 5 Enter birth month: 5 Enter birth year: 5 Birth: 5/5/5 Today: 1/1/0 Age: 0 Michaels Birth: 5/7/1995 Milestone: 5/7/2016 Age at Milestone: 0 ----jGRASP: operatio
I have a non directed graph that is connected. I want to make it bi-connected by adding minimum number of edges. How can i do it? I tried searching online for this particular algorithm and also tried thinking myself without success. Please help me un
I have a set of objects (rectangles having 4 vertices of (X,Y) each) draw on a map using OpenGL ES. I would want to implement way finding between each of them. For example I have rectangles A,B,C,D,E Structure: A[Vertex(X,Y),Vertex(X,Y),Vertex(X,Y),V
I am trying to implement a randomly generated maze using Prim's algorithm. I want my maze to look like this: however the mazes that I am generating from my program look like this: I'm currently stuck on correctly implementing the steps highlighted in
Let's say you have a text file that contains a few encrypted words. You don't know the encryption algorithm, but you know that the method that the encryption uses its just replacing every letter with another one. Lets say we've got a regular word, 'S
Context I have an application that selects a weighted random entry from a table for which prefix summation (of weights) is a crucial part. The simplified table definition looks like this: CREATE TABLE entries ( id INT NOT NULL PRIMARY KEY AUTO_INCREM
I literally tried everything, tried every solution but it still won't work. It seems like Hoare partition works only in certain cases but once in a while i don't even understand what it is doing. Yes, I know how the algorithm works, but implementatio
I am constructing a btree from some data. Once I construct the btree (i.e. insert all the elements) I no longer insert or remove elements. However the resulting btree is not optimal in a sense that if I can have n maximum elements per node very frequ
I have a 2D plane in three dimensions: x+y+z=1, and I want to generate random points(x,y,z) on the plane. How can I choose these points so that they are distributed uniformly? --------------Solutions------------- Eugene had it almost right: generate
Problem I came across is as follows: We have n tasks with l_i and w_i being completion time and weight of task i. Come up with an algorithm that minimizes sum for all i of f_i * w_i where f_i is time when task i was finished. If for example some task
As far as I know the method to find distance between 3D point to triangle is to check if the point is lie inside triangle's plane so the distance will be closest distance to triangle's plane, otherwise if the point lie outside of the triangle then th
I am trying to find the largest prime value of a big number, but it takes far too long. For example, to find the largest prime of 999999999, it takes about 55 seconds. How can I improve this? require 'prime' def highestprime num i = 1 counter = 0 cou
I recently saw this question on a programming challenge, and I'd like to know which well-known CS algorithm this resembles. I implemented a crude solution. I know there must be a better way to do it, but I'm not sure of the terms to search for. It se
I have been working on making a neural network that has a goal, of hitting a moving target, it has inputs based on the distance from the shooter to the target from both axis, the rotation of the shooter, and the wind speed. Every 5 seconds the shoote
A container stores pointers to integers. I would like to find integer=66 using normal variable. When I am trying to do this by pointer it is ok. Code: #include <iostream> #include <algorithm> #include <vector> using namespace std; int ma
I have a very large dataset (500 Million) of documents and want to cluster all documents according to their content. What would be the best way to approach this? I tried using k-means but it does not seem suitable because it needs all documents at on
Because we know that the integers representing a vertex can take values in [0,...,|V|-1] range, we can use counting sort in order to sort each entry of the adjacency list in O(V) time. Since we have V lists to sort, that would give us a O(V^2) time a
I'm studying Codility Counting Lesson (https://codility.com/media/train/2-CountingElements.pdf) and I need help to understand the fastest solution. I would like to know what does counting function means: count = counting(A, m) The Problem: You are gi
I have one requirement where we need to form a dynamic SQL query which will have 100 OR conditions as shown below, The number of parameters inside the in clause can very from 1 - 50. All the parameters will come from UI. No of Records in GK_QUEUE = 1