mirror of
https://github.com/mfocko/blog.git
synced 2024-11-24 22:11:54 +01:00
1 line
No EOL
15 KiB
JavaScript
1 line
No EOL
15 KiB
JavaScript
"use strict";(self.webpackChunkfi=self.webpackChunkfi||[]).push([[354],{50476:(e,t,n)=>{n.r(t),n.d(t,{assets:()=>h,contentTitle:()=>l,default:()=>x,frontMatter:()=>r,metadata:()=>d,toc:()=>c});var i=n(85893),s=n(11151);const r={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,d={id:"bonuses/seminar-04",title:"4th seminar",description:"Robot in a maze.\n",source:"@site/c/bonuses/04.md",sourceDirName:"bonuses",slug:"/bonuses/seminar-04",permalink:"/c/bonuses/seminar-04",draft:!1,unlisted:!1,editUrl:"https://github.com/mfocko/blog/tree/main/c/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:"/c/bonuses/seminar-03"},next:{title:"5th and 6th seminar",permalink:"/c/bonuses/seminar-05-06"}},h={},c=[{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}];function o(e){const t={a:"a",admonition:"admonition",code:"code",em:"em",h2:"h2",li:"li",ol:"ol",p:"p",pre:"pre",strong:"strong",table:"table",tbody:"tbody",td:"td",th:"th",thead:"thead",tr:"tr",ul:"ul",...(0,s.a)(),...e.components};return(0,i.jsxs)(i.Fragment,{children:[(0,i.jsx)(t.admonition,{title:"caution",type:"warning",children:(0,i.jsxs)(t.p,{children:["Deadline for the submission of the bonus is ",(0,i.jsx)(t.strong,{children:"March 23th 24:00"}),"."]})}),"\n",(0,i.jsx)(t.admonition,{type:"tip",children:(0,i.jsxs)(t.p,{children:["In case you have any questions, feel free to reach out either by email, Discord\nor just by submitting an issue ",(0,i.jsx)(t.a,{href:"https://gitlab.fi.muni.cz/xfocko/kb/-/issues/new",children:"here"}),"."]})}),"\n",(0,i.jsx)(t.p,{children:"For this bonus you can get 3 K\u20a1 and another 0.5 K\u20a1 for the bonus part of it."}),"\n",(0,i.jsx)(t.p,{children:(0,i.jsx)(t.a,{href:"pathname:///files/c/bonuses/04.tar.gz",children:"Source"})}),"\n",(0,i.jsx)(t.h2,{id:"introduction",children:"Introduction"}),"\n",(0,i.jsx)(t.p,{children:"In this task you are given a 2D map for a robot. The map contains multiple markers:"}),"\n",(0,i.jsxs)(t.ul,{children:["\n",(0,i.jsxs)(t.li,{children:[(0,i.jsx)(t.code,{children:"^v<>"})," - which denote the directions the robot will be facing when he steps into\nthe cell or starts on it."]}),"\n",(0,i.jsxs)(t.li,{children:[(0,i.jsx)(t.code,{children:"K"})," - denotes the key."]}),"\n",(0,i.jsxs)(t.li,{children:[(0,i.jsx)(t.code,{children:"T"})," - denotes the treasure."]}),"\n"]}),"\n",(0,i.jsxs)(t.p,{children:["In case robot lands at the beginning on unknown field, e.g. ",(0,i.jsx)(t.code,{children:"."})," in the tests, he\nfaces the direction that is given through the parameter."]}),"\n",(0,i.jsxs)(t.p,{children:["Your task is to write the ",(0,i.jsx)(t.code,{children:"walk"})," function that returns end result of the walk.\nWalk can end in multiple ways:"]}),"\n",(0,i.jsxs)(t.ul,{children:["\n",(0,i.jsxs)(t.li,{children:[(0,i.jsx)(t.code,{children:"FOUND_TREASURE"})," - when you find the treasure"]}),"\n",(0,i.jsxs)(t.li,{children:[(0,i.jsx)(t.code,{children:"FOUND_KEY"})," - when you find the key"]}),"\n",(0,i.jsxs)(t.li,{children:[(0,i.jsx)(t.code,{children:"OUT_OF_BOUNDS"})," - when the robot falls off the map"]}),"\n",(0,i.jsxs)(t.li,{children:[(0,i.jsx)(t.code,{children:"INFINITE_LOOP"})," - in case you will implement the bonus"]}),"\n",(0,i.jsxs)(t.li,{children:[(0,i.jsx)(t.code,{children:"NONE"})," - which is used right now as a default return in the skeleton, has no meaning\nlater on"]}),"\n"]}),"\n",(0,i.jsx)(t.h2,{id:"hard-requirement",children:"Hard requirement"}),"\n",(0,i.jsx)(t.p,{children:"There is only one hard requirement that tests cannot check."}),"\n",(0,i.jsxs)(t.p,{children:[(0,i.jsx)(t.strong,{children:"You are not allowed to use any indexing related to map or your current position"}),"\n",(0,i.jsx)(t.strong,{children:"in your implementation."})]}),"\n",(0,i.jsx)(t.p,{children:"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."}),"\n",(0,i.jsx)(t.h2,{id:"example-of-run",children:"Example of run"}),"\n",(0,i.jsx)(t.p,{children:"For a better understanding of your task, I will describe a simple walk with corresponding\nfunction call."}),"\n",(0,i.jsx)(t.pre,{children:(0,i.jsx)(t.code,{className:"language-c",children:'const char *map = (\n ">.v"\n ".K<"\n "..."\n);\n\nwalk(map, &map[6], \'^\', 3, 3);\n'})}),"\n",(0,i.jsxs)(t.p,{children:["For this call, you should return ",(0,i.jsx)(t.code,{children:"FOUND_KEY"}),". Let us walk through the walk ;)"]}),"\n",(0,i.jsxs)(t.ol,{children:["\n",(0,i.jsxs)(t.li,{children:["\n",(0,i.jsxs)(t.p,{children:["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,i.jsx)(t.code,{children:"N"}),"(orth),\nso that we can differentiate markers on the map with the robot when using printing\nfunction)."]}),"\n",(0,i.jsx)(t.pre,{children:(0,i.jsx)(t.code,{children:">.v\n.K<\nN..\n"})}),"\n"]}),"\n",(0,i.jsxs)(t.li,{children:["\n",(0,i.jsx)(t.p,{children:"Moves up:"}),"\n",(0,i.jsx)(t.pre,{children:(0,i.jsx)(t.code,{children:">.v\nNK<\n...\n"})}),"\n"]}),"\n",(0,i.jsxs)(t.li,{children:["\n",(0,i.jsxs)(t.p,{children:["Moves up (now covers ",(0,i.jsx)(t.code,{children:">"}),"), changes direction to right:"]}),"\n",(0,i.jsx)(t.pre,{children:(0,i.jsx)(t.code,{children:"E.v\n.K<\n...\n"})}),"\n"]}),"\n",(0,i.jsxs)(t.li,{children:["\n",(0,i.jsx)(t.p,{children:"Moves to right:"}),"\n",(0,i.jsx)(t.pre,{children:(0,i.jsx)(t.code,{children:">Ev\n.K<\n...\n"})}),"\n"]}),"\n",(0,i.jsxs)(t.li,{children:["\n",(0,i.jsx)(t.p,{children:"Moves to right, faces south:"}),"\n",(0,i.jsx)(t.pre,{children:(0,i.jsx)(t.code,{children:">.S\n.K<\n...\n"})}),"\n"]}),"\n",(0,i.jsxs)(t.li,{children:["\n",(0,i.jsx)(t.p,{children:"Moves down, faces west:"}),"\n",(0,i.jsx)(t.pre,{children:(0,i.jsx)(t.code,{children:">.v\n.KW\n...\n"})}),"\n"]}),"\n",(0,i.jsxs)(t.li,{children:["\n",(0,i.jsxs)(t.p,{children:["Moves left, founds key, returns ",(0,i.jsx)(t.code,{children:"FOUND_KEY"}),":"]}),"\n",(0,i.jsx)(t.pre,{children:(0,i.jsx)(t.code,{children:">.v\n.W<\n...\n"})}),"\n"]}),"\n"]}),"\n",(0,i.jsx)(t.h2,{id:"bonus-part",children:"Bonus part"}),"\n",(0,i.jsxs)(t.p,{children:["For the bonus part you are supposed to return ",(0,i.jsx)(t.code,{children:"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. :)"]}),"\n",(0,i.jsx)(t.h2,{id:"easter-eggs",children:"Easter eggs"}),"\n",(0,i.jsxs)(t.ul,{children:["\n",(0,i.jsxs)(t.li,{children:["\n",(0,i.jsx)(t.p,{children:"Statistics"}),"\n",(0,i.jsxs)(t.table,{children:[(0,i.jsx)(t.thead,{children:(0,i.jsxs)(t.tr,{children:[(0,i.jsx)(t.th,{children:"Language"}),(0,i.jsx)(t.th,{style:{textAlign:"right"},children:"Files"}),(0,i.jsx)(t.th,{style:{textAlign:"right"},children:"Lines"}),(0,i.jsx)(t.th,{style:{textAlign:"right"},children:"Blanks"}),(0,i.jsx)(t.th,{style:{textAlign:"right"},children:"Comments"}),(0,i.jsx)(t.th,{style:{textAlign:"right"},children:"Code"}),(0,i.jsx)(t.th,{style:{textAlign:"right"},children:"Complexity"})]})}),(0,i.jsxs)(t.tbody,{children:[(0,i.jsxs)(t.tr,{children:[(0,i.jsx)(t.td,{children:(0,i.jsx)(t.em,{children:"C"})}),(0,i.jsx)(t.td,{style:{textAlign:"right"},children:"4"}),(0,i.jsx)(t.td,{style:{textAlign:"right"},children:"458"}),(0,i.jsx)(t.td,{style:{textAlign:"right"},children:"34"}),(0,i.jsx)(t.td,{style:{textAlign:"right"},children:"58"}),(0,i.jsx)(t.td,{style:{textAlign:"right"},children:"366"}),(0,i.jsx)(t.td,{style:{textAlign:"right"},children:"33"})]}),(0,i.jsxs)(t.tr,{children:[(0,i.jsx)(t.td,{children:(0,i.jsx)(t.code,{children:"test_maze.c"})}),(0,i.jsx)(t.td,{style:{textAlign:"right"}}),(0,i.jsx)(t.td,{style:{textAlign:"right"},children:"225"}),(0,i.jsx)(t.td,{style:{textAlign:"right"},children:"9"}),(0,i.jsx)(t.td,{style:{textAlign:"right"},children:"0"}),(0,i.jsx)(t.td,{style:{textAlign:"right"},children:"216"}),(0,i.jsx)(t.td,{style:{textAlign:"right"},children:"4"})]}),(0,i.jsxs)(t.tr,{children:[(0,i.jsx)(t.td,{children:(0,i.jsx)(t.code,{children:"sol.maze.c"})}),(0,i.jsx)(t.td,{style:{textAlign:"right"}}),(0,i.jsx)(t.td,{style:{textAlign:"right"},children:"141"}),(0,i.jsx)(t.td,{style:{textAlign:"right"},children:"15"}),(0,i.jsx)(t.td,{style:{textAlign:"right"},children:"28"}),(0,i.jsx)(t.td,{style:{textAlign:"right"},children:"98"}),(0,i.jsx)(t.td,{style:{textAlign:"right"},children:"24"})]}),(0,i.jsxs)(t.tr,{children:[(0,i.jsx)(t.td,{children:(0,i.jsx)(t.code,{children:"maze.c"})}),(0,i.jsx)(t.td,{style:{textAlign:"right"}}),(0,i.jsx)(t.td,{style:{textAlign:"right"},children:"84"}),(0,i.jsx)(t.td,{style:{textAlign:"right"},children:"8"}),(0,i.jsx)(t.td,{style:{textAlign:"right"},children:"30"}),(0,i.jsx)(t.td,{style:{textAlign:"right"},children:"46"}),(0,i.jsx)(t.td,{style:{textAlign:"right"},children:"5"})]}),(0,i.jsxs)(t.tr,{children:[(0,i.jsx)(t.td,{children:(0,i.jsx)(t.code,{children:"main.c"})}),(0,i.jsx)(t.td,{style:{textAlign:"right"}}),(0,i.jsx)(t.td,{style:{textAlign:"right"},children:"8"}),(0,i.jsx)(t.td,{style:{textAlign:"right"},children:"2"}),(0,i.jsx)(t.td,{style:{textAlign:"right"},children:"0"}),(0,i.jsx)(t.td,{style:{textAlign:"right"},children:"6"}),(0,i.jsx)(t.td,{style:{textAlign:"right"},children:"0"})]}),(0,i.jsxs)(t.tr,{children:[(0,i.jsx)(t.td,{children:(0,i.jsx)(t.em,{children:"C Header"})}),(0,i.jsx)(t.td,{style:{textAlign:"right"},children:"1"}),(0,i.jsx)(t.td,{style:{textAlign:"right"},children:"33"}),(0,i.jsx)(t.td,{style:{textAlign:"right"},children:"3"}),(0,i.jsx)(t.td,{style:{textAlign:"right"},children:"19"}),(0,i.jsx)(t.td,{style:{textAlign:"right"},children:"11"}),(0,i.jsx)(t.td,{style:{textAlign:"right"},children:"0"})]}),(0,i.jsxs)(t.tr,{children:[(0,i.jsx)(t.td,{children:(0,i.jsx)(t.code,{children:"maze.h"})}),(0,i.jsx)(t.td,{style:{textAlign:"right"}}),(0,i.jsx)(t.td,{style:{textAlign:"right"},children:"33"}),(0,i.jsx)(t.td,{style:{textAlign:"right"},children:"3"}),(0,i.jsx)(t.td,{style:{textAlign:"right"},children:"19"}),(0,i.jsx)(t.td,{style:{textAlign:"right"},children:"11"}),(0,i.jsx)(t.td,{style:{textAlign:"right"},children:"0"})]}),(0,i.jsxs)(t.tr,{children:[(0,i.jsx)(t.td,{children:(0,i.jsx)(t.em,{children:"CMake"})}),(0,i.jsx)(t.td,{style:{textAlign:"right"},children:"1"}),(0,i.jsx)(t.td,{style:{textAlign:"right"},children:"25"}),(0,i.jsx)(t.td,{style:{textAlign:"right"},children:"4"}),(0,i.jsx)(t.td,{style:{textAlign:"right"},children:"6"}),(0,i.jsx)(t.td,{style:{textAlign:"right"},children:"15"}),(0,i.jsx)(t.td,{style:{textAlign:"right"},children:"2"})]}),(0,i.jsxs)(t.tr,{children:[(0,i.jsx)(t.td,{children:(0,i.jsx)(t.code,{children:"CMakeLists.txt"})}),(0,i.jsx)(t.td,{style:{textAlign:"right"}}),(0,i.jsx)(t.td,{style:{textAlign:"right"},children:"25"}),(0,i.jsx)(t.td,{style:{textAlign:"right"},children:"4"}),(0,i.jsx)(t.td,{style:{textAlign:"right"},children:"6"}),(0,i.jsx)(t.td,{style:{textAlign:"right"},children:"15"}),(0,i.jsx)(t.td,{style:{textAlign:"right"},children:"2"})]}),(0,i.jsxs)(t.tr,{children:[(0,i.jsx)(t.td,{children:(0,i.jsx)(t.strong,{children:"Total"})}),(0,i.jsx)(t.td,{style:{textAlign:"right"},children:"6"}),(0,i.jsx)(t.td,{style:{textAlign:"right"},children:"516"}),(0,i.jsx)(t.td,{style:{textAlign:"right"},children:"41"}),(0,i.jsx)(t.td,{style:{textAlign:"right"},children:"83"}),(0,i.jsx)(t.td,{style:{textAlign:"right"},children:"392"}),(0,i.jsx)(t.td,{style:{textAlign:"right"},children:"35"})]})]})]}),"\n"]}),"\n",(0,i.jsxs)(t.li,{children:["\n",(0,i.jsx)(t.p,{children:"Majority of the line count in solution is caused by the formatting :)"}),"\n"]}),"\n",(0,i.jsxs)(t.li,{children:["\n",(0,i.jsxs)(t.p,{children:["Included headers can be interpreted as hints, same goes for the unimplemented\n",(0,i.jsx)(t.code,{children:"static"})," functions which you can use, but ",(0,i.jsx)(t.strong,{children:"are not required"}),"."]}),"\n"]}),"\n",(0,i.jsxs)(t.li,{children:["\n",(0,i.jsxs)(t.p,{children:["Given ",(0,i.jsx)(t.code,{children:"CMakeLists.txt"})," will generate 2 binaries, ",(0,i.jsx)(t.code,{children:"test_maze"})," and ",(0,i.jsx)(t.code,{children:"maze"}),"."]}),"\n",(0,i.jsxs)(t.ul,{children:["\n",(0,i.jsxs)(t.li,{children:[(0,i.jsx)(t.code,{children:"test_maze"})," runs the tests you are given."]}),"\n",(0,i.jsxs)(t.li,{children:[(0,i.jsx)(t.code,{children:"maze"})," runs the ",(0,i.jsx)(t.code,{children:"main.c"}),", where you can debug, print mazes and whatever else\nyou want."]}),"\n"]}),"\n"]}),"\n",(0,i.jsxs)(t.li,{children:["\n",(0,i.jsxs)(t.p,{children:["I keep only one copy of ",(0,i.jsx)(t.code,{children:"cut.h"})," in my repository, so you need to download it from\n",(0,i.jsx)(t.a,{href:"https://gitlab.fi.muni.cz/pb071/cut/-/jobs/159010/artifacts/file/1header/cut.h",children:"here"})," and place it into the directory where you have your source code."]}),"\n",(0,i.jsxs)(t.ul,{children:["\n",(0,i.jsx)(t.li,{children:"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."}),"\n"]}),"\n"]}),"\n",(0,i.jsxs)(t.li,{children:["\n",(0,i.jsxs)(t.p,{children:["I would recommend cloning this repository and copying the ",(0,i.jsx)(t.code,{children:"maze"})," directory to\nyour own repository, since there are multiple files and it may be easier for you."]}),"\n"]}),"\n"]}),"\n",(0,i.jsx)(t.p,{children:"In case you have any questions, feel free to reach out to me."}),"\n",(0,i.jsx)(t.h2,{id:"submitting",children:"Submitting"}),"\n",(0,i.jsx)(t.p,{children:"For submitting the bonus assignment you can follow the same procedure as for\nsubmitting the homeworks, that is:"}),"\n",(0,i.jsxs)(t.ol,{children:["\n",(0,i.jsxs)(t.li,{children:["On branch ",(0,i.jsx)(t.code,{children:"main"})," add the provided skeleton."]}),"\n",(0,i.jsxs)(t.li,{children:["Checkout new branch ",(0,i.jsx)(t.code,{children:"seminar-bonus-04"}),"."]}),"\n",(0,i.jsx)(t.li,{children:"Add your solution to the newly created branch."}),"\n",(0,i.jsxs)(t.li,{children:["Create a MR to the ",(0,i.jsx)(t.code,{children:"main"})," branch with me (",(0,i.jsx)(t.code,{children:"@xfocko"}),") as the reviewer."]}),"\n"]})]})}function x(e={}){const{wrapper:t}={...(0,s.a)(),...e.components};return t?(0,i.jsx)(t,{...e,children:(0,i.jsx)(o,{...e})}):o(e)}},11151:(e,t,n)=>{n.d(t,{Z:()=>d,a:()=>l});var i=n(67294);const s={},r=i.createContext(s);function l(e){const t=i.useContext(r);return i.useMemo((function(){return"function"==typeof e?e(t):{...t,...e}}),[t,e])}function d(e){let t;return t=e.disableParentContext?"function"==typeof e.components?e.components(s):e.components||s:l(e.components),i.createElement(r.Provider,{value:t},e.children)}}}]); |