Skip to main content
Nice golf
Source Link
user
  • 387
  • 2
  • 21
  • 68

Scala 3 -language:postfixOps, 940940 748 bytes

@main def m:Unit=
  val s="""@main def m:Unit=
  val s=Q%sQ
  var x=()
  def p=print("515")
 s=Q%sQ;var classx=0;class main extends annotation.Annotation{valdef dval=0;defdval=print(420);def d=printf(s.replace(""+81.toChar,(""+34.toChar)*3"\""*3),s,s)}
  return
    new main()dval
    
    x=px=0
  @main def n=
    {val s=Q%sQ
    printfs=Q%sQ;printf(s.replace(""+81.toChar,(""+34.toChar)*3"\""*3),s,s)
val p=0"""
  var x=()
  def p=print("515")
 }""";var classx=0;class main extends annotation.Annotation{valdef dval=0;defdval=print(420);def d=printf(s.replace(""+81.toChar,(""+34.toChar)*3"\""*3),s,s)}
  return
    new main()dval
    
    x=px=0
  @main def n=
    {val s="""@main def m:Unit=
  val s=Q%sQ
  var x=()
  def p=print("515")
 s=Q%sQ;var classx=0;class main extends annotation.Annotation{valdef dval=0;defdval=print(420);def d=printf(s.replace(""+81.toChar,(""+34.toChar)*3"\""*3),s,s)}
  return
    new main()dval
    
    x=px=0
  @main def n=
    {val s=Q%sQ
    printfs=Q%sQ;printf(s.replace(""+81.toChar,(""+34.toChar)*3"\""*3),s,s)
val p=0"""
    printf}""";printf(s.replace(""+81.toChar,(""+34.toChar)*3"\""*3),s,s)
val p=0}

x is 515420.

Try it online!Try it online!

Try the first x bytes online!Try the first x bytes online!

Try the last (n-x) bytes online!Try the last (n-x) bytes online!

The entire thingFirst x bytes, prettified (minimized... contains the entire program):

@main def m:Unit= Unit =
  val s="""s = """..."""
  var x=()
 x def= p=print("515")0
  class main extends annotation.Annotation{val dval=0;def d=printf(s.replace(""+81.toChar,(""+34.toChar)*3),s,s)}{
  return
  def dval new= mainprint(420)dval //The split happens between 'd' and 'v' here
    
    x=p
  @main def n=
    val s="""..."""
  d = printf(s.replace(""+81.toChar,(""+34.toChar)*3),s,s)
val p=0

First x bytes (minimized):

@main def m:Unit=
 "" val+ s="""..81."""
  var x=()
  def p=print("515")
  class main extendstoChar, annotation.Annotation{val"\"" dval=0;def* d=printf(s.replace(""+81.toChar,(""+34.toChar)*33), s, s)}
  return}
   return new main().d

Last (n-x) bytes, prettified (minimized... contains the entire program):

val
    
  x = x=p0
  @main def n=
n = {
  val s="""s = """..."""
  printf(s.replace(""+81"" + 81.toChar,(""+34.toChar)*3 "\"" * 3), s, s)
val p=0}

Scala 3 -language:postfixOps, 940 bytes

@main def m:Unit=
  val s="""@main def m:Unit=
  val s=Q%sQ
  var x=()
  def p=print("515")
  class main extends annotation.Annotation{val dval=0;def d=printf(s.replace(""+81.toChar,(""+34.toChar)*3),s,s)}
  return
    new main()dval
    
    x=p
  @main def n=
    val s=Q%sQ
    printf(s.replace(""+81.toChar,(""+34.toChar)*3),s,s)
val p=0"""
  var x=()
  def p=print("515")
  class main extends annotation.Annotation{val dval=0;def d=printf(s.replace(""+81.toChar,(""+34.toChar)*3),s,s)}
  return
    new main()dval
    
    x=p
  @main def n=
    val s="""@main def m:Unit=
  val s=Q%sQ
  var x=()
  def p=print("515")
  class main extends annotation.Annotation{val dval=0;def d=printf(s.replace(""+81.toChar,(""+34.toChar)*3),s,s)}
  return
    new main()dval
    
    x=p
  @main def n=
    val s=Q%sQ
    printf(s.replace(""+81.toChar,(""+34.toChar)*3),s,s)
val p=0"""
    printf(s.replace(""+81.toChar,(""+34.toChar)*3),s,s)
val p=0

x is 515.

Try it online!

Try the first x bytes online!

Try the last (n-x) bytes online!

The entire thing (minimized):

@main def m:Unit=
  val s="""..."""
  var x=()
  def p=print("515")
  class main extends annotation.Annotation{val dval=0;def d=printf(s.replace(""+81.toChar,(""+34.toChar)*3),s,s)}
  return
    new main()dval //The split happens between 'd' and 'v' here
    
    x=p
  @main def n=
    val s="""..."""
    printf(s.replace(""+81.toChar,(""+34.toChar)*3),s,s)
