My FeedDiscussionsHeadless CMS
New
Sign in
Log inSign up
Learn more about Hashnode Headless CMSHashnode Headless CMS
Collaborate seamlessly with Hashnode Headless CMS for Enterprise.
Upgrade ✨Learn more

Challenge: Underhanded Hello World

Marco Alka's photo
Marco Alka
·Feb 14, 2019

For my 200th thread, a little challenge for you!

Everyone knows Hello-World programs. They are the first things we create in any new language, and sometimes even later on, to test stuff out (like the compiler chain).

fn main() {
  println!("Hello World");
}

However, here's the twist: Instead of straight printing the string, how complicated of an algorithm can you craft which does this exact same thing, while at the same time looking like it would do something very useful?

Rules

  • Program must print "Hello World"
  • The program should look like it does something useful. It should pass as valid from a glance
  • No esoteric languages allowed (it doesn't matter, what you write in Brainfuck, it's always difficult)
  • Also explain your algorithm, so the rest of us can understand what you did there.
  • If possible, embed a run-able example

Example

Here is an example in JS.

It works by encoding the hello world string using char-code deltas, which were base64-encoded and written to a function body. Additionally, I encoded the 'reduce' method name in one place, using the sum of all char-codes from the user name to offset the char-code deltas.

In order to not look suspicious, the code looks like it loads a database from a binary file, decrypts it and even implements a method to read values! Lots of fancy stuff, just to base64-decode the string. Would you have guessed that the whole code is so very pointless? 😂