Showing posts with label puzzle. Show all posts
Showing posts with label puzzle. Show all posts

Dog got lost

Your dog got lost in one of the 17 rooms arranged next to each other.
There is a small channel between two adjacent rooms thorough which
that dog can pass. There's a channel between 1-2, 6-7, 7-8, 16-17 and
so on. There is no connection between room # 1 and room # 17. They are
situated at the two ends.

Your aim is to search out the dog in the least number of days. If you
are allergic to dogs or do not like dogs; it doesn't matter. You can
change that noun to anyone whom you love very much and would like to
find out as soon as possible. But, let me continue with that dog in
his problem. (A gentleman has advised long ago ==> Try to become that
man that your pet dog thinks you to be. The world be a real wonderful
place then.)

You can check any 2 rooms in the day time. Please, keep a note that
you cannot perceive if the dog is any of the adjacent rooms from that
particular room in which you are in for checking.

The dog also loves you and tries to find you. But, primarily it is
more active during the night. So, every mid-night it moves either one
room to the right or left. The dog is random in selecting if it would
move right or left and it doesn't believe in any kind of mathematics
or strategy.

You again come and get the opportunity to check any of the 2 rooms
during the day when the dog is waiting silently in its present room
for your visit.

What should be your strategy to find out your lost dog in the least
possible number of days?

looks simple; But not ...:)

-> means writes into.
- means numerical subtraction

There are three operations supported on three registers:
A->R
B->R
A-R->A
----------------------------
A=5, B=3
Transfer the contents of B to A. Finally A should contain 3.

Normal interview puzzle

##########################################
There is a unique number of ten digits, for which the following holds:
* all digits from 0 up to 9 occur exactly once in the number;
* the first digits is divisible by 1;
* the number formed by the first two digits is divisible by 2;
* the number formed by the first three digits is divisible by 3;
* the number formed by the first four digits is divisible by 4;
* the number formed by the first five digits is divisible by 5;
* the number formed by the first six digits is divisible by 6;
* the number formed by the first seven digits is divisible by 7;
* the number formed by the first eight digits is divisible by 8;
* the number formed by the first nine digits is divisible by 9;
* the number formed by the ten digits is divisible by 10.
give the solution with details.

Difficult One

##########################################
There is an array (say 'A') with 'n' (n >= 3) distinct positive integers.
There is an array 'B' with n*(n-1)/2 elements which represents the sum of all the possible pairs of two numbers of the array

Example

A = Set of Distinct +ve Integer = {12,2,3,1}
B = Set of sum of any two elements of A = {12+2,12+3,12+1,2+3,2+1,3+1} = {14,15,13,5,3,4}.

Now, if you are given the array B, get the array A.

interview question

########################################
There are numbers from 1 to N in an array. out of these, one of the number gets duplicated and one is missing. The task is to find out the duplicate number. Conditions: you have to do it in O(n) time without using any auxiliary space (array, bit sets, maps etc..)

puzz1-pendulum

########################################
If a pendulum clock take 2 seconds to give 2 bells when it’s a 2’O Clock.
How many seconds it will take to give 3 bells when it is 3’ O clock?

Inserting a node before the pointer in linked list

########################################
Insert a new node to a link list when u dont know pointer to the starting node. Let u have a pointer P and u have to insert a node before that node.and P is not the starting node.

SOLVED : Swap two variable

SOLVED:-How to swap 2 variable values without using a temp(3rd) variable.

Google question

given an array of n integers A[n]
find maximum and second maximum element in N+logN comparisons

SOLVED:Linked list

In a linked list U have to delete the Node XXX , XXX->link and XXX->info is given

void delete ( NODE XXX ){
----fill u r code here----
}
ANSWER IS THERE IN COMMENTs ,still u can add ur answer .

SOLVED:some Good questions

Let x,y,z be 3 integers . We have to find the greatest of 3 integers, without using relational and conditional operator?
ANSWER IS THERE IN COMMENTs ,still u can add ur answer .