Skip to main content
Commonmark migration
Source Link

##C, 112 101 96 98 104 bytes

C, 112 101 96 98 104 bytes

Thanks to @MartinEnder for saving 5 3 bytes while fixing my code!

j,i,k,l;f(char*s){l=strlen(s);for(i=l,j=k=0;j<l;)k+=(s[j++]-48)*(i>1?i--:-1);return!(k%11)&&k&&(l^8)<2;}

Returns 0 if invalid, 1 if valid. Try it online!

##C, 112 101 96 98 104 bytes

Thanks to @MartinEnder for saving 5 3 bytes while fixing my code!

j,i,k,l;f(char*s){l=strlen(s);for(i=l,j=k=0;j<l;)k+=(s[j++]-48)*(i>1?i--:-1);return!(k%11)&&k&&(l^8)<2;}

Returns 0 if invalid, 1 if valid. Try it online!

C, 112 101 96 98 104 bytes

Thanks to @MartinEnder for saving 5 3 bytes while fixing my code!

j,i,k,l;f(char*s){l=strlen(s);for(i=l,j=k=0;j<l;)k+=(s[j++]-48)*(i>1?i--:-1);return!(k%11)&&k&&(l^8)<2;}

Returns 0 if invalid, 1 if valid. Try it online!

added 6 characters in body
Source Link
betseg
  • 8.7k
  • 3
  • 28
  • 60

##C, 112 101 96 98 104 bytes

Thanks to @MartinEnder for saving 5 3 bytes while fixing my code!

j,i,k,l;f(char*s){l=strlen(s);for(i=l;j<l;i=l,j=k=0;j<l;)k+=(s[j++]-48)*(i>1?i--:-1);return!(k%11)&&k&&(l^8)<2;}

Returns 0 if invalid, 1 if valid. Try it online!

##C, 112 101 96 98 104 bytes

Thanks to @MartinEnder for saving 5 3 bytes while fixing my code!

j,i,k,l;f(char*s){l=strlen(s);for(i=l;j<l;)k+=(s[j++]-48)*(i>1?i--:-1);return!(k%11)&&k&&(l^8)<2;}

Returns 0 if invalid, 1 if valid. Try it online!

##C, 112 101 96 98 104 bytes

Thanks to @MartinEnder for saving 5 3 bytes while fixing my code!

j,i,k,l;f(char*s){l=strlen(s);for(i=l,j=k=0;j<l;)k+=(s[j++]-48)*(i>1?i--:-1);return!(k%11)&&k&&(l^8)<2;}

Returns 0 if invalid, 1 if valid. Try it online!

added 24 characters in body
Source Link
betseg
  • 8.7k
  • 3
  • 28
  • 60

##C, 112 101 96 9898 104 bytes

Thanks to @MartinEnder for saving 5 3 bytes while fixing my code!

j,i,k,l;f(char*s){l=strlen(s);for(i=l;j<l;)k+=(s[j++]-48)*(i>1?i--:-1);return!(k%11)&&k&&(l^8)<2;}

Returns 0 if invalid, 1 if valid. Try it online!Try it online!

##C, 112 101 96 98 bytes

Thanks to @MartinEnder for saving 5 3 bytes while fixing my code!

j,i,k,l;f(char*s){l=strlen(s);for(i=l;j<l;)k+=(s[j++]-48)*(i>1?i--:-1);return!(k%11)&&k&&(l^8)<2;}

Returns 0 if invalid, 1 if valid. Try it online!

##C, 112 101 96 98 104 bytes

Thanks to @MartinEnder for saving 5 3 bytes while fixing my code!

j,i,k,l;f(char*s){l=strlen(s);for(i=l;j<l;)k+=(s[j++]-48)*(i>1?i--:-1);return!(k%11)&&k&&(l^8)<2;}

Returns 0 if invalid, 1 if valid. Try it online!

Post Undeleted by betseg
Post Deleted by betseg
added 34 characters in body
Source Link
betseg
  • 8.7k
  • 3
  • 28
  • 60
Loading
added 61 characters in body
Source Link
betseg
  • 8.7k
  • 3
  • 28
  • 60
Loading
added 10 characters in body
Source Link
betseg
  • 8.7k
  • 3
  • 28
  • 60
Loading
added 10 characters in body
Source Link
betseg
  • 8.7k
  • 3
  • 28
  • 60
Loading
Post Undeleted by betseg
Post Deleted by betseg
Source Link
betseg
  • 8.7k
  • 3
  • 28
  • 60
Loading