avoin/avoin23
Huom! TÄMÄ ON AVOIMEN YLIOPISTON SIVU.
Et voi suorittaa kurssia, ellet ole ilmoittautunut täällä.
```
Demotilanne:
- Pisteet päivittyvät pienellä viiveellä.
- Värit: Punainen - puutteellinen. Vihreä - hyväksytty (vähintään 6p, joista 2p tähtiä)
Please
Osa-alue |
0 |
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
12 |
12 |
Luennot | 1&2 | 3&4 | 5&6 | 7&8 | 9&10 | 11&12 | 13&14 | 15&16 | 17&18 | 19&20 | 21&22 | 23&24 | |||
Deadlinet |
HT1 (suu- nnitelma) |
Väli- kysely |
Debug- näyte |
HT2 (50%) |
Tentti- ilmo |
HT3 (100%) |
Tentti | ||||||||
Ohjaus | 1 | 2 | 3 | 4 | 5 | ||||||||||
Demo | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | Summa | d% | |
Pisteet |
Please |
Please |
Please |
Please |
Please |
Please |
Please |
Please |
Please |
Please |
Please |
Please |
Please |
Please |
|
Korjattu |
Please |
Please |
Please |
Please |
Please |
Please |
Please |
Please |
Please |
Please |
Please |
||||
Tunnit |
Please |
Please |
Please |
Please |
Please |
Please |
Please |
Please |
Please |
Please |
Please |
Please |
Please |
Please |
Please |
Please
Ohjelmointi 1, autumn 2016 / Demo 1
Tehtävät perustuvat luentoihin: 01 ja 02.
OPPIMISTAVOITTEET
Täytä sitä mukaa, kun koet oppineesi uusia asioita. Työkirja-sivulla näet yhteenvedon kaikkien demojen osalta.
Programming 1, autumn 2016 / Demo 1
General information about demos, the points they give and how they are counted, is fully explained at the courses Demos page.
Demos are to be handed in by Monday 11 AM. You can hand in some or all of the exercises beforehand and edit these answers freely until the due time.
You will come across a big M and a link along the demo tasks, this is a reference to the lecture notes. This link will take you to the TIM lecture notes but every click will start a new “session”. After you have opened up the TIM lecture notes once, if you want to save time, check out the heading after the letter M and go to this heading manually (or by search Ctrl-F). You can also hover over the M link and click the right mouse button and select “Copy the address of this link” and go to the tab where you have opened up the TIM already and paste the new address to the address field. This should take you to the right place in the notes without reloading them again.
About the points from the tasks
Every weekly demos can contain normal tasks, Ville tasks (V=Ville), Tauno tasks (T=Tauno), Bonus tasks (B=Bonus) and advance tasks (G=Guru).
Tasks are worth one point unless it is specially mentioned that the tasks give more than one point (for example Ville
, Task 1
and B2
means Bonus 2
are worth one point at maximum but G1-2
or T1-2
has a maximum of two points).
When you have completed a task, remember to check that the points are correct. The points received from the latest Run/Test remain in effect. Tasks that have the Test
button usually generate different amount of points from running and testing.
Example:
Running was successful -> 0.5p
Tests passed -> 1p
If in the previous example you would click the Run
button after you had done the tests your points would go down to 0,5p
and to get the full points again you would have to press the Test
button again. This might not be the case in all of the exercises so be vigilant.

The maximum points for each demo week is the number of regular exercises. This way Ville/bonus/GURU exercises can be used to "collect points to the reserve". The point of the GURU exercises is to offer more challenging exercises for people who already know something about programming. Every demo week is going to give you a maximum of 8 points even If you earn more than 8 it will be marked as 8 points in Korppi.
Old answers or your friends answers
There might be answers from previous years going around but if you get caught using them or your friends answers the punishment is comparable of that of cheating! The most important thing during this course is LEARNING not fishing for demo points or copying.
Group work is allowed but this needs to be clearly indicated by writing the names of all the members of the group in, for example the comments of the program.
Instructions for using the Tauno:
At the beginning of each Tauno exercise click the Click here to show Tauno
link.
In Tauno drag the table elements in a way that at the end you have the desired result. Look at the same time what kind of code Tauno generates for you. This code is the algorithm for executing this task in the C# language. If you want to restart, hide and reopen the Tauno.
Instead of dragging (In some mobiles this can’t be done) you can also first tap the source element and then the target element.
If you need support variables where you can put the elements in for a temporary “safe keeping”, click new variable
button. Give the variable a descriptive name. You can give the variable a start value but this is not mandatory if you are planning to drag another variable’s value on it immediately.
Mathematical operations can be done by dragging values into the calculation area in the bottom left corner and choosing the operation from between the values. The result you can drag back on some variable (also on the table elements).
You can increase or degrees the value of a variable by one by dragging the +1
or -1
operations on it.
When you think the program is ready you can click the Run
or Test
buttons to see how the program works. In both cases the program code done by Tauno is copied to the program field and run. A different table of numbers can be used when running the program, then what the Tauno used, but a good "algorithm" will survive this. If the tests turn up red, read the error message carefully and think what went wrong.
If you want you can restart Tauno or if you know how, you can fix the code copied in the program area. As an answer to the demo task you need to have the same code above the Run
button and in the Tauno's code field.
From the Show all code
link you can see what values are used when the program is run and what kind of values are used when testing. You don’t need to understand all of this at the begging of this course but of course you can always try and “guess” what everything is all about.
Task Tauno T1 a
Create a program using Tauno that turns the table into a reverse order.
Task Tauno T1 b
Do a program using Tauno that switches every other element with each other. For example table 1, 2, 3, 4 becomes 2, 1, 4, 3.
Task Ville V1
Do part 1 of Ville.
Do also the exercise 2.1 in Ville. Complete this task by writing what you learned and what you thought about this times Ville exercises and did they help you at all, in the text box bellow. Only few lines is enough.
Task 1. Command line
Create a directory structure, based on the example bellow, for the Programming 1 demo answers by using PowerShell on your computer (or on your U:-drive in Agora computer rooms). The indentations show which files are which files subdirectories.
Note In the following command line-commands it is assumed that the courses
directory is located at the root of the drive, for example U:\courses
. If you create it, for example under a file called things ´U:then you have to replace the path
with a path
` in the commands.
courses
prog1
demos
demo1
demo2
pw
After you have created the above file structure using PowerShell write a command
dir -s courses
Same for the command line
dir \courses /s (or in linux: ls -R DIRECTORY)
Now, if you have done this exercise correctly you should see, among other things, the following lines (in linux/command line the data will appear a little different but the idea is the same):
Directory: U:\courses
Mode LastWriteTime Length Name
---- ------------- ------ ----
d----- 1.9.2017 16.16 ohj1
Directory: U:\courses\prog1
Mode LastWriteTime Length Name
---- ------------- ------ ----
d----- 1.9.2017 16.16 demos
d----- 1.9.2017 16.22 pw
Directory: U:\courses\prog1\demos
Mode LastWriteTime Length Name
---- ------------- ------ ----
d----- 1.9.2017 16.16 demo1
d----- 1.9.2017 16.16 demo2
You will create a task1.txt
file, which you will hand in as your answer to this task:
cd \courses\prog1\demos\demo1
dir -s U:\courses >task1.txt (in linux ls -R ~/courses/ > task1.txt)
Check what was written in the task1.txt
file:
type task1.txt (in linux cat task1.txt)
or you can view the content of the task1.txt
file by using some text editor (for example ConText or NotePad++).
Copy the content of the task1.txt
in the text field bellow
Task 2. Writing a data file
Test your skills of using an editor: take time with a stopwatch and see how long you take to create a text file based on the instructions bellow. Don’t cheat! This is just a fun little exercise.
First read the instructions carefully. When you have understood all the instructions start with a plank text file and only use the text editor of your chose and your own hands. (ConTEXT, NotePad++, SublimeText, VIM, Emacs are examples of a text editor. Word or other "Office" type program is not a text editor). All the features of the text editor are, of course, in your disposal (meaning Copy-Paste, Find and edit, and so on). You are NOT ALLOWED to use a mouse during this task. Start to take time when you write the first character and stop when the last character has been written. The content of the file has to be as follows:
First write exactly hundred lines which all read:
I’m practicing the creation of a text file!
After that there is exactly 80 minus signs '
-
' on a one line and nothing else, not even white spaces.Then forty lines that contain numbers from one to forty expressed with two numbers in a way that every line only contains one number. This sequence would start like this:
01 02 03
...and it would end like this:
39 40
After this there is another line with 80 minus signs on it. No other lines or empty lines should exist. White spaces are not allowed at the beginning or the end of a line.
Stop the time. Save this file as task2.txt
. Afterwards write at the end of the file ( as a new last line right after the minus signs), how long you took. Time needs to be presented in a form of mm:ss
where mm
is the number of minutes and ss
is the number of seconds. After this, on a new line, write what and how you did things during this task. Here is your answer file for this task. The result gives you an idea of your efficiency as a keyboard typer compared to other students on this course. If you want you can do this test again at the end of this course and see if you have made any progress.
Copy the content of the file you have written into the answer box bellow and be very careful that the content is exactly as it was described in the instruction. Otherwise the checker will not give you the 1 point. Error could be:
- extra white spaces at the end of the lines
- there aren't exactly 80
-
signs - time is written 3:45 not 03:45
- on the line where the time is there is something else as well
- There isn't a line break at the end of the time
- after the time line there isn't an explanations on how you did things
Task 3. Tools
Make sure that you have the minimum tools required for this course at your disposal. Download links and installing information for the tools can be found from the tools page in TIM so that you can install them on your computer. In Agora’s computer classes Mountains 212.2 and Lakes 213.1 these tools are already installed (except the Visual Studio (VS) might be an older version).
- Good/Smart text editor
- .NET Framework 4 (Comes with VS if you don’t have it)
- Microsoft Visual Studio 2015 Community Edition (or Ultimate version if you want)
- Microsoft XNA Game Studio 4 (you can get by following the VS instructions)
- Jypeli library (you can get by following the VS instructions)
- Jypeli project model for Visual Studio (you can get by following the VS instructions)
- Shell (always ready in a computer)
- Internet access ja SSH terminal connection program (like PuTTY or similar)
- TortoiseSVN for the project work
If problems occur when installing these programs you can ask advice from your friend, check out the installation instructions in the courses wiki page or ask on the mailing list ohj1s16s@korppi.jyu.fi
. If you are going to work from home it means you are going to need to install these tools sooner or later! At the very beginning you can get by with only using a text editor, .NET Framework 4 and XNA Game Studio 4.
Try out (M: 2. First C# program):
Save the example program HelloWorld.cs from the internet into your demo directory.
Copy the file into a folder
C:\mytemp\USERNAME\prog1\demo1
(when using a university computer).- Move
C:\mytemp\USERNAME\prog1\demo1
directory. - For the time being programs can only be run in the
C:\mytemp
directory. Hence this copying. - Also
Jypeli.dll
needs to copied into the sameC:\mytemp\USERNAME\prog1\demo1
directory when Jypeli is used. - When the task is ready, copy the
.cs
file back into the U drive.
- Move
By using PowerShell compile the program and run it. Quick instructions can be found from the course wiki. Here in short:
Powershell
$env:Path += ";$env:WINDIR\Microsoft.NET\Framework\v4.0.30319" csc HelloWorld.cs .\HelloWorld.exe
Command line
path=%WINDIR%\Microsoft.NET\Framework\v4.0.30319;%path% csc HelloWorld.cs HelloWorld.exe
As an answer to this task add your name (or all of your team member’s names) into the comments of the HelloWorld.cs
file. Copy the content of the HelloWorld.cs
into the text field bellow. For the documentation take hints from the example: 2.4.1 Documentation.
Task 4. ASCII code
M: 27. ASCII code: Ou my! Simo has broken his USB drive. There are only fragments of data left in the drive and no way of knowing what fragment goes with what. There were lots of MP3 files and junk in it… Simo knows that in one important file there was a clear text written with capital letters. The bit sequence bellow seems promising but what text is saved there:
Table 1:
01010100 01010101 01010100 01001011
01001001 01000101 01001100 01001101
01010011
Let’s make this easier: the next table has the same one byte long strings as above, converted into numbers of the base 10 (decimal) numeral system (as seen in table 3 01010100 = 84 and so on) . As an example one of the numbers have been converted into a letter in the table 2 bellow.
Table 2:
binary dec char hex
==========================
01010100 = 84
01010101 = 85 => U 55
01010100 = 84
01001011 = 75
... fill in the rest of the table…
hexadecimal (hex) values will be filled in later in this task after you
have completed this part.
Convert the rest of the characters and answer the following questions:
- What text is saved in this part of the USB memory?
- How many millimeters Simo has missed the right key in the case of the incorrect letter if he has the same keyboard as you?
- What binary number should be in place of the incorrect letter?
As an answer to this task fill the table 2 and answer the questions. Simo knows that in the file format he uses symbols are represented by the following codes (piece of an ASCII code):
Table 3:
Decimalnumber Binarynumber Corresponding symbol
-------------------------------------------
32 00100000 [white space]
33 00100001 !
46 00101110 .
65 01000001 A
66 01000010 B
67 01000011 C
68 01000100 D
69 01000101 E
70 01000110 F
71 01000111 G
72 01001000 H
73 01001001 I
74 01001010 J
75 01001011 K
76 01001100 L
77 01001101 M
78 01001110 N
79 01001111 O
80 01010000 P
81 01010001 Q
82 01010010 R
83 01010011 S
84 01010100 T
85 01010101 U
86 01010110 V
87 01010111 W
88 01011000 X
89 01011001 Y
90 01011010 Z
When you have interpreted all the symbols install some hex editor using the instructions in the course's homepage. Create a file using a text editor (for example ConText) where the text you just translated is written with letters. Then open this file in the hex editor and check out the hex numbers for each of the symbols. Fill them into the table 2 next to the letters. Usually in computer science hex numbers are used when talking about things represented by binary numbers (like in this exercise we are talking about the codes of letters).
Task 5. Printing out information
M: 2. First C# program: First copy the task 3 file HelloWorld.cs
into a file Me.cs
:
copy HelloWorld.cs Me.cs
Open Me.cs
in any text editor and change the class name to Me
. Then change the program code so that instead of printing Hello World
it prints your name, your cellphone manufacturer and your cellphone operator's name each on their own line. Copy the content of Me.cs
to the text field below and click Run
. Remember to write comments.
Task 6. Snowman
M: 4. Simple graphic C# program: Edit the program so that it draws eyes and nose for the snowman.
This task can also be done on a computer where .NET Framework 4 and XNA Game Studio 4 have been installed. If you do this task using some program other than TIM then copy the part of the finished program that is inside the begin
subroutines { }
brackets into the answer box bellow (because the rest of the code is already in TIM, click Show all code
to see it).
B1. Alice
Download and install Alice by following the instructions. If you are using Alice 2 start by going through the first (skating) tutorial. If you use Alice 3 create a "program" where you have couple of objects that do something. As an answer write few lines on what you learned and what Alice felt like, should we have more examples from it in the future. (Watch video)
B2. Moving a number
By moving a single number (referring to single digits 6, 2, 3 or 1, not 62 or 63) to make the equation 62 – 63 = 1
true. Moving means that if the symbols (there are 7, 5 numbers and - and =) in the given equation were on pieces of paper in front of you, you could move only one of them.
B3. Courses start questionnaire
Answer the courses starting questionnaire. As an answer to this task write down a question you would like to ask from the teacher. The best questions are answered in the lectures. If you have already done this in the demo 0, you can copy your question from there to here. All the questions and most of the answers can be found from the QA page.
Task G1-2. Numbers which square root is an integer
Write a C# program that prints out all of the integers that are <=1000, which have a square root that is an integer. Each number is printed out on its own line. TDD: Before you start writing the code, write down some numbers and their square roots by hand.
These are the current permissions for this document; please modify if needed. You can always modify these permissions from the manage page.