Skip to main content
added 21 characters in body
Source Link
Jerry Jeremiah
  • 1.4k
  • 10
  • 10

C99 - 86 (GCC 4.9.0 and Visual C++ 2013)

Edit: Both GCC 4.9.0 (with -std=c99) and Visual C++ 2013 successfully build (with warnings) the same code without the includes. I didn't know you could do that! Thanks for the hint.

Edit: It didn't even occur to me that I should write it to the screen on the fly instead of creating the string and then printing it. That makes a huge difference. Thanks Dennis!

This is using a hard coded string but the contents of the string are not counted towards the total (the ="" is counted).

main(i){for(char*q,*s="test123test999test-1test";i=strtol(s,&q,0),*s;q>s?printf("%d",i+1,s=q):putchar(*s++));}

Basically it runs through the string one character at a time checking each to see if it is an integer. If it is then it increments the integer and writes it to the output otherwise it copies the current character to the output.

This leaks the hardcoded string because it increments s.

C99 - 86 (GCC 4.9.0 and Visual C++ 2013)

Edit: Both GCC 4.9.0 (with -std=c99) and Visual C++ 2013 successfully build (with warnings) the same code without the includes. I didn't know you could do that! Thanks for the hint.

Edit: It didn't even occur to me that I should write it to the screen on the fly instead of creating the string and then printing it. That makes a huge difference. Thanks Dennis!

This is using a hard coded string but the contents of the string are not counted towards the total.

main(i){for(char*q,*s="test123test999test-1test";i=strtol(s,&q,0),*s;q>s?printf("%d",i+1,s=q):putchar(*s++));}

Basically it runs through the string one character at a time checking each to see if it is an integer. If it is then it increments the integer and writes it to the output otherwise it copies the current character to the output.

This leaks the hardcoded string because it increments s.

C99 - 86 (GCC 4.9.0 and Visual C++ 2013)

Edit: Both GCC 4.9.0 (with -std=c99) and Visual C++ 2013 successfully build (with warnings) the same code without the includes. I didn't know you could do that! Thanks for the hint.

Edit: It didn't even occur to me that I should write it to the screen on the fly instead of creating the string and then printing it. That makes a huge difference. Thanks Dennis!

This is using a hard coded string but the contents of the string are not counted towards the total (the ="" is counted).

main(i){for(char*q,*s="test123test999test-1test";i=strtol(s,&q,0),*s;q>s?printf("%d",i+1,s=q):putchar(*s++));}

Basically it runs through the string one character at a time checking each to see if it is an integer. If it is then it increments the integer and writes it to the output otherwise it copies the current character to the output.

This leaks the hardcoded string because it increments s.

deleted 204 characters in body
Source Link
Jerry Jeremiah
  • 1.4k
  • 10
  • 10

C 90C99 - 86 (GCC 4.9.0 and Visual C++ 2013)

Edit: Both GCC 4.9.0 (with -std=c99) and Visual C++ 2013 successfully build (with warnings) the same code without the includes. I didn't know you could do that! Thanks for the hint.

Edit: It didn't even occur to me that I should write it to the screen on the fly instead of creating the string and then printing it. That makes a huge difference. Thanks Dennis!

This is using a hard coded string but the contents of the string are not counted towards the total.

Thanks to Dennis it is now 90:

