Skip to main content
We’ve updated our Terms of Service. A new AI Addendum clarifies how Stack Overflow utilizes AI interactions.
Code Golf

Return to Answer

Commonmark migration
Source Link

#Java 10, (削除) 283 (削除ここまで)(削除) 279 (削除ここまで)(削除) 277 (削除ここまで) 257 bytes

Java 10, (削除) 283 (削除ここまで)(削除) 279 (削除ここまで)(削除) 277 (削除ここまで) 257 bytes

#Java 10, (削除) 283 (削除ここまで)(削除) 279 (削除ここまで)(削除) 277 (削除ここまで) 257 bytes

Java 10, (削除) 283 (削除ここまで)(削除) 279 (削除ここまで)(削除) 277 (削除ここまで) 257 bytes

deleted 25 characters in body
Source Link
Kevin Cruijssen
  • 136.2k
  • 14
  • 154
  • 394

#Java 10, (削除) 283 (削除ここまで) (削除) 279 (削除ここまで) 277(削除) 277 (削除ここまで) 257 bytes

-20 bytes thanks to @nwellnhof's tip of using Math.hypot .

The result-array is in the order [R,X,Y].

Try it online. Try it online.

C->{ // Method with 2D int-array as parameter & int-array as return-type
 int M=1<<31, // Minimum `M`, starting at -2,147,483,648
 m=M, // Temp integer, start itstarting at -2,147,483,648 as well
 X=M, // Largest X coordinate, starting at -2,147,483,648 as well
 Y=M, // Largest Y coordinate, starting at -2,147,483,648 as well
 x=M-1, // Smallest X coordinate, starting at 2,147,483,647
 y=x, // Smallest Y coordinate, starting at 2,147,483,647 as well
 t,a,b, // Temp integers, starting uninitialized
 r[]={x}; // Result-array, starting at one 2,147,483,647
 for(var c:C){ // Loop over the input-coordinates
 x=(t=c[0])<x?t:x; // If the X coordinate is smaller than `x`, change it
 X=t>X?t:X; // If the X coordinate is larger than `X`, change it
 y=(t=c[1])<y?t:y; // If the Y coordinate is smaller than `y`, change it
 Y=t>Y?t:Y;} // If the Y coordinate is larger than `Y`, change it
 for(;y<=Y;y++) // Loop `y` in the range [`y`,`Y`]:
 for(t=x;t<=X // Inner loop `t` in the range [`x`,`X`]:
 ; // After every iteration:
 r=m<r[0]? // If `m` is smaller than the first value:
 new int[]{m,t,y}
 // Replace the result with `m,t,y`
 : // Else:
 r, // Leave `r` unchanged
 m=M, // Reset `m` to -2,147,483,648 for the next iteration
 t++) // And increase `t` by 1
 for(var c:C){ // Inner loop over the input-coordinates
 a=c[0]-t; // Set `a` to the X coordinate minus `t`
 b=c[1]-y; // Set `b` to the Y coordinate minus `y`
 a*=a; // Take the square of `a`
  m=(a=(int)Math.ceil(Math.sqrthypot(a+=b*=bc[0]-t,c[1]-y)))
 // Take theSubtract square`t` offrom `b`the asX well;coordinate;
 // thensubtract add`y` `a`from andthe `b`Y together;coordinate;
 // take the squarehypot (<-root sqrt(x*x+y*y)) of itthose
 // ceil it
 // And set `a` to this value
 >m? // If `a` is larger than `m`:
 a // Set `m` to `a`
 : // Else:
 m;} // Leave `m` unchanged
 return r;} // Return the result `r`

#Java 10, (削除) 283 (削除ここまで) (削除) 279 (削除ここまで) 277 bytes

The result-array is in the order [R,X,Y].

Try it online.

