Skip to main content
Code shortening
Source Link
ErikF
  • 4.8k
  • 9
  • 11

C (gcc), 118 111109 bytes

The input can contain jagged lines: newlines are printed if they exist in the y-range.

Thanks to ceilingcat for the suggestion.

f(s,x,y,w,h,a,b,c)char*s;{for(b=1,a=0;*s;c&&(a=0,a=0;*s;a=c?!b++):a,s++)((c=*s==10)|++a>=x&a-x<w)&b>=y&b-y<h-c&&putchar(*s);} 

Try it online!Try it online!

C (gcc), 118 111 bytes

The input can contain jagged lines: newlines are printed if they exist in the y-range.

f(s,x,y,w,h,a,b,c)char*s;{for(b=1,a=0;*s;c&&(a=0,b++),s++)((c=*s==10)|++a>=x&a-x<w)&b>=y&b-y<h-c&&putchar(*s);} 

Try it online!

C (gcc), 118 109 bytes

The input can contain jagged lines: newlines are printed if they exist in the y-range.

Thanks to ceilingcat for the suggestion.

f(s,x,y,w,h,a,b,c)char*s;{for(b=1,a=0;*s;a=c?!b++:a,s++)((c=*s==10)|++a>=x&a-x<w)&b>=y&b-y<h-c&&putchar(*s);} 

Try it online!

Code shortening
Source Link
ErikF
  • 4.8k
  • 9
  • 11

C (gcc), 118 115111 bytes

The input can contain jagged lines: newlines are printed if they exist in the y-range.

f(s,x,y,w,h,a,b,c)char*s;{for(b=1,a=0;*s;c&&(a=0,b++),s++)((c=*s==10)||++a>=x&&a|++a>=x&a-x<w)&&b>=y&&b&b>=y&b-y<h-c&&putchar(*s);} 

Try it online!Try it online!

C (gcc), 118 115 bytes

The input can contain jagged lines: newlines are printed if they exist in the y-range.

f(s,x,y,w,h,a,b,c)char*s;{for(b=1,a=0;*s;c&&(a=0,b++),s++)((c=*s==10)||++a>=x&&a-x<w)&&b>=y&&b-y<h-c&&putchar(*s);} 

Try it online!

C (gcc), 118 111 bytes

The input can contain jagged lines: newlines are printed if they exist in the y-range.

f(s,x,y,w,h,a,b,c)char*s;{for(b=1,a=0;*s;c&&(a=0,b++),s++)((c=*s==10)|++a>=x&a-x<w)&b>=y&b-y<h-c&&putchar(*s);} 

Try it online!

Code shortening
Source Link
ErikF
  • 4.8k
  • 9
  • 11

C (gcc), 117118 115 bytes

The input can contain jagged lines: newlines are printed if they exist in the y-range.

f(s,x,y,w,h,a,b,c)char*s;{for(b=1,a=0;*s;c&&(a=0,b++),s++)if(((c=*s==10)||++a>=x&&a-x<w)&&b>=y&&b-y<h-c)putcharc&&putchar(*s);} 

Try it online!Try it online!

C (gcc), 117 bytes

The input can contain jagged lines: newlines are printed if they exist in the y-range.

f(s,x,y,w,h,a,b,c)char*s;{for(b=1,a=0;*s;c&&(a=0,b++),s++)if(((c=*s==10)||++a>=x&&a-x<w)&&b>=y&&b-y<h-c)putchar(*s);} 

Try it online!

C (gcc), 118 115 bytes

The input can contain jagged lines: newlines are printed if they exist in the y-range.

f(s,x,y,w,h,a,b,c)char*s;{for(b=1,a=0;*s;c&&(a=0,b++),s++)((c=*s==10)||++a>=x&&a-x<w)&&b>=y&&b-y<h-c&&putchar(*s);} 

Try it online!

Code shortening
Source Link
ErikF
  • 4.8k
  • 9
  • 11
Loading
Source Link
ErikF
  • 4.8k
  • 9
  • 11
Loading