Attribution Non-Commercial (BY-NC)

121 views

Attribution Non-Commercial (BY-NC)

- Dive Into Deep Learning - d2l-En
- DIP Quiz 2 & 3 Solution
- Trans Cad Assignment
- 3
- DMR
- dropbox cookies1
- Brute Force Attack
- Must Ask VMware Engineer Interview Questions
- Operator SWP20
- How2Use FLIP Eng
- Badi Information
- Log Don't starve
- CMakeLists.txt
- Introduction to Postgis 1.5.1 3
- 845qref0
- - Development of Quran Reciter Identification System Using MFCC and Neural Network
- How to Make Key Generators
- Sazetak 1
- How to Get More Views to Your Research Paper
- p 020130828561586361528

You are on page 1of 2

Problem 1. Prolog: U2 Crossing a Bridge "U2" has a concert that starts in 17 minutes and they must all cross a bridge to get there. All four men begin on the same side of the bridge. You must help them across to the other side. It is night. There is one flashlight. A maximum of two people cross at one time. Any party who crosses, either 1 or 2 people, must have the flashlight with them. The flashlight must be walked back and forth, it cannot be thrown, etc. Each band member walks at a different speed. A pair must walk together at the rate of the slower man's pace. Bono - 1 minute to cross Edge - 2 minutes to cross Adam - 5 minutes to cross Larry - 10 minutes to cross For example - If Bono and Larry walk across first, 10 minutes have elapsed when they get to the other side of the bridge. If Larry then returns with the flashlight, a total of 20 minutes has passed and the mission has failed. Write a Prolog program (facts and rules) to find the solution. There are several ways to code this problem. Do not worry if your solution is not the most efficient. The following facts and rules can be helpful: duration(bono, 1). duration(edge, 2). duration(adam, 5). duration(larry, 10). max(X, Y, X) :- X>Y. max(X, Y, Y) :- X=<Y. opposite(left, right). opposite(right, left). You can define rules to handle the movements of each person or persons. The direction of movement depends on which side the flashlight is on. You also will need to keep track of the current elapsed time. If the current time exceeds the elapsed time, you should stop further processing and go back to a previous state and continue from there. There are two solutions to this problem which take exactly 17 minutes.

Nicola Nobile

February 2009

Page 1 of 2

Use the following facts and rules to get started. % Member speed values duration(bono, 1). duration(edge, 2). duration(adam, 5). duration(larry, 10). % Return the maximum value max(X, Y, X) :- X>Y. max(X, Y, Y) :- X=<Y. % Return the opposite side opposite(left, right). opposite(right, left).