val p=0

First x bytes (minimized):

@main def m:Unit=
  val s="""..."""
  var x=()
  def p=print("515")
  class main extends annotation.Annotation{val dval=0;def d=printf(s.replace(""+81.toChar,(""+34.toChar)*3),s,s)}
  return
    new main()d

Last (n-x) bytes (minimized):

val
    
    x=p
  @main def n=
    val s="""..."""
printf(s.replace(""+81.toChar,(""+34.toChar)*3),s,s)
val p=0

Scala 3 -language:postfixOps, 940 748 bytes

@main def m:Unit=
 val s="""@main def m:Unit=
 val s=Q%sQ;var x=0;class main extends annotation.Annotation{def dval=print(420);def d=printf(s.replace(""+81.toChar,"\""*3),s,s)}
 return
  new main()dval

 x=0
 @main def n={val s=Q%sQ;printf(s.replace(""+81.toChar,"\""*3),s,s)}""";var x=0;class main extends annotation.Annotation{def dval=print(420);def d=printf(s.replace(""+81.toChar,"\""*3),s,s)}
 return
  new main()dval

 x=0
 @main def n={val s="""@main def m:Unit=
 val s=Q%sQ;var x=0;class main extends annotation.Annotation{def dval=print(420);def d=printf(s.replace(""+81.toChar,"\""*3),s,s)}
 return
  new main()dval

 x=0
 @main def n={val s=Q%sQ;printf(s.replace(""+81.toChar,"\""*3),s,s)}""";printf(s.replace(""+81.toChar,"\""*3),s,s)}

x is 420.

Try it online!

Try the first x bytes online!

Try the last (n-x) bytes online!

First x bytes, prettified (... contains the entire program):

@main def m: Unit =
  val s = """..."""
  var x = 0
  class main extends annotation.Annotation {
    def dval = print(420)
    def d = printf(s.replace("" + 81.toChar, "\"" * 3), s, s)
  }
  return new main().d

Last (n-x) bytes, prettified (... contains the entire program):

val x = 0
@main def n = {
  val s = """..."""
  printf(s.replace("" + 81.toChar, "\"" * 3), s, s)
}
Golfed a bit because I was stupid before
Source Link
user
  • 387
  • 2
  • 21
  • 68

The entire thing (minimized):

@main def m:Unit=
  val s="""..."""
  var x=()
  def p=print("515")
  class main extends annotation.Annotation{val dval=0;def d=printf(s.replace(""+81.toChar,(""+34.toChar)*3),s,s)}
  return
    new main()dval //The split happens between 'd' and 'v' here
    
    x=p
  @main def n=
    val s="""..."""
    printf(s.replace(""+81.toChar,(""+34.toChar)*3),s,s)
val p=0

First x bytes (minimized):

First x bytes (minimized):

The entire thing (minimized):

@main def m:Unit=
  val s="""..."""
  var x=()
  def p=print("515")
  class main extends annotation.Annotation{val dval=0;def d=printf(s.replace(""+81.toChar,(""+34.toChar)*3),s,s)}
  return
    new main()dval //The split happens between 'd' and 'v' here
    
    x=p
  @main def n=
    val s="""..."""
    printf(s.replace(""+81.toChar,(""+34.toChar)*3),s,s)
val p=0

First x bytes (minimized):

Golfed a bit because I was stupid before
Source Link
user
  • 387
  • 2
  • 21
  • 68

Scala 3 -language:postfixOps, 1099940 bytes

@main def m:Unit=
  val s="""@main def m:Unit=
  val s=Q%sQ
  var x=()
  valdef Console=scala.Consolep=print("515")
  class main extends annotation.Annotation{val dval=0;def d=printf(s.replace(""+81.toChar,(""+34.toChar)*3),s,s)}
  return
    new main()dval
    
    x=Console.print("574")x=p
  @main def n=
    val s=Q%sQ
    printf(s.replace(""+81.toChar,(""+34.toChar)*3),s,s)
object Console{defval print(x:Any)=x}"""p=0"""
  var x=()
  valdef Console=scala.Consolep=print("515")
  class main extends annotation.Annotation{val dval=0;def d=printf(s.replace(""+81.toChar,(""+34.toChar)*3),s,s)}
  return
    new main()dval
    
    x=Console.print("574")x=p
  @main def n=
    val s="""@main def m:Unit=
  val s=Q%sQ
  var x=()
  valdef Console=scala.Consolep=print("515")
  class main extends annotation.Annotation{val dval=0;def d=printf(s.replace(""+81.toChar,(""+34.toChar)*3),s,s)}
  return
    new main()dval
    
    x=Console.print("574")x=p
  @main def n=
    val s=Q%sQ
    printf(s.replace(""+81.toChar,(""+34.toChar)*3),s,s)
