======Programming I - Labs 2017/2018====== This page contains materials for the practice lessons of the [[https://is.cuni.cz/studium/predmety/index.php?tid=&do=predmet&kod=NPRG030|Programming I (NPRG030)]] course that is being/has been taught during winter semester 2017/2018 at [[http://www.mff.cuni.cz/|Charles University]] in [[http://www.praha.eu/jnp/cz/home/magistrat/index.html|Prague]], Czech Republic. The course official web page is/was to be found at Tomáš Holan's [[http://ksvi.mff.cuni.cz/~holan/|webpage]]. The practice lessons (labs) are/were backed by many, for this [[https://is.cuni.cz/studium/rozvrhng/roz_predmet_gl.php?tid=&gl=17aNPRG030x10&fak=11320&skr=2017&sem=1|group]], concretely, by [[http://gamedev.cuni.cz/contacts/|Jakub Gemrot]] Permalink: [[http://bit.ly/mff-uk-labs-prg1-2017|http://bit.ly/mff-uk-labs-prg1-2017]] ---------------------- ======Dates====== Wednesday's labs, 09:00, SW2, Jakub Gemrot: [[mailto:jakub.gemrot@gmail.com|jakub.gemrot@gmail.com]] ---------------------- ======Interesting====== [[https://visualgo.net|VisuAlgo]] - visualization of algorithms including AVL trees! ---------------------- ======How to pass the labs====== * Do **ALL homeworks** I give you * Almost no excuses here, it has very good motivation I('ll) share during the first lab * Pass a **lab exam** * Two dates: **3. / 10. 1. 2018** * **Come up** with an individual **semester project** * Project idea deadline: **1.12.2017** * Describe what you would like to create in 3-10 sentences and send it to [[mailto:jakub.gemrot@gmail.com|jakub.gemrot@gmail.com]] * Description deadline: **20.12.2017** * Use (copy-and-update) the following [[https://drive.google.com/open?id=1ImYy5oSpeOJqeGweRxZb2MgxwvO_cDno4W3UEP5XkEg|template]] * Ideas can be get from Martin Mareš's [[http://mj.ucw.cz/vyuka/zap/|topic examples]] * **Deliver a semester project** * Delivery deadline: "up-to-you" = to be negotiated :) * Apart from the implementation you will also have to create user's manual and programmer's manual * [[https://drive.google.com/open?id=1dkn6TmHeqm37TeEXAJ_0CipW3ThnWRVa-f9aGq5EzlM|User's manual guidelines]] * [[https://drive.google.com/open?id=1PeRXbtEoPiDQpm291ol9iMMc_0of2FxSdVaD8EeU3og|Programmer's manual guidelines]] * Follow [[https://drive.google.com/open?id=1sraaknvWJtWYsTrSFyw7whwtxRtRspY1q-iHaf89ttg|delivery guidelines]] when submitting your work ---------------------- ======Submitting homeworks====== Submit via email to: [[mailto:jakub.gemrot@gmail.com|jakub.gemrot@gmail.com]] Always use subject: PRG1 - 2017 - L[lab number] - [homework name] ---------------------- ======Labs History====== ==== Lab 11 ==== * **20.12.2017** * Dynamic variables, linked lists! * [[https://drive.google.com/open?id=1nuGpxAVaCCYpsGkyen1twa3ahoQSaE2D|Linked List Example - Pascal]] ==== Lab 10 ==== * **13.12.2017** * [[https://drive.google.com/open?id=1BZu4-hYnD5zRLVahNtaA2ZBVca9BTcmz|Slides]] * Recursion! Oh what a nice beast to tame :) ==== Lab 09 ==== * **6.12.2017** * [[https://www.sunnyskyz.com/happy-videos/5369/This-Hilarious-Job-Interview-With-Jesus-Explains-How-Santa-Claus-Got-His-Job|Saint Nicholas]]! * So we make it a bit eeeeasier :] * Time to think not about "what we are writing", but "[[https://en.wikipedia.org/wiki/Coding_conventions |how we are writing it]]" * [[https://drive.google.com/open?id=1Em9R0iYYAqFbbJ43qA_PBjFteAOy_83U|Homework]] * There are four folders, the first is just an example of stuff I deem a violation to formatting conventions * Given this insight read some thoughts about conventsion: * You might be interested in reading about [[https://en.wikipedia.org/wiki/Coding_conventions|Coding conventions]] * Especially, [[https://en.wikipedia.org/wiki/Naming_convention_(programming)|Naming conventions]] * Then: - Create a document where you will create your own formatting conventions - Solve all three homeworks from the zip (there are readmes in there) ==== Lab 08 ==== * **29.11.2017** * We did declaration of a "record" type * Two assignments in the CodEx ==== Lab 07 ==== * **22.11.2017** * Sort or "review the lump of assignment from the last week" * We did debugging, "how to incrementally create your program" and how to encapsulate things in functions ==== Lab 06 ==== * **15.11.2017** * We did arrays, the greatest common divisor, binary search in the sorted array ... and trains! (Front in the circular-array) * There are three homeworks (deadline 23.11.2017): - The greatest common divisor for "long numbers" * Numbers can be up-to 100 digits long (only positive numbers) * Input: * Long number 1 * Long number 2 * Output: * Greatest common divisor of those two numbers * - Binary search in the sorted array * Input: * Number N <= 10000 * Number a1, ..., aN sorted in ascending order (numbers may repeat) * Number X * Output: * If X in the array, output the first index (1-based) of X in the array, if not, output -1 - Trains and Bridges * Train is going over the bridge, the bridge has length L (meters, integer) and can hold at max M (tons, integer) of weight * Train is composed of wagons, each wagon has lenght Lw (meters, integer) and weight Mw (tons, integer) * Wagons may be of different lenghts! Engine is just another wagon for us... * Your program must compute whether the train can pass the bridge... * Input: * L M * Lw1 Mw1 * ... * Lwn Mwn (you do not know 'n' in advance!) * xxx (this marks the end of the train) * Output: * O.K. or K.O. according to whether the train can pass the bridge (O.K.) or the bridge will crumble (K.O.) * Notes: * If a wagon is partially on the bridge only, we count as its full weight burden the bridge still. ==== Lab 05 ==== * **1.11.2017** * We went through functions and procedures for String manipulations * We showcased them with the following code: [[https://drive.google.com/open?id=0B49ID9s3-zhTbUVycDh4QW05akk|stringy.pas]] * There are two homeworks (deadline 16.11.2017): - ToUpperCase * The input consists of 1+N lines, the first line contains an N integer number, then follows N lines (up-to 255 characters long), which you should turn into upper-case * You should output the same string but turning all ('a'-'z') lower-case characters into upper-case ones * Example * Input: * 2 * f867sdgu9pdsgkl;s[0ate79 * abc * Output: * F867SDGU9PDSGKL;S[0ATE79 * ABC - Case-insensitive pos * You have to write a program that can realize case-insensitive substring search (i.e., case-insensitive pos) * The input has 2 lines, the first line is the string you are searching for, the second line is the string you have to search in * The output is the first position of the first string within the second one or 0 if the substring cannot be found * Example * Input: * abc123 * s76sdfgkhjlAbC123svoihsd * Output: * 11 ==== Lab 04 ==== * **25.10.2017** * We talked about functions, procedures and how they can be used to divide the program into multiple "sub-programs" * You were given a ReCodEx assignment (to find root-digit-sum of a given number) ==== Lab 03 ==== * **18.10.2017** * Guide how to install [[https://docs.google.com/document/d/1XlP3FcoG1umScLF0s-J-4SexRh6Jn7uHWqkURyRaZkc/edit?usp=sharing|Lazarus+FreePascal on Macs]] (Czech only), kudos to Jan Hamalčík, ping me if its not working for you (or comment directly in the doc) * We've been through basic Pascal stuff * Homework * Create [[https://drive.google.com/open?id=0B49ID9s3-zhTbFE2S005N3ZpdEk|22 small programs]] * Each one in its own file (separate program) * Send them via email (zip it or not) * Deadline: 24.10.2017 ==== Lab 02 ==== * **11.10.2017** * We did some mind-troubling puzzles again :) * Homeworks * If on Win/Linux - install Free Pascal, compile and run the following [[http://bit.ly/mff-uk-prg1-sumthing|code]] and send me a screenshot * If on Win - install [[http://www.contexteditor.org/index.php|ConTEXT]] and [[http://www.pascalgamedevelopment.com/showthread.php?2376-I-found-the-perfect-IDE-for-Freepascal|configure it]] so you can compile and run the code above from it as well, send me a screenshot * If on Mac - hmm, [[https://www.google.cz/search?q=mac+os+free+pascal+ide|try to find]] some decent Free Pascal IDE, compile and run the code from above and send me a screenshot * Solve the following problem [[https://docs.google.com/document/d/1ZTuZ6-bdp7djapbhVTvejMlym99FNHec-VuxPb2prS0/|Wizard & Prisoner - Glasses problem]] and send me the solution ==== Lab 01 ==== * **4.10.2017** * Welcome to Programming! * Some introductory formal / informal info * First homeworks :) - Go to [[http://www.ms.mff.cuni.cz/acad/sisal/sisal.html.cz|SISAL]] and create an account for the lab - Create an account in [[codex.ms.mff.cuni.cz|CodEx]] and [[recodex.mff.cuni.cz|ReCodEx]] - Send me an email with you CUNI number and logins to both codexes - Solve the following problem ([[https://docs.google.com/document/d/1NnabyT3LzNw6wfskJ6C2kjjlITzmGFZyyVzWY8bgh9s/edit?usp=sharing|Wizard & Prisoner - Coins]]) in a way that it is obvious that your algorithm works