3
\$\begingroup\$

Print the following text and nothing else:

<html>
  <body>

    <p>HTML is kinda annoying</p>

  </body>
</html>
I'm happy I'm not a web developer.

The catch? Your code must fit the template: print(<?>), where ? can be any group of characters. You can paste your completed code (with the print(<>) part) into this Scastie to test it. When posting an answer, please mark it as a spoiler.

Here is the sbt configuration:

scalaVersion := "2.13.6"
addCompilerPlugin("org.typelevel" %% "kind-projector" % "0.13.0" cross CrossVersion.full)

scalacOptions ++= Seq(
  "-language:higherKinds",
  "-Ydelambdafy:inline",
  "-deprecation",
  "-encoding", "UTF-8",
  "-feature",
  "-unchecked",
  "-language:postfixOps"
)
libraryDependencies ++= Seq(
  "org.scala-lang.modules" %% "scala-xml" % "2.0.0",
  "org.scastie" %% "runtime-scala" % "1.0.0-SNAPSHOT"
)

Beware, while the configuration provides one hint, some of these are red herrings.

This is the md5 hash of my solution: 5aa91599e4a8e194b5097b36bdb3dabf. N.B. it looks like the hash didn't work well with newlines and certain other characters - it may have skipped over them entirely.

Hints:

Types are involved near the end, at least in the solution I had. > is a single token that isn't part of the XML, and it's not a method or field.

hyper-neutrino and pxeger found answers, but they use workarounds that I didn't intend to be used and should have thought of while writing the question. I'll award a 500 rep bounty to another answer, provided they meet certain criteria. This is the solution.

\$\endgroup\$
9
  • \$\begingroup\$ So the challenge is essentially try to guess what your solution is? \$\endgroup\$
    – Luis Mendo
    Jun 18, 2021 at 16:01
  • \$\begingroup\$ @LuisMendo No, other solutions are okay too (preferred, really). The one with comments was just a really trivial one (that I should have disallowed). \$\endgroup\$
    – user
    Jun 18, 2021 at 16:02
  • 1
    \$\begingroup\$ May I ask what the downvotes are for? Is the question not well-specified or interesting enough? \$\endgroup\$
    – user
    Jun 18, 2021 at 18:32
  • 7
    \$\begingroup\$ I downvoted because I find challenge uninteresting, and I don't think it adds anything to the site. As I see it, it's just "try to guess the solution I wrote for this problem". It is not possible to assess the quality of an answer by objective, known-in-advance criteria. Note that other challenges with the programming-puzzle tag usually include those criteria. \$\endgroup\$
    – Luis Mendo
    Jun 18, 2021 at 20:18
  • \$\begingroup\$ @LuisMendo ¯\_(ツ)_/¯ I can't do much about the challenge seeming uninteresting to people, and I couldn't find any tie-breaker criteria that worked ([code-golf], [fastest-code], etc. don't make much sense here). \$\endgroup\$
    – user
    Jun 18, 2021 at 20:47

2 Answers 2

7
\$\begingroup\$

print(<html>
   <body>

     <p>HTML is kinda annoying</p>

   </body>
 </html>)
 print("\nI'm happy I'm not a web developer.")
 //>)

Probably not intended :)

\$\endgroup\$
1
  • 1
    \$\begingroup\$ This is infuriating. +1 >(. If another answer with my intended solution doesn't pop up in a month or so, I'll accept this, but right now, I'm too angry to do so. \$\endgroup\$
    – user
    Jun 18, 2021 at 15:15
5
+500
\$\begingroup\$

print(<html>
   <body>

     <p>HTML is kinda annoying</p>

   </body>
 </html> + "\nI'm happy I'm not a web developer.")
 def x = (<x />)
Try it on Scastie!

\$\endgroup\$
1
  • \$\begingroup\$ Still not my intended solution, but nice find :P (I'll start a bounty in two days) \$\endgroup\$
    – user
    Jun 18, 2021 at 17:51

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.