## Open Sublime Text from Terminal in macOS

Steps:

Step 1: Open Terminal

Step 2: Hit below command.

For mac 10.8+

sudo ln -s /Applications/Sublime\ Text.app/Contents/SharedSupport/bin/subl /usr/local/bin/subl

Step 3: Now you can open sublime with the following command

subl "/a/path/to/the/directory/you/want/to/open"

More info: Run subl --help,
Usage: subl [arguments] [files]         edit the given files   or: subl [arguments] [directories]   open the given directories   or: subl [arguments] -               edit stdinArguments:  --project <project>: Load the given project  --command <command>: Run the given command  -n or --new-window:  Open a new window  -a or --add:         Add folders to the current window  -w or --wait:        Wait for the files to be closed before returning  -b or --background:  Don't activate the application  -s or --stay:        Keep the application activated after closing the file  -h or --help:        Show help (this message) and exit  -v or --version:     Show version and exit--wait is implied if reading from stdin. Use --stay to not switch backto the terminal when a file is closed (only relevant if waiting for a file).Filenames may be given a :line or :line:column suffix to open at a specificlocation.

References: http://www.sublimetext.com/docs/2/osx_command_line.html

Tags:

# open sublime text 3 from terminal,open sublime from terminal ubuntu,open sublime from terminal mac os,open sublime from terminal windows,subl command not found mac sublime text 3,how to open sublime text,open file in sublime from terminal ubuntu,sublime text osx terminal,subl command not found,open sublime from terminal windows,open sublime from terminal ubuntu,bin/subl: no such file or directory,sublime open bash,ln: /usr/local/bin/sublime: permission denied,sublime terminal view,set editor to sublime,ln permission denied mac,sublime command line ubuntu,ln: /bin/subl: operation not permitted,sublime command line windows 10,sublime text command line plugin,sublime commands,mac sublime text 2 command line,sublime_text command options

## Best Karachi Bakery Biscuits for to take Home, to Give Gift, to give on Birthday, For Party

I didn’t get even a single penny from Karachi bakery. so don’t think it is a promotional Article.

I have used these Biscuits from 2years when I was working in Hitech city Hyderabad. now I am living in Bengaluru but these biscuits are my favorite till now.

Note: I have created this list for myself for Deepavali. Now I am sharing my List.

List of Best Best Karachi Bakery Biscuits: not in a particular order

# 1. Fruit Biscuits (Code: KBBI 283)

Most Famous Karachi bakery Product

# 2. Fruit Biscuits (Code: KBBI 284)

Most Famous Karachi bakery Product

# 3. Chocolate Cashew Biscuits (Code: KBBI 291)

best for a chocolate lover.

# 4. Sugarlite Cashew Cookies- KBBI 232

best for sugar related people.

# 8. Kaju Badam Biscotti- KBBI 285

This is my list.

## Machine Learning Tutorial | Beginner to Advanced Level.

I am writing a series on Machine Learning. It will take more than 3 months for me. Because I write articles only on weekends.

Currently, I am working as Data Scientist in Sentienz Solutions Pvt. Ltd. Sentienz is primarily a technology Solutions company supplying turn-key solutions based on the latest technologies in Cloud, Bigdata, Text Mining and Deep learning space.

## History of Artificial Intelligence

Advances in artificial intelligence and the science behind it can be broken into a few main chapters, described below:

### AI in Fiction

Works of fiction detailing inanimate beings that display consciousness date back centuries. However, the first meaningful milestones in the history of artificial intelligence are tied to the invention of the computer and the early study of formal and mechanical reasoning.

### Turing and Early Theory of Computation

Study of the theory of computation suggested that machines would be able to simulate a wide range of deductive acts through binary operations. The Turing-Church thesis eventually proposed that any “effectively calculable function is a computable function”, meaning that anything that a human can calculate through an algorithmic process, a machine can too calculate.

These ideas eventually led researchers in neurology and cybernetics to begin exploring the idea of building an electronic brain. Walter Pitts and Warren McCulloch formally proposed designs for artificial neurons in 1943.

### Dartmouth and the Formalization of AI Research

In 1956, at a workshop at Dartmouth college, several leaders from universities and companies began to formalize the study of artificial intelligence. This group of individuals included Arthur Samuel from IBM, Allen Newell and Herbert Simon from CMU, and John McCarthy and Marvin Minsky from MIT. This team and their students began developing some of the early AI programs that learned checkers strategies, spoke English, and solved word problems, which were very significant developments.

### Increased Computing Power Enables AI Revolution

After this initial burst of progress in the 1950’s, little more progress was made until the late 90’s, when increases in computing power made it possible to apply machine learning techniques that were very slow when computational resources were more limited. This led to artificial intelligence/machine learning techniques being applied to several fields, including medical diagnosis, data mining, and logistics planning.

Continued and steady progress has been made since, with such milestones as IBM’s Watson winning Jeopardy! and the release of Xbox Kinect which reads and responds to body motion and voice control. Additionally, artificial intelligence based code libraries that enable image and speech recognition are becoming more widely available and easier to use. Thus, these AI techniques, that were once unusable because of limitations in computing power, have become accessible to any developer willing to learn how to use them.

## How Does Artificial Intelligence Work?

Artificial intelligence “works” by combining several approaches to problem-solving from mathematics, computational statistics, machine learning, and predictive analytics.

A typical artificial intelligence system will take in a large dataset as input and quickly process the data using intelligent algorithms that learn and improve each time a new dataset is processed.

In order to fully understand how an artificial intelligence system quickly and “intelligently” process new data, it is helpful to understand some of the main tools and approaches that AI systems use to solve problems. Below are the most common techniques used in artificial intelligence systems today:

### Neural Networks

Neural networks  – or more specifically, artificial neural networks – are computing systems that progressively improve their ability to complete a task without specific programming on the task. The approach that these artificial neural networks use is based on the method that actual biological neural networks in human brains use to solve problems. Read more about artificial neural networks.

### Statistical Learning and Classification

A classifier is a function that uses pattern recognition and pattern matching to identify the closest match. In supervised learning, the classifier will attempt to match the pattern out of a limited set of options. In unsupervised learning, there is no predefined pattern that the classification function needs to be used with.

Classifiers are ideal for artificial intelligence applications because their predictive models are adjusted and improved as they process more new data. Read more about classifiers and statistical learning.

### Optimized Search Tactics

Typically exhaustively scanning through every possible solution is not a very efficient way to solve a problem, especially in artificial intelligence applications where speed may be very important. However, it is possible to apply rules of thumb or heuristics to prioritize possible solutions and complete the problem-solving process more quickly.

Some search algorithms will also use mathematical optimization to solve problems. A mathematical optimization is an approach that involves taking the best guess to the solution based on limited information, and then evaluating “nearby” solutions until the best answer is reached. This can be thought of as using “blind hill climbing” as an approach to reach the solution, or “top of the hill.”

There are many other approaches to search optimization, including beam search, simulated annealing, random optimization, and evolutionary computation, which more specifically includes various swarm intelligence algorithms and evolutionary algorithms.

