This is an old revision of the document!
Programming I - Labs 2017/2018
This page contains materials for the practice lessons of the Programming I (NPRG030) course that is being/has been taught during winter semester 2017/2018 at Charles University in Prague, Czech Republic. The course official web page is/was to be found at Tomáš Holan's webpage. The practice lessons (labs) are/were backed by many, for this group, concretely, by Jakub Gemrot
Permalink: http://bit.ly/mff-uk-labs-prg1-2017
Dates
Wednesday's labs, 09:00, SW2, Jakub Gemrot: jakub.gemrot@gmail.com
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 jakub.gemrot@gmail.com
- Description deadline: 20.12.2017
- Use (copy-and-update) the following template
- Ideas can be get from Martin Mareš's 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
- Follow delivery guidelines when submitting your work
Submitting homeworks
Submit via email to: jakub.gemrot@gmail.com
Always use subject: PRG1 - 2017 - L[lab number] - [homework name]
Labs History
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: 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 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 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 code and send me a screenshot
- If on Win - install ConTEXT and configure it so you can compile and run the code above from it as well, send me a screenshot
- If on Mac - hmm, try to find some decent Free Pascal IDE, compile and run the code from above and send me a screenshot
- Solve the following problem 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 SISAL and create an account for the lab
- Send me an email with you CUNI number and logins to both codexes
- Solve the following problem (Wizard & Prisoner - Coins) in a way that it is obvious that your algorithm works