Skip to main content
Commonmark migration
Source Link

#Java 10, 339 308 265 227 225 186 184 bytes

Java 10, 339 308 265 227 225 186 184 bytes

v->{var s="v->{var s=%c%s%1$c;return 0+new java.math.BigInteger(s.format(s,34,s).getBytes()).toString(2);}";return 0+new java.math.BigInteger(s.format(s,34,s).getBytes()).toString(2);}

-8 bytes thanks to @NahuelFouilleul removing the unnecessary &255 (and an additional -35 for bringing to my attention that the full program specs of the challenge had been revoked and a function is allowed now as well..)
-41 bytes thanks to @OlivierGrégoire.

Try it online.

Explanation:

-part:

  • var s contains the unformatted source code String
  • %s is used to put this String into itself with s.format(...)
  • %c, %1$c and 34 are used to format the double-quotes (")
  • s.format(s,34,s) puts it all together

Challenge part:

v->{                         //  Method with empty unused parameter and String return-type
  var s="...";               //   Unformatted source code String
  return 0+                  //   Return, with a leading "0":
   new java.math.BigInteger( //    A BigInteger of:
     s.format(s,34,s)        //     The actual source code String
      .getBytes())           //     Converted to a list of bytes (UTF-8 by default)
   .toString(2);}            //    And convert this BigInteger to a binary-String      

#Java 10, 339 308 265 227 225 186 184 bytes

v->{var s="v->{var s=%c%s%1$c;return 0+new java.math.BigInteger(s.format(s,34,s).getBytes()).toString(2);}";return 0+new java.math.BigInteger(s.format(s,34,s).getBytes()).toString(2);}

-8 bytes thanks to @NahuelFouilleul removing the unnecessary &255 (and an additional -35 for bringing to my attention that the full program specs of the challenge had been revoked and a function is allowed now as well..)
-41 bytes thanks to @OlivierGrégoire.

Try it online.

Explanation:

-part:

  • var s contains the unformatted source code String
  • %s is used to put this String into itself with s.format(...)
  • %c, %1$c and 34 are used to format the double-quotes (")
  • s.format(s,34,s) puts it all together

Challenge part:

v->{                         //  Method with empty unused parameter and String return-type
  var s="...";               //   Unformatted source code String
  return 0+                  //   Return, with a leading "0":
   new java.math.BigInteger( //    A BigInteger of:
     s.format(s,34,s)        //     The actual source code String
      .getBytes())           //     Converted to a list of bytes (UTF-8 by default)
   .toString(2);}            //    And convert this BigInteger to a binary-String      

Java 10, 339 308 265 227 225 186 184 bytes

v->{var s="v->{var s=%c%s%1$c;return 0+new java.math.BigInteger(s.format(s,34,s).getBytes()).toString(2);}";return 0+new java.math.BigInteger(s.format(s,34,s).getBytes()).toString(2);}

-8 bytes thanks to @NahuelFouilleul removing the unnecessary &255 (and an additional -35 for bringing to my attention that the full program specs of the challenge had been revoked and a function is allowed now as well..)
-41 bytes thanks to @OlivierGrégoire.

Try it online.

Explanation:

-part:

  • var s contains the unformatted source code String
  • %s is used to put this String into itself with s.format(...)
  • %c, %1$c and 34 are used to format the double-quotes (")
  • s.format(s,34,s) puts it all together

Challenge part:

v->{                         //  Method with empty unused parameter and String return-type
  var s="...";               //   Unformatted source code String
  return 0+                  //   Return, with a leading "0":
   new java.math.BigInteger( //    A BigInteger of:
     s.format(s,34,s)        //     The actual source code String
      .getBytes())           //     Converted to a list of bytes (UTF-8 by default)
   .toString(2);}            //    And convert this BigInteger to a binary-String      
deleted 41 characters in body
Source Link
Kevin Cruijssen
  • 136.3k
  • 14
  • 155
  • 394

#Java 10, 339 308 265 227 225 186 184 bytes

v->{var s="v->{var s=%c%s%1$c;ss=%c%s%1$c;return 0+new java.math.BigInteger(s.format(s,34,s).charsgetBytes().forEach(c->System.out.printf(%1$c%%08d%1$c,new Long(Long).toString(c,2))));}";s";return 0+new java.math.BigInteger(s.format(s,34,s).charsgetBytes().forEach(c->System.out.printf("%08d",new Long(Long).toString(c,2))));}

-8 bytes thanks to @NahuelFouilleul removing the unnecessary &255 (and an additional -35 for bringing to my attention that the full program specs of the challenge had been revoked and a function is allowed now as well..)
-41 bytes thanks to @OlivierGrégoire.

Try it online.

Explanation:

-part:

  • var s contains the unformatted source code String
  • %s is used to put this String into itself with s.format(...)
  • %c, %1$c and 34 are used to format the double-quotes (")
  • s.format(s,34,s) puts it all together

Challenge part:

v->{                         //  Method with empty unused parameter and String return-type
  var s="...";               //   Unformatted source code String
  return 0+                  //   Return, with a leading "0":
   new java.math.BigInteger( //    A BigInteger of:
     s.format(s,34,s)        //     The actual source code String
      .getBytes())           //     Converted to a list of bytes (UTF-8 by default)
   .toString(2);}            //    And convert this BigInteger to a binary-String      

#Java 10, 339 308 265 227 225 186 184 bytes

v->{var s="v->{var s=%c%s%1$c;s.format(s,34,s).chars().forEach(c->System.out.printf(%1$c%%08d%1$c,new Long(Long.toString(c,2))));}";s.format(s,34,s).chars().forEach(c->System.out.printf("%08d",new Long(Long.toString(c,2))));}

-8 bytes thanks to @NahuelFouilleul removing the unnecessary &255 (and an additional -35 for bringing to my attention that the full program specs of the challenge had been revoked and a function is allowed now as well..)
-41 bytes thanks to @OlivierGrégoire.

Try it online.

Explanation:

-part:

  • var s contains the unformatted source code String
  • %s is used to put this String into itself with s.format(...)
  • %c, %1$c and 34 are used to format the double-quotes (")
  • s.format(s,34,s) puts it all together

Challenge part:

v->{                         //  Method with empty unused parameter and String return-type
  var s="...";               //   Unformatted source code String
  return 0+                  //   Return, with a leading "0":
   new java.math.BigInteger( //    A BigInteger of:
     s.format(s,34,s)        //     The actual source code String
      .getBytes())           //     Converted to a list of bytes (UTF-8 by default)
   .toString(2);}            //    And convert this BigInteger to a binary-String      

#Java 10, 339 308 265 227 225 186 184 bytes

v->{var s="v->{var s=%c%s%1$c;return 0+new java.math.BigInteger(s.format(s,34,s).getBytes()).toString(2);}";return 0+new java.math.BigInteger(s.format(s,34,s).getBytes()).toString(2);}

-8 bytes thanks to @NahuelFouilleul removing the unnecessary &255 (and an additional -35 for bringing to my attention that the full program specs of the challenge had been revoked and a function is allowed now as well..)
-41 bytes thanks to @OlivierGrégoire.

Try it online.

Explanation:

-part:

  • var s contains the unformatted source code String
  • %s is used to put this String into itself with s.format(...)
  • %c, %1$c and 34 are used to format the double-quotes (")
  • s.format(s,34,s) puts it all together

Challenge part:

v->{                         //  Method with empty unused parameter and String return-type
  var s="...";               //   Unformatted source code String
  return 0+                  //   Return, with a leading "0":
   new java.math.BigInteger( //    A BigInteger of:
     s.format(s,34,s)        //     The actual source code String
      .getBytes())           //     Converted to a list of bytes (UTF-8 by default)
   .toString(2);}            //    And convert this BigInteger to a binary-String      
deleted 316 characters in body
Source Link
Kevin Cruijssen
  • 136.3k
  • 14
  • 155
  • 394

#Java 10, 339 308 265 227 225225 186 184 bytes

-8 bytes thanks to @NahuelFouilleul removing the unnecessary &255 (and an additional -35 for bringing to my attention that the full program specs of the challenge had been revoked and a function is allowed now as well..)
-241 bytes thanks to @OlivierGrégoire.

Try it online.Try it online.

  • var s contains the unformatted source code String
  • %s is used to put this String into itself with s.format(...)
  • %c, %1$c and 34 are used to format the double-quotes (")
  • %% is used to format the %
  • s.format(s,34,s) puts it all together
v->{                             //  Method with empty unused parameter and noString return-type
  var s="...";                   //   Unformatted source code String
  s.format(s,34,s)        return 0+      //   Create the actual source code String
   .chars().forEach(c->          //   Loop overReturn, itswith decimala unicodeleading values"0":
                                 //  new java.math.BigInteger(since we're only using ASCII in the program,
                                 //   this is equal toA UTF-8BigInteger bytes)of:
    System.out s.printfformat(   s,34,s)        //    Print withThe formatactual andsource withoutcode newline:String
      "%08d",         .getBytes())           //     With "0"s prependedConverted to make it size 8:
   a list of newbytes Long( UTF-8 by default)
   .toString(2);}            //    And Convertedconvert fromthis StringBigInteger to integer:
        Long.toString(c,2))));}  //     The UTF-8 byte converted toa binary-String
          

#Java 10, 339 308 265 227 225 bytes

-8 bytes thanks to @NahuelFouilleul removing the unnecessary &255 (and an additional -35 for bringing to my attention that the full program specs of the challenge had been revoked and a function is allowed now as well..)
-2 bytes thanks to @OlivierGrégoire.

Try it online.

  • var s contains the unformatted source code String
  • %s is used to put this String into itself with s.format(...)
  • %c, %1$c and 34 are used to format the double-quotes (")
  • %% is used to format the %
  • s.format(s,34,s) puts it all together
v->{                             //  Method with empty unused parameter and no return-type
  var s="...";                   //   Unformatted source code String
  s.format(s,34,s)               //   Create the actual source code String
   .chars().forEach(c->          //   Loop over its decimal unicode values:
                                 //   (since we're only using ASCII in the program,
                                 //   this is equal to UTF-8 bytes)
    System.out.printf(           //    Print with format and without newline:
      "%08d",                    //     With "0"s prepended to make it size 8:
      new Long(                  //     Converted from String to integer:
        Long.toString(c,2))));}  //     The UTF-8 byte converted to binary-String
          

#Java 10, 339 308 265 227 225 186 184 bytes

-8 bytes thanks to @NahuelFouilleul removing the unnecessary &255 (and an additional -35 for bringing to my attention that the full program specs of the challenge had been revoked and a function is allowed now as well..)
-41 bytes thanks to @OlivierGrégoire.

Try it online.

  • var s contains the unformatted source code String
  • %s is used to put this String into itself with s.format(...)
  • %c, %1$c and 34 are used to format the double-quotes (")
  • s.format(s,34,s) puts it all together
v->{                         //  Method with empty unused parameter and String return-type
  var s="...";               //   Unformatted source code String
  return 0+                  //   Return, with a leading "0":
   new java.math.BigInteger( //    A BigInteger of:
     s.format(s,34,s)        //     The actual source code String
      .getBytes())           //     Converted to a list of bytes (UTF-8 by default)
   .toString(2);}            //    And convert this BigInteger to a binary-String      
added 217 characters in body
Source Link
Kevin Cruijssen
  • 136.3k
  • 14
  • 155
  • 394
Loading
deleted 1 character in body
Source Link
Kevin Cruijssen
  • 136.3k
  • 14
  • 155
  • 394
Loading
added 113 characters in body
Source Link
Kevin Cruijssen
  • 136.3k
  • 14
  • 155
  • 394
Loading
deleted 36 characters in body
Source Link
Kevin Cruijssen
  • 136.3k
  • 14
  • 155
  • 394
Loading
added 996 characters in body
Source Link
Kevin Cruijssen
  • 136.3k
  • 14
  • 155
  • 394
Loading
Source Link
Kevin Cruijssen
  • 136.3k
  • 14
  • 155
  • 394
Loading