Skip to content

Commit d7161c1

Browse files
authored
1511 23 t1 buildfix (#233)
* preview fixed shauns_sheep mdx * preview sweet_potatoes mdx fix * hotfix sweet_potatoes.mdx * subscript fix sweet_potatoes.mdx * hotfix sweet_potatoes * subscript fix for shauns sheep + sweet_potatoes * fix weird inequality format for sweet_potatoes
1 parent 0dca687 commit d7161c1

File tree

2 files changed

+31
-18
lines changed

2 files changed

+31
-18
lines changed

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

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,25 +4,28 @@ desc: Determine if Shaun can drive to the end of the road!
44
class: COMP1511
55
difficulty: 3
66
---
7+
78
# Shaun's Sheeps
8-
Shaun Forza needs your help! Currently, Shaun is on the uppermost left $(1, 1)$, of a two lane road of $n$ length, specifically a $2 \times n$ rectangle grid, and needs to transport all his sheep to the end, $(2, n)$ safely. Shaun's car, the Sheepgatti Chiron, can only move in four directions, that is, left, right, up, and down.
99

10-
Unfortunately, aliens have attacked Earth's sheep, and one notorious alien, Blamo, is specifically targeting Shaun by dropping sheep onto the road, causing certain positions in the grid to be blocked (forbidding Shaun to drive over them).
10+
Shaun Forza needs your help! Currently, Shaun is on the uppermost left $(1, 1)$, of a two lane road of $n$ length, specifically a $2 \times n$ rectangle grid, and needs to transport all his sheep to the end, $(2, n)$ safely. Shaun's car, the Sheepgatti Chiron, can only move in four directions, that is, left, right, up, and down.
11+
12+
Unfortunately, aliens have attacked Earth's sheep, and one notorious alien, Blamo, is specifically targeting Shaun by dropping sheep onto the road, causing certain positions in the grid to be blocked (forbidding Shaun to drive over them).
1113

12-
Fortunately, Blamo is not a very smart alien, and if he happens upon a position where he previously dropped a sheep, Blamo, mistaking the sheep for Shaun, will blast the sheep into dust, freeing the position up again for Shaun.
14+
Fortunately, Blamo is not a very smart alien, and if he happens upon a position where he previously dropped a sheep, Blamo, mistaking the sheep for Shaun, will blast the sheep into dust, freeing the position up again for Shaun.
1315

14-
Shaun knows that Blamo only has $p$ minutes, and it takes him exactly 1 minute to either drop a sheep or blow it up into smithereens, where the $i$-th minute is where Blamo chooses to target position $(r_{i}, c_{i})$.
16+
Shaun knows that Blamo only has $p$ minutes, and it takes him exactly 1 minute to either drop a sheep or blow it up into smithereens, where the $i$-th minute is where Blamo chooses to target position (**r<sub>i</sub>**, **c<sub>i</sub>**).
1517

1618
Shaun wonders, after every minute, whether it is still possible for him to move from his starting position $(1, 1)$, to the end, $(2, n)$ without driving into any sheep.
1719

1820
Although Shaun is a superb driver, he isn't skilled enough to calculate such positions, and needs your help in writing a program, `shauns_sheep.c` to figure out if it is possible for him to drive to the end.
1921

2022
The first line of input contains the integers $n$ and $p$.
21-
And each subsequent $p$ lines contain two integers $r_{i}$ and $c_{i}$.
23+
And each subsequent $p$ lines contain two integers **r<sub>i</sub>** and **c<sub>i</sub>**.
2224

2325
Your output should consist of either a 'Yes' if Shaun can make it to the end, or 'No' if not, after every minute.
2426

2527
The output from your program should look **exactly** like this:
28+
2629
```bash
2730
$ dcc shauns_sheep -o shauns_sheep
2831
$ ./shauns_sheep
@@ -40,6 +43,7 @@ Yes
4043
```
4144

4245
## Assumptions/Restrictions/Clarifications
46+
4347
$2 \leq n \leq 10^5$
4448
$1 \leq p \leq 10^5$
4549
Note that this means that your inputs will fit in an `int`.
@@ -53,7 +57,6 @@ When you think your program is working, you can use CSE autotest to test your so
5357
$ 1511 csesoc-autotest shauns_sheep
5458
```
5559

56-
5760
## Solution
5861

5962
You can view the solution code to this problem [here](https://github.com/csesoc/comp1511-revision-t1-2022/blob/master/solutions/shauns_sheep/solution.c).

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

Lines changed: 22 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -4,24 +4,29 @@ desc: Determine the best place to setup your Sweet Potato Stall!
44
class: COMP1511
55
difficulty: 2
66
---
7+
78
# X marks the Starch
8-
You've recently been reading the news and have seen a gap in the market for delicious, delectable sweet potatoes!
9+
10+
You've recently been reading the news and have seen a gap in the market for delicious, delectable sweet potatoes!
911
You've decided to set up shop at Town Hall, but unfortunately, you can only serve people in a cross pattern!
12+
1013
```
1114
X 0 X
1215
0 X 0
1316
X 0 X
1417
```
15-
Even worse, your constant back pain forces you to stay still for the entire day.
16-
Luckily, you've prepared for this and you have a map with $m$ rows and $n$ columns that contains the density of people who walk throughout Town Hall everyday.
18+
19+
Even worse, your constant back pain forces you to stay still for the entire day.
20+
Luckily, you've prepared for this and you have a map with **m** rows and **n** columns that contains the density of people who walk throughout Town Hall everyday.
1721
You know that everyone will want to taste your sweet potatoes as long as you can serve them. Therefore, your task is to write a program `sweet_potatoes.c` that finds the best place to put your cart so that you will end up serving the most people!
1822

19-
For each testcase, print three integers - the row and column index (starting from $0$) of the best position to place your cart, and the total number of people you will serve.
23+
For each testcase, print three integers - the row and column index (starting from **0**) of the best position to place your cart, and the total number of people you will serve.
2024

21-
The first line contains integer $m, n$.
22-
The next $m$ lines will have $n$ integers $r_{1}, r_{2}, ...,r_{n}$ denoting the density of people at that coordinate.
25+
The first line contains integer **m, n**.
26+
The next **m** lines will have **n** integers **r<sub>1</sub>, r<sub>2</sub>, ...,r<sub>n</sub>** denoting the density of people at that coordinate.
2327

2428
The output from your program should look **exactly** like this:
29+
2530
```bash
2631
Input:
2732
$ dcc sweet_potatoes.c -o sweet_potatoes
@@ -34,28 +39,33 @@ $ ./sweet_potatoes
3439
```
3540

3641
### Assumptions/Restrictions/Clarifications
37-
$3 \leq m, n \leq 10^5$
38-
$0 \leq r_{i} \leq 10^5$ for any $1 \leq i \leq n$.
39-
Note that this means your inputs will fit inside an `int`.
42+
43+
$3 \leq m, n \leq 10^5$
44+
$0 \leq$ **r<sub>i</sub>** $\leq 10^5$ for any $1 \leq i \leq n$.
45+
Note that this means your inputs will fit inside an `int`.
4046

4147
If there exists multiple places where it is best to place your cart, any applicable answer is accepted.
4248

43-
Note that you can place your cart at indexes where it is not possible to form an X shape.
49+
Note that you can place your cart at indexes where it is not possible to form an X shape.
4450
For example,
51+
4552
```
4653
X 0 0
4754
0 X 0
4855
0 0 0
4956
```
57+
5058
at the uppermost left corner of your map.
5159

52-
Hint: You can dynamically allocate an array by defining an array of int pointers in the form `int **arr`.
60+
Hint: You can dynamically allocate an array by defining an array of int pointers in the form `int **arr`.
5361
This can be thought as a pointer to a bunch of integer pointers, which can then be thought of as a sort of 2D array when dynamically allocated.
62+
5463
```
5564
**int -> *int *int *int *int
5665
| | | |
5766
int int int int
58-
```
67+
```
68+
5969
## CSE Autotest
6070

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

0 commit comments

Comments
 (0)