Skip to content

Commit b880898

Browse files
author
Vladimir Damov
committed
adding programming fundamentals README.md
1 parent ea8fd6a commit b880898

File tree

4 files changed

+324
-0
lines changed

4 files changed

+324
-0
lines changed

programming-fundamentals/Programming Fundamentals Exam - January 2018/01. Padawan Equipment/README.md

Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
# Problem 1. Padawan Equipment
2+
3+
Yoda is starting his newly created Jedi academy. So, he asked master Ivan Cho to **buy** the **needed equipment**. The number of **items** depends on **how many students will sign up**. The equipment for the Padawan contains **lightsabers, belts and robes**.
4+
5+
You will be given **the amount of money Ivan Cho has**, the **number of students **and the **prices of each item**. You have to help Ivan Cho **calculate** if the **money** he has is **enough to buy all of the equipment**, or how much more money he needs. Because the lightsabres sometimes brake, Ivan Cho should **buy 10% more**, **rounded up** to the next integer. Also, every **sixth belt is free**.
6+
7+
## Input / Constraints
8+
9+
The input data should be read from the console. It will consist of **exactly 5 lines**:
10+
11+
* The **amount of money** Ivan Cho has – **floating-point number** in **range [0.00…1,000.00]**
12+
13+
* The **count of students – integer in range [0…100]**
14+
15+
* The **price of lightsabers** for a **single sabre – floating-point number** in **range [0.00…100.00]**
16+
17+
* The **price of robes** for a **single robe – floating-point number** in **range [0.00…100.00]**
18+
19+
* The **price of belts** for a **single** **belt – floating-point number** in **range [0.00…100.00]**
20+
21+
The **input data will always be valid**. **There is no need to check it explicitly**.
22+
23+
## Output
24+
25+
The output should be printed on the console.
26+
27+
* **If the calculated price of the equipment is less or equal to the money Ivan Cho has:**
28+
29+
* "**The money is enough - it would cost {the cost of the equipment}lv.**"
30+
31+
* **If the calculated price of the equipment is more than the money Ivan Cho has:**
32+
33+
* "**Ivan Cho will need {neededMoney}lv more.**"
34+
35+
* **All prices** must be **rounded to two digits after the decimal point.**
36+
37+
## Examples
38+
39+
<table>
40+
<tr>
41+
<td>Input</td>
42+
<td>Output</td>
43+
<td>Comments</td>
44+
</tr>
45+
<tr>
46+
<td>100
47+
2
48+
1.0
49+
2.0
50+
3.0</td>
51+
<td>The money is enough - it would cost 13.00lv.</td>
52+
<td>Needed equipment for 2 padawans :
53+
sabresPrice*(studentsCount + 10%) + robesPrice * (studentsCount) + beltsPrice*(studentsCount-freeBelts)
54+
1*(3) + 2*(2) + 3*(2) = 13.00
55+
13.00 <= 100 – the money will be enough.</td>
56+
</tr>
57+
<tr>
58+
<td>Input</td>
59+
<td>Output</td>
60+
<td>Comments</td>
61+
</tr>
62+
<tr>
63+
<td>100
64+
42
65+
12.0
66+
4.0
67+
3.0</td>
68+
<td>Ivan Cho will need 737.00lv more.</td>
69+
<td>Needed equipment for 42 padawans:
70+
12*47 + 4*42 + 3*35 = 837.00
71+
837 > 100 – need 737.00 lv. more.</td>
72+
</tr>
73+
</table>
74+
75+
76+
*...May the force be with you...*
77+
Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
# Problem 2. Kamino Factory
2+
3+
The clone factory in Kamino got another order to clone troops. But this time you are tasked to find **the best DNA** sequence to use in the production.
4+
5+
You will receive the **DNA length** and until you receive the command **"Clone them!"** you will be receiving a **DNA sequences of ones and zeroes, split by "!"** **(one or several).**
6+
7+
You should select the sequence with the **longest subsequence of ones**. If there are several sequences with **same length of** **subsequence of ones**, print the one with the **leftmost** **starting index**, if there are several sequences with same **length and starting index**, select the sequence with the **greater sum** of its elements.
8+
9+
After you receive the last command **"Clone them!"** you should print the collected information in the following format:
10+
11+
**"Best DNA sample {bestSequenceIndex} with sum: {bestSequenceSum}."**
12+
13+
**"{DNA sequence, joined by space}"**
14+
15+
## Input / Constraints
16+
17+
* The **first line** holds the **length** of the **sequences****integer in range [1…100];**
18+
19+
* On the next lines until you receive **"Clone them!"** you will be receiving sequences (at least one) of ones and zeroes, **split by "!"** (one or several).
20+
21+
## Output
22+
23+
The output should be printed on the console and consists of two lines in the following format:
24+
25+
**"Best DNA sample {bestSequenceIndex} with sum: {bestSequenceSum}."**
26+
27+
**"{DNA sequence, joined by space}"**
28+
29+
## Examples
30+
31+
<table>
32+
<tr>
33+
<td>Input</td>
34+
<td>Output</td>
35+
<td>Comments</td>
36+
</tr>
37+
<tr>
38+
<td>5
39+
1!0!1!1!0
40+
0!1!1!0!0
41+
Clone them!</td>
42+
<td>Best DNA sample 2 with sum: 2.
43+
0 1 1 0 0</td>
44+
<td>We receive 2 sequences with same length of subsequence of ones, but the second is printed, because its subsequence starts at index[1].</td>
45+
</tr>
46+
<tr>
47+
<td>Input</td>
48+
<td>Output</td>
49+
<td>Comments</td>
50+
</tr>
51+
<tr>
52+
<td>4
53+
1!1!0!1
54+
1!0!0!1
55+
1!1!0!0
56+
Clone them!</td>
57+
<td>Best DNA sample 1 with sum: 3.
58+
1 1 0 1</td>
59+
<td>We receive 3 sequences. Both 1 and 3 have same length of subsequence of ones -> 2, and both start from index[0], but the first is printed, because its sum is greater.</td>
60+
</tr>
61+
</table>
62+
63+
64+
"FEAR IS THE PATH TO THE DARK SIDE...
65+
66+
FEAR LEADS TO ANGER...
67+
68+
ANGER LEADS TO HATE...
69+
70+
HATE LEADS TO SUFFERING...."
71+

