SlideShare a Scribd company logo
1 of 3
Download to read offline
Environment:
Let assume the environment is a grid of colored
tiles(WHITE,BLUE,GREEN,BLACK,YELLOW).Robot is standing on a tile.Every tile has
a(X,Y) Position
We use a function getTileColor(x,y) to know color of current tile(x,y position).
ALGORITHM:
TRESUREHUNT(x,y)
1. color=getColor(x,y)
2. IF color=YELLOW
3. Return "tiles"+x+y+" Is a tresure"
4. ELSE IF color=WHITE
5. TRESUREHUNT(x,y-1) // move to front tile by decrementing y by 1
6 ELSE IF color=BLUE
7. TRESUREHUNT(x-1,y) // move to left bydecrementing x by 1
8. ELSE IF color=GREEN
9. TRESUREHUNT(x+1,y) // move to right tile by incrementing x by 1
10. ELSE IF color=BLACK
11. TRESUREHUNT(x,y+2) // move to front tile by incrementint y by 2
12. ELSE
13. Return "Unsucessfull"
12.END iF
C++ CODE
//for simplicity i represent entite grid in a 2;D array .Each cell is viewed as a tile.It contains
arbitary color values,0-BLACK
//1-BLUE,2;GREEN,14;YELLOW,15-WHITE
//accordingly the x,y value is changed. if current cell(tile)=15(WHITE) robot moves to front tile.
// so x=x-1 and y=y
#include
#include
void tresurehunt(int x,int y);
int grid[][7]={ {1, 1, 1, 14,2, 0, 15},
{0, 1, 1, 1, 0, 0, 2},
{2, 2 ,1, 0, 15,14,1},
{15,15,14,0, 1, 2, 1},
{15,0, 0, 1, 2, 2, 14},
{14,14,14,15,0, 2, 2},
{15,15,15,1, 1, 2, 1}};
int main()
{
tresurehunt(4,4);
return 0;
}
void tresurehunt(int x,int y)
{
//int color=getpixel(x,y);
int color=grid[x][y];
if(color==YELLOW)
{
cout<<"Tresure is in:"<
Solution
Environment:
Let assume the environment is a grid of colored
tiles(WHITE,BLUE,GREEN,BLACK,YELLOW).Robot is standing on a tile.Every tile has
a(X,Y) Position
We use a function getTileColor(x,y) to know color of current tile(x,y position).
ALGORITHM:
TRESUREHUNT(x,y)
1. color=getColor(x,y)
2. IF color=YELLOW
3. Return "tiles"+x+y+" Is a tresure"
4. ELSE IF color=WHITE
5. TRESUREHUNT(x,y-1) // move to front tile by decrementing y by 1
6 ELSE IF color=BLUE
7. TRESUREHUNT(x-1,y) // move to left bydecrementing x by 1
8. ELSE IF color=GREEN
9. TRESUREHUNT(x+1,y) // move to right tile by incrementing x by 1
10. ELSE IF color=BLACK
11. TRESUREHUNT(x,y+2) // move to front tile by incrementint y by 2
12. ELSE
13. Return "Unsucessfull"
12.END iF
C++ CODE
//for simplicity i represent entite grid in a 2;D array .Each cell is viewed as a tile.It contains
arbitary color values,0-BLACK
//1-BLUE,2;GREEN,14;YELLOW,15-WHITE
//accordingly the x,y value is changed. if current cell(tile)=15(WHITE) robot moves to front tile.
// so x=x-1 and y=y
#include
#include
void tresurehunt(int x,int y);
int grid[][7]={ {1, 1, 1, 14,2, 0, 15},
{0, 1, 1, 1, 0, 0, 2},
{2, 2 ,1, 0, 15,14,1},
{15,15,14,0, 1, 2, 1},
{15,0, 0, 1, 2, 2, 14},
{14,14,14,15,0, 2, 2},
{15,15,15,1, 1, 2, 1}};
int main()
{
tresurehunt(4,4);
return 0;
}
void tresurehunt(int x,int y)
{
//int color=getpixel(x,y);
int color=grid[x][y];
if(color==YELLOW)
{
cout<<"Tresure is in:"<

More Related Content

More from aplolomedicalstoremr

Matter is made up of electrically charge particle but the Constituen.pdf
Matter is made up of electrically charge particle but the Constituen.pdfMatter is made up of electrically charge particle but the Constituen.pdf
Matter is made up of electrically charge particle but the Constituen.pdfaplolomedicalstoremr
 
it is a polynomial of degree 3Solutionit is a polynomial of de.pdf
it is a polynomial of degree 3Solutionit is a polynomial of de.pdfit is a polynomial of degree 3Solutionit is a polynomial of de.pdf
it is a polynomial of degree 3Solutionit is a polynomial of de.pdfaplolomedicalstoremr
 
JUnit is a Regression Testing Framework used by developers to implem.pdf
JUnit is a Regression Testing Framework used by developers to implem.pdfJUnit is a Regression Testing Framework used by developers to implem.pdf
JUnit is a Regression Testing Framework used by developers to implem.pdfaplolomedicalstoremr
 
Intitially take a graph sheet and plot the points and the whole figu.pdf
Intitially take a graph sheet and plot the points and the whole figu.pdfIntitially take a graph sheet and plot the points and the whole figu.pdf
Intitially take a graph sheet and plot the points and the whole figu.pdfaplolomedicalstoremr
 
Incapsula Enterprise is the best mitigation service provider with th.pdf
Incapsula Enterprise is the best mitigation service provider with th.pdfIncapsula Enterprise is the best mitigation service provider with th.pdf
Incapsula Enterprise is the best mitigation service provider with th.pdfaplolomedicalstoremr
 
Go with the most obvious one first...Carboxylic Acids will have a.pdf
Go with the most obvious one first...Carboxylic Acids will have a.pdfGo with the most obvious one first...Carboxylic Acids will have a.pdf
Go with the most obvious one first...Carboxylic Acids will have a.pdfaplolomedicalstoremr
 
Flexible benefit plans gives employees a choice between qualified be.pdf
Flexible benefit plans gives employees a choice between qualified be.pdfFlexible benefit plans gives employees a choice between qualified be.pdf
Flexible benefit plans gives employees a choice between qualified be.pdfaplolomedicalstoremr
 
f(x) = cos(x)Solutionf(x) = cos(x).pdf
f(x) = cos(x)Solutionf(x) = cos(x).pdff(x) = cos(x)Solutionf(x) = cos(x).pdf
f(x) = cos(x)Solutionf(x) = cos(x).pdfaplolomedicalstoremr
 
Classification of organisms is based upon a number of physical and p.pdf
Classification of organisms is based upon a number of physical and p.pdfClassification of organisms is based upon a number of physical and p.pdf
Classification of organisms is based upon a number of physical and p.pdfaplolomedicalstoremr
 
Assets=Liabilities+Paid in capital+Retained earnings1..pdf
Assets=Liabilities+Paid in capital+Retained earnings1..pdfAssets=Liabilities+Paid in capital+Retained earnings1..pdf
Assets=Liabilities+Paid in capital+Retained earnings1..pdfaplolomedicalstoremr
 
Hypothesis Test for population variance If we have a sample fro.pdf
 Hypothesis Test for population variance If we have a sample fro.pdf Hypothesis Test for population variance If we have a sample fro.pdf
Hypothesis Test for population variance If we have a sample fro.pdfaplolomedicalstoremr
 
ANSWERFundamental configurations of Windows printer Deployments.pdf
ANSWERFundamental configurations of Windows printer Deployments.pdfANSWERFundamental configurations of Windows printer Deployments.pdf
ANSWERFundamental configurations of Windows printer Deployments.pdfaplolomedicalstoremr
 
Since HCl is strong acid , it dissociates fully t.pdf
                     Since HCl is strong acid , it dissociates fully t.pdf                     Since HCl is strong acid , it dissociates fully t.pdf
Since HCl is strong acid , it dissociates fully t.pdfaplolomedicalstoremr
 
@author public class Person{   String sname, .pdf
  @author   public class Person{   String sname, .pdf  @author   public class Person{   String sname, .pdf
@author public class Person{   String sname, .pdfaplolomedicalstoremr
 
no even covalent coupunds also relese heat thos.pdf
                     no even covalent coupunds also relese heat   thos.pdf                     no even covalent coupunds also relese heat   thos.pdf
no even covalent coupunds also relese heat thos.pdfaplolomedicalstoremr
 
organic layer note this ammonium salt (itself is.pdf
                     organic layer note this ammonium salt (itself is.pdf                     organic layer note this ammonium salt (itself is.pdf
organic layer note this ammonium salt (itself is.pdfaplolomedicalstoremr
 
Glucose is more sluble in water because it has mo.pdf
                     Glucose is more sluble in water because it has mo.pdf                     Glucose is more sluble in water because it has mo.pdf
Glucose is more sluble in water because it has mo.pdfaplolomedicalstoremr
 
compounds 1 and 3 are the same be cause they are .pdf
                     compounds 1 and 3 are the same be cause they are .pdf                     compounds 1 and 3 are the same be cause they are .pdf
compounds 1 and 3 are the same be cause they are .pdfaplolomedicalstoremr
 
C) Its a double displacement reaction .pdf
                     C) Its a double displacement reaction          .pdf                     C) Its a double displacement reaction          .pdf
C) Its a double displacement reaction .pdfaplolomedicalstoremr
 
B)light interacting with a metal and producing a .pdf
                     B)light interacting with a metal and producing a .pdf                     B)light interacting with a metal and producing a .pdf
B)light interacting with a metal and producing a .pdfaplolomedicalstoremr
 

More from aplolomedicalstoremr (20)

Matter is made up of electrically charge particle but the Constituen.pdf
Matter is made up of electrically charge particle but the Constituen.pdfMatter is made up of electrically charge particle but the Constituen.pdf
Matter is made up of electrically charge particle but the Constituen.pdf
 
it is a polynomial of degree 3Solutionit is a polynomial of de.pdf
it is a polynomial of degree 3Solutionit is a polynomial of de.pdfit is a polynomial of degree 3Solutionit is a polynomial of de.pdf
it is a polynomial of degree 3Solutionit is a polynomial of de.pdf
 
JUnit is a Regression Testing Framework used by developers to implem.pdf
JUnit is a Regression Testing Framework used by developers to implem.pdfJUnit is a Regression Testing Framework used by developers to implem.pdf
JUnit is a Regression Testing Framework used by developers to implem.pdf
 
Intitially take a graph sheet and plot the points and the whole figu.pdf
Intitially take a graph sheet and plot the points and the whole figu.pdfIntitially take a graph sheet and plot the points and the whole figu.pdf
Intitially take a graph sheet and plot the points and the whole figu.pdf
 
Incapsula Enterprise is the best mitigation service provider with th.pdf
Incapsula Enterprise is the best mitigation service provider with th.pdfIncapsula Enterprise is the best mitigation service provider with th.pdf
Incapsula Enterprise is the best mitigation service provider with th.pdf
 
Go with the most obvious one first...Carboxylic Acids will have a.pdf
Go with the most obvious one first...Carboxylic Acids will have a.pdfGo with the most obvious one first...Carboxylic Acids will have a.pdf
Go with the most obvious one first...Carboxylic Acids will have a.pdf
 
Flexible benefit plans gives employees a choice between qualified be.pdf
Flexible benefit plans gives employees a choice between qualified be.pdfFlexible benefit plans gives employees a choice between qualified be.pdf
Flexible benefit plans gives employees a choice between qualified be.pdf
 
f(x) = cos(x)Solutionf(x) = cos(x).pdf
f(x) = cos(x)Solutionf(x) = cos(x).pdff(x) = cos(x)Solutionf(x) = cos(x).pdf
f(x) = cos(x)Solutionf(x) = cos(x).pdf
 
Classification of organisms is based upon a number of physical and p.pdf
Classification of organisms is based upon a number of physical and p.pdfClassification of organisms is based upon a number of physical and p.pdf
Classification of organisms is based upon a number of physical and p.pdf
 
Assets=Liabilities+Paid in capital+Retained earnings1..pdf
Assets=Liabilities+Paid in capital+Retained earnings1..pdfAssets=Liabilities+Paid in capital+Retained earnings1..pdf
Assets=Liabilities+Paid in capital+Retained earnings1..pdf
 
Hypothesis Test for population variance If we have a sample fro.pdf
 Hypothesis Test for population variance If we have a sample fro.pdf Hypothesis Test for population variance If we have a sample fro.pdf
Hypothesis Test for population variance If we have a sample fro.pdf
 
ANSWERFundamental configurations of Windows printer Deployments.pdf
ANSWERFundamental configurations of Windows printer Deployments.pdfANSWERFundamental configurations of Windows printer Deployments.pdf
ANSWERFundamental configurations of Windows printer Deployments.pdf
 
Since HCl is strong acid , it dissociates fully t.pdf
                     Since HCl is strong acid , it dissociates fully t.pdf                     Since HCl is strong acid , it dissociates fully t.pdf
Since HCl is strong acid , it dissociates fully t.pdf
 
@author public class Person{   String sname, .pdf
  @author   public class Person{   String sname, .pdf  @author   public class Person{   String sname, .pdf
@author public class Person{   String sname, .pdf
 
no even covalent coupunds also relese heat thos.pdf
                     no even covalent coupunds also relese heat   thos.pdf                     no even covalent coupunds also relese heat   thos.pdf
no even covalent coupunds also relese heat thos.pdf
 
organic layer note this ammonium salt (itself is.pdf
                     organic layer note this ammonium salt (itself is.pdf                     organic layer note this ammonium salt (itself is.pdf
organic layer note this ammonium salt (itself is.pdf
 
Glucose is more sluble in water because it has mo.pdf
                     Glucose is more sluble in water because it has mo.pdf                     Glucose is more sluble in water because it has mo.pdf
Glucose is more sluble in water because it has mo.pdf
 
compounds 1 and 3 are the same be cause they are .pdf
                     compounds 1 and 3 are the same be cause they are .pdf                     compounds 1 and 3 are the same be cause they are .pdf
compounds 1 and 3 are the same be cause they are .pdf
 
C) Its a double displacement reaction .pdf
                     C) Its a double displacement reaction          .pdf                     C) Its a double displacement reaction          .pdf
C) Its a double displacement reaction .pdf
 
B)light interacting with a metal and producing a .pdf
                     B)light interacting with a metal and producing a .pdf                     B)light interacting with a metal and producing a .pdf
B)light interacting with a metal and producing a .pdf
 

Recently uploaded

UChicago CMSC 23320 - The Best Commit Messages of 2024
UChicago CMSC 23320 - The Best Commit Messages of 2024UChicago CMSC 23320 - The Best Commit Messages of 2024
UChicago CMSC 23320 - The Best Commit Messages of 2024Borja Sotomayor
 
Analyzing and resolving a communication crisis in Dhaka textiles LTD.pptx
Analyzing and resolving a communication crisis in Dhaka textiles LTD.pptxAnalyzing and resolving a communication crisis in Dhaka textiles LTD.pptx
Analyzing and resolving a communication crisis in Dhaka textiles LTD.pptxLimon Prince
 
MuleSoft Integration with AWS Textract | Calling AWS Textract API |AWS - Clou...
MuleSoft Integration with AWS Textract | Calling AWS Textract API |AWS - Clou...MuleSoft Integration with AWS Textract | Calling AWS Textract API |AWS - Clou...
MuleSoft Integration with AWS Textract | Calling AWS Textract API |AWS - Clou...MysoreMuleSoftMeetup
 
Rich Dad Poor Dad ( PDFDrive.com )--.pdf
Rich Dad Poor Dad ( PDFDrive.com )--.pdfRich Dad Poor Dad ( PDFDrive.com )--.pdf
Rich Dad Poor Dad ( PDFDrive.com )--.pdfJerry Chew
 
Sternal Fractures & Dislocations - EMGuidewire Radiology Reading Room
Sternal Fractures & Dislocations - EMGuidewire Radiology Reading RoomSternal Fractures & Dislocations - EMGuidewire Radiology Reading Room
Sternal Fractures & Dislocations - EMGuidewire Radiology Reading RoomSean M. Fox
 
8 Tips for Effective Working Capital Management
8 Tips for Effective Working Capital Management8 Tips for Effective Working Capital Management
8 Tips for Effective Working Capital ManagementMBA Assignment Experts
 
Contoh Aksi Nyata Refleksi Diri ( NUR ).pdf
Contoh Aksi Nyata Refleksi Diri ( NUR ).pdfContoh Aksi Nyata Refleksi Diri ( NUR ).pdf
Contoh Aksi Nyata Refleksi Diri ( NUR ).pdfcupulin
 
How To Create Editable Tree View in Odoo 17
How To Create Editable Tree View in Odoo 17How To Create Editable Tree View in Odoo 17
How To Create Editable Tree View in Odoo 17Celine George
 
How to Send Pro Forma Invoice to Your Customers in Odoo 17
How to Send Pro Forma Invoice to Your Customers in Odoo 17How to Send Pro Forma Invoice to Your Customers in Odoo 17
How to Send Pro Forma Invoice to Your Customers in Odoo 17Celine George
 
male presentation...pdf.................
male presentation...pdf.................male presentation...pdf.................
male presentation...pdf.................MirzaAbrarBaig5
 
COMMUNICATING NEGATIVE NEWS - APPROACHES .pptx
COMMUNICATING NEGATIVE NEWS - APPROACHES .pptxCOMMUNICATING NEGATIVE NEWS - APPROACHES .pptx
COMMUNICATING NEGATIVE NEWS - APPROACHES .pptxannathomasp01
 
AIM of Education-Teachers Training-2024.ppt
AIM of Education-Teachers Training-2024.pptAIM of Education-Teachers Training-2024.ppt
AIM of Education-Teachers Training-2024.pptNishitharanjan Rout
 
When Quality Assurance Meets Innovation in Higher Education - Report launch w...
When Quality Assurance Meets Innovation in Higher Education - Report launch w...When Quality Assurance Meets Innovation in Higher Education - Report launch w...
When Quality Assurance Meets Innovation in Higher Education - Report launch w...Gary Wood
 
DEMONSTRATION LESSON IN ENGLISH 4 MATATAG CURRICULUM
DEMONSTRATION LESSON IN ENGLISH 4 MATATAG CURRICULUMDEMONSTRATION LESSON IN ENGLISH 4 MATATAG CURRICULUM
DEMONSTRATION LESSON IN ENGLISH 4 MATATAG CURRICULUMELOISARIVERA8
 
ĐỀ THAM KHẢO KÌ THI TUYỂN SINH VÀO LỚP 10 MÔN TIẾNG ANH FORM 50 CÂU TRẮC NGHI...
ĐỀ THAM KHẢO KÌ THI TUYỂN SINH VÀO LỚP 10 MÔN TIẾNG ANH FORM 50 CÂU TRẮC NGHI...ĐỀ THAM KHẢO KÌ THI TUYỂN SINH VÀO LỚP 10 MÔN TIẾNG ANH FORM 50 CÂU TRẮC NGHI...
ĐỀ THAM KHẢO KÌ THI TUYỂN SINH VÀO LỚP 10 MÔN TIẾNG ANH FORM 50 CÂU TRẮC NGHI...Nguyen Thanh Tu Collection
 
TỔNG HỢP HƠN 100 ĐỀ THI THỬ TỐT NGHIỆP THPT TOÁN 2024 - TỪ CÁC TRƯỜNG, TRƯỜNG...
TỔNG HỢP HƠN 100 ĐỀ THI THỬ TỐT NGHIỆP THPT TOÁN 2024 - TỪ CÁC TRƯỜNG, TRƯỜNG...TỔNG HỢP HƠN 100 ĐỀ THI THỬ TỐT NGHIỆP THPT TOÁN 2024 - TỪ CÁC TRƯỜNG, TRƯỜNG...
TỔNG HỢP HƠN 100 ĐỀ THI THỬ TỐT NGHIỆP THPT TOÁN 2024 - TỪ CÁC TRƯỜNG, TRƯỜNG...Nguyen Thanh Tu Collection
 
e-Sealing at EADTU by Kamakshi Rajagopal
e-Sealing at EADTU by Kamakshi Rajagopale-Sealing at EADTU by Kamakshi Rajagopal
e-Sealing at EADTU by Kamakshi RajagopalEADTU
 

Recently uploaded (20)

UChicago CMSC 23320 - The Best Commit Messages of 2024
UChicago CMSC 23320 - The Best Commit Messages of 2024UChicago CMSC 23320 - The Best Commit Messages of 2024
UChicago CMSC 23320 - The Best Commit Messages of 2024
 
Analyzing and resolving a communication crisis in Dhaka textiles LTD.pptx
Analyzing and resolving a communication crisis in Dhaka textiles LTD.pptxAnalyzing and resolving a communication crisis in Dhaka textiles LTD.pptx
Analyzing and resolving a communication crisis in Dhaka textiles LTD.pptx
 
MuleSoft Integration with AWS Textract | Calling AWS Textract API |AWS - Clou...
MuleSoft Integration with AWS Textract | Calling AWS Textract API |AWS - Clou...MuleSoft Integration with AWS Textract | Calling AWS Textract API |AWS - Clou...
MuleSoft Integration with AWS Textract | Calling AWS Textract API |AWS - Clou...
 
Rich Dad Poor Dad ( PDFDrive.com )--.pdf
Rich Dad Poor Dad ( PDFDrive.com )--.pdfRich Dad Poor Dad ( PDFDrive.com )--.pdf
Rich Dad Poor Dad ( PDFDrive.com )--.pdf
 
Sternal Fractures & Dislocations - EMGuidewire Radiology Reading Room
Sternal Fractures & Dislocations - EMGuidewire Radiology Reading RoomSternal Fractures & Dislocations - EMGuidewire Radiology Reading Room
Sternal Fractures & Dislocations - EMGuidewire Radiology Reading Room
 
8 Tips for Effective Working Capital Management
8 Tips for Effective Working Capital Management8 Tips for Effective Working Capital Management
8 Tips for Effective Working Capital Management
 
Contoh Aksi Nyata Refleksi Diri ( NUR ).pdf
Contoh Aksi Nyata Refleksi Diri ( NUR ).pdfContoh Aksi Nyata Refleksi Diri ( NUR ).pdf
Contoh Aksi Nyata Refleksi Diri ( NUR ).pdf
 
How To Create Editable Tree View in Odoo 17
How To Create Editable Tree View in Odoo 17How To Create Editable Tree View in Odoo 17
How To Create Editable Tree View in Odoo 17
 
How to Send Pro Forma Invoice to Your Customers in Odoo 17
How to Send Pro Forma Invoice to Your Customers in Odoo 17How to Send Pro Forma Invoice to Your Customers in Odoo 17
How to Send Pro Forma Invoice to Your Customers in Odoo 17
 
male presentation...pdf.................
male presentation...pdf.................male presentation...pdf.................
male presentation...pdf.................
 
COMMUNICATING NEGATIVE NEWS - APPROACHES .pptx
COMMUNICATING NEGATIVE NEWS - APPROACHES .pptxCOMMUNICATING NEGATIVE NEWS - APPROACHES .pptx
COMMUNICATING NEGATIVE NEWS - APPROACHES .pptx
 
AIM of Education-Teachers Training-2024.ppt
AIM of Education-Teachers Training-2024.pptAIM of Education-Teachers Training-2024.ppt
AIM of Education-Teachers Training-2024.ppt
 
When Quality Assurance Meets Innovation in Higher Education - Report launch w...
When Quality Assurance Meets Innovation in Higher Education - Report launch w...When Quality Assurance Meets Innovation in Higher Education - Report launch w...
When Quality Assurance Meets Innovation in Higher Education - Report launch w...
 
DEMONSTRATION LESSON IN ENGLISH 4 MATATAG CURRICULUM
DEMONSTRATION LESSON IN ENGLISH 4 MATATAG CURRICULUMDEMONSTRATION LESSON IN ENGLISH 4 MATATAG CURRICULUM
DEMONSTRATION LESSON IN ENGLISH 4 MATATAG CURRICULUM
 
ĐỀ THAM KHẢO KÌ THI TUYỂN SINH VÀO LỚP 10 MÔN TIẾNG ANH FORM 50 CÂU TRẮC NGHI...
ĐỀ THAM KHẢO KÌ THI TUYỂN SINH VÀO LỚP 10 MÔN TIẾNG ANH FORM 50 CÂU TRẮC NGHI...ĐỀ THAM KHẢO KÌ THI TUYỂN SINH VÀO LỚP 10 MÔN TIẾNG ANH FORM 50 CÂU TRẮC NGHI...
ĐỀ THAM KHẢO KÌ THI TUYỂN SINH VÀO LỚP 10 MÔN TIẾNG ANH FORM 50 CÂU TRẮC NGHI...
 
TỔNG HỢP HƠN 100 ĐỀ THI THỬ TỐT NGHIỆP THPT TOÁN 2024 - TỪ CÁC TRƯỜNG, TRƯỜNG...
TỔNG HỢP HƠN 100 ĐỀ THI THỬ TỐT NGHIỆP THPT TOÁN 2024 - TỪ CÁC TRƯỜNG, TRƯỜNG...TỔNG HỢP HƠN 100 ĐỀ THI THỬ TỐT NGHIỆP THPT TOÁN 2024 - TỪ CÁC TRƯỜNG, TRƯỜNG...
TỔNG HỢP HƠN 100 ĐỀ THI THỬ TỐT NGHIỆP THPT TOÁN 2024 - TỪ CÁC TRƯỜNG, TRƯỜNG...
 
e-Sealing at EADTU by Kamakshi Rajagopal
e-Sealing at EADTU by Kamakshi Rajagopale-Sealing at EADTU by Kamakshi Rajagopal
e-Sealing at EADTU by Kamakshi Rajagopal
 
Mattingly "AI and Prompt Design: LLMs with NER"
Mattingly "AI and Prompt Design: LLMs with NER"Mattingly "AI and Prompt Design: LLMs with NER"
Mattingly "AI and Prompt Design: LLMs with NER"
 
ESSENTIAL of (CS/IT/IS) class 07 (Networks)
ESSENTIAL of (CS/IT/IS) class 07 (Networks)ESSENTIAL of (CS/IT/IS) class 07 (Networks)
ESSENTIAL of (CS/IT/IS) class 07 (Networks)
 
VAMOS CUIDAR DO NOSSO PLANETA! .
VAMOS CUIDAR DO NOSSO PLANETA!                    .VAMOS CUIDAR DO NOSSO PLANETA!                    .
VAMOS CUIDAR DO NOSSO PLANETA! .
 

EnvironmentLet assume the environment is a grid of colored tiles(.pdf

  • 1. Environment: Let assume the environment is a grid of colored tiles(WHITE,BLUE,GREEN,BLACK,YELLOW).Robot is standing on a tile.Every tile has a(X,Y) Position We use a function getTileColor(x,y) to know color of current tile(x,y position). ALGORITHM: TRESUREHUNT(x,y) 1. color=getColor(x,y) 2. IF color=YELLOW 3. Return "tiles"+x+y+" Is a tresure" 4. ELSE IF color=WHITE 5. TRESUREHUNT(x,y-1) // move to front tile by decrementing y by 1 6 ELSE IF color=BLUE 7. TRESUREHUNT(x-1,y) // move to left bydecrementing x by 1 8. ELSE IF color=GREEN 9. TRESUREHUNT(x+1,y) // move to right tile by incrementing x by 1 10. ELSE IF color=BLACK 11. TRESUREHUNT(x,y+2) // move to front tile by incrementint y by 2 12. ELSE 13. Return "Unsucessfull" 12.END iF C++ CODE //for simplicity i represent entite grid in a 2;D array .Each cell is viewed as a tile.It contains arbitary color values,0-BLACK //1-BLUE,2;GREEN,14;YELLOW,15-WHITE //accordingly the x,y value is changed. if current cell(tile)=15(WHITE) robot moves to front tile. // so x=x-1 and y=y #include #include void tresurehunt(int x,int y); int grid[][7]={ {1, 1, 1, 14,2, 0, 15}, {0, 1, 1, 1, 0, 0, 2}, {2, 2 ,1, 0, 15,14,1}, {15,15,14,0, 1, 2, 1}, {15,0, 0, 1, 2, 2, 14},
  • 2. {14,14,14,15,0, 2, 2}, {15,15,15,1, 1, 2, 1}}; int main() { tresurehunt(4,4); return 0; } void tresurehunt(int x,int y) { //int color=getpixel(x,y); int color=grid[x][y]; if(color==YELLOW) { cout<<"Tresure is in:"< Solution Environment: Let assume the environment is a grid of colored tiles(WHITE,BLUE,GREEN,BLACK,YELLOW).Robot is standing on a tile.Every tile has a(X,Y) Position We use a function getTileColor(x,y) to know color of current tile(x,y position). ALGORITHM: TRESUREHUNT(x,y) 1. color=getColor(x,y) 2. IF color=YELLOW 3. Return "tiles"+x+y+" Is a tresure" 4. ELSE IF color=WHITE 5. TRESUREHUNT(x,y-1) // move to front tile by decrementing y by 1 6 ELSE IF color=BLUE 7. TRESUREHUNT(x-1,y) // move to left bydecrementing x by 1 8. ELSE IF color=GREEN 9. TRESUREHUNT(x+1,y) // move to right tile by incrementing x by 1 10. ELSE IF color=BLACK 11. TRESUREHUNT(x,y+2) // move to front tile by incrementint y by 2 12. ELSE 13. Return "Unsucessfull"
  • 3. 12.END iF C++ CODE //for simplicity i represent entite grid in a 2;D array .Each cell is viewed as a tile.It contains arbitary color values,0-BLACK //1-BLUE,2;GREEN,14;YELLOW,15-WHITE //accordingly the x,y value is changed. if current cell(tile)=15(WHITE) robot moves to front tile. // so x=x-1 and y=y #include #include void tresurehunt(int x,int y); int grid[][7]={ {1, 1, 1, 14,2, 0, 15}, {0, 1, 1, 1, 0, 0, 2}, {2, 2 ,1, 0, 15,14,1}, {15,15,14,0, 1, 2, 1}, {15,0, 0, 1, 2, 2, 14}, {14,14,14,15,0, 2, 2}, {15,15,15,1, 1, 2, 1}}; int main() { tresurehunt(4,4); return 0; } void tresurehunt(int x,int y) { //int color=getpixel(x,y); int color=grid[x][y]; if(color==YELLOW) { cout<<"Tresure is in:"<