Skip to content

Commit 9751e03

Browse files
terriedevdqna64
andauthored
[22T3 1511 Revision] Add best_youtuber.mdx and train_trauma.mdx (#199)
* Add best_youtuber.mdx * Update best_youtuber.mdx * Add train_trauma.mdx * --amend Co-authored-by: Gordon Huang <dqna64@gmail.com> Co-authored-by: dqna64 <76837291+dqna64@users.noreply.github.com>
1 parent 22b5dc6 commit 9751e03

File tree

3 files changed

+178
-0
lines changed

3 files changed

+178
-0
lines changed
Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
---
2+
title: Best Youtuber
3+
desc: Traverse and construct linked lists + more.
4+
class: COMP1511
5+
difficulty: 3
6+
---
7+
8+
# Best Youtuber
9+
10+
Your program is given a list of thought-provoking YouTube videos. Each video has a creator and a number of likes. (They don’t, however, have any dislikes because YouTube removed the dislike button. 😢)
11+
12+
Your task is to print out the YouTuber from among the videos with the best likes-to-videos ratio, along with that YouTuber's video count and total number of likes to prove it. They are thusly crowned the best YouTuber!
13+
14+
A YouTuber’s likes-to-videos ratio is calculated by `their total likes / their number of videos`.
15+
16+
If there's a tie, the program should print "It's a tie! There is no best YouTuber."
17+
18+
Each line of input will be in the format `[video creator], [video likes]` (note the separating comma).
19+
20+
The output from your program should look **exactly** like this:
21+
22+
```bash:~/1511-revision/best_youtuber
23+
$ dcc best_youtuber.c -o best_youtuber
24+
$ ./best_youtuber
25+
**Wild Candy, 84317**
26+
**Logan Paul, 9185**
27+
**Wild Candy, 20097**
28+
**Jaden Smith, 35664**
29+
**Wild Candy, 15321**
30+
**Logan Paul, 75820**
31+
<CTRL+D>
32+
Logan Paul is the best YouTuber.
33+
Number of videos: 2
34+
Total likes: 85005
35+
```
36+
37+
Explanation: There are three YouTubers found from among the given videos: Wild Candy, Logan Paul, and Jaden Smith. Calculating each of their likes-to-videos ratios gives `39,911.66...`, `2,502.5`, and `35,664`, respectively. As Logan Paul has the greatest likes-to-videos ratio, he's the best YouTuber.
38+
39+
```bash:~/1511-revision/best_youtuber
40+
$ dcc best_youtuber.c -o best_youtuber
41+
$ ./best_youtuber
42+
**Will Smith, 2000**
43+
**Logan Paul, 2000**
44+
**Will Smith, 2000**
45+
<CTRL+D>
46+
It's a tie! There is no best YouTuber.
47+
```
48+
49+
## Assumptions/Restrictions/Clarifications
50+
51+
You can assume each YouTuber's name contains no more than 128 characters (including the '\0' null terminator).
52+
53+
As you're calculating a ratio, fractional numbers will be involved. Please use a `double` for this (and not `float`, for example). Note that the nature of floating-point numbers like `double` and `float` mean they can experience a loss of precision when doing certain operations. You do not have to account for this loss of precision; just use `double` as though it'll always be accurate!
54+
55+
## CSE Autotest
56+
57+
When you think your program is working, you can use CSE autotest to test your solution.
58+
59+
```bash:~/1511-revision/best_youtuber
60+
$ 1511 csesoc-autotest best_youtuber
61+
```
62+
63+
## Solution
64+
65+
You can view the solution code to this problem [here](https://github.com/csesoc/comp1511-revision-t1-2022/blob/master/solutions/best-youtuber/solution.c).

data/course-revision/1511-22T3/billys_books.mdx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ ABCDEFGHIJK
5555

5656
When you think your program is working, you can use CSE autotest to test your solution.
5757

58+
5859
```bash:~/1511-revision/billys_books
5960
$ 1511 csesoc-autotest billys_books
6061
```
Lines changed: 112 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,112 @@
1+
---
2+
title: Train Trauma
3+
desc: Representing data as a linked list for traversal.
4+
class: COMP1511
5+
difficulty: 3
6+
---
7+
8+
# Train Trauma
9+
10+
The train network in Sydney has been problematic for some time now, so the government is trying a new 'rapid prototyping approach'. Every day, one of the following will happen:
11+
12+
1) A new station will be added. This station will initially be unconnected to the rest of the network.
13+
2) A new track will be added between two existing stations, replacing the previous track coming out from the start station if one existed.
14+
15+
Before the start of day 1, there are two stations: one near your house (initially named "home"), and one at UNSW (initially named "unsw"), which are initially connected by a track. At the start of each day, one of the above operations will occur.
16+
17+
Every day, your task is to determine whether it is possible to make it to UNSW by train.
18+
19+
The first line of input is an integer: the number of days over which the prototyping will occur.
20+
21+
Following this will be the same number of lines, which may be any of the following ([x] represents a string):
22+
23+
- 's [name]', representing the construction of a new station called [name]. [name] will not match any existing station.
24+
- 't [start]\n[end]', representing the construction of a new track from [start] to [end]. [start] and [end] will both match an existing station. '\n' represents a new line.
25+
26+
Your output should contain a number of lines equal to the integer.
27+
28+
On each line of output, you should output "YES" if it is possible to travel from the stop at your house to the stop at UNSW after the change on the that day, and "NO" otherwise.
29+
30+
The output from your program should look **exactly** like this:
31+
32+
```bash:~/1511-revision/train_trauma
33+
$ dcc train_trauma.c -o train_trauma
34+
$ ./train_trauma
35+
**5**
36+
**s central**
37+
**s moore_park**
38+
**t central**
39+
**moore_park**
40+
**t home**
41+
**central**
42+
**t moore_park**
43+
**unsw**
44+
<CTRL+D>
45+
YES
46+
YES
47+
YES
48+
NO
49+
YES
50+
```
51+
52+
**Explanation**
53+
54+
On each day, the train's path is
55+
56+
1. home -> unsw
57+
2. home -> unsw
58+
3. home -> unsw
59+
4. home -> central -> moore_park
60+
5. home -> central -> moore_park -> unsw
61+
62+
```bash:~/1511-revision/train_trauma
63+
$ dcc train_trauma.c -o train_trauma
64+
$ ./train_trauma
65+
**6**
66+
**s central**
67+
**t home**
68+
**central**
69+
**s surry_hills**
70+
**t central**
71+
**surry_hills**
72+
**t surry_hills**
73+
**home**
74+
**t surry_hills**
75+
**unsw**
76+
<CTRL+D>
77+
YES
78+
NO
79+
NO
80+
NO
81+
NO
82+
YES
83+
```
84+
85+
**Explanation**
86+
87+
On each day, the train's path is
88+
89+
1. home -> unsw
90+
2. home -> central
91+
3. home -> central
92+
4. home -> central -> surry_hills
93+
5. home -> central -> surry_hills -> home -> (repeats infinitely)
94+
6. home -> central -> surry_hills -> unsw
95+
96+
## Assumptions/Restrictions/Clarifications
97+
98+
Each station has at most one track leading out from it.
99+
100+
Station names will be up to 100 characters long (including the '\0' null terminator).
101+
102+
## CSE Autotest
103+
104+
When you think your program is working, you can use CSE autotest to test your solution.
105+
106+
```bash:~/1511-revision/train_trauma
107+
$ 1511 csesoc-autotest train_trauma
108+
```
109+
110+
## Solution
111+
112+
You can view the solution code to this problem [here](https://github.com/csesoc/comp1511-revision-t1-2022/blob/master/solutions/train-trauma/solution.c).

0 commit comments

Comments
 (0)