Skip to main content
edited body
Source Link
Kosatka
  • 121
  • 4

C(GCC), 105 99 bytes

-6 bytes thanks to @ceilingcat, but I want to keep the inside while

j(a,b)char*a;{char*c=a,*d=a,m=1,o=0;for(;c-a<b;o|=m++,d=c++)while(*++d)m&=*d-48||(d-c)%b;return o;}

Try it online The idea is to try all possible starting points and then go through the whole string and do something only when on a place the frog lands. If frog's jumping power would be limited to 32 max, it would be possible to golf more (8388 bytes), like:

j(a,b)char*a;{char*d=a;unsigned m=(1<<b)-1;while(*++d)m&=-1u^49-*d<<(d-a)%b;return !!m;}

Try it online Here I would simply have a bitflag for each possible start, and use !! to normalize the result.

C(GCC), 105 99 bytes

-6 bytes thanks to @ceilingcat, but I want to keep the inside while

j(a,b)char*a;{char*c=a,*d=a,m=1,o=0;for(;c-a<b;o|=m++,d=c++)while(*++d)m&=*d-48||(d-c)%b;return o;}

Try it online The idea is to try all possible starting points and then go through the whole string and do something only when on a place the frog lands. If frog's jumping power would be limited to 32 max, it would be possible to golf more (83 bytes), like:

j(a,b)char*a;{char*d=a;unsigned m=(1<<b)-1;while(*++d)m&=-1u^49-*d<<(d-a)%b;return !!m;}

Try it online Here I would simply have a bitflag for each possible start, and use !! to normalize the result.

C(GCC), 105 99 bytes

-6 bytes thanks to @ceilingcat, but I want to keep the inside while

j(a,b)char*a;{char*c=a,*d=a,m=1,o=0;for(;c-a<b;o|=m++,d=c++)while(*++d)m&=*d-48||(d-c)%b;return o;}

Try it online The idea is to try all possible starting points and then go through the whole string and do something only when on a place the frog lands. If frog's jumping power would be limited to 32 max, it would be possible to golf more (88 bytes), like:

j(a,b)char*a;{char*d=a;unsigned m=(1<<b)-1;while(*++d)m&=-1u^49-*d<<(d-a)%b;return !!m;}

Try it online Here I would simply have a bitflag for each possible start, and use !! to normalize the result.

added 124 characters in body
Source Link
Kosatka
  • 121
  • 4

C(GCC), 105105 99 bytes

j(char*a,int b){char*c=a,*d=a,m=1,o=0;for(;c-a<b;d=c++){while(*(++d))m&=*d-48||(d-c)%b;o|=m++;}return o;}

-6 bytes thanks to @ceilingcat, but I want to keep the inside while

j(a,b)char*a;{char*c=a,*d=a,m=1,o=0;for(;c-a<b;o|=m++,d=c++)while(*++d)m&=*d-48||(d-c)%b;return o;}

Try it onlineTry it online The idea is to try all possible starting points and then go through the whole string and do something only when on a place the frog lands. If frog's jumping power would be limited to 32 max, it would be possible to golf more (8783 bytes), like:

j(char*a,int b){char*d=a;unsigned m=(1<<b)-1;while(*(++d))m&=-1u^49-*d<<(d-a)%b;return !!m;}
j(a,b)char*a;{char*d=a;unsigned m=(1<<b)-1;while(*++d)m&=-1u^49-*d<<(d-a)%b;return !!m;}

Try it online Here I would simply have a bitflag for each possible start, and use !! to normalize the result.

C(GCC), 105 bytes

j(char*a,int b){char*c=a,*d=a,m=1,o=0;for(;c-a<b;d=c++){while(*(++d))m&=*d-48||(d-c)%b;o|=m++;}return o;}

Try it online The idea is to try all possible starting points and then go through the whole string and do something only when on a place the frog lands. If frog's jumping power would be limited to 32 max, it would be possible to golf more (87 bytes), like:

j(char*a,int b){char*d=a;unsigned m=(1<<b)-1;while(*(++d))m&=-1u^49-*d<<(d-a)%b;return !!m;}

Try it online Here I would simply have a bitflag for each possible start, and use !! to normalize the result.

C(GCC), 105 99 bytes

-6 bytes thanks to @ceilingcat, but I want to keep the inside while

j(a,b)char*a;{char*c=a,*d=a,m=1,o=0;for(;c-a<b;o|=m++,d=c++)while(*++d)m&=*d-48||(d-c)%b;return o;}

Try it online The idea is to try all possible starting points and then go through the whole string and do something only when on a place the frog lands. If frog's jumping power would be limited to 32 max, it would be possible to golf more (83 bytes), like:

j(a,b)char*a;{char*d=a;unsigned m=(1<<b)-1;while(*++d)m&=-1u^49-*d<<(d-a)%b;return !!m;}

Try it online Here I would simply have a bitflag for each possible start, and use !! to normalize the result.

Source Link
Kosatka
  • 121
  • 4

C(GCC), 105 bytes

j(char*a,int b){char*c=a,*d=a,m=1,o=0;for(;c-a<b;d=c++){while(*(++d))m&=*d-48||(d-c)%b;o|=m++;}return o;}

Try it online The idea is to try all possible starting points and then go through the whole string and do something only when on a place the frog lands. If frog's jumping power would be limited to 32 max, it would be possible to golf more (87 bytes), like:

j(char*a,int b){char*d=a;unsigned m=(1<<b)-1;while(*(++d))m&=-1u^49-*d<<(d-a)%b;return !!m;}

Try it online Here I would simply have a bitflag for each possible start, and use !! to normalize the result.