Converted everything to orgmode

converted everything to orgmode and added solution to the README files
This commit is contained in:
2025-03-31 08:37:19 +02:00
parent 3013d7ad47
commit 311cb8434c
25 changed files with 319 additions and 502 deletions

View File

@@ -40,9 +40,9 @@ void print_weekday(int day, int month, int year);
To complete the task, you have to provide the definition of the aforementioned functions.
The `calendar.cpp` file contains skeletons of the functions to be implemented. The `main.cpp` file contains testing functions and the main function. In the main function, a menu is printed to select the function that has to be tested.
The =calendar.cpp= file contains skeletons of the functions to be implemented. The =main.cpp= file contains testing functions and the main function. In the main function, a menu is printed to select the function that has to be tested.
**Important** the main is not editable. Required functions must be implemented in `calendar.cpp`.
**Important** the main is not editable. Required functions must be implemented in =calendar.cpp=.
**Additional notes:**

View File

@@ -2,7 +2,7 @@
/This task is a text-based task. You do not need to write any program/C++ file: the answer should be written in functions.cpp./
Consider the functions implemented in `functions.cpp`. For each function, add proper pre- and post-conditions.
Consider the functions implemented in =functions.cpp=. For each function, add proper pre- and post-conditions.
- If no pre-condition is needed, you can simply write "n/a".
- The post-condition does not have to be a mathematical formula, e.g. it can be an informal description, but it must completely characterize the results and effects of the functions depending on the provided parameters.

View File

@@ -7,12 +7,12 @@ Run-length encoding is a simple data compression technique that represents \(N\)
[[./pictures/encode_decode.png]]
Write a program that implements run-length encoding and decoding of a byte sequence as described above. By a byte, we mean an integer value in the range \([ 0; 255 ]\). Use the stepwise refinement method to implement the program. **Your solution must consist of at least two functions, encode and decode. Please implement them in `run_length.cpp`.**
Write a program that implements run-length encoding and decoding of a byte sequence as described above. By a byte, we mean an integer value in the range \([ 0; 255 ]\). Use the stepwise refinement method to implement the program. **Your solution must consist of at least two functions, encode and decode. Please implement them in =run_length.cpp=.**
The _input_ is structured as follows:
1. One integer that determines whether to encode: \(0\) or decode: \(1\).
1. Byte sequence to be encoded or decoded (of arbitrary length). If a value outside the range \([ 0; 255 ]\) (except $-1$) is entered, output `error` and stop the en- or decoding.
1. Byte sequence to be encoded or decoded (of arbitrary length). If a value outside the range \([ 0; 255 ]\) (except $-1$) is entered, output =error= and stop the en- or decoding.
1. Integer -1 signaling the end of the byte sequence. Any extra input should be ignored.
For the example above, the inputs are:
@@ -39,13 +39,13 @@ I.e., you can 'reuse' the output as the input.
**Note 1):** As the encoded sequence must be a _byte_ sequence, runs of length 256 or longer need to be split into multiple runs of length 255 at most.
**Note 2):** The first input element (the integer that determines wether to encode or decode), is already consumed by the `main`, that calls either the encode or decode function.
**Note 2):** The first input element (the integer that determines wether to encode or decode), is already consumed by the =main=, that calls either the encode or decode function.
**Note 3):** Your output should not be followed by new line (i.e., do not use `std::endl` or `\n` at the end of your printout)
**Note 3):** Your output should not be followed by new line (i.e., do not use =std::endl= or =\n= at the end of your printout)
**Note 4):** The program will print your output (the result of the decoding or encoding), surrounded by asterisks. You don't have to worry about them, the autograder can safely recognize your solution
**Note 5):** Output only what is strictly required (the encoded or decoded sequence). The autograder will only accept output that exactly matches the expected result. For all other messages, use `std::cerr` as in:
**Note 5):** Output only what is strictly required (the encoded or decoded sequence). The autograder will only accept output that exactly matches the expected result. For all other messages, use =std::cerr= as in:
#+begin_src cpp
std::cerr << "This is a test message\n"
@@ -55,10 +55,10 @@ Those will be ignored by the autograder.
**Special cases**: While decoding a byte sequence two special cases can occur. These must be handled as follows:
1. If a byte sequence ends in the middle of a tuple, stop printing the output of en- or decoding and output `error`.
1. If a byte sequence ends in the middle of a tuple, stop printing the output of en- or decoding and output =error=.
1. Tuples of run-length 0 are possible. For such tuples, output only the leading indicator (\(0\)/\(1\)) and the trailing \(-1\).
**Hint**: You can enter multiple numbers at once separated with a space on the console, e.g, you can copy and paste the above examples, and sequentially read them using multiple `std::cin >> _var_` calls.
**Hint**: You can enter multiple numbers at once separated with a space on the console, e.g, you can copy and paste the above examples, and sequentially read them using multiple =std::cin >> _var_= calls.
Also note that, even though the program's output and the user input are both shown in the same console, they are processed separately internally, so you do not have to worry that the two will mix: if your program outputs something to the console before reading another value, it will only read the user input and not the previous output value. See the Calculator code in the Lecture 4 handout for an example of reading input and producing output in a loop.