object Console{defval print(x:Any)=x}"""p=0"""
    printf(s.replace(""+81.toChar,(""+34.toChar)*3),s,s)
object Console{defval print(x:Any)=x}p=0

x is 574515.

Try it online!Try it online!

Try the last n-x bytes online!Try the first x bytes online!

Try the first x bytes online!Try the last (n-x) bytes online!

@main def m:Unit=
  val s="""..."""
  var x=()
  valdef Console=scala.Consolep=print("515")
  class main extends annotation.Annotation{val dval=0;def d=printf(s.replace(""+81.toChar,(""+34.toChar)*3),s,s)}
  return
    new main()d
val
    
    x=Console.print("574")x=p
  @main def n=
    val s="""..."""
    printf(s.replace(""+81.toChar,(""+34.toChar)*3),s,s)
object Console{defval print(x:Any)=x}p=0

Scala 3 -language:postfixOps, 1099 bytes

@main def m:Unit=
  val s="""@main def m:Unit=
  val s=Q%sQ
  var x=()
  val Console=scala.Console
  class main extends annotation.Annotation{val dval=0;def d=printf(s.replace(""+81.toChar,(""+34.toChar)*3),s,s)}
  return
    new main()dval
    
    x=Console.print("574")
  @main def n=
    val s=Q%sQ
    printf(s.replace(""+81.toChar,(""+34.toChar)*3),s,s)
object Console{def print(x:Any)=x}"""
  var x=()
  val Console=scala.Console
  class main extends annotation.Annotation{val dval=0;def d=printf(s.replace(""+81.toChar,(""+34.toChar)*3),s,s)}
  return
    new main()dval
    
    x=Console.print("574")
  @main def n=
    val s="""@main def m:Unit=
  val s=Q%sQ
  var x=()
  val Console=scala.Console
  class main extends annotation.Annotation{val dval=0;def d=printf(s.replace(""+81.toChar,(""+34.toChar)*3),s,s)}
  return
    new main()dval
    
    x=Console.print("574")
  @main def n=
    val s=Q%sQ
    printf(s.replace(""+81.toChar,(""+34.toChar)*3),s,s)
object Console{def print(x:Any)=x}"""
    printf(s.replace(""+81.toChar,(""+34.toChar)*3),s,s)
object Console{def print(x:Any)=x}

x is 574.

Try it online!

Try the last n-x bytes online!

Try the first x bytes online!

@main def m:Unit=
  val s="""..."""
  var x=()
  val Console=scala.Console
  class main extends annotation.Annotation{val dval=0;def d=printf(s.replace(""+81.toChar,(""+34.toChar)*3),s,s)}
  return
    new main()d
val
    
    x=Console.print("574")
  @main def n=
    val s="""..."""
    printf(s.replace(""+81.toChar,(""+34.toChar)*3),s,s)
object Console{def print(x:Any)=x}

Scala 3 -language:postfixOps, 940 bytes

@main def m:Unit=
  val s="""@main def m:Unit=
  val s=Q%sQ
  var x=()
  def p=print("515")
  class main extends annotation.Annotation{val dval=0;def d=printf(s.replace(""+81.toChar,(""+34.toChar)*3),s,s)}
  return
    new main()dval
    
    x=p
  @main def n=
    val s=Q%sQ
    printf(s.replace(""+81.toChar,(""+34.toChar)*3),s,s)
val p=0"""
  var x=()
  def p=print("515")
  class main extends annotation.Annotation{val dval=0;def d=printf(s.replace(""+81.toChar,(""+34.toChar)*3),s,s)}
  return
    new main()dval
    
    x=p
  @main def n=
    val s="""@main def m:Unit=
  val s=Q%sQ
  var x=()
  def p=print("515")
  class main extends annotation.Annotation{val dval=0;def d=printf(s.replace(""+81.toChar,(""+34.toChar)*3),s,s)}
  return
    new main()dval
    
    x=p
  @main def n=
    val s=Q%sQ
    printf(s.replace(""+81.toChar,(""+34.toChar)*3),s,s)
val p=0"""
    printf(s.replace(""+81.toChar,(""+34.toChar)*3),s,s)
val p=0

x is 515.

Try it online!

Try the first x bytes online!

Try the last (n-x) bytes online!

@main def m:Unit=
  val s="""..."""
  var x=()
  def p=print("515")
  class main extends annotation.Annotation{val dval=0;def d=printf(s.replace(""+81.toChar,(""+34.toChar)*3),s,s)}
  return
    new main()d
val
    
    x=p
  @main def n=
    val s="""..."""
printf(s.replace(""+81.toChar,(""+34.toChar)*3),s,s)
val p=0
Source Link
user
  • 387
  • 2
  • 21
  • 68
Loading