puzzle

Identify file format from header?

I got some files , which has header, {AD08E961-F492-11d1-B0EA-00AA00683350}2.00:en_US:45015:021 Can you please help me in finding out, from which software it is created. Only information I have is, This file is created around 2000-2003. I want to parse these files and want to extract some data. Thanks, Sunny. ...

How to most elegantly iterate through parallel collections in C#?

var a = new Collection<string> {"a", "b", "c"}; var b = new Collection<int> { 1, 2, 3 }; What is the most elegant way to iterate through both yielding a set of results "a1", "b2", "c3"? ...

Programmer Puzzle: Encoding a chess board state throughout a game.

Not strictly a question, more of a puzzle... Over the years, I've been involved in a few technical interviews of new employees. Other than asking the standard "do you know X technology" questions, I've also tried to get a feel for how they approach problems. Typically, I'd send them the question by email the day before the interview, an...

Algorithm for solving the "Unblock Me" puzzles

"Unblock Me" is an iPhone game (screenshot here: http://www.kiragames.com/games/unblockme-free.) I was wondering how would one go about solving this programmatically and what class of algorithms help out here. Has anyone cracked this? ...

Multithreading Puzzles

I'm trying to come up with some programming puzzles focused on multi-threading. Most of the problems I've been able to come up with, so far, have been pretty domain specific. Does anybody have any decent programming puzzles for developers attempting to learn the core concepts of multi-threading applications? ...

N-Queens Problem..How far can we go?

The N-Queens Problem: This problem states that Given a chess board of size N by N. Find the different permutations in which N queens can be placed on the Board without any one killing each other. My question is: What is the maximum value of N for which a program can calculate the answer in reasonable amount of time? Or what is the lar...

Running out of java heap space- 15 puzzle problem.

G'day all, I tried the solution for eight puzzle problem posted here by joel Neely and played around with it and modified it so that can be used to solve for higher grids[Changed the String representation of the grid to two dimensional integer representation and modified the logic accordingly]. However the modified code can solve th...

Clever algorithm to find times where the sum of digits equals the number of segments in the digital dispay

So, my friend sent me a puzzle this morning: Find the number of distinct times of the day (using 24-hour display and assuming that morning hours are presented as 8:15 as opposed to 08:15) where the number of segments are equal to the sum of the digits. Eg. 8:15 has 7+2+5=14 segments in electronic format and the sum of t...

How to mix two ARGB pixels ?

How can I mix two ARGB pixels ? Example Here A is (Red with Alpha) and B is ( Blue with Alpha ). ...

Finding the largest positive int in an array by recursion

I decided to implement a very simple program recursively, to see how well Java handles recursion*, and came up a bit short. This is what I ended up writing: public class largestInIntArray { public static void main(String[] args) { // These three lines just set up an array of ints: int[] ints = new int[100]; java.util.Ran...

Formula for the max number of paths through a grid?

Given a grid of open spots, and a certain number of tiles to place in those spots, what function f(openSpots, tilesToPlace) will give you the number of continuous paths you can form? Continuous paths are placements of the tiles such that each tile shares an edge with another. (Only corners touching is not good enough. So (0, 1) and (0, ...

How to combine two generators in a non-trivial way.

Hi, I have a generator which produces all positive integers that are powers of 2, and another which produces all integers that are powers of 3. I now need to use those to produce integers of the form 2^i*3^j where i,j >=0,0 in the increasing order. The point of using generators is to reduce memory consumption, I think. I have been tryin...

What makes the following code print false?

public class Guess { public static void main(String[] args){ <sometype> x = <somevalue>; System.out.println(x == x); } } i have to change sometype and somevalue so that it returns false? is it possible? ...

Given a function for a fair coin, write a function for a biased coin?

I came across this reported interview question when doing some reviewing (the following quote is all the info I found about the problem): Given a function for a fair coin, write a function for a biased coin that returns heads 1/n times (n is a param) At first glance I wrote: int biased_coin(n) { //0=Tails, 1=Heads int sum...

How does this pointer arithmetic work?

#include <stdio.h> int main(void){ unsigned a[3][4] = { {2,23,6,7}, {8,5,1,4}, {12,15,3,9} }; printf("%u",*((int*)(((char*)a)+4))); return 0; } The output in my machine is the value at a[0][1] i.e 23.Could somebody explain how is this working ? Edit: Rolling Back to old yucky code,exactly what was presented to me :P ...

Grid based puzzle board game block removal algorithm

I have a "samegame" grid represented by a 1D array of integers. 0 to 63 to represent an 8x8 grid. the rules are that same coloured blocks of two or more can be removed by clicking on them. blocks then slide down from above. if a column is empty columns other columns move in from the sides. when someone clicks on the green blocks in t...

C puzzle: Output of printf should be '5' always

Hi, I found this puzzle in a C aptitude paper. void change() { //write something in this function so that output of printf in main function //should always give 5.you can't change the main function } int main() { int i = 5; change(); i = 10; printf("%d", i); return 0; } Any solutions.? ...

AI: selecting immediate acceleration/rotation to get to a final point

I'm working on a game where on each update of the game loop, the AI is run. During this update, I have the chance to turn the AI-controlled entity and/or make it accelerate in the direction it is facing. I want it to reach a final location (within reasonable range) and at that location have a specific velocity and direction (again it doe...

How to create a biased number generator using a pair of six sided dice

What is the most efficient way to use a pair of six sided dice to generate a random number in [1, 4] unevenly: it should produce 1 in 40% of the time, 2 in 30%, 3 in 20%, and 4 in 10%. Please justify the correctness of the method and give an algorithm. Dice could be of different colors. Note: the only random number generators availa...

javascript ken ken puzzle generator

Heloo, I am in need of generating a ken ken puzzle in javascript.. but have no idea where to start. any help would be appreciated. ...