programming-fundamentals/Programming Fundamentals Exam - January 2018/03. Start Enigma/README.md

Lines changed: 88 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,88 @@
1+
# Problem 3. Star Enigma
2+
3+
The war is in its peak, but you, young Padawan, can turn the tides with your programming skills. You are tasked to create a program to **decrypt** the messages of The Order and prevent the death of hundreds of lives.
4+
5+
You will receive several messages, which are **encrypted** using the legendary star enigma. You should **decrypt the messages**, following these rules:
6+
7+
To properly decrypt a message, you should **count all the letters** **[s, t, a, r]****case insensitive** and **remove** the count from the **current ASCII value of each symbol** of the encrypted message.
8+
9+
After decryption:
10+
11+
Each message should have a** planet name, population, attack type ('A', as attack or 'D', as destruction) and soldier count.**
12+
13+
The planet name **starts after** **'@'** and contains **only letters from the Latin alphabet**.
14+
15+
The planet population **starts after ':'** and is an** Integer**;
16+
17+
The attack type may be **"A"(attack) or "D"(destruction)** and must be **surrounded by "!" **(exclamation mark).
18+
19+
The **soldier count **starts after **"->"** and should be an Integer.
20+
21+
The order in the message should be: **planet name -> planet population -> attack type -> soldier count. **Each part can be separated from the others by** any character except: '@', '-', '!', ':' and '>'.**
22+
23+
## Input / Constraints
24+
25+
* The **first line** **holds n** – the number of **messages****integer in range [1…100];**
26+
27+
* On the next **n** lines, you will be receiving encrypted messages.
28+
29+
## Output
30+
31+
After decrypting all messages, you should print the decrypted information in the following format:
32+
33+
First print the attacked planets, then the destroyed planets.**"Attacked planets: {attackedPlanetsCount}""-> {planetName}""Destroyed planets: {destroyedPlanetsCount}""-> {planetName}"**
34+
35+
The planets should be **ordered by name** **alphabetically.**
36+
37+
## Examples
38+
39+
<table>
40+
<tr>
41+
<td>Input</td>
42+
<td>Output</td>
43+
<td>Comments</td>
44+
</tr>
45+
<tr>
46+
<td>2
47+
STCDoghudd4=63333$D$0A53333
48+
EHfsytsnhf?8555&I&2C9555SR</td>
49+
<td>Attacked planets: 1
50+
-> Alderaa
51+
Destroyed planets: 1
52+
-> Cantonica</td>
53+
<td>We receive two messages, to decrypt them we calculate the key:
54+
First message has decryption key 3. So we substract from each characters code 3.
55+
PQ@Alderaa1:30000!A!->20000
56+
The second message has key 5.
57+
@Cantonica:3000!D!->4000NM
58+
Both messages are valid and they contain planet, population, attack type and soldiers count.
59+
After decrypting all messages we print each planet according the format given.</td>
60+
</tr>
61+
<tr>
62+
<td>Input</td>
63+
<td>Output</td>
64+
<td>Comments</td>
65+
</tr>
66+
<tr>
67+
<td>3
68+
tt(''DGsvywgerx>6444444444%H%1B9444
69+
GQhrr|A977777(H(TTTT
70+
EHfsytsnhf?8555&I&2C9555SR</td>
71+
<td>Attacked planets: 0
72+
Destroyed planets: 2
73+
-> Cantonica
74+
-> Coruscant</td>
75+
<td>We receive three messages.
76+
Message one is decrypted with key 4:
77+
pp$##@Coruscant:2000000000!D!->5000
78+
Message two is decrypted with key 7:
79+
@Jakku:200000!A!MMMM
80+
This is invalid message, missing soldier count, so we continue.
81+
The third message has key 5.
82+
@Cantonica:3000!D!->4000NM</td>
83+
</tr>
84+
</table>
85+
86+
87+
"It’s a trap!" – Admiral Ackbar
88+

programming-fundamentals/Programming Fundamentals Exam - January 2018/04. ForceBook/README.md

Lines changed: 88 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,88 @@
1+
# Problem 4. ForceBook
2+
3+
The force users are struggling to remember which side are the different forceUsers from, because they switch them too often. So you are tasked to create a web application to manage their profiles. You should store information for every **unique forceUser**, registered in the application.
4+
5+
You will receive **several input lines** in one of the following formats:
6+
7+
**{forceSide} | {forceUser}**
8+
9+
**{forceUser} -> {forceSide}**
10+
11+
The **forceUser and forceSide** are strings, containing any character.
12+
13+
If you receive **forceSide | forceUser** you should **check if such forceUser already exists**, and **if not**, **add** him/her to the corresponding side.
14+
15+
If you receive a **forceUser -> forceSide** you should check if there is such **forceUser** already and if so, **change his/her side**. If there is no such **forceUser**, add him/her to the corresponding forceSide, treating the command **as new registered forceUser.****Then you should print on the console: ****"{forceUser} joins the {forceSide} side!"**** **
16+
17+
You should end your program when you receive the command **"Lumpawaroo"**. At that point you should print each force side, **ordered descending by forceUsers count, than ordered by name**. For each side print the **forceUsers**, **ordered by name**.
18+
19+
In case there are **no forceUsers in a side**, you **shouldn`t print** the side information.
20+
21+
## Input / Constraints
22+
23+
* The input comes in the form of commands in one of the formats specified above.
24+
25+
* The input ends when you receive the command **"Lumpawaroo"**.
26+
27+
## Output
28+
29+
* As output for each forceSide, **ordered descending by forceUsers count**, **then by name**, you must print all the forceUsers, **ordered by name alphabetically**.
30+
31+
* The output format is:
32+
33+
**Side: {forceSide}, Members: {forceUsers.Count}**
34+
35+
**! {forceUser}**
36+
37+
**! {forceUser}**
38+
39+
**! {forceUser}**
40+
41+
* In case there are **NO** **forceUsers**, don`t print this side.
42+
43+
## Examples
44+
45+
<table>
46+
<tr>
47+
<td>Input</td>
48+
<td>Output</td>
49+
<td>Comments</td>
50+
</tr>
51+
<tr>
52+
<td>Light | Gosho
53+
Dark | Pesho
54+
Lumpawaroo</td>
55+
<td>Side: Dark, Members: 1
56+
! Pesho
57+
Side: Light, Members: 1
58+
! Gosho</td>
59+
<td>We register Gosho in the Light side and Pesho in the Dark side. After receiving "Lumpawaroo" we print both sides, ordered by membersCount and then by name.</td>
60+
</tr>
61+
<tr>
62+
<td>Input</td>
63+
<td>Output</td>
64+
<td>Comments</td>
65+
</tr>
66+
<tr>
67+
<td>Lighter | Royal
68+
Darker | DCay
69+
Ivan Ivanov -> Lighter
70+
DCay -> Lighter
71+
Lumpawaroo</td>
72+
<td>Ivan Ivanov joins the Lighter side!
73+
DCay joins the Lighter side!
74+
Side: Lighter, Members: 3
75+
! DCay
76+
! Ivan Ivanov
77+
! Royal
78+
</td>
79+
<td>Although Ivan Ivanov doesn`t have profile, we register him and add him to the Lighter side.
80+
We remove DCay from Darker side and add him to Lighter side.
81+
We print only Lighter side because Darker side has no members.
82+
</td>
83+
</tr>
84+
</table>
85+
86+
87+
"I find your lack of faith disturbing." — Darth Vader
88+

0 commit comments

Comments
 (0)