blog/assets/js/4f96b16e.05a86290.js
github-actions[bot] 34fc48031b deploy: 2fb4765b1f
2023-11-24 15:55:55 +00:00

1 line
No EOL
11 KiB
JavaScript

"use strict";(self.webpackChunkfi=self.webpackChunkfi||[]).push([[6306],{4693:(e,n,t)=>{t.r(n),t.d(n,{assets:()=>c,contentTitle:()=>r,default:()=>h,frontMatter:()=>i,metadata:()=>o,toc:()=>l});var s=t(5893),a=t(1151);const i={slug:"cams",title:"Practice exam C",description:"Stalking cars\u2026\n",last_update:{date:new Date("2023-05-07T00:00:00.000Z")}},r="Watching Cams",o={id:"pexam/c-cams",title:"Practice exam C",description:"Stalking cars\u2026\n",source:"@site/c/pexam/c-cams.md",sourceDirName:"pexam",slug:"/pexam/cams",permalink:"/c/pexam/cams",draft:!1,unlisted:!1,editUrl:"https://github.com/mfocko/blog/tree/main/c/pexam/c-cams.md",tags:[],version:"current",lastUpdatedAt:1683417600,formattedLastUpdatedAt:"May 7, 2023",frontMatter:{slug:"cams",title:"Practice exam C",description:"Stalking cars\u2026\n",last_update:{date:"2023-05-07T00:00:00.000Z"}},sidebar:"autogeneratedBar",previous:{title:"Practice exam B",permalink:"/c/pexam/garbage_collect"},next:{title:"Submitting merge requests",permalink:"/c/mr"}},c={},l=[{value:"Format of the input file",id:"format-of-the-input-file",level:2},{value:"Examples",id:"examples",level:4},{value:"Format of the output",id:"format-of-the-output",level:2},{value:"Example usage",id:"example-usage",level:2},{value:"Requirements and notes",id:"requirements-and-notes",level:2}];function d(e){const n={a:"a",admonition:"admonition",code:"code",em:"em",h1:"h1",h2:"h2",h4:"h4",li:"li",ol:"ol",p:"p",pre:"pre",section:"section",strong:"strong",sup:"sup",ul:"ul",...(0,a.a)(),...e.components};return(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(n.h1,{id:"watching-cams",children:"Watching Cams"}),"\n",(0,s.jsx)(n.admonition,{title:"Exam environment",type:"caution",children:(0,s.jsxs)(n.ul,{children:["\n",(0,s.jsxs)(n.li,{children:["During the exam you will be provided with a barebone ",(0,s.jsx)(n.em,{children:"exam session"})," on the\n",(0,s.jsx)(n.em,{children:"faculty computers"}),"."]}),"\n",(0,s.jsxs)(n.li,{children:["In browser you are only allowed to have the following tabs open:","\n",(0,s.jsxs)(n.ul,{children:["\n",(0,s.jsx)(n.li,{children:(0,s.jsx)(n.a,{href:"https://en.cppreference.com",children:"C documentation"})}),"\n",(0,s.jsx)(n.li,{children:"page containing the assignment"}),"\n"]}),"\n"]}),"\n",(0,s.jsxs)(n.li,{children:["You ",(0,s.jsx)(n.strong,{children:"are not"})," allowed to use your own source code, e.g. prepared beforehand\nor from the seminars."]}),"\n",(0,s.jsxs)(n.li,{children:["You have ",(0,s.jsx)(n.strong,{children:"5 minutes"})," to read through the assignment and ask any follow-up\nquestions should be there something unclear."]}),"\n",(0,s.jsxs)(n.li,{children:["You have ",(0,s.jsx)(n.strong,{children:"60 minutes"})," to work on the assignment, afterward your work will be\ndiscussed with your seminar tutor."]}),"\n"]})}),"\n",(0,s.jsxs)(n.p,{children:["Your task is to write a program ",(0,s.jsx)(n.code,{children:"cams"})," that will be processing input from the\ncams that are capable of identifying license plates on the cars and then\nprint out summary based on the input data. Your contributions to the society are\nvery much appreciated and may (or may not) be used for (each or none) of the\nfollowing purposes",(0,s.jsx)(n.sup,{children:(0,s.jsx)(n.a,{href:"#user-content-fn-1",id:"user-content-fnref-1","data-footnote-ref":!0,"aria-describedby":"footnote-label",children:"1"})}),":"]}),"\n",(0,s.jsxs)(n.ul,{children:["\n",(0,s.jsx)(n.li,{children:"stalking people leaving and coming back home,"}),"\n",(0,s.jsx)(n.li,{children:"retroactively making people pay for the parking,"}),"\n",(0,s.jsx)(n.li,{children:"providing evidence of people speeding on highways,"}),"\n",(0,s.jsx)(n.li,{children:"tracking people that don't pay tolls, or"}),"\n",(0,s.jsx)(n.li,{children:"convict employees leaving the work prematurely."}),"\n"]}),"\n",(0,s.jsx)(n.h2,{id:"format-of-the-input-file",children:"Format of the input file"}),"\n",(0,s.jsxs)(n.p,{children:["Input for your program consists of the data from the cameras. You will be given\nthe data from the cameras as a path to a file and user should also be able to\nspecify ",(0,s.jsx)(n.code,{children:"-"})," (i.e. ",(0,s.jsx)(n.code,{children:"stdin"}),") as the path."]}),"\n",(0,s.jsx)(n.p,{children:"Each \u201cscan\u201d (i.e. reading) of the cameras consists of the following data:"}),"\n",(0,s.jsxs)(n.ul,{children:["\n",(0,s.jsxs)(n.li,{children:["\n",(0,s.jsxs)(n.p,{children:[(0,s.jsx)(n.em,{children:"camera ID"}),": non-negative integer identifying a camera"]}),"\n"]}),"\n",(0,s.jsxs)(n.li,{children:["\n",(0,s.jsxs)(n.p,{children:[(0,s.jsx)(n.em,{children:"plate"}),": string of unknown length that can consist of any characters apart\nfrom whitespace"]}),"\n"]}),"\n",(0,s.jsxs)(n.li,{children:["\n",(0,s.jsxs)(n.p,{children:[(0,s.jsx)(n.em,{children:"timestamp"}),": date and time of the scan as an unsigned integer (represented as\na UNIX time)"]}),"\n",(0,s.jsx)(n.admonition,{type:"tip",children:(0,s.jsxs)(n.p,{children:["When programming on UN*X(-like) systems, you can assume that the ",(0,s.jsx)(n.code,{children:"time_t"}),"\nstructure from the system header ",(0,s.jsx)(n.code,{children:"time.h"})," ",(0,s.jsx)(n.strong,{children:"is"})," the ",(0,s.jsx)(n.code,{children:"unsigned int"})," that you\nare provided in the input file."]})}),"\n"]}),"\n"]}),"\n",(0,s.jsx)(n.p,{children:"And they are compiled into one reading such as:"}),"\n",(0,s.jsx)(n.p,{children:"camera_ID: plate timestamp"}),"\n",(0,s.jsxs)(n.p,{children:["There should be always ",(0,s.jsx)(n.strong,{children:"at least one"})," space in between each part of the\nreading. Readings are separated by the commas, which may, but don't have to, be\naccompanied by whitespace around."]}),"\n",(0,s.jsx)(n.h4,{id:"examples",children:"Examples"}),"\n",(0,s.jsx)(n.p,{children:"Few examples of the data from the cameras follow"}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{children:"10: ABC-12-34 1664608712, 289: XYZ-98-76 1665416417,\n25: ABC-12-34 1633078256 , 42: TryToCatchMe 1671602419,\n11: EL9-987 1679541338 ,2 : Foo-666 1683170082,42: YourMum 1683170082,\n42: TryToCatchMe 1671602419 , 1234: TryToCatchMe 1671602419,\n19: ABC-12-34 1664659649, 69:YouShould-not-pLaCe-4ny-expectations%on^the(input 1680307994,\n9 : 9B9-161 1665416417 , 10: 1a1-999 1671602419,1:lmao 1633078256,\n16: ABC-12-34 1664609012\n"})}),"\n",(0,s.jsx)(n.h2,{id:"format-of-the-output",children:"Format of the output"}),"\n",(0,s.jsx)(n.admonition,{type:"info",children:(0,s.jsx)(n.p,{children:"All the examples consider using data from the example of the input."})}),"\n",(0,s.jsx)(n.p,{children:"You are expected to print out the dates and cameras that has captured the\nlicense plate for each of them (in a sorted fashion)."}),"\n",(0,s.jsx)(n.p,{children:"If there are multiple scans present and the timespan (i.e. time difference\nbetween the scans is bigger than 60 minutes, you should separate them by a\nnewline). For example:"}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{children:"*** ABC-12-34 ***\n 25: Fri Oct 1 10:50:56 2021\n\n 10: Sat Oct 1 09:18:32 2022\n 16: Sat Oct 1 09:23:32 2022\n\n 19: Sat Oct 1 23:27:29 2022\n"})}),"\n",(0,s.jsx)(n.admonition,{type:"tip",children:(0,s.jsxs)(n.p,{children:["Since you are given the timestamp in a ",(0,s.jsx)(n.code,{children:"time_t"})," compatible type on UN*X, you\ncan safely use ",(0,s.jsx)(n.code,{children:"ctime(3)"})," for printing the timestamp as a ",(0,s.jsx)(n.em,{children:"human readable"})," time\nwhen outputting the date and time."]})}),"\n",(0,s.jsx)(n.admonition,{type:"tip",children:(0,s.jsx)(n.p,{children:"For a better readability you can include one more newline after the last line\nof the output."})}),"\n",(0,s.jsx)(n.h2,{id:"example-usage",children:"Example usage"}),"\n",(0,s.jsx)(n.p,{children:"You can also have a look at example usage of your program. We can run your\nprogram from the shell like"}),"\n",(0,s.jsx)(n.p,{children:"$ ./cams example_1.txt"}),"\n",(0,s.jsx)(n.p,{children:"And it will produce an output:"}),"\n",(0,s.jsx)(n.p,{children:"*** ABC-12-34 ***\n25: Fri Oct 1 10:50:56 2021"}),"\n",(0,s.jsx)(n.p,{children:"10: Sat Oct 1 09:18:32 2022\n16: Sat Oct 1 09:23:32 2022"}),"\n",(0,s.jsx)(n.p,{children:"19: Sat Oct 1 23:27:29 2022"}),"\n",(0,s.jsx)(n.p,{children:"*** EL9-987 ***\n11: Thu Mar 23 04:15:38 2023"}),"\n",(0,s.jsx)(n.p,{children:"*** Foo-666 ***\n2: Thu May 4 05:14:42 2023"}),"\n",(0,s.jsx)(n.p,{children:"*** TryToCatchMe ***\n42: Wed Dec 21 07:00:19 2022\n42: Wed Dec 21 07:00:19 2022\n1234: Wed Dec 21 07:00:19 2022"}),"\n",(0,s.jsx)(n.p,{children:"*** XYZ-98-76 ***\n289: Mon Oct 10 17:40:17 2022"}),"\n",(0,s.jsx)(n.p,{children:"*** YouShould-not-pLaCe-4ny-expectations%on^the(input ***\n69: Sat Apr 1 02:13:14 2023"}),"\n",(0,s.jsx)(n.p,{children:"*** YourMum ***\n42: Thu May 4 05:14:42 2023"}),"\n",(0,s.jsx)(n.h2,{id:"requirements-and-notes",children:"Requirements and notes"}),"\n",(0,s.jsxs)(n.ul,{children:["\n",(0,s.jsxs)(n.li,{children:["Define ",(0,s.jsx)(n.strong,{children:"structures"})," (and ",(0,s.jsx)(n.strong,{children:"enumerations"}),", if applicable) for the parsed\ninformation from the files."]}),"\n",(0,s.jsxs)(n.li,{children:["For keeping the \u201crecords\u201d, use some ",(0,s.jsx)(n.strong,{children:"dynamic"})," data structure.","\n",(0,s.jsxs)(n.ul,{children:["\n",(0,s.jsxs)(n.li,{children:["Don't forget to consider pros and cons of using ",(0,s.jsx)(n.em,{children:"specific"})," data structures\nbefore going through implementing."]}),"\n"]}),"\n"]}),"\n",(0,s.jsxs)(n.li,{children:["You ",(0,s.jsx)(n.strong,{children:"are not required"})," to produce 1:1 output to the provided examples, they\nare just a hint to not waste your time tinkering with a user experience."]}),"\n",(0,s.jsxs)(n.li,{children:["If any of the operations on the input files should fail,\n",(0,s.jsx)(n.strong,{children:"you are expected to"})," handle the situation ",(0,s.jsx)(n.em,{children:"accordingly"}),"."]}),"\n",(0,s.jsxs)(n.li,{children:["Failures of any other common functions (e.g. functions used for memory\nmanagement) should be handled in ",(0,s.jsx)(n.strong,{children:"the same way"})," as they were in the\nhomeworks and seminars."]}),"\n",(0,s.jsxs)(n.li,{children:["Your program ",(0,s.jsx)(n.strong,{children:"must free"})," all the resources before exiting."]}),"\n"]}),"\n",(0,s.jsxs)(n.section,{"data-footnotes":!0,className:"footnotes",children:[(0,s.jsx)(n.h2,{className:"sr-only",id:"footnote-label",children:"Footnotes"}),"\n",(0,s.jsxs)(n.ol,{children:["\n",(0,s.jsxs)(n.li,{id:"user-content-fn-1",children:["\n",(0,s.jsxs)(n.p,{children:["Subject to NDA. ",(0,s.jsx)(n.a,{href:"#user-content-fnref-1","data-footnote-backref":"","aria-label":"Back to reference 1",className:"data-footnote-backref",children:"\u21a9"})]}),"\n"]}),"\n"]}),"\n"]})]})}function h(e={}){const{wrapper:n}={...(0,a.a)(),...e.components};return n?(0,s.jsx)(n,{...e,children:(0,s.jsx)(d,{...e})}):d(e)}},1151:(e,n,t)=>{t.d(n,{Z:()=>o,a:()=>r});var s=t(7294);const a={},i=s.createContext(a);function r(e){const n=s.useContext(i);return s.useMemo((function(){return"function"==typeof e?e(n):{...n,...e}}),[n,e])}function o(e){let n;return n=e.disableParentContext?"function"==typeof e.components?e.components(a):e.components||a:r(e.components),s.createElement(i.Provider,{value:n},e.children)}}}]);