{"id":9514,"date":"2024-09-05T08:58:38","date_gmt":"2024-09-05T06:58:38","guid":{"rendered":"https:\/\/blue.pri.ee\/ttu\/?p=9514"},"modified":"2024-09-05T09:01:43","modified_gmt":"2024-09-05T07:01:43","slug":"pretest-homework","status":"publish","type":"post","link":"https:\/\/blue.pri.ee\/ttu\/pretest-hw\/pretest-homework\/","title":{"rendered":"pretest homework"},"content":{"rendered":"<h4>Task<\/h4>\n<p>Your task is to generate a F1 racing event results. The results will be displayed on the screen with an option to store them to a file.<\/p>\n<h4><strong>Generic requirements<\/strong><\/h4>\n<ul>\n<li>Program must be written in either C90, C99, C11 or C17 standard. GNU extensions are permitted. The necessary C standard version must be specified in the header of the code file.<\/li>\n<li>You can only use standard libraries and the GNU extensions.<\/li>\n<li>The program must compile under either\n<ul>\n<li>Ubuntu 24.04 with GCC-13 (based on the recommended software)<\/li>\n<li>OpenSUSE Linux 15 SP5 with GCC-11 (lab configuration)<\/li>\n<\/ul>\n<\/li>\n<li>All arrays must be created with static sizes\n<ul>\n<li>Arrays must be large enough that the program can operate within the specified limitations. Specification is listed under task specifications<\/li>\n<li>Program does not need to work with larger inputs, but also must not crash when those are entered. The decision on how to handle improper input is left to the developer.<\/li>\n<\/ul>\n<\/li>\n<li>If the program uses dynamic memory allocation, all of the best practices regarding it must be followed. All dynamically allocated memory must be freed before exit. Note that dynamic memory is not a part of Programming 1, so it is not necessary to use it.<\/li>\n<li>Program must be divided into functions.<\/li>\n<li>Use of global variables is forbidden<\/li>\n<li>Use of GOTO statements is forbidden<\/li>\n<li>The user experience for the program must be clear. Any errors\u00a0 that occur must be described to the user of the application in a clear manner. The program is not allowed to &#8220;just close&#8221; without informing the user what happened.<\/li>\n<\/ul>\n<h4><strong>Program flow general description<\/strong><\/h4>\n<ol>\n<li>The program will read the names of the pilots from an input file and pick the participating pilots.<\/li>\n<li>The number of laps will be specified by the user inside of the program by inputting the number..<\/li>\n<li>All lap times are generated as random numbers.<\/li>\n<li>Total time is calculated for each pilot who participated.<\/li>\n<li>Pilots, their lap times and the total time is shown on the screen as a table.<\/li>\n<li>If an output file name was specified as a command line argument, all results are also written to the output file with that name as a CSV file.<\/li>\n<\/ol>\n<h4>Task specific requirements<\/h4>\n<ul>\n<li>The program will take either 1 or 2 arguments from the command line\n<ul>\n<li>Execution pattern: \u00a0<span class=\"lang:default highlight:0 decode:true crayon-inline\">.\/binary_name number_of_pilots [name_of_output_file]<\/span><\/li>\n<\/ul>\n<ul>\n<li>First argument is the number of pilots participating. This argument is mandatory.<\/li>\n<li>Second argument is the name of the output file. This argument is optional. If this argument is given, an output file that name with the name will be created. Results will be stored into that file.<\/li>\n<\/ul>\n<\/li>\n<li>The program must support up to 10 participating pilots. The maximum length for the name name of a participant is 32 characters. The number of laps can range from 5 &#8211; 15.<\/li>\n<li>The first <strong>n<\/strong> pilots will be chosen to participate in the race, based on the order that they are given in the input file. <strong>n<\/strong> is the number of pilots, given from the command line. You must validate that you have enough pilots given in the data file.<\/li>\n<li>Each lap time will be a randomly generated number between 70 and 125 seconds.<\/li>\n<li>Each pilot will have a 3% probability that they have to abandon the race during any lap. If a pilot needs to abandon, they will no longer drive the following laps. The decision (dice roll) will be redone on each lap.<\/li>\n<li>For pilots who abandon the race, a <span class=\"lang:c highlight:0 decode:true crayon-inline\">&#8211;<\/span>\u00a0 symbol will be used for the lap that they stopped on and all the following laps. Previous lap times must be present. The total time for that pilot will be presented as DNF (did not finish).<\/li>\n<\/ul>\n<h4>Data file requirements<\/h4>\n<p><strong>Input file<\/strong><\/p>\n<p>The names of pilots will be read by the program from a file called <span class=\"lang:default highlight:0 decode:true crayon-inline\">pilots.dat<\/span>.\u00a0 The data file must be in the same directory as the binary fine. Name of the file will be hardcoded into the program.<\/p>\n<p>The data file is formatted as an ASCII text file, containing all pilots with the format\u00a0 <span class=\"lang:default highlight:0 decode:true crayon-inline\">initial.last_name<\/span>.\u00a0 Names are separated by a space. The number of names can range from 5 &#8211; 10.<\/p>\n<p><strong>Names for the input file<\/strong><\/p>\n<pre class=\"wrap:true lang:default highlight:0 decode:true\">F.Alonso M.Webber L.Hamilton S.Vettel J.Button F.Massa T.Glock N.Rosberg M.Schumacher P.delaRosa<\/pre>\n<p><strong>Output file<\/strong><\/p>\n<p>The program will generate a CSV file. File must contain a header with the column names. As data, you need to include the name, all lap times and total time. The output file will be created in the same directory as the binary file.<\/p>\n<h4>Examples of expected output<\/h4>\n<p><strong>Example\u00a0 1<\/strong><\/p>\n<pre class=\"theme:cisco-router font:monospace toolbar:1 toolbar-hide:false show-lang:2 striped:false nums:false nums-toggle:false wrap-toggle:false plain-toggle:false copy:false popup:false expand-toggle:false lang:batch highlight:0 decode:true\" title=\"N\u00e4ide\">user@host:~&gt; .\/formula 10\r\nNumber of laps: 12\r\n\r\n      F.Alonso     65 100  70  58  50  71  95  89  82  53  88  66 |   887s\r\n      M.Webber     52  69  64  56  72  64  61  51  64 104  54  84 |   795s\r\n    L.Hamilton     62  63  83  96  70  90  93  71  98 103  74  76 |   978s\r\n      S.Vettel     93 104  84 100  58  65  57  81  96  74  62  72 |   946s\r\n      J.Button     77  97  71  88  90  59  99  78  94  55  53  89 |   950s\r\n       F.Massa     63  91  64  54  85  93  67  70  95  81  86  70 |   919s\r\n       T.Glock     58  54  68  88  88  97  60  73   -   -   -   - |    DNF\r\n     N.Rosberg     59  87  91  95  50  76  84  97  94  58  90  55 |   936s\r\n  M.Schumacher     91 103 100  90  82  54  80  82 104  92  52  82 |  1012s\r\n P.delaRosa        92  91 104  60   -   -   -   -   -   -   -   - |    DNF\r\n<\/pre>\n<p><strong>Example 2:<\/strong><\/p>\n<pre class=\"theme:cisco-router font:monospace toolbar:1 toolbar-hide:false show-lang:2 striped:false nums:false nums-toggle:false wrap-toggle:false plain-toggle:false copy:false popup:false expand-toggle:false lang:batch highlight:0 decode:true\" title=\"N\u00e4ide\">user@host:~&gt; .\/formula 4 formula_results.txt\r\nNumber of laps: 12\r\n\r\n      F.Alonso     65 100  70  58  50  71  95  89  82  53  88  66 |   887s\r\n      M.Webber     52  69  64  56  72  64  61  51  64 104  54  84 |   795s\r\n    L.Hamilton     62  63  83  96  70  90  93  71  98 103  74  76 |   978s\r\n      S.Vettel     93 104  84 100  58  65  57  81  96  74  62  72 |   946s\r\n\r\nResults stored in \"formula_results.txt\" file.<\/pre>\n<p><strong>Example 3:<\/strong><\/p>\n<pre class=\"theme:cisco-router font:monospace toolbar:1 toolbar-hide:false show-lang:2 striped:false nums:false nums-toggle:false wrap-toggle:false plain-toggle:false copy:false popup:false expand-toggle:false lang:batch highlight:0 decode:true\" title=\"N\u00e4ide\">user@host:~&gt; .\/formula formula_results.txt\r\nError! Invalid number of pilots!\r\n\r\nUsage: .\/formula number_of_laps [output_file_name]<\/pre>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Task Your task is to generate a F1 racing event results. The results will be displayed on the screen with an option to store them to a file. Generic requirements Program must be written in either C90, C99, C11 or C17 standard. GNU extensions are permitted. The necessary C standard version must be specified in &hellip; <a href=\"https:\/\/blue.pri.ee\/ttu\/pretest-hw\/pretest-homework\/\" class=\"more-link\">Loe edasi <span class=\"screen-reader-text\">pretest homework<\/span> <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[209],"tags":[],"class_list":["post-9514","post","type-post","status-publish","format-standard","hentry","category-pretest-hw"],"_links":{"self":[{"href":"https:\/\/blue.pri.ee\/ttu\/wp-json\/wp\/v2\/posts\/9514","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/blue.pri.ee\/ttu\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blue.pri.ee\/ttu\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blue.pri.ee\/ttu\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/blue.pri.ee\/ttu\/wp-json\/wp\/v2\/comments?post=9514"}],"version-history":[{"count":3,"href":"https:\/\/blue.pri.ee\/ttu\/wp-json\/wp\/v2\/posts\/9514\/revisions"}],"predecessor-version":[{"id":9517,"href":"https:\/\/blue.pri.ee\/ttu\/wp-json\/wp\/v2\/posts\/9514\/revisions\/9517"}],"wp:attachment":[{"href":"https:\/\/blue.pri.ee\/ttu\/wp-json\/wp\/v2\/media?parent=9514"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blue.pri.ee\/ttu\/wp-json\/wp\/v2\/categories?post=9514"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blue.pri.ee\/ttu\/wp-json\/wp\/v2\/tags?post=9514"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}