Skip to main content
4 of 6
added 2 characters in body
Conor O'Brien
  • 40.2k
  • 3
  • 91
  • 180

#JavaScript ES6, 85 bytes

As an anonymous function

a=>["Blinky","Inky","Pinky","Clyde"].filter(c=>!a.includes(c)||a.includes("Pac-Man"))

Today I learned about this filter function. Fun!

15 bytes saved thanks to Neil.

Usage:

(a=>["Blinky","Inky","Pinky","Clyde"].filter(c=>!a.includes(c)||a.includes("Pac-Man")))(["Pac-Man"])
> ["Blinky","Inky","Pinky","Clyde"]
(a=>["Blinky","Inky","Pinky","Clyde"].filter(c=>!a.includes(c)||a.includes("Pac-Man")))(["Pinky"])
> ["Blinky","Inky","Clyde"]
(a=>["Blinky","Inky","Pinky","Clyde"].filter(c=>!a.includes(c)||a.includes("Pac-Man")))([])
> ["Blinky","Inky","Pinky","Clyde"]