Skip to main content
Commonmark migration
Source Link

#Java 10, 88 bytes

Java 10, 88 bytes

C->S->{var r=new int[C][C];for(;S>0;)for(int s=S--;s-->0;)r[S][s]=r[s][S]=S+1;return r;}

Try it online.

Explanation:

C->S->{                     // Method with two int parameters and int-matrix return-type
  var r=new int[C][C];      //  Result-matrix of size `C` by `C`
  for(;S>0;)                //  Loop as long as `S` is not 0 yet:
    for(int s=S--;s-->0;)   //   Inner loop `s` in the range (`S`, 0]
                            //   (and decrease `S` by 1 in the process with `S--`)
      r[S][s]=r[s][S]=S+1;  //    Set the values at both {`S`,`s`} and {`s`,`S`} to `S+1`
  return r;}                //  Return the result

#Java 10, 88 bytes

C->S->{var r=new int[C][C];for(;S>0;)for(int s=S--;s-->0;)r[S][s]=r[s][S]=S+1;return r;}

Try it online.

Explanation:

C->S->{                     // Method with two int parameters and int-matrix return-type
  var r=new int[C][C];      //  Result-matrix of size `C` by `C`
  for(;S>0;)                //  Loop as long as `S` is not 0 yet:
    for(int s=S--;s-->0;)   //   Inner loop `s` in the range (`S`, 0]
                            //   (and decrease `S` by 1 in the process with `S--`)
      r[S][s]=r[s][S]=S+1;  //    Set the values at both {`S`,`s`} and {`s`,`S`} to `S+1`
  return r;}                //  Return the result

Java 10, 88 bytes

C->S->{var r=new int[C][C];for(;S>0;)for(int s=S--;s-->0;)r[S][s]=r[s][S]=S+1;return r;}

Try it online.

Explanation:

C->S->{                     // Method with two int parameters and int-matrix return-type
  var r=new int[C][C];      //  Result-matrix of size `C` by `C`
  for(;S>0;)                //  Loop as long as `S` is not 0 yet:
    for(int s=S--;s-->0;)   //   Inner loop `s` in the range (`S`, 0]
                            //   (and decrease `S` by 1 in the process with `S--`)
      r[S][s]=r[s][S]=S+1;  //    Set the values at both {`S`,`s`} and {`s`,`S`} to `S+1`
  return r;}                //  Return the result
added 20 characters in body
Source Link
Kevin Cruijssen
  • 131.4k
  • 13
  • 144
  • 384

#Java 10, 88 bytes

C->S->{var r=new int[C][C];for(;S>0;)for(int s=S--;s-->0;)r[S][s]=r[s][S]=S+1;return r;}

Try it online.Try it online.

Explanation:

C->S->{                     // Method with two int parameters and int-matrix return-type
  var r=new int[C][C];      //  Result-matrix of size `C` by `C`
  for(;S>0;)                //  Loop as long as `S` is not 0 yet:
    for(int s=S--;s-->0;)   //   Inner loop `s` in the range (`S`, 0]
                            //   (and decrease `S` by 1 in the process with `S--`)
      r[S][s]=r[s][S]=S+1;  //    Set the values at both {`S`,`s`} and {`s`,`S`} to `S+1`
  return r;}                //  Return the result

#Java 10, 88 bytes

C->S->{var r=new int[C][C];for(;S>0;)for(int s=S--;s-->0;)r[S][s]=r[s][S]=S+1;return r;}

Try it online.

Explanation:

C->S->{                     // Method with two int parameters and int-matrix return-type
  var r=new int[C][C];      //  Result-matrix of size `C` by `C`
  for(;S>0;)                //  Loop as long as `S` is not 0 yet:
    for(int s=S--;s-->0;)   //   Inner loop `s` in the range (`S`, 0]
                            //   (and decrease `S` by 1 in the process with `S--`)
      r[S][s]=r[s][S]=S+1;  //    Set the values at both {`S`,`s`} and {`s`,`S`} to `S+1`
  return r;}                //  Return the result

#Java 10, 88 bytes

C->S->{var r=new int[C][C];for(;S>0;)for(int s=S--;s-->0;)r[S][s]=r[s][S]=S+1;return r;}

Try it online.

Explanation:

C->S->{                     // Method with two int parameters and int-matrix return-type
  var r=new int[C][C];      //  Result-matrix of size `C` by `C`
  for(;S>0;)                //  Loop as long as `S` is not 0 yet:
    for(int s=S--;s-->0;)   //   Inner loop `s` in the range (`S`, 0]
                            //   (and decrease `S` by 1 in the process with `S--`)
      r[S][s]=r[s][S]=S+1;  //    Set the values at both {`S`,`s`} and {`s`,`S`} to `S+1`
  return r;}                //  Return the result
Source Link
Kevin Cruijssen
  • 131.4k
  • 13
  • 144
  • 384

#Java 10, 88 bytes

C->S->{var r=new int[C][C];for(;S>0;)for(int s=S--;s-->0;)r[S][s]=r[s][S]=S+1;return r;}

Try it online.

Explanation:

C->S->{                     // Method with two int parameters and int-matrix return-type
  var r=new int[C][C];      //  Result-matrix of size `C` by `C`
  for(;S>0;)                //  Loop as long as `S` is not 0 yet:
    for(int s=S--;s-->0;)   //   Inner loop `s` in the range (`S`, 0]
                            //   (and decrease `S` by 1 in the process with `S--`)
      r[S][s]=r[s][S]=S+1;  //    Set the values at both {`S`,`s`} and {`s`,`S`} to `S+1`
  return r;}                //  Return the result