Skip to main content
7 of 7
Commonmark migration

Python 2, 74 72 bytes

Having already been soundly beaten by @Flp.Tkc I'll just post my 74 72 byte recursive solution because it's different and it works and not because it will win (and also because I like recursive functions).

def f(a,b,c=1):
 print(c,"Shaggy")[c%b<1or`b`in`c`]
 if c<a:f(a,b,c+1)

Edit

-2 by removing the unneeded `` around the c in the print statement

From comments:

Call using

 f(a,b)

c will default to 1 due to the

 c=1

in the function definition and can then be incremented for the recursive function calls.

ElPedro
  • 6.5k
  • 2
  • 24
  • 38