mirror of
https://github.com/mfocko/blog.git
synced 2024-11-10 08:19:07 +01:00
1 line
No EOL
16 KiB
JavaScript
1 line
No EOL
16 KiB
JavaScript
"use strict";(self.webpackChunkfi=self.webpackChunkfi||[]).push([[2167],{3905:(t,e,n)=>{n.d(e,{Zo:()=>s,kt:()=>h});var a=n(7294);function r(t,e,n){return e in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function i(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(t);e&&(a=a.filter((function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),n.push.apply(n,a)}return n}function l(t){for(var e=1;e<arguments.length;e++){var n=null!=arguments[e]?arguments[e]:{};e%2?i(Object(n),!0).forEach((function(e){r(t,e,n[e])})):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):i(Object(n)).forEach((function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(n,e))}))}return t}function o(t,e){if(null==t)return{};var n,a,r=function(t,e){if(null==t)return{};var n,a,r={},i=Object.keys(t);for(a=0;a<i.length;a++)n=i[a],e.indexOf(n)>=0||(r[n]=t[n]);return r}(t,e);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(t);for(a=0;a<i.length;a++)n=i[a],e.indexOf(n)>=0||Object.prototype.propertyIsEnumerable.call(t,n)&&(r[n]=t[n])}return r}var p=a.createContext({}),m=function(t){var e=a.useContext(p),n=e;return t&&(n="function"==typeof t?t(e):l(l({},e),t)),n},s=function(t){var e=m(t.components);return a.createElement(p.Provider,{value:e},t.children)},d="mdxType",k={inlineCode:"code",wrapper:function(t){var e=t.children;return a.createElement(a.Fragment,{},e)}},u=a.forwardRef((function(t,e){var n=t.components,r=t.mdxType,i=t.originalType,p=t.parentName,s=o(t,["components","mdxType","originalType","parentName"]),d=m(n),u=r,h=d["".concat(p,".").concat(u)]||d[u]||k[u]||i;return n?a.createElement(h,l(l({ref:e},s),{},{components:n})):a.createElement(h,l({ref:e},s))}));function h(t,e){var n=arguments,r=e&&e.mdxType;if("string"==typeof t||r){var i=n.length,l=new Array(i);l[0]=u;var o={};for(var p in e)hasOwnProperty.call(e,p)&&(o[p]=e[p]);o.originalType=t,o[d]="string"==typeof t?t:r,l[1]=o;for(var m=2;m<i;m++)l[m]=n[m];return a.createElement.apply(null,l)}return a.createElement.apply(null,n)}u.displayName="MDXCreateElement"},6652:(t,e,n)=>{n.r(e),n.d(e,{assets:()=>p,contentTitle:()=>l,default:()=>k,frontMatter:()=>i,metadata:()=>o,toc:()=>m});var a=n(7462),r=(n(7294),n(3905));const i={id:"seminar-04",title:"4th seminar",description:"Robot in a maze.\n",last_update:{date:new Date("2023-03-13T00:00:00.000Z")}},l=void 0,o={unversionedId:"bonuses/seminar-04",id:"bonuses/seminar-04",title:"4th seminar",description:"Robot in a maze.\n",source:"@site/pb071/bonuses/04.md",sourceDirName:"bonuses",slug:"/bonuses/seminar-04",permalink:"/pb071/bonuses/seminar-04",draft:!1,editUrl:"https://github.com/mfocko/blog/tree/main/pb071/bonuses/04.md",tags:[],version:"current",lastUpdatedAt:1678665600,formattedLastUpdatedAt:"Mar 13, 2023",frontMatter:{id:"seminar-04",title:"4th seminar",description:"Robot in a maze.\n",last_update:{date:"2023-03-13T00:00:00.000Z"}},sidebar:"autogeneratedBar",previous:{title:"3rd seminar",permalink:"/pb071/bonuses/seminar-03"},next:{title:"5th and 6th seminar",permalink:"/pb071/bonuses/seminar-05-06"}},p={},m=[{value:"Introduction",id:"introduction",level:2},{value:"Hard requirement",id:"hard-requirement",level:2},{value:"Example of run",id:"example-of-run",level:2},{value:"Bonus part",id:"bonus-part",level:2},{value:"Easter eggs",id:"easter-eggs",level:2},{value:"Submitting",id:"submitting",level:2}],s={toc:m},d="wrapper";function k(t){let{components:e,...n}=t;return(0,r.kt)(d,(0,a.Z)({},s,n,{components:e,mdxType:"MDXLayout"}),(0,r.kt)("admonition",{type:"caution"},(0,r.kt)("p",{parentName:"admonition"},"Deadline for the submission of the bonus is ",(0,r.kt)("strong",{parentName:"p"},"March 23th 24:00"),".")),(0,r.kt)("admonition",{type:"tip"},(0,r.kt)("p",{parentName:"admonition"},"In case you have any questions, feel free to reach out either by email, Discord\nor just by submitting an issue ",(0,r.kt)("a",{parentName:"p",href:"https://gitlab.fi.muni.cz/xfocko/kb/-/issues/new"},"here"),".")),(0,r.kt)("p",null,"For this bonus you can get 3 K\u20a1 and another 0.5 K\u20a1 for the bonus part of it."),(0,r.kt)("p",null,(0,r.kt)("a",{parentName:"p",href:"pathname:///files/pb071/bonuses/04.tar.gz"},"Source")),(0,r.kt)("h2",{id:"introduction"},"Introduction"),(0,r.kt)("p",null,"In this task you are given a 2D map for a robot. The map contains multiple markers:"),(0,r.kt)("ul",null,(0,r.kt)("li",{parentName:"ul"},(0,r.kt)("inlineCode",{parentName:"li"},"^v<>")," - which denote the directions the robot will be facing when he steps into\nthe cell or starts on it."),(0,r.kt)("li",{parentName:"ul"},(0,r.kt)("inlineCode",{parentName:"li"},"K")," - denotes the key."),(0,r.kt)("li",{parentName:"ul"},(0,r.kt)("inlineCode",{parentName:"li"},"T")," - denotes the treasure.")),(0,r.kt)("p",null,"In case robot lands at the beginning on unknown field, e.g. ",(0,r.kt)("inlineCode",{parentName:"p"},".")," in the tests, he\nfaces the direction that is given through the parameter."),(0,r.kt)("p",null,"Your task is to write the ",(0,r.kt)("inlineCode",{parentName:"p"},"walk")," function that returns end result of the walk.\nWalk can end in multiple ways:"),(0,r.kt)("ul",null,(0,r.kt)("li",{parentName:"ul"},(0,r.kt)("inlineCode",{parentName:"li"},"FOUND_TREASURE")," - when you find the treasure"),(0,r.kt)("li",{parentName:"ul"},(0,r.kt)("inlineCode",{parentName:"li"},"FOUND_KEY")," - when you find the key"),(0,r.kt)("li",{parentName:"ul"},(0,r.kt)("inlineCode",{parentName:"li"},"OUT_OF_BOUNDS")," - when the robot falls off the map"),(0,r.kt)("li",{parentName:"ul"},(0,r.kt)("inlineCode",{parentName:"li"},"INFINITE_LOOP")," - in case you will implement the bonus"),(0,r.kt)("li",{parentName:"ul"},(0,r.kt)("inlineCode",{parentName:"li"},"NONE")," - which is used right now as a default return in the skeleton, has no meaning\nlater on")),(0,r.kt)("h2",{id:"hard-requirement"},"Hard requirement"),(0,r.kt)("p",null,"There is only one hard requirement that tests cannot check."),(0,r.kt)("p",null,(0,r.kt)("strong",{parentName:"p"},"You are not allowed to use any indexing related to map or your current position"),"\n",(0,r.kt)("strong",{parentName:"p"},"in your implementation.")),(0,r.kt)("p",null,"Reason for this requirement is for you to get used to working with pointers. And\nfor the implementation of this task it is much easier to use just the pointers."),(0,r.kt)("h2",{id:"example-of-run"},"Example of run"),(0,r.kt)("p",null,"For a better understanding of your task, I will describe a simple walk with corresponding\nfunction call."),(0,r.kt)("pre",null,(0,r.kt)("code",{parentName:"pre",className:"language-c"},'const char *map = (\n ">.v"\n ".K<"\n "..."\n);\n\nwalk(map, &map[6], \'^\', 3, 3);\n')),(0,r.kt)("p",null,"For this call, you should return ",(0,r.kt)("inlineCode",{parentName:"p"},"FOUND_KEY"),". Let us walk through the walk ;)"),(0,r.kt)("ol",null,(0,r.kt)("li",{parentName:"ol"},(0,r.kt)("p",{parentName:"li"},"Robot is placed at the bottom left corner, there is no direction specified, so\nhe follows the direction given by parameter (upwards, denoted as ",(0,r.kt)("inlineCode",{parentName:"p"},"N"),"(orth),\nso that we can differentiate markers on the map with the robot when using printing\nfunction)."),(0,r.kt)("pre",{parentName:"li"},(0,r.kt)("code",{parentName:"pre"},">.v\n.K<\nN..\n"))),(0,r.kt)("li",{parentName:"ol"},(0,r.kt)("p",{parentName:"li"},"Moves up:"),(0,r.kt)("pre",{parentName:"li"},(0,r.kt)("code",{parentName:"pre"},">.v\nNK<\n...\n"))),(0,r.kt)("li",{parentName:"ol"},(0,r.kt)("p",{parentName:"li"},"Moves up (now covers ",(0,r.kt)("inlineCode",{parentName:"p"},">"),"), changes direction to right:"),(0,r.kt)("pre",{parentName:"li"},(0,r.kt)("code",{parentName:"pre"},"E.v\n.K<\n...\n"))),(0,r.kt)("li",{parentName:"ol"},(0,r.kt)("p",{parentName:"li"},"Moves to right:"),(0,r.kt)("pre",{parentName:"li"},(0,r.kt)("code",{parentName:"pre"},">Ev\n.K<\n...\n"))),(0,r.kt)("li",{parentName:"ol"},(0,r.kt)("p",{parentName:"li"},"Moves to right, faces south:"),(0,r.kt)("pre",{parentName:"li"},(0,r.kt)("code",{parentName:"pre"},">.S\n.K<\n...\n"))),(0,r.kt)("li",{parentName:"ol"},(0,r.kt)("p",{parentName:"li"},"Moves down, faces west:"),(0,r.kt)("pre",{parentName:"li"},(0,r.kt)("code",{parentName:"pre"},">.v\n.KW\n...\n"))),(0,r.kt)("li",{parentName:"ol"},(0,r.kt)("p",{parentName:"li"},"Moves left, founds key, returns ",(0,r.kt)("inlineCode",{parentName:"p"},"FOUND_KEY"),":"),(0,r.kt)("pre",{parentName:"li"},(0,r.kt)("code",{parentName:"pre"},">.v\n.W<\n...\n")))),(0,r.kt)("h2",{id:"bonus-part"},"Bonus part"),(0,r.kt)("p",null,"For the bonus part you are supposed to return ",(0,r.kt)("inlineCode",{parentName:"p"},"INFINITE_LOOP")," in case the robot\nis stuck in the infinite loop. There are three tests for it. If you pass only the\neasy and medium one, you can get 0.25 K\u20a1 for doing your best and trying it out. :)"),(0,r.kt)("h2",{id:"easter-eggs"},"Easter eggs"),(0,r.kt)("ul",null,(0,r.kt)("li",{parentName:"ul"},(0,r.kt)("p",{parentName:"li"},"Statistics"),(0,r.kt)("table",{parentName:"li"},(0,r.kt)("thead",{parentName:"table"},(0,r.kt)("tr",{parentName:"thead"},(0,r.kt)("th",{parentName:"tr",align:null},"Language"),(0,r.kt)("th",{parentName:"tr",align:"right"},"Files"),(0,r.kt)("th",{parentName:"tr",align:"right"},"Lines"),(0,r.kt)("th",{parentName:"tr",align:"right"},"Blanks"),(0,r.kt)("th",{parentName:"tr",align:"right"},"Comments"),(0,r.kt)("th",{parentName:"tr",align:"right"},"Code"),(0,r.kt)("th",{parentName:"tr",align:"right"},"Complexity"))),(0,r.kt)("tbody",{parentName:"table"},(0,r.kt)("tr",{parentName:"tbody"},(0,r.kt)("td",{parentName:"tr",align:null},(0,r.kt)("em",{parentName:"td"},"C")),(0,r.kt)("td",{parentName:"tr",align:"right"},"4"),(0,r.kt)("td",{parentName:"tr",align:"right"},"458"),(0,r.kt)("td",{parentName:"tr",align:"right"},"34"),(0,r.kt)("td",{parentName:"tr",align:"right"},"58"),(0,r.kt)("td",{parentName:"tr",align:"right"},"366"),(0,r.kt)("td",{parentName:"tr",align:"right"},"33")),(0,r.kt)("tr",{parentName:"tbody"},(0,r.kt)("td",{parentName:"tr",align:null},(0,r.kt)("inlineCode",{parentName:"td"},"test_maze.c")),(0,r.kt)("td",{parentName:"tr",align:"right"}),(0,r.kt)("td",{parentName:"tr",align:"right"},"225"),(0,r.kt)("td",{parentName:"tr",align:"right"},"9"),(0,r.kt)("td",{parentName:"tr",align:"right"},"0"),(0,r.kt)("td",{parentName:"tr",align:"right"},"216"),(0,r.kt)("td",{parentName:"tr",align:"right"},"4")),(0,r.kt)("tr",{parentName:"tbody"},(0,r.kt)("td",{parentName:"tr",align:null},(0,r.kt)("inlineCode",{parentName:"td"},"sol.maze.c")),(0,r.kt)("td",{parentName:"tr",align:"right"}),(0,r.kt)("td",{parentName:"tr",align:"right"},"141"),(0,r.kt)("td",{parentName:"tr",align:"right"},"15"),(0,r.kt)("td",{parentName:"tr",align:"right"},"28"),(0,r.kt)("td",{parentName:"tr",align:"right"},"98"),(0,r.kt)("td",{parentName:"tr",align:"right"},"24")),(0,r.kt)("tr",{parentName:"tbody"},(0,r.kt)("td",{parentName:"tr",align:null},(0,r.kt)("inlineCode",{parentName:"td"},"maze.c")),(0,r.kt)("td",{parentName:"tr",align:"right"}),(0,r.kt)("td",{parentName:"tr",align:"right"},"84"),(0,r.kt)("td",{parentName:"tr",align:"right"},"8"),(0,r.kt)("td",{parentName:"tr",align:"right"},"30"),(0,r.kt)("td",{parentName:"tr",align:"right"},"46"),(0,r.kt)("td",{parentName:"tr",align:"right"},"5")),(0,r.kt)("tr",{parentName:"tbody"},(0,r.kt)("td",{parentName:"tr",align:null},(0,r.kt)("inlineCode",{parentName:"td"},"main.c")),(0,r.kt)("td",{parentName:"tr",align:"right"}),(0,r.kt)("td",{parentName:"tr",align:"right"},"8"),(0,r.kt)("td",{parentName:"tr",align:"right"},"2"),(0,r.kt)("td",{parentName:"tr",align:"right"},"0"),(0,r.kt)("td",{parentName:"tr",align:"right"},"6"),(0,r.kt)("td",{parentName:"tr",align:"right"},"0")),(0,r.kt)("tr",{parentName:"tbody"},(0,r.kt)("td",{parentName:"tr",align:null},(0,r.kt)("em",{parentName:"td"},"C Header")),(0,r.kt)("td",{parentName:"tr",align:"right"},"1"),(0,r.kt)("td",{parentName:"tr",align:"right"},"33"),(0,r.kt)("td",{parentName:"tr",align:"right"},"3"),(0,r.kt)("td",{parentName:"tr",align:"right"},"19"),(0,r.kt)("td",{parentName:"tr",align:"right"},"11"),(0,r.kt)("td",{parentName:"tr",align:"right"},"0")),(0,r.kt)("tr",{parentName:"tbody"},(0,r.kt)("td",{parentName:"tr",align:null},(0,r.kt)("inlineCode",{parentName:"td"},"maze.h")),(0,r.kt)("td",{parentName:"tr",align:"right"}),(0,r.kt)("td",{parentName:"tr",align:"right"},"33"),(0,r.kt)("td",{parentName:"tr",align:"right"},"3"),(0,r.kt)("td",{parentName:"tr",align:"right"},"19"),(0,r.kt)("td",{parentName:"tr",align:"right"},"11"),(0,r.kt)("td",{parentName:"tr",align:"right"},"0")),(0,r.kt)("tr",{parentName:"tbody"},(0,r.kt)("td",{parentName:"tr",align:null},(0,r.kt)("em",{parentName:"td"},"CMake")),(0,r.kt)("td",{parentName:"tr",align:"right"},"1"),(0,r.kt)("td",{parentName:"tr",align:"right"},"25"),(0,r.kt)("td",{parentName:"tr",align:"right"},"4"),(0,r.kt)("td",{parentName:"tr",align:"right"},"6"),(0,r.kt)("td",{parentName:"tr",align:"right"},"15"),(0,r.kt)("td",{parentName:"tr",align:"right"},"2")),(0,r.kt)("tr",{parentName:"tbody"},(0,r.kt)("td",{parentName:"tr",align:null},(0,r.kt)("inlineCode",{parentName:"td"},"CMakeLists.txt")),(0,r.kt)("td",{parentName:"tr",align:"right"}),(0,r.kt)("td",{parentName:"tr",align:"right"},"25"),(0,r.kt)("td",{parentName:"tr",align:"right"},"4"),(0,r.kt)("td",{parentName:"tr",align:"right"},"6"),(0,r.kt)("td",{parentName:"tr",align:"right"},"15"),(0,r.kt)("td",{parentName:"tr",align:"right"},"2")),(0,r.kt)("tr",{parentName:"tbody"},(0,r.kt)("td",{parentName:"tr",align:null},(0,r.kt)("strong",{parentName:"td"},"Total")),(0,r.kt)("td",{parentName:"tr",align:"right"},"6"),(0,r.kt)("td",{parentName:"tr",align:"right"},"516"),(0,r.kt)("td",{parentName:"tr",align:"right"},"41"),(0,r.kt)("td",{parentName:"tr",align:"right"},"83"),(0,r.kt)("td",{parentName:"tr",align:"right"},"392"),(0,r.kt)("td",{parentName:"tr",align:"right"},"35"))))),(0,r.kt)("li",{parentName:"ul"},(0,r.kt)("p",{parentName:"li"},"Majority of the line count in solution is caused by the formatting :)")),(0,r.kt)("li",{parentName:"ul"},(0,r.kt)("p",{parentName:"li"},"Included headers can be interpreted as hints, same goes for the unimplemented\n",(0,r.kt)("inlineCode",{parentName:"p"},"static")," functions which you can use, but ",(0,r.kt)("strong",{parentName:"p"},"are not required"),".")),(0,r.kt)("li",{parentName:"ul"},(0,r.kt)("p",{parentName:"li"},"Given ",(0,r.kt)("inlineCode",{parentName:"p"},"CMakeLists.txt")," will generate 2 binaries, ",(0,r.kt)("inlineCode",{parentName:"p"},"test_maze")," and ",(0,r.kt)("inlineCode",{parentName:"p"},"maze"),"."),(0,r.kt)("ul",{parentName:"li"},(0,r.kt)("li",{parentName:"ul"},(0,r.kt)("inlineCode",{parentName:"li"},"test_maze")," runs the tests you are given."),(0,r.kt)("li",{parentName:"ul"},(0,r.kt)("inlineCode",{parentName:"li"},"maze")," runs the ",(0,r.kt)("inlineCode",{parentName:"li"},"main.c"),", where you can debug, print mazes and whatever else\nyou want."))),(0,r.kt)("li",{parentName:"ul"},(0,r.kt)("p",{parentName:"li"},"I keep only one copy of ",(0,r.kt)("inlineCode",{parentName:"p"},"cut.h")," in my repository, so you need to download it from\n",(0,r.kt)("a",{parentName:"p",href:"https://gitlab.fi.muni.cz/pb071/cut/-/jobs/159010/artifacts/file/1header/cut.h"},"here")," and place it into the directory where you have your source code."),(0,r.kt)("ul",{parentName:"li"},(0,r.kt)("li",{parentName:"ul"},"Or you can use the one you have from the latest homework, git will keep it\nonly once, so it doesn't take up more space."))),(0,r.kt)("li",{parentName:"ul"},(0,r.kt)("p",{parentName:"li"},"I would recommend cloning this repository and copying the ",(0,r.kt)("inlineCode",{parentName:"p"},"maze")," directory to\nyour own repository, since there are multiple files and it may be easier for you."))),(0,r.kt)("p",null,"In case you have any questions, feel free to reach out to me."),(0,r.kt)("h2",{id:"submitting"},"Submitting"),(0,r.kt)("p",null,"For submitting the bonus assignment you can follow the same procedure as for\nsubmitting the homeworks, that is:"),(0,r.kt)("ol",null,(0,r.kt)("li",{parentName:"ol"},"On branch ",(0,r.kt)("inlineCode",{parentName:"li"},"main")," add the provided skeleton."),(0,r.kt)("li",{parentName:"ol"},"Checkout new branch ",(0,r.kt)("inlineCode",{parentName:"li"},"seminar-bonus-04"),"."),(0,r.kt)("li",{parentName:"ol"},"Add your solution to the newly created branch."),(0,r.kt)("li",{parentName:"ol"},"Create a MR to the ",(0,r.kt)("inlineCode",{parentName:"li"},"main")," branch with me (",(0,r.kt)("inlineCode",{parentName:"li"},"@xfocko"),") as the reviewer.")))}k.isMDXComponent=!0}}]); |