% Start by typing the query: go. go:solve(left, left, left, left, left, 0, [(left, left, left, left, left)]), fail. go:write('\n\nFinished\n'). % Determine if we reached the goal (flashlight and everyone on the right, and Time <= 17 solve(right, right, right, right, right, T, _):- T=<17, nl, nl. % Move Bono to the opposite side - ALONE solve(X, Edge, Adam, Larry, X, Time, BeenThere):- % Bono Alone duration(bono, TB), NewTime is Time + TB, NewTime =< 17, opposite(X, Y), \+ member((Y, Edge, Adam, Larry, Y), BeenThere), append(BeenThere, [(Y, Edge, Adam, Larry, Y)], NewBT), solve(Y, Edge, Adam, Larry, Y, NewTime, NewBT), write('Bono crosses alone from '), write(X), write(' to '), write(Y), write(': Time: '), write(NewTime), nl.

Nicola Nobile

February 2009

Page 2 of 2

- Dive Into Deep Learning - d2l-EnUploaded bytnaabc
- DIP Quiz 2 & 3 SolutionUploaded byMd Saidur Rahman Kohinoor
- Trans Cad AssignmentUploaded byYaneth Vera
- 3Uploaded byVenkat Teja
- DMRUploaded byRahul Jain
- dropbox cookies1Uploaded byAlign Engineering
- Brute Force AttackUploaded bybudi.hw748
- Must Ask VMware Engineer Interview QuestionsUploaded bynaraynapotugari
- Operator SWP20Uploaded bynsnmibaca
- How2Use FLIP EngUploaded bytahirtp02
- Badi InformationUploaded bysrinu
- Log Don't starveUploaded byGeorge Marius
- CMakeLists.txtUploaded byRinu Ravikumar
- Introduction to Postgis 1.5.1 3Uploaded byMathias Eder
- 845qref0Uploaded byapi-3736461
- - Development of Quran Reciter Identification System Using MFCC and Neural NetworkUploaded byUniversitas Malikussaleh
- How to Make Key GeneratorsUploaded bypremadarsh
- Sazetak 1Uploaded byAmina
- How to Get More Views to Your Research PaperUploaded byIJARBEST
- p 020130828561586361528Uploaded byELben Rescober
- Brute Force AttackUploaded bybudi.hw748
- Brute Force AttackUploaded bybudi.hw748
- autamata project gantt chart - sheet1Uploaded byapi-371579645
- E-ContinuousHandDrawingUploaded bySamira
- Convert 1Uploaded byhbgfjghjj hhfh
- Mostrar ClienteUploaded byIVAN PERCY GUTIERREZ HUAMAN
- grade 6 patterning test reviewUploaded byapi-248504182
- AirplaneGame_June1stTest_AtmakuriUploaded byvatsal gupta
- VS-2100Pro+ QIG-2_51000-023333-RS_20130121Uploaded byjfelectronica
- Class 16Uploaded byDarya Memon

- 1434005957 PMP Exam FormulasUploaded bydayalume
- Lifting Sets Calculation - API RP 2AUploaded byQuang-derer
- ScienceUploaded byZabhipray
- Ppt Heat Transfer VacuumUploaded bypatrick1101
- Dyeing With Polyester Using HTHP BEAM DYEING MACHINEUploaded bySivakumar K
- DW&DMUploaded byBalaram Singh
- ArtCAM Tutorijal4Uploaded byIvan Nikolic
- How to Change the Maximum Dialog Runtime of a Process in NW2004sUploaded byManish Talreja
- AlfaLaval Heat Transfer TheoryUploaded byAndrés Ramón Linares
- Janbu Concept for HpdUploaded byEndless Journey
- Methods TI-nspire CAS calculater companionUploaded byhummatafique
- Adaptation of the ESPSS Platform for the Design and Analysis of Liquid Propellant Rocket EnginesUploaded byjakub_gramol
- G014-e87 Measurement DensityUploaded byDiego Tobr
- 10.1.1.63Uploaded byDanielle Hays
- Data StructuresUploaded bysdenmike97
- Solid State FermentationUploaded bybalaspillai2609
- Lean Six Sigma IntegratedUploaded bySteven Bonacorsi
- Cloud Computing-Based Forensic Analysis for Collaborative Network.pdfUploaded bySuganya Periasamy
- 9075 Reflux Classifier BrochureUploaded byNeeraj Agrawal
- Voltage Drop Calculations.Uploaded byShijumon Kp
- bus90_lecture1=course-overview-and-start-chapter-entitled-introduction-and-data-collectionUploaded byLance Grow Plants
- Unit 05Uploaded bymanu
- Honors_AP Physics Algebra Review Problem SheetUploaded byjtpml
- CV.pdfUploaded bymohsen
- Design of SunshadeUploaded byNitesh Singh
- Application of Neural Networks to Compression of CT ImagesUploaded byLuana Palma
- Arithmetic Sequences and ExamplesUploaded byOmer Ahmed Ahmed
- Feature Selection Techniques: A ReviewUploaded byInternational Journal for Scientific Research and Development - IJSRD
- LINX_Configurator-User-Manual.pdfUploaded byahmad jaber
- Set LogicUploaded byMohd Tirmizi