From 7f5af3503f8ee6bedf7887895e1d69161eab7f7a Mon Sep 17 00:00:00 2001 From: Shubham Singh Date: Tue, 31 Aug 2021 12:29:42 +0530 Subject: [PATCH] Added new riddle --- .DS_Store | Bin 0 -> 8196 bytes Riddles/.DS_Store | Bin 0 -> 6148 bytes Riddles/Riddle Interview Problems/.DS_Store | Bin 0 -> 6148 bytes ...oners and hats - SOLUTION-checkpoint.ipynb | 6 ++ .../Coins and a Scale - SOLUTION.ipynb | 12 ++-- .../Prisoners and hats - SOLUTION.ipynb | 50 ++++++++++++++++ .../Prisoners and hats-checkpoint.ipynb | 6 ++ .../Bridge Crossing.ipynb | 12 ++-- .../Prisoners and hats.ipynb | 54 ++++++++++++++++++ 9 files changed, 128 insertions(+), 12 deletions(-) create mode 100644 .DS_Store create mode 100644 Riddles/.DS_Store create mode 100644 Riddles/Riddle Interview Problems/.DS_Store create mode 100644 Riddles/Riddle Interview Problems/Riddle Interview Problems - SOLUTIONS/.ipynb_checkpoints/Prisoners and hats - SOLUTION-checkpoint.ipynb create mode 100644 Riddles/Riddle Interview Problems/Riddle Interview Problems - SOLUTIONS/Prisoners and hats - SOLUTION.ipynb create mode 100644 Riddles/Riddle Interview Problems/Riddle Interview Problems /.ipynb_checkpoints/Prisoners and hats-checkpoint.ipynb create mode 100644 Riddles/Riddle Interview Problems/Riddle Interview Problems /Prisoners and hats.ipynb diff --git a/.DS_Store b/.DS_Store new file mode 100644 index 0000000000000000000000000000000000000000..ceb9393f5cfcdc75a13768152ff4a2934e4cfba6 GIT binary patch literal 8196 zcmeHM%We}f6us_qQlPB_h$4YB8+K9E2Lif4N<%7CiANz7EC7|6OlU`>Ga)l+R6e+)IiLccs6!#8v`72oj+C|uRspMkRlq7>6|f5Y3ku-OW^+zB_jRuItpZko|55?| zesJL!D+Y%e<*NgpTmgU+NESmF_WL=Sp!>6^+)n3Rne372v!36eQq+)P)~W1AbCqe<`r1=&o?v zcuy#lRaXmT&(b~gDWcb?mwU*u1TPUq-iHEjj_zaB4e(sr1V078LkD0tsW-y@USQAC zmh`XzUMOQ)1hz5Si2VHM#&!$b57q@Zk(i1mV_ROj=bP|$9Jh|bp8q6l_IBnk+=-*q z3!`R7$YIb#k>^jtD2RL2xElqD)Kk|Pj#F|rVjvb(x`b5M5sYb#4-_xkFM z!Jy<^y0(0K^X2~G+y1-3`;U+jrj$l3?hsy%V+Kh$op@7qQrRGx4&BWUKtz zI=l%y2qxgP?EAN^s7u#2M1sTdq;L<-D41c(gQ KvkLrG1%3hp8Xa!{ literal 0 HcmV?d00001 diff --git a/Riddles/.DS_Store b/Riddles/.DS_Store new file mode 100644 index 0000000000000000000000000000000000000000..7b6bc068aa3967888779966c9f0b9099ecd6d7f2 GIT binary patch literal 6148 zcmeHK-D(p-6h70&I*CYgA+%l;=El2Fl2%%KQP{>7%w2JdUZ}LY-Nh_ycf#(bOO26z z4Sk6|hfmPQ(QkfIj8y~$5j$r&^PM>}=S=1!^G8IiKaP4tZ6e}Og^d=9ABbvKdP5eh zrvYR-M@fII6UTsK;9qAzt=%VX<*%=`QCj-n!p<;}2!!mq9r$`a%9m)eeJl7+U*C%JkX}!WT(g z9k(Amm01}iS)A+OB#P1H^~)rSWYw4BEGl#!-!yRESVIGXiVDoN-+qxtw3(qdY6Ce*ddjT5esqcuC5R>|E)*3J-K0R#7!6 zhtc>2*S4eTAa?ey*7*-Ril1d^z1O|=P#0B{73tUnXGsc|m(Q~z(e+SIilj7oLfau_ zTekPQE7R%Py^Wq)AKabw)O2I5-&42O@62Xxd3|+of3$!2_TBXT?88ShToTv-ja+qj z0-sXml?5C#=RWIj(0r!`c zm(Rms{TMw1o`FANfcFOlWeglP7R}ay!aMyL|pX`u+R=Y>=;c z20R1*6$7HR8Ey_SBzLyX4UW%R1>J|TuwP@*grIQ8u`&24UV$1xpJD?TIBYDU1>!FP Nh6Z1F2L37o-vO()iDCc% literal 0 HcmV?d00001 diff --git a/Riddles/Riddle Interview Problems/Riddle Interview Problems - SOLUTIONS/.ipynb_checkpoints/Prisoners and hats - SOLUTION-checkpoint.ipynb b/Riddles/Riddle Interview Problems/Riddle Interview Problems - SOLUTIONS/.ipynb_checkpoints/Prisoners and hats - SOLUTION-checkpoint.ipynb new file mode 100644 index 00000000..363fcab7 --- /dev/null +++ b/Riddles/Riddle Interview Problems/Riddle Interview Problems - SOLUTIONS/.ipynb_checkpoints/Prisoners and hats - SOLUTION-checkpoint.ipynb @@ -0,0 +1,6 @@ +{ + "cells": [], + "metadata": {}, + "nbformat": 4, + "nbformat_minor": 5 +} diff --git a/Riddles/Riddle Interview Problems/Riddle Interview Problems - SOLUTIONS/Coins and a Scale - SOLUTION.ipynb b/Riddles/Riddle Interview Problems/Riddle Interview Problems - SOLUTIONS/Coins and a Scale - SOLUTION.ipynb index dd6ce0ad..a0fe7e34 100644 --- a/Riddles/Riddle Interview Problems/Riddle Interview Problems - SOLUTIONS/Coins and a Scale - SOLUTION.ipynb +++ b/Riddles/Riddle Interview Problems/Riddle Interview Problems - SOLUTIONS/Coins and a Scale - SOLUTION.ipynb @@ -17,23 +17,23 @@ ], "metadata": { "kernelspec": { - "display_name": "Python 2", + "display_name": "Python 3", "language": "python", - "name": "python2" + "name": "python3" }, "language_info": { "codemirror_mode": { "name": "ipython", - "version": 2 + "version": 3 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", - "pygments_lexer": "ipython2", - "version": "2.7.11" + "pygments_lexer": "ipython3", + "version": "3.8.8" } }, "nbformat": 4, - "nbformat_minor": 0 + "nbformat_minor": 1 } diff --git a/Riddles/Riddle Interview Problems/Riddle Interview Problems - SOLUTIONS/Prisoners and hats - SOLUTION.ipynb b/Riddles/Riddle Interview Problems/Riddle Interview Problems - SOLUTIONS/Prisoners and hats - SOLUTION.ipynb new file mode 100644 index 00000000..9b818c89 --- /dev/null +++ b/Riddles/Riddle Interview Problems/Riddle Interview Problems - SOLUTIONS/Prisoners and hats - SOLUTION.ipynb @@ -0,0 +1,50 @@ +{ + "cells": [ + { + "cell_type": "markdown", + "id": "f40082e5", + "metadata": {}, + "source": [ + "# Prisoners and hats - SOLUTION" + ] + }, + { + "cell_type": "markdown", + "id": "de7dfbd9", + "metadata": {}, + "source": [ + "## Problem Statement\n", + "There are 100 prisoners all sentenced to death. One night before the execution, the warden gives them a chance to live if they all work on a strategy together. The execution scenario is as follows –\n", + "\n", + "On the day of execution, all the prisoners will be made to stand in a straight line such that one prisoner stands just behind another and so on. All prisoners will be wearing a hat either of Blue colour or Red. The prisoners don’t know what colour of hat they are wearing. The prisoner who is standing at the last can see all the prisoners in front of him (and what colour of hat they are wearing). A prisoner can see all the hats in front of him. The prisoner who is standing in the front of the line cannot see anything.\n", + "\n", + "The executioner will ask each prisoner what colour of hat they are wearing one by one, starting from the last in the line. The prisoner can only speak “Red” or “Blue”. He cannot say anything else. If he gets it right, he lives otherwise he is shot instantly. All the prisoners standing in front of him can hear the answers and gunshots.\n", + "\n", + "Assuming that the prisoners are intelligent and would stick to the plan, what strategy would the prisoners make over the night to minimize the number of deaths?\n", + "\n", + "## Solution\n" + ] + } + ], + "metadata": { + "kernelspec": { + "display_name": "Python 3", + "language": "python", + "name": "python3" + }, + "language_info": { + "codemirror_mode": { + "name": "ipython", + "version": 3 + }, + "file_extension": ".py", + "mimetype": "text/x-python", + "name": "python", + "nbconvert_exporter": "python", + "pygments_lexer": "ipython3", + "version": "3.8.8" + } + }, + "nbformat": 4, + "nbformat_minor": 5 +} diff --git a/Riddles/Riddle Interview Problems/Riddle Interview Problems /.ipynb_checkpoints/Prisoners and hats-checkpoint.ipynb b/Riddles/Riddle Interview Problems/Riddle Interview Problems /.ipynb_checkpoints/Prisoners and hats-checkpoint.ipynb new file mode 100644 index 00000000..363fcab7 --- /dev/null +++ b/Riddles/Riddle Interview Problems/Riddle Interview Problems /.ipynb_checkpoints/Prisoners and hats-checkpoint.ipynb @@ -0,0 +1,6 @@ +{ + "cells": [], + "metadata": {}, + "nbformat": 4, + "nbformat_minor": 5 +} diff --git a/Riddles/Riddle Interview Problems/Riddle Interview Problems /Bridge Crossing.ipynb b/Riddles/Riddle Interview Problems/Riddle Interview Problems /Bridge Crossing.ipynb index 405b8032..db56cd03 100644 --- a/Riddles/Riddle Interview Problems/Riddle Interview Problems /Bridge Crossing.ipynb +++ b/Riddles/Riddle Interview Problems/Riddle Interview Problems /Bridge Crossing.ipynb @@ -24,23 +24,23 @@ ], "metadata": { "kernelspec": { - "display_name": "Python 2", + "display_name": "Python 3", "language": "python", - "name": "python2" + "name": "python3" }, "language_info": { "codemirror_mode": { "name": "ipython", - "version": 2 + "version": 3 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", - "pygments_lexer": "ipython2", - "version": "2.7.11" + "pygments_lexer": "ipython3", + "version": "3.8.8" } }, "nbformat": 4, - "nbformat_minor": 0 + "nbformat_minor": 1 } diff --git a/Riddles/Riddle Interview Problems/Riddle Interview Problems /Prisoners and hats.ipynb b/Riddles/Riddle Interview Problems/Riddle Interview Problems /Prisoners and hats.ipynb new file mode 100644 index 00000000..855d6281 --- /dev/null +++ b/Riddles/Riddle Interview Problems/Riddle Interview Problems /Prisoners and hats.ipynb @@ -0,0 +1,54 @@ +{ + "cells": [ + { + "cell_type": "markdown", + "id": "dce1a8f7", + "metadata": {}, + "source": [ + "# Prisoners and hats" + ] + }, + { + "cell_type": "markdown", + "id": "aade5a41", + "metadata": {}, + "source": [ + "## Problem statement\n", + "There are 100 prisoners all sentenced to death. One night before the execution, the warden gives them a chance to live if they all work on a strategy together. The execution scenario is as follows –\n", + "\n", + "On the day of execution, all the prisoners will be made to stand in a straight line such that one prisoner stands just behind another and so on. All prisoners will be wearing a hat either of Blue colour or Red. The prisoners don’t know what colour of hat they are wearing. The prisoner who is standing at the last can see all the prisoners in front of him (and what colour of hat they are wearing). A prisoner can see all the hats in front of him. The prisoner who is standing in the front of the line cannot see anything.\n", + "\n", + "The executioner will ask each prisoner what colour of hat they are wearing one by one, starting from the last in the line. The prisoner can only speak “Red” or “Blue”. He cannot say anything else. If he gets it right, he lives otherwise he is shot instantly. All the prisoners standing in front of him can hear the answers and gunshots.\n", + "\n", + "Assuming that the prisoners are intelligent and would stick to the plan, what strategy would the prisoners make over the night to minimize the number of deaths?\n" + ] + }, + { + "cell_type": "markdown", + "id": "ed90d944", + "metadata": {}, + "source": [] + } + ], + "metadata": { + "kernelspec": { + "display_name": "Python 3", + "language": "python", + "name": "python3" + }, + "language_info": { + "codemirror_mode": { + "name": "ipython", + "version": 3 + }, + "file_extension": ".py", + "mimetype": "text/x-python", + "name": "python", + "nbconvert_exporter": "python", + "pygments_lexer": "ipython3", + "version": "3.8.8" + } + }, + "nbformat": 4, + "nbformat_minor": 5 +}