Skip to main content

Puzzles

 Collection of brain teasers I have found from various sources:

Weighing & Logical Deduction Puzzles

  1. Odd Coin Problem: You have 6 coins and a balance. One coin is either lighter or heavier than the rest. What is the minimum number of weighings needed to certainly find the odd coin?

  2. Finding the Heavier Ball: You have 27 balls, one of which is heavier. Using a balance scale, describe the steps to find the heavier ball in the minimum number of weighings.

  3. Defective Jar Puzzle: You have 10 jars filled with marbles. Each marble weighs 10 grams, except one jar, which contains defective marbles weighing 9 grams. Using one measurement on a modern digital scale, how do you find the jar with defective marbles?

Real-World Logic & Constraint-Based Puzzles

  1. Tunnel Escape Puzzle: Two people are walking through a railway tunnel. When they have crossed 2/3rd of the tunnel, they suddenly see a train approaching from behind. They immediately run in opposite directions, both at 10 km/h, and barely escape as the train passes. What is the speed of the train?

  2. Light Bulb & Switch Puzzle: You have three switches outside a closed room, each controlling one of three light bulbs inside. You may enter the room only once. How can you determine which switch corresponds to which bulb?

  3. Bridge Crossing at Night: Four people need to cross a bridge at night. The bridge can hold only two people at a time and requires a torch to cross. Each person walks at a different speed:

    • Person 1: 1 minute
    • Person 2: 2 minutes
    • Person 3: 5 minutes
    • Person 4: 10 minutes
      If two people cross together, they move at the speed of the slower person. What is the fastest time in which all four can cross?
  4. Age Riddle: A person's age in days is equal to his father's age in weeks, and his age in months is equal to his grandfather’s age in years. The sum of all three ages is 120 years. What are their ages?

  5. Burning Ropes: You have two ropes, each of which takes exactly one hour to burn completely. However, the ropes burn at an inconsistent rate. Using only a lighter, how can you measure exactly 45 minutes?


Coding & Algorithmic Thinking Puzzles

  1. Water Jug Puzzle: You have a 5-liter jug and a 3-liter jug, along with an unlimited water supply. There are no measurement markings on the jugs. How can you measure exactly 4 liters of water?

  2. Shooting, Drowning, and Hanging Riddle: A man shoots his wife, then holds her underwater for 5 minutes, and then hangs her. After 10 minutes, they both leave for dinner together. How is this possible?

  3. Doctor & Son Puzzle: A father and son are in a car accident. The father dies on the spot, and the son is rushed to the hospital. The doctor looks at the boy and says, "I can't operate on him—he's my son!" How is this possible?

  4. 100 Doors Puzzle: There are 100 closed doors in a row. A person walks through them 100 times following this pattern:

    • The first time, they toggle all doors (open all).
    • The second time, they toggle every second door (close doors 2, 4, 6, ...).
    • The third time, they toggle every third door (change the state of doors 3, 6, 9, ...).
    • This continues up to the 100th pass.
      After the 100th pass, which doors remain open?
  5. Prisoners and the Bulb Puzzle: There are 100 prisoners in separate, isolated cells. They have no way to communicate with each other, except that every day, one prisoner is randomly selected to enter a room with a single light bulb. They can either toggle the bulb (switch it on/off) or do nothing. The bulb is initially off. The warden tells them:

  • At any time, any prisoner can declare that all 100 prisoners have visited the bulb room at least once.
  • If the prisoner is correct, they are all set free; if wrong, they are executed.
  • The prisoners can discuss a strategy before the game starts.
    What is the best strategy for them to ensure their freedom?

Comments

Popular posts from this blog

Virtual environments in python

 Creating virtual environments is essential for isolating dependencies and ensuring consistency across different projects. Here are the main methods and tools available, along with their pros, cons, and recommendations : 1. venv (Built-in Python Virtual Environment) Overview: venv is a lightweight virtual environment module included in Python (since Python 3.3). It allows you to create isolated environments without additional dependencies. How to Use: python -m venv myenv source myenv/bin/activate # On macOS/Linux myenv\Scripts\activate # On Windows Pros: ✅ Built-in – No need to install anything extra. ✅ Lightweight – Minimal overhead compared to other tools. ✅ Works across all platforms . ✅ Good for simple projects . Cons: ❌ No dependency management – You still need pip and requirements.txt . ❌ Not as feature-rich as other tools . ❌ No package isolation per project directory (requires manual activation). Recommendation: Use venv if you need a simple, lightweight solut...

Building a Simple Text Generator: A Hands-on Introduction

Introduction Text generation is one of the most exciting applications of Natural Language Processing (NLP) . From autocorrect and chatbots to AI-generated stories and news articles , text generation models help machines produce human-like text. In this blog post, we’ll introduce a simple yet effective text generation method using Markov Chains . Unlike deep learning models like GPT, this approach doesn’t require complex neural networks—it relies on probability-based word transitions to create text. We’ll walk through: ✅ The concept of Markov Chains and how they apply to text generation. ✅ A step-by-step implementation , fetching Wikipedia text and training a basic text generator. ✅ Example outputs and future improvements. The Concept of Markov Chains in Text Generation A Markov Chain is a probabilistic model that predicts future states (or words) based only on the current state (or word), rather than the full sentence history. How it works in text generation: 1️⃣ We analyze a gi...

Mastering Trade-Off Analysis in System Architecture: A Strategic Guide for Architects

 In system architecture and design, balancing conflicting system qualities is both an art and a science. Trade-off analysis is a strategic evaluation process that enables architects to make informed decisions that align with business goals and technical constraints. By prioritizing essential system attributes while acknowledging inevitable compromises, architects can craft resilient and efficient solutions. This enhanced guide provides actionable insights and recommendations for architects aiming to master trade-off analysis for impactful architectural decisions. 1. Understanding Trade-Off Analysis Trade-off analysis involves identifying and evaluating the conflicting requirements and design decisions within a system. Architects must balance critical aspects like performance, scalability, cost, security, and maintainability. Since no system can be optimized for every quality simultaneously, prioritization based on project goals is essential. Actionable Insights: Define key quality ...