Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Annalyn's Infiltration - Task 4 - Instructions don't match tests #786

Merged
merged 6 commits into from
Aug 11, 2024
4 changes: 2 additions & 2 deletions config.json
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@
},
{
"slug": "annalyns-infiltration",
"name": "Annalyns Infiltration",
"name": "Annalyn's Infiltration",
"uuid": "18c47e7b-fb34-4d00-b693-a3a5917e5f15",
"concepts": [
"booleans"
Expand Down Expand Up @@ -1508,4 +1508,4 @@
"used_for/scripts",
"used_for/web_development"
]
}
}
mk-mxp marked this conversation as resolved.
Show resolved Hide resolved
2 changes: 1 addition & 1 deletion exercises/concept/annalyns-infiltration/.docs/hints.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
- Logical operators in the order of their precedence (from highest to lowest): `!`, `&&`, `||`.
- Check out [this article][operator-precedence] on Operator Precedence

## 4. Check if the 'Free Prisoner' action is possible
## 4. Check if the 'Liberate Prisoner' action is possible

- `()` is the operator with the highest precedence. Use it to group logical expressions.

Expand Down
4 changes: 2 additions & 2 deletions exercises/concept/annalyns-infiltration/.docs/instructions.md
Original file line number Diff line number Diff line change
Expand Up @@ -70,12 +70,12 @@ $infiltration->canSignal($is_archer_awake, $is_prisoner_awake);
// => true
```

## 4. Check if the 'Free Prisoner' action is possible
## 4. Check if the 'Liberate Prisoner' action is possible

Implement a function named `canLiberate` that takes four boolean values.
The first three parameters indicate if the knight, archer and the prisoner, respectively, are awake.
The last parameter indicates if Annalyn's pet dog is present.
The function returns `true` if the 'Free Prisoner' action is available based on the state of the characters and Annalyn's pet dog presence.
The function returns `true` if the 'Liberate Prisoner' action is available based on the state of the characters and Annalyn's pet dog presence.
Otherwise, it returns `false`:

```php
Expand Down
45 changes: 45 additions & 0 deletions exercises/concept/annalyns-infiltration/.meta/design.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,3 +31,48 @@ This exercise could benefit from the following rules added to the analyzer:
- Verify that the `canSignal` function is as simple as possible (single OR `||` and single negation `!`)
- Verify that the `canLiberate` function is not overly complex.
Helper variables may be used, but those should result in a suggestion about combining them (informational, non-essential).

## Truth Tables

For tasks 2 - 4, the truth tables for the required tests read as such:

### Task 2: Can Spy
Test | Knight Awake | Archer Awake | Prisoner Awake | Can Spy
-- | -- | -- | -- | --
Everyone Asleep | FALSE | FALSE | FALSE | FALSE
Only Prisoner Awake | FALSE | FALSE | TRUE | TRUE
Only Archer Awake | FALSE | TRUE | FALSE | TRUE
Only Knight Awake | TRUE | FALSE | FALSE | TRUE
Only Prisoner Asleep | TRUE | TRUE | FALSE | TRUE
Only Archer Asleep | TRUE | FALSE | TRUE | TRUE
Only Knight Asleep | FALSE | TRUE | TRUE | TRUE
Everyone Awake | TRUE | TRUE | TRUE | TRUE

### Task 3: Can Signal
Test | Archer Awake | Prisoner Awake | Can Signal
-- | -- | -- | --
Everyone Asleep | FALSE | FALSE | FALSE
Only Prisoner Awake | FALSE | TRUE | TRUE
Only Archer Awake | TRUE | FALSE | FALSE
Everyone Awake | TRUE | TRUE | FALSE

### Task 4: Can Liberate
Test | Knight Awake | Archer Awake | Prisoner Awake | Dog Present | Can Liberate
-- | -- | -- | -- | -- | --
Everyone Asleep - Dog Present | FALSE | FALSE | FALSE | TRUE | TRUE
Only Prisoner Awake - Dog Present | FALSE | FALSE | TRUE | TRUE | TRUE
Only Archer Awake - Dog Present | FALSE | TRUE | FALSE | TRUE | FALSE
Only Knight Awake - Dog Present | TRUE | FALSE | FALSE | TRUE | TRUE
Only Prisoner Asleep - Dog Present | TRUE | TRUE | FALSE | TRUE | FALSE
Only Archer Asleep - Dog Present | TRUE | FALSE | TRUE | TRUE | TRUE
Only Knight Asleep - Dog Present | FALSE | TRUE | TRUE | TRUE | FALSE
Everyone Awake - Dog Present | TRUE | TRUE | TRUE | TRUE | FALSE
Everyone Asleep - No Dog | FALSE | FALSE | FALSE | FALSE | FALSE
Only Prisoner Awake - No Dog | FALSE | FALSE | TRUE | FALSE | TRUE
Only Archer Awake - No Dog | FALSE | TRUE | FALSE | FALSE | FALSE
Only Knight Awake - No Dog | TRUE | FALSE | FALSE | FALSE | FALSE
Only Prisoner Asleep - No Dog | TRUE | TRUE | FALSE | FALSE | FALSE
Only Archer Asleep - No Dog | TRUE | FALSE | TRUE | FALSE | FALSE
Only Knight Asleep - No Dog | FALSE | TRUE | TRUE | FALSE | FALSE
Everyone Awake - No Dog | TRUE | TRUE | TRUE | FALSE | FALSE

Loading
Loading