### Other Artificial Intelligence Techniques

Various approaches to artificial intelligence design and programming have been taken from concepts in logic programming and automated reasoning. These techniques allow programs to “reason” through problems.

There have also been many models and approaches designed for situations where information is uncertain or incomplete. Some of these tools include Bayesian networks, hidden Markov models, Kalman filters, decision theory and analysis, and Markov decision processes. Even certain programming languages, like Prolog, have been adapted to be used in artificial intelligence applications.

Tags:

## Applications of Artificial Intelligence | AI vs machine learning

There are many applications for artificial intelligence being used today, and many more that are being researched. A few of the more popular uses of artificial intelligence systems today are in industries like healthcare, automotive technology, and video games, to name a few. Below are a few of the common uses of artificial intelligence in the industries where it is already gaining popularity.

### Healthcare

In healthcare, the number of applications for artificial intelligence is expanding rapidly. Artificial intelligence is currently being used to interpret lab results in blood tests and genetic testing. There are also efforts being made to use AI to interpret medical imaging, such as X-rays and MRI results.

### Aviation

Artificial intelligence is commonly used in flight simulations and simulated aircraft warfare. Many aircrafts are also equipped with sensors which feed data to a system that uses AI to evaluate the mechanical ‘health’ of the aircraft.

### Automotive

Artificial intelligence is a growing component of the automotive industry. Many companies, like Tesla, are incorporating self-driving technology into their vehicles. Self-driving vehicles use AI to read data of the vehicle’s surroundings and respond to other drivers, lines on the road, and similar feedback read by the vehicle’s sensors.

### Finance

Financial institutions have been using artificial intelligence to analyze market trends and even automate trades based on various market indicators and triggers. Many banks and financial institutions have also been using AI algorithms and neural network systems to identify fraudulent bank and credit charges, and then trigger human managed investigations.

### Video Games

Many debate how much AI is truly used in video games. This is because machine learning techniques are rarely used and games typically only choose between a handful of automated responses, rather than actually “learning” to defeat their opponents. However, as the gameplay has grown in complexity, so has the AI programming that governs it. AI is most commonly seen when the game player interacts with non-player characters in a game. Actions of these characters are often governed by complex AI algorithms that depend on the game player’s actions.

### Applications to Other Industries

As stated above, artificial intelligence is really the application of machine learning, predictive analysis, and automation, so its applications are vast. AI has been spreading rapidly to technology-driven industries, so it is quickly becoming an important element of several other major industries, including:

• Manufacturing – AI is being used to automate the building of vehicles and other large machinery and equipment
• Marketing – AI solutions are being used to analyze user behavior and more effectively target potential customers
• Employee Recruiting – AI technology is now frequently used to match employers to job seekers
• Transportation – GPS systems and city planners use AI programs to identify and suggest the most efficient routes

As time goes on and artificial intelligence techniques become more widely understood and accessible, more industries will surely benefit from the efficiency and scaling effects that AI can provide.

Tags:

## Artificial Intelligence vs Machine Learning

Machine learning and artificial intelligence are very related and often confused as being one in the same.

In short, machine learning is the science and approach that enables the creation of artificially intelligent machines and programs.

Artificial intelligence frequently uses machine learning techniques to improve the system’s ability to “learn” and better interpret and react to inputs. Many in the field only consider a system to be “intelligent” when it uses machine learning to learn and improve.

Tags:

## Artificial Intelligence Definition:

Artificial intelligence is the application of rapid data processing, machine learning, predictive analysis, and automation to simulate the intelligent behavior and problem-solving capabilities with machines and software.

It is the intelligence of machines and computer programs, versus natural intelligence, which is the intelligence of humans and animals.

Machines and programs that use artificial intelligence are typically designed to read and interpret a data input and then respond to it by using predictive analytics.

Tags:

# artificial intelligence definition,artificial intelligence examples,applications of artificial intelligence,artificial intelligence pdf,artificial intelligence article,artificial intelligence wikipedia,artificial intelligence future,what is artificial intelligence in computer,artificial intelligence examples,history of artificial intelligence,advantages of artificial intelligence,types of artificial intelligence,artificial intelligence future,artificial intelligence journal,notes on artificial intelligence,components of artificial intelligence,definition of artificial intelligence pdf,areas of artificial intelligence,categories of artificial intelligence,types of artificial intelligence systems,artificial intelligence article pdf,best definition of artificial intelligence,what is artificial intelligence used for,artificial intelligence articles 2018,artificial intelligence techniques notes,artificial intelligence magazine article,types of artificial intelligence ppt,artificial intelligence explained simply,artificial intelligence in a sentence,what is artificial intelligence exactly,bbc what is artificial intelligence,breaking down artificial intelligence,ai movie explained,ai for dummies pdf,what is artificial intelligence in healthcare,sub areas of artificial intelligence,6 types of artificial intelligence,components of ai program,three levels of artificial intelligence,futurism ai infographic

## Long Weekends in 2019 India | 2019 long weekend list

Unlike 2017 or 2018, there seems to be a very less long weekend in 2019 next year.

Many holidays are on Saturday or Sunday or midweek. There are 15 long weekends in 2018, 13 in 2017, but only 7 in 2019 – if you are lucky at some state/company-specific holidays, there may be more.

Still, this is my compilation of the 2019 weekend. You can use it to start planning a 2019 trip.

long weekends in 2019 india

holidays in 2019 in india,calendar 2019 india pdf,holiday 2019 india,2019 calendar with indian holidays pdf,january 2019 calendar with holidays india,bank holidays in 2019 in india,march 2019 calendar with holidays india,holiday list 2019 maharashtra,2018 calendar with indian holidays,2019 holi date,holidays in 2018 in india,hindu calendar 2019 with tithi,calendar 2019 pdf,long weekends in 2018 usa,kalnirnay calendar 2019 marathi,2019 government holidays in tamilnadu,tcs holidays 2018,august weekend breaks,travel plan calendar,weekend calendar 2018,vacation list 2018,2020 calendar with indian holidays,holi long weekend 2018,places to visit on long weekends,long weekends in 2019 usa,weekend getaways in april 2018,january 2019 calendar with holidays india,2019 calendar with indian holidays pdf,central government holidays 2019,bank holidays 2019 maharashtra,holiday list 2019 west bengal,long weekends in 2018 in india,long weekends in 2018 karnataka,long weekend getaways in india,dussehra weekend trip,is sunday a weekend in india,long weekend in august 2018 usa,long weekend plans near me

# Referral Code –t74cJ

Hi, everyone, Google India eventually launched the fastest UPI payment app for Indian customers, they launched the “Google Pays” app app store for fast and fast payments, using UPI transfers.

Referral Reward has Increased, Now Earn 201/Refer Each … Also Get Rs.51 On Signup (Check Referral Amount in Your Refer & Earn Section)

Google Pay (formerly Google Tez) is a new payment app for Google, and remit money to friends, immediately receive payment directly from your bank account, and pay for Google’s new digital payment app for Google Tez near India coffee shop.

