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

undesired solution to [exercises/concept/pacman-rules] #425

Open
TressaDanvers opened this issue Mar 12, 2024 · 0 comments
Open

undesired solution to [exercises/concept/pacman-rules] #425

TressaDanvers opened this issue Mar 12, 2024 · 0 comments

Comments

@TressaDanvers
Copy link

TressaDanvers commented Mar 12, 2024

There is a valid solution to the win function in the Pacman Rules exercise which is as follows:

pub fn win(
  has_eaten_all_dots: Bool,
  power_pellet_active: Bool,
  touching_ghost: Bool,
) -> Bool {
  has_eaten_all_dots && { power_pellet_active == touching_ghost }
}

As you can see, this is not equivalent to the intended solution of:

pub fn win(
  has_eaten_all_dots: Bool,
  power_pellet_active: Bool,
  touching_ghost: Bool,
) -> Bool {
  has_eaten_all_dots && !lose(power_pellet_active, touching_ghost)
}

If we expand that solution out we get:

pub fn win(
  has_eaten_all_dots: Bool,
  power_pellet_active: Bool,
  touching_ghost: Bool,
) -> Bool {
  has_eaten_all_dots && !{ !power_pellet_active && touching_ghost }
}

a ∧ (b ↔ c) is not equivalent to a ∧ !(!b ∧ c).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant