mirror of
https://github.com/mfocko/blog.git
synced 2024-11-25 06:11:55 +01:00
1 line
12 KiB
JavaScript
1 line
12 KiB
JavaScript
|
"use strict";(self.webpackChunkfi=self.webpackChunkfi||[]).push([[281],{99544:(e,n,t)=>{t.r(n),t.d(n,{assets:()=>a,contentTitle:()=>s,default:()=>h,frontMatter:()=>i,metadata:()=>l,toc:()=>d});var r=t(85893),o=t(11151);const i={id:"karel",slug:"/recursion/karel",title:"Recursion and backtracking with Robot Karel",description:"A problem with too many restrictions.\n",tags:["python","karel","recursion","backtracking"],last_update:{date:new Date("2022-11-29T00:00:00.000Z")}},s=void 0,l={id:"recursion/2022-11-29-karel/karel",title:"Recursion and backtracking with Robot Karel",description:"A problem with too many restrictions.\n",source:"@site/algorithms/04-recursion/2022-11-29-karel/index.md",sourceDirName:"04-recursion/2022-11-29-karel",slug:"/recursion/karel",permalink:"/algorithms/recursion/karel",draft:!1,unlisted:!1,editUrl:"https://github.com/mfocko/blog/tree/main/algorithms/04-recursion/2022-11-29-karel/index.md",tags:[{label:"python",permalink:"/algorithms/tags/python"},{label:"karel",permalink:"/algorithms/tags/karel"},{label:"recursion",permalink:"/algorithms/tags/recursion"},{label:"backtracking",permalink:"/algorithms/tags/backtracking"}],version:"current",lastUpdatedAt:166968e4,formattedLastUpdatedAt:"Nov 29, 2022",frontMatter:{id:"karel",slug:"/recursion/karel",title:"Recursion and backtracking with Robot Karel",description:"A problem with too many restrictions.\n",tags:["python","karel","recursion","backtracking"],last_update:{date:"2022-11-29T00:00:00.000Z"}},sidebar:"autogeneratedBar",previous:{title:"Recursion",permalink:"/algorithms/category/recursion"},next:{title:"Solution to the problem",permalink:"/algorithms/recursion/karel/solution"}},a={},d=[{value:"Introduction",id:"introduction",level:2},{value:"Your environment and problem description",id:"your-environment-and-problem-description",level:2},{value:"Environment",id:"environment",level:3},{value:"Interface",id:"interface",level:3},{value:"Problem",id:"problem",level:3},{value:"Simple problem to get familiar with the robot",id:"simple-problem-to-get-familiar-with-the-robot",level:2},{value:"Brainstorm the idea",id:"brainstorm-the-idea",level:2},{value:"\xbbRough\xab pseudocode",id:"rough-pseudocode",level:2},{value:"\xbbProper\xab pseudocode",id:"proper-pseudocode",level:2},{value:"Library",id:"library",level:2},{value:"Solution",id:"solution",level:2}];function c(e){const n={a:"a",admonition:"admonition",code:"code",em:"em",h2:"h2",h3:"h3",img:"img",li:"li",ol:"ol",p:"p",pre:"pre",strong:"strong",ul:"ul",...(0,o.a)(),...e.components};return(0,r.jsxs)(r.Fragment,{children:[(0,r.jsxs)(n.ul,{children:["\n",(0,r.jsx)(n.li,{children:(0,r.jsx)(n.a,{href:"pathname:///files/algorithms/recursion/karel-1.tar.gz",children:"Sources"})}),"\n"]}),"\n",(0,r.jsx)(n.h2,{id:"introduction",children:"Introduction"}),"\n",(0,r.jsx)(n.p,{children:"In this exercise we will be working with a Robot Karel and with a \xbbvery\xab limited\nresources. The point of this exercise is to show how powerful recursion and\nbacktracking can be even without anything else at your hand."}),"\n",(0,r.jsx)(n.h2,{id:"your-environment-and-problem-description",children:"Your environment and problem description"}),"\n",(0,r.jsx)(n.h3,{id:"environment",children:"Environment"}),"\n",(0,r.jsx)(n.p,{children:"You are given a robot that is present in a maze and is looking for an exit. Maze\nconsists of different walls and exit is marked with a single so-called \u201cbeeper\u201d."}),"\n",(0,r.jsx)(n.p,{children:"Walking into a wall results in a permanent damage of the robot."}),"\n",(0,r.jsx)(n.h3,{id:"interface",children:"Interface"}),"\n",(0,r.jsx)(n.p,{children:"You can control the robot using the following interface:"}),"\n",(0,r.jsxs)(n.ul,{children:["\n",(0,r.jsxs)(n.li,{children:["actions \u200b\xad\u2014 you can use them to change the current state of the robot and its\nsurroundings","\n",(0,r.jsxs)(n.ul,{children:["\n",(0,r.jsxs)(n.li,{children:[(0,r.jsx)(n.code,{children:"robot.step()"})," \u2014 moves robot one step further"]}),"\n",(0,r.jsxs)(n.li,{children:[(0,r.jsx)(n.code,{children:"
|