Use NPCI (Indian National Payments Corporation) Unified Payment Interface (UPI) to make simple and secure remittance through Google Pay.

# How to apply referral code in Google Pay / Tez

Install and open the app:

3) First select the language preference.

4) Go to >>Top right menu>>Referral code>>Enter Tez App Referral code “t74cJ

Note: I have tested for my referral code it is working but i don’t know about other..

5) Now enter the mobile number you registered in your bank account.
6) Select the Google account you want to select during registration.

7) Then set the lock screen password or set a new Google PIN code.

8) That’s it! You are now registered in Google’s tez app.

9) Now send 1 rupee(because the first transaction is needed to get money) to my account or any other friends account (Google pay ID: rahulpatel11315@okhdfcbank ). now to will get 201 rupees as first sign up.

10). To send money in G Pay option : New -> UPI or QR -> rahulpatel11315@okhdfcbank

11). Important: Till now I have returned All people 1 rupee, so feel free to send 1 rupee to me.

Tags:

## Zomato Referral Code: RAHU32006

Download the Zomato App and Use my Zomato Promo Code to get up to Rs 200 credit. Zomato recently released a Zomato Order app and they have started the refer and earn program also.

In which they are giving Rs 200 per referral. And the new user will also get Rs 200 Zomato credit. Also when you order apply this

Zomato referral coupon code RAHU32006 to get a discount of flat Rs 100.

With the Zomato order app, you can order anything from your nearest restaurant. They are now giving a good offer and discount.

### Zomato Refer and Earn Offer

Now you can earn more Zomato credit with a new refer and earn program. For each friend, you refer to download the Zomato app. When they order food from Zomato with your Zomato referral code. He will get Rs 100 flat discount and you will earn Rs 100 credit.

So just start referring your friend to download the Zomato app and tell them to order so you both get some benefit. Do it asap, because this offer is for a limited time.

### How to Get RS 100 off:

• Now signup with your mail or FB.
• Now go to the Credit section, you will found that it is preloaded with some credit. They are giving credit up to Rs 200. It depends on your luck.
• Now select the restaurant and order some food.
• At the time of payment using this Zomato Promo code to get a Rs 100 extra discount.

### How to order Free Food From Zomato App

• Open the Zomato app and select your location, it will list all the nearby restaurant.
• Now order food.
• Enter an address and verify the phone number.
• Now apply Zomato Promo Code, you will get Rs 100 discount.
• Now make payment. That’s it.

TAGS:

zomato referral code india
zomato referral code
zomato promo code
zomato gold promo code
zomato first order promo code
zomato promo code for existing user
how to get zomato referral code
how to get my zomato referral code
zomato first order code, zomato referral code in app, Zomato Referral Code, Zomato Referral, Referral Code, zomato promo code,zomato gold referral code,zomato referral code 2018,zomato referral code india,how to get my zomato referral code,zomato referral code 2019,zomato invite code piggy bank,how to share zomato referral code,uber eats promo code,swiggy offers,zomato gold,uber eats offers,foodpanda offers,zomato gold promo code,zomato new user coupon,zomato new user code,zomato app download for android,offers on home delivery food,refer and earn food apps,zomato invite code piggy bank,how to earn points on zomato,how to verify phone number on zomato,zomato server down,zomato credits trick,how to use zomato credits for payment,zomato membership activation code,zomato promo code for existing user,how to send referral  code in swiggy,Zomato, Zomato Promo Code

## Top 10 Commonly Asked Interview Puzzles

Here is a list of 10 Commonly Asked Interview puzzles which have been asked on a Microsoft, Google, Amazon, Adobe, Samsung, Oracle Interview and so on.

Some Other Interview Puzzles

1. While drafting the list of top 10 puzzles our team successfully reviewed and selected 10 best puzzles asked in these company interviews:

## 1 run to win from 1 ball with 1 wicket

If a team requires 1 run to win from 1 ball with 1 wicket remaining, and the wicket-keeper stumps the batsman out on a wide ball, what is the final result of the match?

The batting team wins(by 1 wicket). The wide happened first and then the stumping. So, with the wide itself, the batting team wins, and all other actions after it (the result of the match is decided) remain void.

Popular incident:
One most popular and similar incident is from IND vs SL in 2010
When Sehwag was batting on 99* and IND needed 1 run to win.
To avoid Sehwag from scoring a century, Suraj Randiv bowled a deliberate no-ball and thus, IND won by the run given by No Ball.
Later on, Dilshan and Randiv were found guilty and were punished.

## 10 batsmen gets out in 10 consecutive balls

One simple question for cricket lovers. Batting team comes for batting and the 10 batsmen get out in 10 consecutive balls, without making any attempt to make any runs. Question is which number batsmen will be shown not out on scorecard?

The person who did not face any ball is shown not out
1st ball 1
2nd ball 3
3rd ball 4
4th ball 5
5th ball 6
6th ball 7
..next over
1st ball 2
2nd ball 9
3rd ball 10
4th ball no.11
.. remaining no.8

If all batsman bowled out…then it is number 8

## 3 Runs Required in 2 balls

### Q: The batsman is on 98 and the non-striker is on 97. How will both batsman score centuries as well as winning the match? cricket lovers if you are really genius and you have the knowledge of cricket solve it?

Striker batsman takes 3 run and 1 run short then his century has done then non-striker batsman heat six or four.

I think its possible by duck worth-lewis method
Ex: sum runs to need in 43.1 overs,

Striker playing 42.6 ball. he hit 2 runs completes his century.

Now last ball of innings(43.1) nonstriker comes to play n hits 3 or 4 and he also made a century.

## And now:

Both the batsmen now dances on opuammm Ganganam style……..:p :p

## Max runs by single player in cricket match

Q: How many max runs can be scored by a single player in cricket one-day match puzzle?
How many runs a single player can score in One day match (50 overs/ 300 balls)… No ‘no balls’, no wides, no extras, no overthrows.
So how much runs he can score max?

The correct answers is That would be 1653 runs. If he hits first 5 balls of an over for 5 sixes and scores 3 runs of the last ball( to retain strike)…and scores 6 sixes of the last over(as he does need to retain strike now),
that would make a calculation like… 49*5*6+49*3+6*6 = 1653 runs

## 2 batsmen are on 94. 2 balls remaining and 7 runs to win. Both batsmen make 100 & win the match?

Striker batsman hits the ball for 3 runs but when he runs he made 1 run short and fielder throw the ball and batsman get 4 more runs by through by.by this he got 6 run and nonstriker batsman will reach at striker end and he made 6 runs at last ball.

1)The batsman facing last before ball scored one run by placing the ball back to the keeper.
2) The ball hits the keepers helmet placed in the ground.
3) So the umpire signals 5 runs penalty. This is added to batsman’s score. So he made a century and now he is in non-strikers end and the scores are level.
4) The batsman facing the last ball hits six and he too scored century and win the match

## Two batsmen are each on 94 runs. 7 runs are needed to win in the last 3 balls and both batsmen make 100 not out. How? How can it be done with just the last 2 balls?

