Skip to main content
3 of 5
other form of binary operators
hdrz
  • 1k
  • 6
  • 6

Object Pascal, 204 200 bytes

Two loops, using a binary to find which ghosts+pacman are present. Takes the arguments from the commandline. Thanks to @manatwork for saving some more bytes!

var a:array[1..4]of string=('Blinky','Inky','Pinky','Clyde');i,s:Byte;begin for i:=1to ParamCount do s:=1<<Pos(ParamStr(i)[4],'nykd-')or s;for i:=1to 4do if(1<<i and s=0)or(s>31)then WriteLn(a[i])end.

Ungolfed:

var
  a: array[1..4] of string = ('Blinky', 'Inky', 'Pinky', 'Clyde');
  i, s: byte;
begin
  for i:=1 to ParamCount do
    s := 1 << pos(ParamStr(i)[4], 'nykd-') or s; // fill bits by shifting, check for unique 4th char of names, '-' in 'pac-man', could also use the 3rd char
  for i:=1 to 4 do
    if (1 << i and s=0) or (s>31) then    // check if bits are on
      writeln(a[i]);
end.

Old version using a set, 227 209 bytes

Two loops, using a set to find which ghosts+pacman are present. Takes the arguments from the commandline.

var a:array[1..4]of string=('Blinky','Inky','Pinky','Clyde');i:byte;s:set of 1..5;begin for i:=1to ParamCount do s:=s+[pos(ParamStr(i)[4],'nykd-')];for i:=1to 4do if not(i in s)or(5in s)then writeln(a[i]);end.

Ungolfed:

var
  a: array[1..4] of string = ('Blinky', 'Inky', 'Pinky', 'Clyde');
  i: integer;
  g: string = 'nykd-'; // unique 4th char of names, '-' in 'pac-man', could also use the 3rd char
  s: set of 1..5;
begin
  for i:=1 to ParamCount do
    s := s + [pos(ParamStr(i)[4], g)]; // fill set with indxs
  for i:=1 to 4 do
    if not(i in s) or (5 in s) then    // check indx not in set or pac-man is
      writeln(a[i]);
end.
hdrz
  • 1k
  • 6
  • 6