SlideShare a Scribd company logo
getMeOutOfTheRoom
PSG College of Technology
MurtazaA
NageswaranS
Specification
Language C++
Platform Portable
Data Structures
Stack to store the visited path
Array to store multiple inputs
Algorithm
Backtracking brute force with a brain!
Finds all paths that are unvisited previously and settles on to the minimum path
solveTheProblem()
maze()
work our way thro’ the maze to find the key
findNearestTrap()
Locate the very first ‘#’ (wall) in each of the four directions
neighbourTravel()
Get to the ‘.’ (space) within touching distance of the current position
findKey()
It checks if the key is at a walkable distance from current position
maze()
maze (testcase_no, input_graph, rows, cols, currentPosition,
keyPosition, move, visited_stack)
if currentPosition == keyPosition {
minmoves = move;
return 1
}
findNearestTrap (graph, distances, currentPosition, outPositions)
min = minimum(distances)
……. //next slide
maze()
for i=1 to 4 {
if(directions = min) continue;
else if move < minmoves {
has the currrentPosition already been visited? if so return 0
else {
returnValue= maze ( testcase_no, input_graph, rows, cols, outPositions[i],
keyPosition, move+min, visited_stack )
if returnValue != 1 {
neighbourTravel ( testcase_no, input_graph, rows, cols, outPositions[i],
keyPosition, move+min, visited_stack )
}
}}
else return 0
}
findNearestTrap()
findNearestTrap(graph, distances, currentPosition, outPositions)
//east
i = currentPosition [col] + 1
while ( graph[ currentPosition[row] ] [i]!= ‘#’ ) i++
outPosition [east][row] = currentPosition [row]
outPosition [east][col] = i-1
distances[east] = i – currentPosition [col]
//west
i = currentPosition [col] - 1
while ( graph[ currentPosition[row] ] [i]!= ‘#’ ) i--
outPosition [west][row] = currentPosition [row]
outPosition [west][col] = i + 1
distances[west] = currentPosition [col] - i
findNearestTrap()
findNearestTrap(graph, distances, currentPosition, outPositions)
//south
i = currentPosition [row] + 1
while ( graph [i] [ currentPosition[col] ] != ‘#’ ) i++
outPosition [south][row] = i - 1
outPosition [south][col] = currentPosition [col]
distances[south] = i – currentPosition [row]
//north
i = currentPosition [row] - 1
while (graph [i] [ currentPosition[col] ] != ‘#’ ) i--
outPosition [north][row] = i + 1
outPosition [north][col] = currentPosition [col]
distances[north] = currentPosition [row] - i
neighbourTravel()
neighbourTravel(neighbourTravel(testcase_no, input_graph,
rows, cols, currentPositions, keyPosition, move, visited_stack)
find if there are ‘.’ in each of the four directions
if ‘.’ exists in the east and this position is not already visited {
findNearestTrap (input_graph, distances, currentPosition, outPositions)
returnValue = findKey (input_graph, currentPosition, outPositions, visited_stack)
if returnValue != 0 and returnValue+move < minmoves {
minmove = returnValue+move
} else {
move a position towards east, that is into the white space and call
returnValue = maze()
if (returnValue == 0 and move+1 < minmoves) neighbourTravel ()
}
}

More Related Content

Viewers also liked

G8WAY
G8WAYG8WAY
11 Most Expensive Catastrophes
11 Most Expensive Catastrophes11 Most Expensive Catastrophes
11 Most Expensive Catastrophes
chlsky
 
MRMW_BEACON_NY_DAVID_WRIGHT
MRMW_BEACON_NY_DAVID_WRIGHTMRMW_BEACON_NY_DAVID_WRIGHT
MRMW_BEACON_NY_DAVID_WRIGHT
David Wright
 
Grammar of the present perfect
Grammar of the present perfectGrammar of the present perfect
Grammar of the present perfect
Ingrid Blanco
 
P resent perfect
P resent perfectP resent perfect
P resent perfect
Ingrid Blanco
 
Apple TV launch 2013?
Apple TV launch 2013?Apple TV launch 2013?
Apple TV launch 2013?
David Wright
 
STORE_DW_FINAL_FINAL_16_BY_9
STORE_DW_FINAL_FINAL_16_BY_9STORE_DW_FINAL_FINAL_16_BY_9
STORE_DW_FINAL_FINAL_16_BY_9
David Wright
 

Viewers also liked (7)

G8WAY
G8WAYG8WAY
G8WAY
 
11 Most Expensive Catastrophes
11 Most Expensive Catastrophes11 Most Expensive Catastrophes
11 Most Expensive Catastrophes
 
MRMW_BEACON_NY_DAVID_WRIGHT
MRMW_BEACON_NY_DAVID_WRIGHTMRMW_BEACON_NY_DAVID_WRIGHT
MRMW_BEACON_NY_DAVID_WRIGHT
 
Grammar of the present perfect
Grammar of the present perfectGrammar of the present perfect
Grammar of the present perfect
 
P resent perfect
P resent perfectP resent perfect
P resent perfect
 
Apple TV launch 2013?
Apple TV launch 2013?Apple TV launch 2013?
Apple TV launch 2013?
 
STORE_DW_FINAL_FINAL_16_BY_9
STORE_DW_FINAL_FINAL_16_BY_9STORE_DW_FINAL_FINAL_16_BY_9
STORE_DW_FINAL_FINAL_16_BY_9
 

Similar to Pristine

Programación funcional con Haskell
Programación funcional con HaskellProgramación funcional con Haskell
Programación funcional con Haskell
Software Guru
 
Retos de Programación en Python
Retos de Programación en PythonRetos de Programación en Python
Retos de Programación en Python
Javier Abadía
 
Skiena algorithm 2007 lecture11 breadth deapth first search
Skiena algorithm 2007 lecture11 breadth deapth first searchSkiena algorithm 2007 lecture11 breadth deapth first search
Skiena algorithm 2007 lecture11 breadth deapth first search
zukun
 
Implement the following sorting algorithms Bubble Sort Insertion S.pdf
Implement the following sorting algorithms  Bubble Sort  Insertion S.pdfImplement the following sorting algorithms  Bubble Sort  Insertion S.pdf
Implement the following sorting algorithms Bubble Sort Insertion S.pdf
kesav24
 
R + Hadoop = Big Data Analytics. How Revolution Analytics' RHadoop Project Al...
R + Hadoop = Big Data Analytics. How Revolution Analytics' RHadoop Project Al...R + Hadoop = Big Data Analytics. How Revolution Analytics' RHadoop Project Al...
R + Hadoop = Big Data Analytics. How Revolution Analytics' RHadoop Project Al...
Revolution Analytics
 
Implementing virtual machines in go & c 2018 redux
Implementing virtual machines in go & c 2018 reduxImplementing virtual machines in go & c 2018 redux
Implementing virtual machines in go & c 2018 redux
Eleanor McHugh
 
Unit 3 daa
Unit 3 daaUnit 3 daa
Unit 3 daa
Nv Thejaswini
 
Chap04alg
Chap04algChap04alg
Chap04alg
Munhchimeg
 
Chap04alg
Chap04algChap04alg
Chap04alg
Munkhchimeg
 
10 Recursion
10 Recursion10 Recursion
10 Recursion
maznabili
 
algorithm Unit 3
algorithm Unit 3algorithm Unit 3
algorithm Unit 3
Monika Choudhery
 
Classical programming interview questions
Classical programming interview questionsClassical programming interview questions
Classical programming interview questions
Gradeup
 
Find the shortest route through a maze using linking and linked list.pdf
Find the shortest route through a maze using linking and linked list.pdfFind the shortest route through a maze using linking and linked list.pdf
Find the shortest route through a maze using linking and linked list.pdf
sanuoptical
 

Similar to Pristine (13)

Programación funcional con Haskell
Programación funcional con HaskellProgramación funcional con Haskell
Programación funcional con Haskell
 
Retos de Programación en Python
Retos de Programación en PythonRetos de Programación en Python
Retos de Programación en Python
 
Skiena algorithm 2007 lecture11 breadth deapth first search
Skiena algorithm 2007 lecture11 breadth deapth first searchSkiena algorithm 2007 lecture11 breadth deapth first search
Skiena algorithm 2007 lecture11 breadth deapth first search
 
Implement the following sorting algorithms Bubble Sort Insertion S.pdf
Implement the following sorting algorithms  Bubble Sort  Insertion S.pdfImplement the following sorting algorithms  Bubble Sort  Insertion S.pdf
Implement the following sorting algorithms Bubble Sort Insertion S.pdf
 
R + Hadoop = Big Data Analytics. How Revolution Analytics' RHadoop Project Al...
R + Hadoop = Big Data Analytics. How Revolution Analytics' RHadoop Project Al...R + Hadoop = Big Data Analytics. How Revolution Analytics' RHadoop Project Al...
R + Hadoop = Big Data Analytics. How Revolution Analytics' RHadoop Project Al...
 
Implementing virtual machines in go & c 2018 redux
Implementing virtual machines in go & c 2018 reduxImplementing virtual machines in go & c 2018 redux
Implementing virtual machines in go & c 2018 redux
 
Unit 3 daa
Unit 3 daaUnit 3 daa
Unit 3 daa
 
Chap04alg
Chap04algChap04alg
Chap04alg
 
Chap04alg
Chap04algChap04alg
Chap04alg
 
10 Recursion
10 Recursion10 Recursion
10 Recursion
 
algorithm Unit 3
algorithm Unit 3algorithm Unit 3
algorithm Unit 3
 
Classical programming interview questions
Classical programming interview questionsClassical programming interview questions
Classical programming interview questions
 
Find the shortest route through a maze using linking and linked list.pdf
Find the shortest route through a maze using linking and linked list.pdfFind the shortest route through a maze using linking and linked list.pdf
Find the shortest route through a maze using linking and linked list.pdf
 

Recently uploaded

What is Digital Literacy? A guest blog from Andy McLaughlin, University of Ab...
What is Digital Literacy? A guest blog from Andy McLaughlin, University of Ab...What is Digital Literacy? A guest blog from Andy McLaughlin, University of Ab...
What is Digital Literacy? A guest blog from Andy McLaughlin, University of Ab...
GeorgeMilliken2
 
Chapter 4 - Islamic Financial Institutions in Malaysia.pptx
Chapter 4 - Islamic Financial Institutions in Malaysia.pptxChapter 4 - Islamic Financial Institutions in Malaysia.pptx
Chapter 4 - Islamic Financial Institutions in Malaysia.pptx
Mohd Adib Abd Muin, Senior Lecturer at Universiti Utara Malaysia
 
How to Make a Field Mandatory in Odoo 17
How to Make a Field Mandatory in Odoo 17How to Make a Field Mandatory in Odoo 17
How to Make a Field Mandatory in Odoo 17
Celine George
 
Film vocab for eal 3 students: Australia the movie
Film vocab for eal 3 students: Australia the movieFilm vocab for eal 3 students: Australia the movie
Film vocab for eal 3 students: Australia the movie
Nicholas Montgomery
 
Beyond Degrees - Empowering the Workforce in the Context of Skills-First.pptx
Beyond Degrees - Empowering the Workforce in the Context of Skills-First.pptxBeyond Degrees - Empowering the Workforce in the Context of Skills-First.pptx
Beyond Degrees - Empowering the Workforce in the Context of Skills-First.pptx
EduSkills OECD
 
clinical examination of hip joint (1).pdf
clinical examination of hip joint (1).pdfclinical examination of hip joint (1).pdf
clinical examination of hip joint (1).pdf
Priyankaranawat4
 
Pengantar Penggunaan Flutter - Dart programming language1.pptx
Pengantar Penggunaan Flutter - Dart programming language1.pptxPengantar Penggunaan Flutter - Dart programming language1.pptx
Pengantar Penggunaan Flutter - Dart programming language1.pptx
Fajar Baskoro
 
Traditional Musical Instruments of Arunachal Pradesh and Uttar Pradesh - RAYH...
Traditional Musical Instruments of Arunachal Pradesh and Uttar Pradesh - RAYH...Traditional Musical Instruments of Arunachal Pradesh and Uttar Pradesh - RAYH...
Traditional Musical Instruments of Arunachal Pradesh and Uttar Pradesh - RAYH...
imrankhan141184
 
Cognitive Development Adolescence Psychology
Cognitive Development Adolescence PsychologyCognitive Development Adolescence Psychology
Cognitive Development Adolescence Psychology
paigestewart1632
 
BÀI TẬP BỔ TRỢ TIẾNG ANH 8 CẢ NĂM - GLOBAL SUCCESS - NĂM HỌC 2023-2024 (CÓ FI...
BÀI TẬP BỔ TRỢ TIẾNG ANH 8 CẢ NĂM - GLOBAL SUCCESS - NĂM HỌC 2023-2024 (CÓ FI...BÀI TẬP BỔ TRỢ TIẾNG ANH 8 CẢ NĂM - GLOBAL SUCCESS - NĂM HỌC 2023-2024 (CÓ FI...
BÀI TẬP BỔ TRỢ TIẾNG ANH 8 CẢ NĂM - GLOBAL SUCCESS - NĂM HỌC 2023-2024 (CÓ FI...
Nguyen Thanh Tu Collection
 
RHEOLOGY Physical pharmaceutics-II notes for B.pharm 4th sem students
RHEOLOGY Physical pharmaceutics-II notes for B.pharm 4th sem studentsRHEOLOGY Physical pharmaceutics-II notes for B.pharm 4th sem students
RHEOLOGY Physical pharmaceutics-II notes for B.pharm 4th sem students
Himanshu Rai
 
Your Skill Boost Masterclass: Strategies for Effective Upskilling
Your Skill Boost Masterclass: Strategies for Effective UpskillingYour Skill Boost Masterclass: Strategies for Effective Upskilling
Your Skill Boost Masterclass: Strategies for Effective Upskilling
Excellence Foundation for South Sudan
 
Digital Artefact 1 - Tiny Home Environmental Design
Digital Artefact 1 - Tiny Home Environmental DesignDigital Artefact 1 - Tiny Home Environmental Design
Digital Artefact 1 - Tiny Home Environmental Design
amberjdewit93
 
BÀI TẬP BỔ TRỢ TIẾNG ANH LỚP 9 CẢ NĂM - GLOBAL SUCCESS - NĂM HỌC 2024-2025 - ...
BÀI TẬP BỔ TRỢ TIẾNG ANH LỚP 9 CẢ NĂM - GLOBAL SUCCESS - NĂM HỌC 2024-2025 - ...BÀI TẬP BỔ TRỢ TIẾNG ANH LỚP 9 CẢ NĂM - GLOBAL SUCCESS - NĂM HỌC 2024-2025 - ...
BÀI TẬP BỔ TRỢ TIẾNG ANH LỚP 9 CẢ NĂM - GLOBAL SUCCESS - NĂM HỌC 2024-2025 - ...
Nguyen Thanh Tu Collection
 
How to Create a More Engaging and Human Online Learning Experience
How to Create a More Engaging and Human Online Learning Experience How to Create a More Engaging and Human Online Learning Experience
How to Create a More Engaging and Human Online Learning Experience
Wahiba Chair Training & Consulting
 
The Diamonds of 2023-2024 in the IGRA collection
The Diamonds of 2023-2024 in the IGRA collectionThe Diamonds of 2023-2024 in the IGRA collection
The Diamonds of 2023-2024 in the IGRA collection
Israel Genealogy Research Association
 
How to deliver Powerpoint Presentations.pptx
How to deliver Powerpoint  Presentations.pptxHow to deliver Powerpoint  Presentations.pptx
How to deliver Powerpoint Presentations.pptx
HajraNaeem15
 
PCOS corelations and management through Ayurveda.
PCOS corelations and management through Ayurveda.PCOS corelations and management through Ayurveda.
PCOS corelations and management through Ayurveda.
Dr. Shivangi Singh Parihar
 
বাংলাদেশ অর্থনৈতিক সমীক্ষা (Economic Review) ২০২৪ UJS App.pdf
বাংলাদেশ অর্থনৈতিক সমীক্ষা (Economic Review) ২০২৪ UJS App.pdfবাংলাদেশ অর্থনৈতিক সমীক্ষা (Economic Review) ২০২৪ UJS App.pdf
বাংলাদেশ অর্থনৈতিক সমীক্ষা (Economic Review) ২০২৪ UJS App.pdf
eBook.com.bd (প্রয়োজনীয় বাংলা বই)
 
writing about opinions about Australia the movie
writing about opinions about Australia the moviewriting about opinions about Australia the movie
writing about opinions about Australia the movie
Nicholas Montgomery
 

Recently uploaded (20)

What is Digital Literacy? A guest blog from Andy McLaughlin, University of Ab...
What is Digital Literacy? A guest blog from Andy McLaughlin, University of Ab...What is Digital Literacy? A guest blog from Andy McLaughlin, University of Ab...
What is Digital Literacy? A guest blog from Andy McLaughlin, University of Ab...
 
Chapter 4 - Islamic Financial Institutions in Malaysia.pptx
Chapter 4 - Islamic Financial Institutions in Malaysia.pptxChapter 4 - Islamic Financial Institutions in Malaysia.pptx
Chapter 4 - Islamic Financial Institutions in Malaysia.pptx
 
How to Make a Field Mandatory in Odoo 17
How to Make a Field Mandatory in Odoo 17How to Make a Field Mandatory in Odoo 17
How to Make a Field Mandatory in Odoo 17
 
Film vocab for eal 3 students: Australia the movie
Film vocab for eal 3 students: Australia the movieFilm vocab for eal 3 students: Australia the movie
Film vocab for eal 3 students: Australia the movie
 
Beyond Degrees - Empowering the Workforce in the Context of Skills-First.pptx
Beyond Degrees - Empowering the Workforce in the Context of Skills-First.pptxBeyond Degrees - Empowering the Workforce in the Context of Skills-First.pptx
Beyond Degrees - Empowering the Workforce in the Context of Skills-First.pptx
 
clinical examination of hip joint (1).pdf
clinical examination of hip joint (1).pdfclinical examination of hip joint (1).pdf
clinical examination of hip joint (1).pdf
 
Pengantar Penggunaan Flutter - Dart programming language1.pptx
Pengantar Penggunaan Flutter - Dart programming language1.pptxPengantar Penggunaan Flutter - Dart programming language1.pptx
Pengantar Penggunaan Flutter - Dart programming language1.pptx
 
Traditional Musical Instruments of Arunachal Pradesh and Uttar Pradesh - RAYH...
Traditional Musical Instruments of Arunachal Pradesh and Uttar Pradesh - RAYH...Traditional Musical Instruments of Arunachal Pradesh and Uttar Pradesh - RAYH...
Traditional Musical Instruments of Arunachal Pradesh and Uttar Pradesh - RAYH...
 
Cognitive Development Adolescence Psychology
Cognitive Development Adolescence PsychologyCognitive Development Adolescence Psychology
Cognitive Development Adolescence Psychology
 
BÀI TẬP BỔ TRỢ TIẾNG ANH 8 CẢ NĂM - GLOBAL SUCCESS - NĂM HỌC 2023-2024 (CÓ FI...
BÀI TẬP BỔ TRỢ TIẾNG ANH 8 CẢ NĂM - GLOBAL SUCCESS - NĂM HỌC 2023-2024 (CÓ FI...BÀI TẬP BỔ TRỢ TIẾNG ANH 8 CẢ NĂM - GLOBAL SUCCESS - NĂM HỌC 2023-2024 (CÓ FI...
BÀI TẬP BỔ TRỢ TIẾNG ANH 8 CẢ NĂM - GLOBAL SUCCESS - NĂM HỌC 2023-2024 (CÓ FI...
 
RHEOLOGY Physical pharmaceutics-II notes for B.pharm 4th sem students
RHEOLOGY Physical pharmaceutics-II notes for B.pharm 4th sem studentsRHEOLOGY Physical pharmaceutics-II notes for B.pharm 4th sem students
RHEOLOGY Physical pharmaceutics-II notes for B.pharm 4th sem students
 
Your Skill Boost Masterclass: Strategies for Effective Upskilling
Your Skill Boost Masterclass: Strategies for Effective UpskillingYour Skill Boost Masterclass: Strategies for Effective Upskilling
Your Skill Boost Masterclass: Strategies for Effective Upskilling
 
Digital Artefact 1 - Tiny Home Environmental Design
Digital Artefact 1 - Tiny Home Environmental DesignDigital Artefact 1 - Tiny Home Environmental Design
Digital Artefact 1 - Tiny Home Environmental Design
 
BÀI TẬP BỔ TRỢ TIẾNG ANH LỚP 9 CẢ NĂM - GLOBAL SUCCESS - NĂM HỌC 2024-2025 - ...
BÀI TẬP BỔ TRỢ TIẾNG ANH LỚP 9 CẢ NĂM - GLOBAL SUCCESS - NĂM HỌC 2024-2025 - ...BÀI TẬP BỔ TRỢ TIẾNG ANH LỚP 9 CẢ NĂM - GLOBAL SUCCESS - NĂM HỌC 2024-2025 - ...
BÀI TẬP BỔ TRỢ TIẾNG ANH LỚP 9 CẢ NĂM - GLOBAL SUCCESS - NĂM HỌC 2024-2025 - ...
 
How to Create a More Engaging and Human Online Learning Experience
How to Create a More Engaging and Human Online Learning Experience How to Create a More Engaging and Human Online Learning Experience
How to Create a More Engaging and Human Online Learning Experience
 
The Diamonds of 2023-2024 in the IGRA collection
The Diamonds of 2023-2024 in the IGRA collectionThe Diamonds of 2023-2024 in the IGRA collection
The Diamonds of 2023-2024 in the IGRA collection
 
How to deliver Powerpoint Presentations.pptx
How to deliver Powerpoint  Presentations.pptxHow to deliver Powerpoint  Presentations.pptx
How to deliver Powerpoint Presentations.pptx
 
PCOS corelations and management through Ayurveda.
PCOS corelations and management through Ayurveda.PCOS corelations and management through Ayurveda.
PCOS corelations and management through Ayurveda.
 
বাংলাদেশ অর্থনৈতিক সমীক্ষা (Economic Review) ২০২৪ UJS App.pdf
বাংলাদেশ অর্থনৈতিক সমীক্ষা (Economic Review) ২০২৪ UJS App.pdfবাংলাদেশ অর্থনৈতিক সমীক্ষা (Economic Review) ২০২৪ UJS App.pdf
বাংলাদেশ অর্থনৈতিক সমীক্ষা (Economic Review) ২০২৪ UJS App.pdf
 
writing about opinions about Australia the movie
writing about opinions about Australia the moviewriting about opinions about Australia the movie
writing about opinions about Australia the movie
 

Pristine

  • 1. getMeOutOfTheRoom PSG College of Technology MurtazaA NageswaranS
  • 2. Specification Language C++ Platform Portable Data Structures Stack to store the visited path Array to store multiple inputs Algorithm Backtracking brute force with a brain! Finds all paths that are unvisited previously and settles on to the minimum path
  • 3. solveTheProblem() maze() work our way thro’ the maze to find the key findNearestTrap() Locate the very first ‘#’ (wall) in each of the four directions neighbourTravel() Get to the ‘.’ (space) within touching distance of the current position findKey() It checks if the key is at a walkable distance from current position
  • 4. maze() maze (testcase_no, input_graph, rows, cols, currentPosition, keyPosition, move, visited_stack) if currentPosition == keyPosition { minmoves = move; return 1 } findNearestTrap (graph, distances, currentPosition, outPositions) min = minimum(distances) ……. //next slide
  • 5. maze() for i=1 to 4 { if(directions = min) continue; else if move < minmoves { has the currrentPosition already been visited? if so return 0 else { returnValue= maze ( testcase_no, input_graph, rows, cols, outPositions[i], keyPosition, move+min, visited_stack ) if returnValue != 1 { neighbourTravel ( testcase_no, input_graph, rows, cols, outPositions[i], keyPosition, move+min, visited_stack ) } }} else return 0 }
  • 6. findNearestTrap() findNearestTrap(graph, distances, currentPosition, outPositions) //east i = currentPosition [col] + 1 while ( graph[ currentPosition[row] ] [i]!= ‘#’ ) i++ outPosition [east][row] = currentPosition [row] outPosition [east][col] = i-1 distances[east] = i – currentPosition [col] //west i = currentPosition [col] - 1 while ( graph[ currentPosition[row] ] [i]!= ‘#’ ) i-- outPosition [west][row] = currentPosition [row] outPosition [west][col] = i + 1 distances[west] = currentPosition [col] - i
  • 7. findNearestTrap() findNearestTrap(graph, distances, currentPosition, outPositions) //south i = currentPosition [row] + 1 while ( graph [i] [ currentPosition[col] ] != ‘#’ ) i++ outPosition [south][row] = i - 1 outPosition [south][col] = currentPosition [col] distances[south] = i – currentPosition [row] //north i = currentPosition [row] - 1 while (graph [i] [ currentPosition[col] ] != ‘#’ ) i-- outPosition [north][row] = i + 1 outPosition [north][col] = currentPosition [col] distances[north] = currentPosition [row] - i
  • 8. neighbourTravel() neighbourTravel(neighbourTravel(testcase_no, input_graph, rows, cols, currentPositions, keyPosition, move, visited_stack) find if there are ‘.’ in each of the four directions if ‘.’ exists in the east and this position is not already visited { findNearestTrap (input_graph, distances, currentPosition, outPositions) returnValue = findKey (input_graph, currentPosition, outPositions, visited_stack) if returnValue != 0 and returnValue+move < minmoves { minmove = returnValue+move } else { move a position towards east, that is into the white space and call returnValue = maze() if (returnValue == 0 and move+1 < minmoves) neighbourTravel () } }