Batsman1 hits 4.
Then he takes 3 runs but 1 run short intentionally.
So 2 runs considered 100* for batsman1.
Batsman2 will be on Strike and he hits 6.
100* for batsman2.

:
Commentator 1:
Last 3 balls left, 7 runs needed, McGrath is bowling, knowing the habit of Ganguly, Gilchrist is standing close to wickets. Mc bowls, Ganguly takes risk come two steps out of the crease and hits the ball, OMG it’s a huge hit, the ball is out of the stadium and hit the standing car but what the hell is this, looks like he tried too hard, his muscles got stretched.

Commentator 2:
It looks like he got seriously injured, well there is two good news for India, they are just 1 run short of the win, and Ganguly has also made his 100 along with one bad news Ganguly is not able to stand and he is retired hurt. 🙁

Commentator 1:
Here comes Mr. Wall, Rahul Dravid, 1 run in 2 balls is looking like a baby chase when Rahul is in batting and on another side it is master blaster Sachin. McGrath is ready to bowl 2nd last ball of the game, Rahul played it on mid off, running fast, Martyn got the ball, and what is this going on, a direct hit on the stumps, Rahul was clearly few inches away, he even did not see Umpire decision and running towards Pavilion.

Commentator 2:
What a twist has come in this match, 1 ball 1 run, looks easy when Sachin is on strike and he is set batting at 94 but he is six-run away from his hundred, will he try for 1 run or will he hit six, time will show, here comes Mc with the last ball, it’s bouncer, Sachin pulled it.

Ohhhh what the hell what a catch taken by this young man.
in yellow dress sitting with a beautiful lady in the crowd.
Commentator 1:

looks like an Australian fan, he is super excited trying to feel virtual victory.

Commentator 2:
What a match it was, I can’t believe it that both Saurav and Sachin have made their 100, both are not out too. It all looks scripted.
Commentator 1:
Ohhh yeah, it all looks so scripted,

## Two Trains and a Bee

Two trains are on the same track a distance 100 km apart heading towards one another, each at a speed of 50 km/h. A Bee starting out at the front of one train, flies towards the other at a speed of 75 km/h. Upon reaching the other train, the Bee turns around and continues towards the first train. How many kilometers does the Bee travel before getting squashed in the collision of the two trains?

Solution:

Let the first train moves at u km/h
second train moves at v km/h
distance between trains be d km
speed of Bee is f km/h
time taken by trains to collide = d/(u+v)
distance travelled by bee = f*d/(u+v) = 75* 100/(50+50) = 75

## Break the Detective's Code

A detective who was mere days away from cracking
an international oil smuggling ring has suddenly gone missing.

While inspecting his last-known location,
officers find a note:

710 57735 34 5508 51 7718

Currently, there are 3 suspects:
Bill, John, and Todd.

Can you break the detective’s code
and find the criminal’s name?

Criminal’s name is BILL
You Rotate the note/code by 180 degree
BILL IS BOSS hE SELLS OIL
8177 15 8055 43 53775 017

## Age of Three Daughters

A census taker approaches a woman leaning on her gate and asks about her children. She says, “I have three children and the product of their ages is 72. The sum of their ages is the number on this gate.” The census taker does some calculation and claims not to have enough information. The woman enters her house, but before slamming the door tells the census taker, “I have to see to my eldest child who is in bed with measles.” The census taker departs, satisfied

### For 72:

The prime factors of 72 are 2, 2, 2, 3, 3; in other words, 2 × 2 × 2 × 3 × 3 = 72
This gives the following triplets of possible solutions;
Age oneAge twoAge threeTotal (Sum)
117274
123639
132428
141823
161219
18918
221822
231217
24915
26614
33814
34613
Because the census taker said that knowing the total (from the number on the gate) did not help, we know that knowing the sum of the ages does not give a definitive answer; thus, there must be more than one solution with the same total.
Only two sets of possible ages add up to the same totals:
A. 2 + 6 + 6 = 14
B. 3 + 3 + 8 = 14
In case ‘A’, there is no ‘eldest child’ – two children are aged six (although one could be a few minutes or around 9 to 12 months older and they still both be 6). Therefore, when told that one child is the eldest, the census-taker concludes that the correct solution is ‘B’.

## 2 Player and N Coin

There are n coins in a line. (Assume n is even). Two players take turns to take a coin from one of the ends of the line until there are no more coins left. The player with the larger amount of money wins.
Would you rather go first or second? Does it matter?
Assume that you go first, describe an algorithm to compute the maximum amount of money you can win.
Note that the strategy to pick maximum of two corners may not work. In the following example, first player looses the game when he/she uses strategy to pick maximum of two corners.
Example 18 20 15 30 10 14
First Player picks 18, now row of coins is
20 15 30 10 14
Second player picks 20, now row of coins is
15 30 10 14
First Player picks 15, now row of coins is
30 10 14
Second player picks 30, now row of coins is
10 14
First Player picks 14, now row of coins is
10
Second player picks 10, game over.
The total value collected by second player is more (20 + 30 + 10) compared to first player (18 + 15 + 14). So the second player wins.
Puzzle Solution:
Going first will guarantee that you will not lose. By following the strategy below, you will always win the game (or get a possible tie).
(1) Count the sum of all coins that are odd-numbered. (Call this X)
(2) Count the sum of all coins that are even-numbered. (Call this Y)
(3) If X > Y, take the left-most coin first. Choose all odd-numbered coins in subsequent moves.
(4) If X < Y, take the right-most coin first. Choose all even-numbered coins in subsequent moves.
(5) If X == Y, you will guarantee to get a tie if you stick with taking only even-numbered/odd-numbered coins.
You might be wondering how you can always choose odd-numbered/even-numbered coins. Let me illustrate this using an example where you have 6 coins:
Example
18 20 15 30 10 14
Sum of odd coins = 18 + 15 + 10 = 43
Sum of even coins = 20 + 30 + 14 = 64.
Since the sum of even coins is more, the first player decides to collect all even coins. He first picks 14, now the other player can only pick a coin (10 or 18). Whichever is picked the other player, the first player again gets an opportunity to pick an even coin and block all even coins.

## 24 from 8,8,3,3 Puzzle

How can I get the answer 24 by only using the numbers 8,8,3,3?
You can use add, subtract, multiply, divide, and parentheses.
Solution:
8/(3-(8/3))
= 8/(1/3)
= 24
Another variation:
Bonus rules: also allowed are logarithms, factorials, and roots
Solution:
(3!/∛8)*8 or
√(8×8)×√(3×3) or
(3! – 3) x √(8 × 8)

## 21 Matchstick Puzzle

Write a program for a matchstick game being played between the computer and a user. Your program should ensure that the computer always wins. Rules for the game are as follows:
− There are 21 matchsticks.
− The computer asks the player to pick 1, 2, 3, or 4
matchsticks.
− After the person picks, the computer does its picking.
− Whoever is forced to pick up the last matchstick loses the game.
This is the heart of the program.
if user picks 1 stick then computer can pick 4 sticks
that means, 5 (i.e. max+1) sticks will be picked out for each round.
For 4 rounds, 20 sticks are out and only 1 stick will be left.
And user picks it, he lose the game.

