Best answer to AMCAT automata 2015

Best answer to AMCAT automata 2015

SHARE:

AMCAT exam there is an optional section that is AUTOMATA which have 2 questions here is the question I am going to solve it written in JAVA and can be written in any other language with minor changes in logic. Lets see the problem and its program

If you have attempted the AMCAT exam there is an optional section that is AUTOMATA which have 2 questions here is the question I am going to solve it written in JAVA and can be written in any other language with minor changes in logic. Let's see the problem and its program

Problem:

Mooshak the mouse has been placed in a maze.There is a huge chunk of cheese somewhere in the maze. The maze is represented as a two-dimensional array of integers, where 0 represents walls.1 represents paths where mooshak can move and 9 represents the huge chunk of cheese.

Also read: AMCAT Automata Important questions 2015


Mooshak starts in the top left corner at 0.
Write a method is Path of class Maze Path to determine if Mooshak can reach the huge chunk of cheese. The input to is Path consists of a two dimensional array gnd for the maze matrix. the method should return 1 if there is a path from Mooshak to the cheese.and 0 if not Mooshak is not allowed to leave the maze or climb on walls.

EX: 8 by 8(8*8) matrix maze where Mooshak can get the cheese.

1 0 1 1 1 0 0 1
1 0 0 0 1 1 1 1
1 0 0 0 0 0 0 0
1 0 1 0 9 0 1 1
1 1 1 0 1 0 0 1
1 0 1 0 1 1 0 1
1 0 0 0 0 1 0 1
1 1 1 1 1 1 1 1

Test Cases:

Case 1:
Input:[[1,1,1,][9,1,1],[0,1,0]]

Expected return value :1


Explanation:

The piece of cheese is placed at(1,0) on the grid Mooshak can move from (0,0) to (1,0) to reach it or can move from (0,0) to (0,1) to (1,1) to (1,0)

Test case 2:

Input: [[0,0,0],[9,1,1],[0,1,1]]

Expected return value: 0


Explanation:


Mooshak cannot move anywhere as there exists a wall right on (0,0)


Code format: (C Language)

//include header files needed by your program
// some libray functionality may be restricted
// define any function needed
// fucion signature begins, this function is required
Int isPath(int **grid,int m,int n)
{/
/ write your code here
}/
/function signature ends

Java Code format:

//import librays packages needed by your program
// some clases with in a package may be restricted
//define any class and method needed
//class begins ,this class is required
Public class MazePath
{
Public static int isPath(int[][] grid)
// insert your code here
}/
/ method signature ends
}
Amcat Automata Paper Question with solution 2015

Java Program Code:

Int isPath(int **grid,int m,int n)
{
Return SolveMazeUtil(grid,0,0,m,n);
}I
nt SolveMazeUtil(int **grid,x,y,m,n)
{
If(x>=0 && x < m && y>=0 && y<n)
{
if(grid[x][y]==9))
{
return 1;
}
// Check if maze[x][y] is valid
if(grid[x][y] == 1)
{
/* Move forward in x direction */
if (solveMazeUtil(grid, x+1, y, m,n) == 1)
return 1;
/* If moving in x direction doesn't give solution then
Move down in y direction */
if (solveMazeUtil(grid, x, y+1, m,n) == 1)
return 1;
/* If none of the above movements work then BACKTRACK:
unmark x,y as part of solution path */
return 0;
}
return 0;
}
return 0;
}
Also read: Recent Automata AMCAT questions answers

Thank you for reading. Share with your friends and help them.

COMMENTS

BLOGGER: 1
  1. in your code, mouse can either move in horizontal right or vertically down...but in some cases it may need that mouse move in horizontal left and vertically up to make a way and get cheese...

    ReplyDelete

Related Articles

Name

Android,41,Blogger,25,Blogging,30,Business,26,Computer,71,Development,6,Finance,1,Games,5,Guest,330,Health,19,iOS,8,Marketing,19,Online Tools,3,Programming,25,SEO,75,Social,278,Software,4,Startup,14,Technology,23,Website,17,Wordpress,20,
ltr
item
MindxMaster: Best answer to AMCAT automata 2015
Best answer to AMCAT automata 2015
AMCAT exam there is an optional section that is AUTOMATA which have 2 questions here is the question I am going to solve it written in JAVA and can be written in any other language with minor changes in logic. Lets see the problem and its program
https://2.bp.blogspot.com/-FQhJSZUETE4/WGEenv2IP3I/AAAAAAAADv4/m-vddjDLEsc2iMg6f2NUAaoHLhRqc6MogCK4B/s1600/dd.png
https://2.bp.blogspot.com/-FQhJSZUETE4/WGEenv2IP3I/AAAAAAAADv4/m-vddjDLEsc2iMg6f2NUAaoHLhRqc6MogCK4B/s72-c/dd.png
MindxMaster
https://www.mindxmaster.com/2015/11/best-answer-to-amcat-automata-2015.html
https://www.mindxmaster.com/
https://www.mindxmaster.com/
https://www.mindxmaster.com/2015/11/best-answer-to-amcat-automata-2015.html
true
5332415103371288268
UTF-8
Loaded All Posts Not found any posts VIEW ALL Readmore Reply Cancel reply Delete By Home PAGES POSTS View All RECOMMENDED FOR YOU LABEL ARCHIVE SEARCH ALL POSTS Not found any post match with your request Back Home Sunday Monday Tuesday Wednesday Thursday Friday Saturday Sun Mon Tue Wed Thu Fri Sat January February March April May June July August September October November December Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec just now 1 minute ago $$1$$ minutes ago 1 hour ago $$1$$ hours ago Yesterday $$1$$ days ago $$1$$ weeks ago more than 5 weeks ago Followers Follow THIS PREMIUM CONTENT IS LOCKED STEP 1: Share to a social network STEP 2: Click the link on your social network Copy All Code Select All Code All codes were copied to your clipboard Can not copy the codes / texts, please press [CTRL]+[C] (or CMD+C with Mac) to copy