C->{ // Method with 2D int-array as parameter & int-array as return-type
 int M=1<<31, // Minimum `M`, starting at -2,147,483,648
 m=M, // Temp integer, start it at -2,147,483,648 as well
 X=M, // Largest X coordinate, starting at -2,147,483,648 as well
 Y=M, // Largest Y coordinate, starting at -2,147,483,648 as well
 x=M-1, // Smallest X coordinate, starting at 2,147,483,647
 y=x, // Smallest Y coordinate, starting at 2,147,483,647 as well
 t,a,b, // Temp integers, starting uninitialized
 r[]={x}; // Result-array, starting at one 2,147,483,647
 for(var c:C){ // Loop over the input-coordinates
 x=(t=c[0])<x?t:x; // If the X coordinate is smaller than `x`, change it
 X=t>X?t:X; // If the X coordinate is larger than `X`, change it
 y=(t=c[1])<y?t:y; // If the Y coordinate is smaller than `y`, change it
 Y=t>Y?t:Y;} // If the Y coordinate is larger than `Y`, change it
 for(;y<=Y;y++) // Loop `y` in the range [`y`,`Y`]:
 for(t=x;t<=X // Inner loop `t` in the range [`x`,`X`]:
 ; // After every iteration:
 r=m<r[0]? // If `m` is smaller than the first value:
 new int[]{m,t,y}
 // Replace the result with `m,t,y`
 : // Else:
 r, // Leave `r` unchanged
 m=M, // Reset `m` to -2,147,483,648 for the next iteration
 t++) // And increase `t` by 1
 for(var c:C){ // Inner loop over the input-coordinates
 a=c[0]-t; // Set `a` to the X coordinate minus `t`
 b=c[1]-y; // Set `b` to the Y coordinate minus `y`
 a*=a; // Take the square of `a`
  m=(a=(int)Math.ceil(Math.sqrt(a+=b*=b)))
 // Take the square of `b` as well;
 // then add `a` and `b` together;
 // take the square-root of it
 // ceil it
 // And set `a` to this value
 >m? // If `a` is larger than `m`:
 a // Set `m` to `a`
 : // Else:
 m;} // Leave `m` unchanged
 return r;} // Return the result `r`

#Java 10, (削除) 283 (削除ここまで) (削除) 279 (削除ここまで) (削除) 277 (削除ここまで) 257 bytes

-20 bytes thanks to @nwellnhof's tip of using Math.hypot .

The result-array is in the order [R,X,Y].

Try it online.

C->{ // Method with 2D int-array as parameter & int-array as return-type
 int M=1<<31, // Minimum `M`, starting at -2,147,483,648
 m=M, // Temp integer, starting at -2,147,483,648 as well
 X=M, // Largest X coordinate, starting at -2,147,483,648 as well
 Y=M, // Largest Y coordinate, starting at -2,147,483,648 as well
 x=M-1, // Smallest X coordinate, starting at 2,147,483,647
 y=x, // Smallest Y coordinate, starting at 2,147,483,647 as well
 t,a, // Temp integers, starting uninitialized
 r[]={x}; // Result-array, starting at one 2,147,483,647
 for(var c:C){ // Loop over the input-coordinates
 x=(t=c[0])<x?t:x; // If the X coordinate is smaller than `x`, change it
 X=t>X?t:X; // If the X coordinate is larger than `X`, change it
 y=(t=c[1])<y?t:y; // If the Y coordinate is smaller than `y`, change it
 Y=t>Y?t:Y;} // If the Y coordinate is larger than `Y`, change it
 for(;y<=Y;y++) // Loop `y` in the range [`y`,`Y`]:
 for(t=x;t<=X // Inner loop `t` in the range [`x`,`X`]:
 ; // After every iteration:
 r=m<r[0]? // If `m` is smaller than the first value:
 new int[]{m,t,y}
 // Replace the result with `m,t,y`
 : // Else:
 r, // Leave `r` unchanged
 m=M, // Reset `m` to -2,147,483,648 for the next iteration
 t++) // And increase `t` by 1
 for(var c:C) // Inner loop over the input-coordinates
 m=(a=(int)Math.ceil(Math.hypot(c[0]-t,c[1]-y)))
 // Subtract `t` from the X coordinate;
 // subtract `y` from the Y coordinate;
 // take the hypot (<- sqrt(x*x+y*y)) of those
 // ceil it
 // And set `a` to this value
 >m? // If `a` is larger than `m`:
 a // Set `m` to `a`
 : // Else:
 m; // Leave `m` unchanged
 return r;} // Return the result `r`
added 52 characters in body
Source Link
Kevin Cruijssen
  • 136.2k
  • 14
  • 154
  • 394

#Java 10, (削除) 283 (削除ここまで) 279(削除) 279 (削除ここまで) 277 bytes