## A King, 1000 Bottles of Wine, 10 Prisoners and a Drop of Poison

You have 1000 bottles of wine but one of them is poisoned! You want to find out exactly which bottle is poisoned.

You have 1000 bottles of wine but one of them is poisoned! You want to find out exactly which bottle is poisoned. To do this, you have access to an unlimited number of prisoners that you can feed wine to. If a prisoner drinks from the bottle that is poisoned, they will die after 24 hours. Prisoners are also allowed to drink from multiple bottles. Assuming that the amount of wine and prisoners is unlimited, what is the least number of prisoners needed to identify the exact bottle that is poisoned within 24 hours?
Think in terms of binary numbers. (now don’t read the solution, give a try).
Number the bottles 1 to 1000 and write the number in binary format.
bottle 1 = 0000000001 (10 digit binary)
bottle 2 = 0000000010
bottle 500 = 0111110100
bottle 1000 = 1111101000
Now take 10 prisoners and number them 1 to 10, now let prisoner 1 take a sip from every bottle that has a 1 in its least significant bit. Let prisoner 10 take a sip from every bottle with a 1 in its most significant bit. etc.
prisoner = 10 9 8 7 6 5 4 3 2 1
bottle 924 = 1 1 1 0 0 1 1 1 0 0
For instance, bottle no. 924 would be sipped by 10,9,8,5,4 and 3. That way if bottle no. 924 was the poisoned one, only those prisoners would die.
After four weeks, line the prisoners up in their bit order and read each living prisoner as a 0 bit and each dead prisoner as a 1 bit. The number that you get is the bottle of wine that was poisoned.
1000 is less than 1024 (2^10). If there were 1024 or more bottles of wine it would take more than 10 prisoners.

## 15 minutes with 7 minute And 11 minute sand hour glasses

I have two sand hour glasses:
1. A 7 minute one and
2. An 11 minute one.
Using just these 2 sand hour glasses, how can i measure time as 15 minutes ?

1. Start both the 7 minute hour glass & 11 minute hour glass.

2. Wait till the 7 minute hour glass times out. Time is 7 minute!
3. Restart the 7 minute hour glass. At this time 11 minute hour glass will have 4 minutes left to time out.
4. As soon as 11 minute glass times out invert the 7 minute hour glass. Total time now is 11 minutes.
5. After inverting 7 minute hour glass, it will now have 4 minutes left for time out.
6. After these 4 minutes times out, the total time is 15 minutes.

## Newspaper Puzzle

A newspaper made of 16 large sheets of paper folded in half. The newspaper has 64 pages altogether. The first sheet contains pages 1, 2, 63, 64. If you pick up a sheet containing page number 45, what are the other pages that this sheet contains?
Solution:

On the back of 45, it is 46.
Then you had to notice that the numbers were arranged in pairs, with the first pair adding up to 64 and the second pair adding up to 66.
Then,
64-45 = 19
66-46 = 20
So the four pages on this sheet are 19, 20, 45 and 46.

## The Tuesday Birthday Problem

I have two children. One is a boy born on a Tuesday. What is the probability I have two boys?
The first thing you think is “What has Tuesday got to do with it?” Well, it has everything to do with it.
Red means “outside the reference class”. Yellow means “in the reference class but not boy-boy”. Green means “inside the reference class and boy-boy”.
Boy-boy in the reference class occurs with probability Green / (Green + Yellow) or 13 /27

## Balls and Bowls Puzzles

How should 50 red and 50 blue balls be distributed between two bowls so as to maximize the chance of picking a red marble?

Solution:

Put 1 red marble in bowls A and put the remaining 99 marbles in bowls B. There’s a 50% chance of selecting the bowls containing 1 ball with a 100% chance of selecting a black ball from that bucket. And a 50% chance of selecting the bowls containing 99 balls with a ~49.5% (49/99) chance of selecting a black ball from that bowls. Total probability of selecting a black ball is (50% % 100%) + (50% * 49.5%) = 74.7%

## 3 bulbs and 3 switches

There are 3 bulbs(B1, B2 and B3) in a room on 1st floor, they can be operated using 3 switches(S1, S2, S3) present on the ground floor. You don’t know which Switch is for which bulb. How can you figure out, which switch is for which bulb if you are allowed to visit 1st floor only once.

Assuming all switches are turned off initially, You can do the following:-

1.) Turn on switch S1 for 5 minutes.

2.) Turn Off switch S1.

3.) Turn on switch S2.

4.) Go Upstairs.

5.) The glowing bulb can be assigned to Switch S2.

6.) Touch both other bulbs, hotter one should be assigned to switch S1 and the other one to switch S3.

## Heaven and Hell

There are two gates in a room, one to heaven and other to hell with each gate having a guard. What will be the question you will ask one of them so you come to know which door is the door to heaven?

The question you need to ask is – “If I ask the other guard which is the door to heaven, which door will he point me to?”

Explanation:
No matter who you ask this question to, that guard will always point you to the door to hell.

1. If you ask this to the truth telling guard – he will honestly tell u that the lying guard will point you to the door to hell
2. If you ask the lying guard – he will lie to you and point you to the door to hell.

## 13 Caves And A Thief Logic Puzzle

There are 13 caves arranged in a circle.
There is a thief hiding in one of the caves.
Each day the the thief can move to any one of of the caves that is adjacent to the cave in which he was staying the previous day.
And each day, you are allowed to enter any two caves of your choice.
What is the minimum number of days to guarantee in which you can catch the thief?
Note:
1. Thief may or may not move to adjacent cave.
2. You can check any two caves, not necessarily be adjacent.
3. If thief and you exchange your caves, you will surely cross at some point, and you can catch the thief immediately.

As the Caves are arranged in a circle, Start Searching in 2 adjacent Caves on 1st day
Then on next day, 1 person moves Clockwise and another moves anticlockwise.
So it would take a maximum (minimum guarantee) of 7 days to catch the thief.

#### 1 Policeman

For example: lets say police checks c1 & c13 on 1st day. Now every day keep checking c2, c3, c4 & so on…and also check c13.
1st Day; c1 & c13
2nd day: c2 & c13
3rd Day: c3 & c13
..
.. 12th Day: c12 & c13
so on max 12th day police can catch the thief.

## Princess, Flowers and Snake

There are three rooms, and there are Princess, Flowers and Snake in those rooms. The doors of all the rooms have incorrect nameplates. i.e., the nameplate for the princess’ room is not Princess. Similarly, the nameplate for the Flowers’ room is not Flowers. You need to find the room of the Princess without going to the room of Snake. How do you find?
Go to the room which has the nameplate Snake. That will not have Snake.
If the room has princess, you are done.
If the room has flowers, then go to the room which has nameplate flowers. Princess would be there in that room. Since, Princess cannot be there in the room which has nameplate Princess.

## Airplane Seating Probability Puzzle

