# Programming Quiz 4.8

 0 Hi, Why my answer in this quiz is displaying as "incorrect" whereas code is displaying right result. Can anyone help ? Answer of quiz should be [11,4,5].. and I am getting same answer . what should I do to make it displayed as"correct" after submitting it? def check_goal(node): if (node[0] == goal[0]) and (node[1]==goal[1]): return True def Add(delta,node): neighbor = [] for i in range(len(delta)): x = node[0] + delta[i][0] y = node[1] + delta[i][1] if(x>=0 and x=0 and y

 2 Hi! Make sure your search function returns (and not just prints) a list in the form of [optimal path length, x, y]. See the user instructions at the top of the provided code. answered 14 Mar '12, 04:10 MichaelUdacity ♦♦ 2.9k●6●22●31
 1 You have to change  if (check_goal(node)): found = True print nextt  to:  if (check_goal(node)): found = True return nextt  and  resign= True print "Fail to complete search"  to  resign= True return "fail"  because right now you print out the right answer, but return a boolean True, and that is now what is asked answered 14 Mar '12, 06:13 Gundega ♦♦ 44.0k●70●170●315
 0 I typed "print search()" to make sure it is working correctly ....if I omit "print" and write only "search()" .. even then "incorrect" message is displayed answered 14 Mar '12, 06:08 zaib 254●3●6●19
 0 still incorrect :( answered 14 Mar '12, 13:27 zaib 254●3●6●19
 0 I'm having similar trouble. The comment block at the beginning of the template code says to "return" [g,x,y] - but in the video that follows it looks like what they wanted was print [g,x,y]. Either way I can't get it accept my routine. Frustrating as it functionally worked with all the test cases from the video. Maybe something similar to the HW3.6 issue edit: switching the code back to "return" the values, resetting the template, then pasting the code back in made it work. This is a problem for homework where you only get one try... answered 14 Mar '12, 13:57 Chad Seymour-1 12●2
 0 If you change position of 1 as shown in grid of quiz 4.8 .. you will get [11,4,5] .. for different position of "1" in grid we can get different values for g,x and y. you are right .. may be it is the same problem as what happened in home works. answered 14 Mar '12, 15:33 zaib 254●3●6●19 /facepalm I was toying around and changed the grid in my example. Sorry for trying to confuse you! have you tried to do the "reset" trick and paste only the function itself, leaving last line intact ? (14 Mar '12, 15:42) Gundega ♦♦
 0 yes I did answered 14 Mar '12, 15:45 zaib 254●3●6●19
Question text:

Markdown Basics

• *italic* or _italic_
• **bold** or __bold__
• image?![alt text](/path/img.jpg "Title")
• numbered list: 1. Foo 2. Bar
• to add a line break simply add two spaces to where you would like the new line to be.
• basic HTML tags are also supported

×5,185
×195