Skip to main content
1 of 3
Mathgeek
  • 587
  • 2
  • 7

GolfScript, 46 bytes

1/.{"o"=},,\{"_"=!},"P"/~"o~"/,\"~o"/,+2-.@\-\

I'm not going to explain everything in depth right now, but the short of it is;

"Split the string into an array of chars, count the mice, then split the array in two, one before the piper and one after. Then count the number of mice in the correct direction, then subtract that from the original count."

This is the brute force method and can likely be very optimized.

Mathgeek
  • 587
  • 2
  • 7