Imagine there are a 100 people in line to board a plane that seats 100. The first person in line realizes he lost his boarding pass so when he boards he decides to take a random seat instead. Every person that boards the plane after him will either take their “proper” seat, or if that seat is taken, a random seat instead.
Question: What is the probability that the last person that boards will end up in his/her proper seat.
Hint: Consider a two-seat airplane, then grow it from there.
Solution: There are many ways to come up with this answer, but here’s one that makes sense to me. For ease of explanation, we’ll say that I’m the first person to sit down and you’re the last. Also if you sit in your own seat then you “win”, otherwise you “lose”.
Let’s say that there are only two seats, yours and mine. If I sit in my own seat, you win. If I sit in your seat, you lose. So you have a 50% chance of winning.
Now let’s go back to 100 seats. The previous paragraph still holds true: you have a 50% chance of winning if we only consider your seat and mine. Now if I sit anywhere else, I’m just postponing the decision. Let’s say I sit in the seat of the person who’s 13th in line. Persons 2 through 12 will sit in their own seats, then when person 13 comes in he can either sit in my original seat (and you win) or yours (and you lose). Or of course he could sit anywhere else and postpone the decision again.
If this keeps going, then eventually there are only two seats left and person 99 is forced to choose either your seat or mine, again with 50% chance. There are only two seats that matter throughout the game: yours and mine. Any sitting in other seats is just postponing the decision of which of the two interesting seats gets sat in first. Note also that you’ll only ever end up in your seat or mine, no one else’s.
It’s a bit like flipping a coin, except that you can postpone flipping, but not indefinitely. What’s the chance of coming out heads? Well 50%, the postponement doesn’t change that.

## 3 Mislabeled Jars

Puzzle:

You have three jars that are all mislabeled. one contains peanut butter jelly beans, another grape jelly jelly beans, and the third has a mix of both (not necessarily a 50/50 mix, could be a 1/99 mix or a 399/22 mix). how many jelly beans would you have to pull out, and out of which jars, to find out how to fix the labels on the jars?
   |     |                  |     |                 |     |  |jar 1|                |jar 2|               |jar 3|   |     |                  |     |                 |     |=======        =======          =======     p.b.                   grape             p.b./grape
Solution:
1. 1 jelly bean from the p.b./grape jar will do the trick. the trick here is to realize that every jar is mislabeled. therefore you know that the peanut butter jelly bean jar is not the penut butter jelly bean jar, and the same goes for the rest.
2. you also need to realize that it is the jar labeled p.b./grape, labelled as the mix jar, that is your best hope. if you choose a jelly bean out of there, then you will know whether that jar is peanut butter or grape jelly jelly beans. it can’t be the mix jar because i already said that every jar is mislabeled.
3. once you know that jar 3 is either peanut butter, or grape jelly, then you know the other jars also. if it is peanut butter, then jar 2 must be mixed because it can’t be grape (as its labelled) and it can’t be peanut butter (that’s jar 3). hence jar 1 is grape.
4. if jar 3 is grape, then you know jar 1 must be the mix because it can’t be p.b. (as its labelled) and it can’t be grape (that’s jar 3). hence jar 2 is peanut butter.
5. if you pick jelly beans from jar 1 or jar 2, then you would have to pick out all of the jelly beans before you knew what that jar was. this is because jar 1 and 2 could be the mix, so in order to disprove that they were the mix, you would have to pull out every jelly bean just to make sure (since there could just be one bean of the opposite flavor in there)

## 9 Minutes with 4 Minute, 7 Minute Hourglass

Puzzle:

How to measure 9 minutes using only a 4 minute and 7-minute hourglass?

This question is similar to 4 Quarts of Water. With water, we were able to fill and pour out the pail multiple times. We can use the same logic and easily come up solutions which start measuring 9 minutes somewhere in the middle of the procedure but those will not be ideal. If possible, we want to measure the 9 minutes right from the start.

 Step Time 4 minute timer 7 minute timer 1 0 min Start Start 2 4 mins Flip 3 minutes left 3 7 mins 1 minute left Flip 4 8 mins Stop Flip (1 minute left) 5 9 mins Stop

# You have 5 jars of pills. Each pill weighs 10 gram, except for contaminated pills contained in one jar, where each pill weighs 9 gm. Given a scale, how could you tell which jar had the contaminated pills in just one measurement?

Solution:
Step 1: Take 1,2,3,4 & 5 pills from jars 1,2,3,4 & 5 respectively.
Step 2: The ideal weight should be (1+2+3+4+5)x10= 150gms.
Step 3: Calculate taken pills weight.
Step:4 if jar 1 contains contaminated pills then weight = 1*9 + (2+3+4+5)*10 = 149
if jar 2 contains contaminated pills then weight = 2*9 + (1+3+4+5)*10 = 148
if jar 3 contains contaminated pills then weight = 3*9 + (1+2+4+5)*10 = 147
if jar 4 contains contaminated pills then weight = 4*9 + (1+2+3+5)*10 = 146
if jar 5 contains contaminated pills then weight = 5*9 + (1+2+3+4)*10 = 145

## MICROSOFT LOGICAL REASONING QUESTION

There are four prisoners. All four prisoners will be freed if at least one of them correctly guesses the color of the hat on his head. They can’t speak to each other, and they can’t touch each other.
Number 1 sees number 2 and 3’s hats.
Number 2 sees number 3’s hat.
Number 3 sees only the wall.
Number 4 sees only the wall.
There are no mirrors.
They all know that there are 2 black hats and 2 white hats and that there are four people.
They know their placement in this room is as follows:
Can the four prisoners be freed? If so, how?

4 can’t see the other three due to the wall so he can’t guess.
3 also can’t see due to the wall.
I eliminate 4 and 3.
For 2, he knows 3 is wearing a white hat. But how could he know he is wearing black?
For 1, if 2 hat is white then 1 hat is black. But if 1’s is black and 2’s is white then, he would be able to know. If the two in front have white hats then, he will answer first and say ‘Mine is black’.
But properly, 2 is aware of 1’s hesitation, ‘Oh 1 is also white’.
Then, 2 will answer ‘Mine is black’. So the answer is 2.

## 10 Coins Puzzle

Puzzle:

You are blindfolded and 10 coins are placed in front of you on the table. You are allowed to touch the coins but can’t tell which way up they are by feel. You are told that there are 5 coins head up, and 5 coins tails up but not which ones are which.
Can you make two piles of coins each with the same number of heads up? You can flip the coins any number of times.

Solution: Yes
Make 2 piles with the equal number of coins. Now, flip all the coins in one of the pile.
How this will work? let’s take an example.
So initially there are 5 heads, so suppose you divide it into 2 piles.
Case 1:
P1: H H T T T
P2: H H H T T
Now when P1 will be flipped
P1: T T H H H
Case 2:
P1: H T T T T
P2: H H H H T
Now when P1 will be flipped
P1: H H H H T
Case 3:
P1 = HHHHH
P2 = TTTTT
Now when P1 will be flipped
P1: T T T T T
Case 4:
P1 = THHTT
P2 = HTHTH
Now when P1 will be flipped
P1: HTTHH

