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

C - 5756

// @ceilingcat - put vars in for loop j(char*s){for(char*q=s,*p=s;*q=*p;q+=q==index(s,*p++));} // @ceilingcat - use index() instead of strchr() j(char*s){char*q=s,*p=s;for(;*q=*p;q+=q==index(s,*p++));} // @hvd - modify in place i(char*s){char*q=s,*p=s;for(;*q=*p;q+=q==strchr(s,*p++));} // @AShelly - keep a histogram of the usage of each character h(char*s){int a[128]={0};for(;*s;s++)a[*s]++||putchar(*s);} // @hvd - always copy to q but only increment q if not found g(char*s,char*r){char*q=r;for(;*q=*s;q+=q==strchr(r,*s++));} // original version - requires -std=c99 void f(char*s,char*r){for(char*q=r;*s;s++)if(!strchr(r,*s))*q++=*s;} 

C - 57

// @ceilingcat - use index() instead of strchr() j(char*s){char*q=s,*p=s;for(;*q=*p;q+=q==index(s,*p++));} // @hvd - modify in place i(char*s){char*q=s,*p=s;for(;*q=*p;q+=q==strchr(s,*p++));} // @AShelly - keep a histogram of the usage of each character h(char*s){int a[128]={0};for(;*s;s++)a[*s]++||putchar(*s);} // @hvd - always copy to q but only increment q if not found g(char*s,char*r){char*q=r;for(;*q=*s;q+=q==strchr(r,*s++));} // original version - requires -std=c99 void f(char*s,char*r){for(char*q=r;*s;s++)if(!strchr(r,*s))*q++=*s;} 

C - 56

// @ceilingcat - put vars in for loop j(char*s){for(char*q=s,*p=s;*q=*p;q+=q==index(s,*p++));} // @ceilingcat - use index() instead of strchr() j(char*s){char*q=s,*p=s;for(;*q=*p;q+=q==index(s,*p++));} // @hvd - modify in place i(char*s){char*q=s,*p=s;for(;*q=*p;q+=q==strchr(s,*p++));} // @AShelly - keep a histogram of the usage of each character h(char*s){int a[128]={0};for(;*s;s++)a[*s]++||putchar(*s);} // @hvd - always copy to q but only increment q if not found g(char*s,char*r){char*q=r;for(;*q=*s;q+=q==strchr(r,*s++));} // original version - requires -std=c99 void f(char*s,char*r){for(char*q=r;*s;s++)if(!strchr(r,*s))*q++=*s;} 
added 214 characters in body
Source Link
Jerry Jeremiah
  • 1.4k
  • 10
  • 10

C - 5857

Thanks to @ceilingcat, @hvd and @AShelly for saving a bunch of characters. There were multiple ways suggested of making it much shorter than the original:

// @hvd@ceilingcat  - alwaysuse copyindex() toinstead qof butstrchr() j(char*s){char*q=s,*p=s;for(;*q=*p;q+=q==index(s,*p++));} // only@hvd increment q if not found - modify in place gi(char*s,char*r){char*q=r;forchar*q=s,*p=s;for(;*q=*s;q+=q==strchr;*q=*p;q+=q==strchr(rs,*s++*p++));} // @AShelly  - keep a histogram of the usage of each character h(char*s){int a[128]={0};for(;*s;s++)a[*s]++||putchar(*s);} // @hvd  - modifyalways incopy placeto q but only increment q if not found ig(char*s,char*r){char*q=s,*p=s;forchar*q=r;for(;*q=*p;q+=q==strchr;*q=*s;q+=q==strchr(sr,*p++*s++));} // original version - requires -std=c99 void f(char*s,char*r){for(char*q=r;*s;s++)if(!strchr(r,*s))*q++=*s;} 

C - 58

Thanks to @hvd and @AShelly for saving a bunch of characters. There were multiple ways suggested of making it much shorter than the original:

// @hvd - always copy to q but only increment q if not found g(char*s,char*r){char*q=r;for(;*q=*s;q+=q==strchr(r,*s++));} // @AShelly - keep a histogram of the usage of each character h(char*s){int a[128]={0};for(;*s;s++)a[*s]++||putchar(*s);} // @hvd - modify in place i(char*s){char*q=s,*p=s;for(;*q=*p;q+=q==strchr(s,*p++));} // original version - requires -std=c99 void f(char*s,char*r){for(char*q=r;*s;s++)if(!strchr(r,*s))*q++=*s;} 

C - 57

Thanks to @ceilingcat, @hvd and @AShelly for saving a bunch of characters. There were multiple ways suggested of making it much shorter than the original:

// @ceilingcat  - use index() instead of strchr() j(char*s){char*q=s,*p=s;for(;*q=*p;q+=q==index(s,*p++));} // @hvd  - modify in place i(char*s){char*q=s,*p=s;for(;*q=*p;q+=q==strchr(s,*p++));} // @AShelly  - keep a histogram of the usage of each character h(char*s){int a[128]={0};for(;*s;s++)a[*s]++||putchar(*s);} // @hvd  - always copy to q but only increment q if not found g(char*s,char*r){char*q=r;for(;*q=*s;q+=q==strchr(r,*s++));} // original version - requires -std=c99 void f(char*s,char*r){for(char*q=r;*s;s++)if(!strchr(r,*s))*q++=*s;} 
Commonmark migration
Source Link

#C - 58

C - 58

#C - 58

C - 58

Added idea by @hvd to modify in place
Source Link
Jerry Jeremiah
  • 1.4k
  • 10
  • 10
Loading
Thanks to @hvd and @AShelly for saving four characters - amazing!; deleted 2 characters in body
Source Link
Jerry Jeremiah
  • 1.4k
  • 10
  • 10
Loading
added 93 characters in body
Source Link
Jerry Jeremiah
  • 1.4k
  • 10
  • 10
Loading
Source Link
Jerry Jeremiah
  • 1.4k
  • 10
  • 10
Loading