puzzle

How to print out "Hello World!" ?

It's kinda interesting question. Please prints out "Hello World!", but you have to do this in the following code pattern: if(/**you may add your code here**/){ System.out.print("Hello "); }else{ System.out.println("world!"); } this is a Java version, you can also implement it i...

Why swap with xor works fine in c++ but in java doesn't ? some puzzle

Possible Duplicate: Why is this statement not working in java x ^= y ^= x ^= y; Sample code int a=3; int b=4; a^=(b^=(a^=b)); In c++ it swaps variables, but in java we get a=0, b=4 why? ...

Covering dots on a Table

In the Communications of the ACM, August 2008 "Puzzled" column, Peter Winkler asked the following question: On the table before us are 10 dots, and in our pocket are 10 $1 coins. Prove the coins can be placed on the table (no two overlapping) in such a way that all dots are covered. Figure 2 shows a valid placement of the c...

Programming two trains to intersect without positional data or communication (logic puzzle)

A helicopter drops two trains, each on a parachute, onto a straight infinite railway line. There is an undefined distance between the two trains. Each faces the same direction, and upon landing, the parachute attached to each train falls to the ground next to the train and detaches. Each train has a microchip that controls its motion....

Tricky algorithm question

Possible Duplicate: Quickest way to find missing number in an array of numbers Input: unsorted array A[1,..,n] which contains all but one of the integers in the range 0,..,n The problem is to determine the missing integer in O(n) time. Each element of A is represented in binary, and the only operation available is the functio...

Programming problem - Game of Blocks

Hi guys, maybe you would have an idea on how to solve the following problem. John decided to buy his son Johnny some mathematical toys. One of his most favorite toy is blocks of different colors. John has decided to buy blocks of C different colors. For each color he will buy googol (10^100) blocks. All blocks of same color are of sa...

What does "straightforward UF" refer to in the context of the solution to the "liarliar" Facebook puzzle?

I've come across the term "straightforward uf" to describe the solution (algorithm ?) to the following facebook engineering puzzle: liarliar. Does anyone know what this means? ...

Puzzle.. solving product of values in array X

Hello, Can you please help me solving this one? You have an unordered array X of n integers. Find the array M containing n elements where Mi is the product of all integers in X except for Xi. You may not use division. You can use extra memory. (Hint: There are solutions faster than O(n^2).) The basic ones - O(n^2) and one using divi...

designing picture puzzle.

I am planning to develop a jigsaw puzzle game. Now I already have images and image pieces, so we don't need algorithm to cut the image in pieces. On the UI side there would be two sections First section contains the broken images in random order. Second section contains the outline of the full image. User need to drag and drop the the...