## 1 bulb and 3 switches

Puzzle:

There are 3 switches and one bulb , the bulb is in the closed room and switches are outside of the room now you have to identify the correct switch of the bulb. you have only once chance to go inside the room.

Solution:
Step 1: Turn on the first switch and wait for 5 min, then off the switch.

Step 2: Turn on the second one and go to the room.

Conclusion: If the correct switch was the first one, the bulb got heated, if it’s the second one, it means the bulb is lighting in the room, else it would be the third one.

## 240 barrels of wine

Puzzle:

You have 240 barrels of wine, one of which has been poisoned. After drinking the poisoned wine, one dies within 24 hours. You have 5 slaves whom you are willing to sacrifice in order to determine which barrel contains the poisoned wine. How do you achieve this in 48 hours?

Solution:

The number system we generally use is base 10, or decimal system. I am assuming that the reader is familiar with the ternary system (base 3) while reading this answer.

The pledge
Let the barrels be numbered from 1 to 240 (base 10)

——————–
3 | 240   | 0
3 | 80     | 2
3 | 26     | 2
3 | 8       | 2
3 | 2       | 2
3 | 0       |

Ans 240(base 10)  = 22220(base 3)

This means in base 3, they will be numbered from 00001 to 22220.

There are 3 digits in the ternary system, corresponding to 3 outcomes in the given problem for each slave. Assigning the digits to the outcomes,
Digit    Outcome
0          – the slave does not die
1           – the slave dies within the first 24 hours (00 to 24)
2           – the slave dies in the last 24 hours (24 to 48)

The turn
We give the wine from each barrel to the slaves, according to the following examples –
Barrel 139
If we take barrel number 139 (base 10) = 12011 (base 3)

3rd digit is 0, so don’t feed slave 3 from this barrel.
1st, 4th and 5th digits are 1, so feed slave number 1,4 and 5 from this barrel at time t=0.
2nd digit is 2, so feed slave 2 from this barrel at time t=24.

Barrel 231
If we take barrel number 231 (base 10) = 22120 (base 3)

5th digit is 0, so don’t feed slave 5 from this barrel.
3rd digit is 1, so feed slave number 3 from this barrel at time t=0.
1st, 2nd and 4th digits are 2, so feed slave number 1,2 and 4 from this barrel at time t=24.

The prestige
If we do that, then we can find which barrel is poisonous, based on which slaves die.
Example: If slave numbers 2 and 4 die in the first 24 hours, and slave 3 dies in the next 24 hours, then..
Barrel number 01210 (base 3)
That is, barrel number 48 (base 10) is poisonous.

## Man with Medical Condition and 2 Pills

Puzzles:

A man has a medical condition that requires him to take two kinds of pills, call them A and B. The man must take exactly one A pill and exactly one B pill each day, or he will die. The pills are taken by first dissolving them in water.

The man has a jar of A pills and a jar of B pills. One day, as he is about to take his pills, he takes out one A pill from the A jar and puts it in a glass of water. Then he accidentally takes out two B pills from the B jar and puts them in the water. Now, he is in the situation of having a glass of water with three dissolved pills, one A pill and two B pills. Unfortunately, the pills are very expensive, so the thought of throwing out the water with the 3 pills and starting over is out of the question. How should the man proceed in order to get the right quantity of A and B while not wasting any pills?

Solution:

Add one more P1 pill to the glass and let it dissolve.

Take half of the water today and half tomorrow.

So, Percentage of Pill P1 and Pill P2 on both the day in overall be managed equal.

It works under the following assumptions:

The dissolved Pills can be used the next day.

## 1000 Coins and 10 Bags

Puzzles:
How will u divide 1000 one Rs. Coins in ten bag so that u can give any amount between 1-1000 by just giving the bags without changing the no of coins in each bag.

Solution:

You set the no. of coins as powers of 2 except for the last bag where you just place whatever remains.
Bag 1 = 1 coin
Bag 2 = 2 coins
Bag 3 = 4 coins
Bag 4 = 8 coins
Bag 5= 16coins
Bag 6= 32coins
Bag 7=64 coins
Bag 8= 128 coins
Bag 9= 256 coins
Bag 10= 488 coins ( If the total no = 1024 coins this should be 512)

Now any number from 1 to 1000 could be obtained by combining these bags.
Notice bag #10 is a little short of 2*256, or 512. That’s because you only have 1000 coins. The previous 9 bags have 511 coins in total, leaving only 489 for bag 10.

Anyway, you can dispense any amount of coins from 1 – 1000 by just choosing bags here.

Try any number: 617. Bag #10 + bag #8

## Cut The Gold Bar Twice And Pay For 7 Days

Question:

You’ve got someone working for you for seven days and a gold bar to pay them. You must pay the worker for their work at the end of every day. If you are only allowed to make two breaks in the gold bar, how do you pay your worker? (Assuming the equal amount of work is done during each day thus requiring an equal amount of pay for each day)

The trick is not to try and how to cut in such a way to make 7 equal pieces but rather to make transactions with the worker. Make two cuts on the gold bar such that you have the following sizes of bars.

1/7, 2/7 and 4/7. For convenience sake, I would just refer to the bars as 1, 2 and 4.
At the end of Day 1: Give Bar 1 (You- 2 and 4, Worker- 1)
At the end of Day 2: Give Bar 2, Take back Bar 1 (You- 1 and 4, Worker- 2)
At the end of Day 3: Give Bar 1 (You- 4, Worker- 1 and 2)
At the end of Day 4: Give Bar 4, Take back Bar 1 and Bar 2 (You- 1 and 2, Worker- 4)
At the end of Day 5: Give Bar 1 (You- 2, Worker- 1 and 4)
At the end of Day 6: Give Bar 2, Take back Bar 1 (You- 1, Worker- 2 and 4)
At the end of Day 7: Give Bar 1 (You- Empty, Worker- 1, 2 and 4)

## 25 horses 5 tracks 5 fastest horses puzzle

Q: 25 horses, 5 race tracks. How many races you have to run to select top 5 horses.

Solution:
Step 1: First, we group the horses into groups of 5 and race each group in the race course. This gives us 5 races.W11   W12   W13   W14   W15W21   W22   W23   W24   W25W31   W32   W33   W34   W35W41   W42   W43   W44   W45W51   W52   W53   W54   W55Step 2:we race the 5 level 1 winners(w11,w21,w31,w41,w51) and assume winning order of this race is w11,w21,w31,w41,w51 (THIS IS 6TH RACE)
Step 3: BECAUSE WE NEED TOP 5 AND W51 HAS COME 5TH Position that is the reason we don’t need to consider W52   W53   W54   W55
now we have
W11   W12   W13   W14   W15W21   W22   W23   W24   W25W31   W32   W33   W34   W35W41   W42   W43   W44   W45W51

Step 4: because we need top 5 then dont need    W25   W34   W35   W43   W44   W45

now we have