C->{int M=1<<31,m=M,X=M,Y=M,x=M-1,y=x,t,a,b,m,r[]={x};for(var c:C){x=(t=c[0])<x?t:x;X=t>X?t:X;y=(t=c[1])<y?t:y;Y=t>Y?t:Y;}for(;y<=Y;y++)for(m=M,t=x;t<=X;r=m<r[0]?new int[]{m,t,y}:r,m=M,t++)for(var c:C){a=c[0]-t;b=c[1]-y;a*=a;m=(a=(int)Math.ceil(Math.sqrt(a+=b*=b)))>m?a:m;}return r;}

Try it online. Try it online.

C->{ // Method with 2D int-array as parameter & int-array as return-type
 int M=1<<31, // Minimum `M`, starting at -2,147,483,648
  m=M, // Temp integer, start it at -2,147,483,648 as well
 X=M, // Largest X coordinate, starting at -2,147,483,648 as well
 Y=M, // Largest Y coordinate, starting at -2,147,483,648 as well
 x=M-1, // Smallest X coordinate, starting at 2,147,483,647
 y=x, // Smallest Y coordinate, starting at 2,147,483,647 as well
 t,a,b,m, // Temp integers, starting uninitialized
 r[]={x}; // Result-array, starting at one 2,147,483,647
 for(var c:C){ // Loop over the input-coordinates
 x=(t=c[0])<x?t:x; // If the X coordinate is smaller than `x`, change it
 X=t>X?t:X; // If the X coordinate is larger than `X`, change it
 y=(t=c[1])<y?t:y; // If the Y coordinate is smaller than `y`, change it
 Y=t>Y?t:Y;} // If the Y coordinate is larger than `Y`, change it
 for(;y<=Y;y++) // Loop `y` in the range [`y`,`Y`]:
 for(m=M, // Reset `m` to -2,147,483,648
 t=x;t<=X // Inner loop `t` in the range [`x`,`X`]:
 ; ; // After every iteration:
 r=m<r[0]? r=m<r[0]? // If `m` is smaller than the first value:
 new int[]{m,t,y}
 // Replace the result with `m,t,y`
 : : // Else:
 r, r, // Leave `r` unchanged
 m=M, m=M, // Reset `m` to -2,147,483,648 for the next iteration
 t++) t++) // And increase `t` by 1
 for(var c:C){ // Inner loop over the input-coordinates
 a=c[0]-t; // Set `a` to the X coordinate minus `t`
 b=c[1]-y; // Set `b` to the Y coordinate minus `y`
 a*=a; // Take the square of `a`
 m=(a=(int)Math.ceil(Math.sqrt(a+=b*=b)))
 // Take the square of `b` as well;
 // then add `a` and `b` together;
 // take the square-root of it
 // ceil it
 // And set `a` to this value
 >m? // If `a` is larger than `m`:
 a // Set `m` to `a`
 : // Else:
 m;} // Leave `m` unchanged
 return r;} // Return the result `r`

#Java 10, (削除) 283 (削除ここまで) 279 bytes

C->{int M=1<<31,X=M,Y=M,x=M-1,y=x,t,a,b,m,r[]={x};for(var c:C){x=(t=c[0])<x?t:x;X=t>X?t:X;y=(t=c[1])<y?t:y;Y=t>Y?t:Y;}for(;y<=Y;y++)for(m=M,t=x;t<=X;r=m<r[0]?new int[]{m,t,y}:r,m=M,t++)for(var c:C){a=c[0]-t;b=c[1]-y;a*=a;m=(a=(int)Math.ceil(Math.sqrt(a+=b*=b)))>m?a:m;}return r;}

Try it online.

