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


Interesting

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
    • Description deadline: 20.12.2017
      • Use (copy-and-update) the following template
    • Ideas can be get from Martin Mareš's topic examples

Submitting homeworks

Submit via email to: jakub.gemrot@gmail.com

Always use subject: PRG1 - 2017 - L[lab number] - [homework name]


Labs History

Lab 11

Lab 10

  • 13.12.2017
    • Recursion! Oh what a nice beast to tame :)

Lab 09

  • 6.12.2017
    • So we make it a bit eeeeasier :]
    • Time to think not about “what we are writing”, but “how we are writing it
      • 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:
      • Then:
        1. Create a document where you will create your own formatting conventions
        2. 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):
      1. 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
      2. 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
      3. 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):
    1. 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
    2. 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
    • 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 :)
    1. Go to SISAL and create an account for the lab
    2. Create an account in CodEx and ReCodEx
    3. Send me an email with you CUNI number and logins to both codexes
    4. Solve the following problem (Wizard & Prisoner - Coins) in a way that it is obvious that your algorithm works
programming_i_2017-18_winter_semester.txt · Last modified: 2017/12/20 21:11 by jakub.gemrot