W11   W12   W13   W14   W15W21   W22   W23   W24   W31   W32   W33  W41   W42   W51
Step 5:  top 1 is already achieved which is W11(winner of 6th race)
remaining are
X        W12   W13   W14   W15W21   W22   W23   W24   W31   W32   W33  W41   W42   W51
Step 6: candidates for 5th position:  W51 W42 W33 W24 W15. 1 RACE TO GET 5TH POSITION (this is 7th race)

remaining are

X     W12   W13   W14   W21   W22   W23   W31   W32 W41

Step 7:  candidates for 4th position: W41 W32 W23 W14. 1 race to get 4th position ((this is 8th race)
X     W12   W13   W21   W22   W31
Step 8: candidates for the 2nd and 3rd position:  W12   W13   W21   W22   W31. 1 race to get the 2nd and 3rd  position ((this is 9th race)

## 25 Horses 5 Tracks 3 Fastest Horses Puzzle

Puzzles:

25 horses, 5 race tracks. How many races you have to run to select top 3 horses.

Solution:

Step 1: First, we group the horses into groups of 5 and race each group in the race course. This gives us 5 races.

W11   W12   W13   W14   W15W21   W22   W23   W24   W25W31   W32   W33   W34   W35W41   W42   W43   W44   W45W51   W52   W53   W54   W55

Step 2:we race the 5 level 1 winners(w11,w21,w31,w41,w51) ans assume winning order of this race is w11,w21,w31,w41,w51

Step 3: BECAUSE WE NEED TOP 3 AND W41 HAS COME 4TH Position that is the reason we don’t need to consider W41   W42   W43   W44   W45 and also W51   W52   W53   W54   W55
now we have

W11   W12   W13   W14   W15W21   W22   W23   W24   W25W31   W32   W33   W34   W35

Step 4: because we need top 3 then don’t need W14   W15   W24   W25   W34   W35

now we have

W11   W12   W13W21   W22   W23W31   W32   W33

Step 5: because in 6th race W31 has come on the 3rd position that is the reason we do not need to consider W32, W33 and also we will not consider W23
now we have

W11   W12   W13W21   W22W31

Step 6:  top 1 is already achieved which is W11(winner of 6th race)
remaining are

W12   W13W21   W22W31

Step 7: now race W12 w13 w21 w22 w31 to get the 2nd and 3rd winner

## Monty Hall Problem Explained

The solution presented by vos Savant (1990b) in Parade shows the three possible arrangements of one car and two goats behind three doors and the result of staying or switching after initially picking door 1 in each case:

Behind door 1Behind door 2Behind door 3Result if staying at door #1Result if switching to the door offered
CarGoatGoatWins carWins goat
GoatCarGoatWins goatWins car
GoatGoatCarWins goatWins car

A player who stays with the initial choice wins in only one out of three of these equally likely possibilities, while a player who switches wins in two out of three

## Two ropes burning riddle 45 minutes

Puzzles:

You have two ropes and a lighter. Each rope has the following property: If you light one end of the rope, it will take one hour to burn to the other end. They don’t necessarily burn at a uniform rate. How can you measure a period of 45 minutes?

1. Light up three out of four ends of the two wires.
2. Once one wire is completely burnt, light up the fourth end.
3. At 45 minutes, both wires are burnt completely.

Reference:

https://codinginterviewquestionsans.blogspot.com/2017/07/rope-puzzle-interview-question-two.html

## 2 Eggs and 100 Floors

Critical Floor: The floor from which, upon drop of an egg causes it to break.All the floors above the critical floor will also break the egg upon drop from them.All the floors below the critical floor are safe floors,i.e. eggs won’t break upon drop from that floor.

1 Egg and k floors:

AIM:we need to find the minimum number of drops required to perfectly figure out the critical floor number.

we have only one egg, so the obvious solution is to throw the egg from 1st floor,

If it breaks then first floor is the critical floor, if it doesn’t break continue testing from 2nd floor, 3rd floor and so on, until the the egg breaks at the required floor.

So, with 1 egg and k floors the worst case is to drop the egg k times

2 Eggs and k floors

Why not Binary Search?

Suppose, we proceed using binary search, we take 50th floor first and test it.

What if the egg breaks? we have to test for the remaining 1 to 49 floors with only 1 egg remaining, that requires 49 more drops in the worst case where the required floor is 49th floor.

Binary search is ruled out as it cannot give us critical floor with optimal number of drops using only 2 eggs.

If we had infinite supply of eggs then binary search is the best method.

Optimal Solution:

Assume we have to drop 2 eggs at most 𝑥xnumber of times.(Keep this in mind)

We need to find out the optimal minimum value of 𝑥,x,for which we can find the critical floor.

A good way to start this problem is to ask “Are we able to cover all the floors with𝑥x drops?”

We should start at the 𝑥xth floor, because if the egg breaks, you will have to check floors 1,2,3,,𝑥21,2,3,…,x−2 and 𝑥1x−1, so the total number of drops will be x.

If it doesn’t break, you will have to check the(𝑥+(𝑥1))(x+(x−1)) th floor.

If the egg breaks,In the worst case, you will have to check the floors(𝑥+1),(𝑥+2),,(𝑥+(𝑥1)1).(x+1),(x+2),…,(x+(x−1)−1). Hence, the number of drops will be ((𝑥+(𝑥1)1)(𝑥+1)+1)+2=𝑥.((x+(x−1)−1)−(x+1)+1)+2=x.Here, 2 is added it accounts for the 𝑥xth floor drop and (𝑥+(𝑥1))(x+(x−1))th floor drop.

Do you realize what we are doing? Based on the assumption that the number of drops will always be 𝑥xin the worst case, we find the floors where we should drop the egg. The crucial point here is understanding that we are not trying to find the minimum number of drops knowing the best strategy; actually, we are trying to find the best strategy supposing that the minimum number of drops is𝑥x, and we have to determine if covering all the floors using at most x attempts is possible or not.

Carrying out the analytical solution to this problem,

In our attempt, we will drop the egg at the 𝑥xth floor,covering 𝑥xfloors, then we will drop it at the (𝑥+(𝑥1))(x+(x−1)) th floor, covering𝑥1x−1 floors, and the third drop would be at the (𝑥+(𝑥1)+(𝑥2))(x+(x−1)+(x−2))th floor, covering

𝑥2x−2 floors. We can see that using this strategy we would cover

𝑥+(𝑥1)+(𝑥2)++2+1=𝑥(𝑥+1)/2x+(x−1)+(x−2)+…+2+1=x(x+1)/2 floors

to get solution for k floors, we need

𝑥(𝑥+1)/2>=𝑘x(x+1)/2>=k

which on solving gives 𝑥=𝑐𝑒𝑖𝑙(1+𝑠𝑞𝑟𝑡(1+8𝑘))/2)x=ceil(−1+sqrt(1+8k))/2)

2 eggs and 100 floors:

This is a special case of the above problem with k=100,

on substituting the value of 𝑘k we get 𝑥=𝑐𝑒𝑖𝑙(13.65)=14x=ceil(13.65)=14

using the above process we will have the below scenario for 2 eggs and 100 floors