C->{ // Method with 2D int-array as parameter & int-array as return-type
 int M=1<<31, // Minimum `M`, starting at -2,147,483,648
 X=M, // Largest X coordinate, starting at -2,147,483,648 as well
 Y=M, // Largest Y coordinate, starting at -2,147,483,648 as well
 x=M-1, // Smallest X coordinate, starting at 2,147,483,647
 y=x, // Smallest Y coordinate, starting at 2,147,483,647 as well
 t,a,b,m, // Temp integers
 r[]={x}; // Result-array, starting at one 2,147,483,647
 for(var c:C){ // Loop over the input-coordinates
 x=(t=c[0])<x?t:x; // If the X coordinate is smaller than `x`, change it
 X=t>X?t:X; // If the X coordinate is larger than `X`, change it
 y=(t=c[1])<y?t:y; // If the Y coordinate is smaller than `y`, change it
 Y=t>Y?t:Y;} // If the Y coordinate is larger than `Y`, change it
 for(;y<=Y;y++) // Loop `y` in the range [`y`,`Y`]:
 for(m=M, // Reset `m` to -2,147,483,648
 t=x;t<=X // Inner loop `t` in the range [`x`,`X`]:
 ; // After every iteration:
 r=m<r[0]? // If `m` is smaller than the first value:
 new int[]{m,t,y}
 // Replace the result with `m,t,y`
 : // Else:
 r, // Leave `r` unchanged
 m=M, // Reset `m` to -2,147,483,648 for the next iteration
 t++) // And increase `t` by 1
 for(var c:C){ // Inner loop over the input-coordinates
 a=c[0]-t; // Set `a` to the X coordinate minus `t`
 b=c[1]-y; // Set `b` to the Y coordinate minus `y`
 a*=a; // Take the square of `a`
 m=(a=(int)Math.ceil(Math.sqrt(a+=b*=b)))
 // Take the square of `b` as well;
 // then add `a` and `b` together;
 // take the square-root of it
 // ceil it
 // And set `a` to this value
 >m? // If `a` is larger than `m`:
 a // Set `m` to `a`
 : // Else:
 m;} // Leave `m` unchanged
 return r;} // Return the result `r`

#Java 10, (削除) 283 (削除ここまで) (削除) 279 (削除ここまで) 277 bytes

C->{int M=1<<31,m=M,X=M,Y=M,x=M-1,y=x,t,a,b,r[]={x};for(var c:C){x=(t=c[0])<x?t:x;X=t>X?t:X;y=(t=c[1])<y?t:y;Y=t>Y?t:Y;}for(;y<=Y;y++)for(t=x;t<=X;r=m<r[0]?new int[]{m,t,y}:r,m=M,t++)for(var c:C){a=c[0]-t;b=c[1]-y;a*=a;m=(a=(int)Math.ceil(Math.sqrt(a+=b*=b)))>m?a:m;}return r;}

Try it online.

C->{ // Method with 2D int-array as parameter & int-array as return-type
 int M=1<<31, // Minimum `M`, starting at -2,147,483,648
  m=M, // Temp integer, start it at -2,147,483,648 as well
 X=M, // Largest X coordinate, starting at -2,147,483,648 as well
 Y=M, // Largest Y coordinate, starting at -2,147,483,648 as well
 x=M-1, // Smallest X coordinate, starting at 2,147,483,647
 y=x, // Smallest Y coordinate, starting at 2,147,483,647 as well
 t,a,b, // Temp integers, starting uninitialized
 r[]={x}; // Result-array, starting at one 2,147,483,647
 for(var c:C){ // Loop over the input-coordinates
 x=(t=c[0])<x?t:x; // If the X coordinate is smaller than `x`, change it
 X=t>X?t:X; // If the X coordinate is larger than `X`, change it
 y=(t=c[1])<y?t:y; // If the Y coordinate is smaller than `y`, change it
 Y=t>Y?t:Y;} // If the Y coordinate is larger than `Y`, change it
 for(;y<=Y;y++) // Loop `y` in the range [`y`,`Y`]:
 for(t=x;t<=X // Inner loop `t` in the range [`x`,`X`]:
 ; // After every iteration:
 r=m<r[0]? // If `m` is smaller than the first value:
 new int[]{m,t,y}
 // Replace the result with `m,t,y`
 : // Else:
 r, // Leave `r` unchanged
 m=M, // Reset `m` to -2,147,483,648 for the next iteration
 t++) // And increase `t` by 1
 for(var c:C){ // Inner loop over the input-coordinates
 a=c[0]-t; // Set `a` to the X coordinate minus `t`
 b=c[1]-y; // Set `b` to the Y coordinate minus `y`
 a*=a; // Take the square of `a`
 m=(a=(int)Math.ceil(Math.sqrt(a+=b*=b)))
 // Take the square of `b` as well;
 // then add `a` and `b` together;
 // take the square-root of it
 // ceil it
 // And set `a` to this value
 >m? // If `a` is larger than `m`:
 a // Set `m` to `a`
 : // Else:
 m;} // Leave `m` unchanged
 return r;} // Return the result `r`
added 2430 characters in body
Source Link
Kevin Cruijssen
  • 136.2k
  • 14
  • 154
  • 394
Loading
Source Link
Kevin Cruijssen
  • 136.2k
  • 14
  • 154
  • 394
Loading

AltStyle によって変換されたページ (->オリジナル) /