main(i){char *qfor(char*q,*s="test123test999test-1test";for(;i=strtol1test";i=strtol(s,&q,0),*s;(q>s)*s;q>s?printf("%d",i+1,s=q):putchar(*s++));}

Previously 135:

i;main(){char o[99],*p=o,*q,*s="test123test999test-1test";for(;*s;*p=0){i=strtol(s,&q,0);if(q>s){sprintf(p,"%d",i+1);p+=strlen(p);s=q;}else*p++=*s++;}puts(o);}

Basically it runs through the string one character at a time checking each to see if it is an integer. If it is then it increments the integer and writes it to the output otherwise it copies the current character to the output.

This leaks the hardcoded string because it increments s.

C 90 (GCC 4.9.0 and Visual C++ 2013)

Edit: Both GCC 4.9.0 and Visual C++ 2013 successfully build (with warnings) the same code without the includes. I didn't know you could do that! Thanks for the hint.

Edit: It didn't even occur to me that I should write it to the screen on the fly instead of creating the string and then printing it. That makes a huge difference. Thanks Dennis!

This is using a hard coded string but the contents of the string are not counted towards the total.

Thanks to Dennis it is now 90:

main(i){char *q,*s="test123test999test-1test";for(;i=strtol(s,&q,0),*s;(q>s)?printf("%d",i+1,s=q):putchar(*s++));}

Previously 135:

i;main(){char o[99],*p=o,*q,*s="test123test999test-1test";for(;*s;*p=0){i=strtol(s,&q,0);if(q>s){sprintf(p,"%d",i+1);p+=strlen(p);s=q;}else*p++=*s++;}puts(o);}

Basically it runs through the string one character at a time checking each to see if it is an integer. If it is then it increments the integer and writes it to the output otherwise it copies the current character to the output.

This leaks the hardcoded string because it increments s.

C99 - 86 (GCC 4.9.0 and Visual C++ 2013)

Edit: Both GCC 4.9.0 (with -std=c99) and Visual C++ 2013 successfully build (with warnings) the same code without the includes. I didn't know you could do that! Thanks for the hint.

Edit: It didn't even occur to me that I should write it to the screen on the fly instead of creating the string and then printing it. That makes a huge difference. Thanks Dennis!

This is using a hard coded string but the contents of the string are not counted towards the total.

main(i){for(char*q,*s="test123test999test-1test";i=strtol(s,&q,0),*s;q>s?printf("%d",i+1,s=q):putchar(*s++));}

Basically it runs through the string one character at a time checking each to see if it is an integer. If it is then it increments the integer and writes it to the output otherwise it copies the current character to the output.

This leaks the hardcoded string because it increments s.

Make it shorter!
Source Link
Jerry Jeremiah
  • 1.4k
  • 10
  • 10

C 13590 (GCC 4.9.0 and Visual C++ 2013)

This will never win but it is in a language that doesn't lend itself to golfing...

Edit: Both GCC 4.9.0 and Visual C++ 2013 successfully build (with warnings) the same code without the includes. I didn't know you could do that! Thanks for the hint.

Edit: It didn't even occur to me that I should write it to the screen on the fly instead of creating the string and then printing it. That makes a huge difference. Thanks Dennis!

This is using a hard coded string but the contents of the string are not counted towards the total.

Thanks to Dennis it is now 90:

main(i){char *q,*s="test123test999test-1test";for(;i=strtol(s,&q,0),*s;(q>s)?printf("%d",i+1,s=q):putchar(*s++));}

Previously 135:

i;main(){char o[99],*p=o,*q,*s="test123test999test-1test";for(;*s;*p=0){i=strtol(s,&q,0);if(q>s){sprintf(p,"%d",i+1);p+=strlen(p);s=q;}else*p++=*s++;}puts(o);}

Basically it runs through the string one character at a time checking each to see if it is an integer. If it is then it increments the integer and writes it to the output otherwise it copies the current character to the output.

This leaks the hardcoded string because it increments s.

C 135 (GCC 4.9.0 and Visual C++ 2013)

This will never win but it is in a language that doesn't lend itself to golfing...

Edit: Both GCC 4.9.0 and Visual C++ 2013 successfully build (with warnings) the same code without the includes. I didn't know you could do that! Thanks for the hint.

This is using a hard coded string but the contents of the string are not counted towards the total.

i;main(){char o[99],*p=o,*q,*s="test123test999test-1test";for(;*s;*p=0){i=strtol(s,&q,0);if(q>s){sprintf(p,"%d",i+1);p+=strlen(p);s=q;}else*p++=*s++;}puts(o);}

Basically it runs through the string one character at a time checking each to see if it is an integer. If it is then it increments the integer and writes it to the output otherwise it copies the current character to the output.

This leaks the hardcoded string because it increments s.

C 90 (GCC 4.9.0 and Visual C++ 2013)

Edit: Both GCC 4.9.0 and Visual C++ 2013 successfully build (with warnings) the same code without the includes. I didn't know you could do that! Thanks for the hint.

Edit: It didn't even occur to me that I should write it to the screen on the fly instead of creating the string and then printing it. That makes a huge difference. Thanks Dennis!

This is using a hard coded string but the contents of the string are not counted towards the total.

Thanks to Dennis it is now 90:

main(i){char *q,*s="test123test999test-1test";for(;i=strtol(s,&q,0),*s;(q>s)?printf("%d",i+1,s=q):putchar(*s++));}

Previously 135:

i;main(){char o[99],*p=o,*q,*s="test123test999test-1test";for(;*s;*p=0){i=strtol(s,&q,0);if(q>s){sprintf(p,"%d",i+1);p+=strlen(p);s=q;}else*p++=*s++;}puts(o);}

Basically it runs through the string one character at a time checking each to see if it is an integer. If it is then it increments the integer and writes it to the output otherwise it copies the current character to the output.

This leaks the hardcoded string because it increments s.

removed 56 characters of includes
Source Link
Jerry Jeremiah
  • 1.4k
  • 10
  • 10
Loading
Source Link
Jerry Jeremiah
  • 1.4k
  • 10
  • 10
Loading