Multi Line Task∞: Hello World - DIMDEN

Multi Line Task∞: Hello World

Posted on Saturday, 25th of May 2019

[CODEWARS SPOILERS]


Hi!

Last days I was playing the Codewars and completed extremely interesting puzzle called Multi Line Task∞: Hello World. In this challenge you should write the function that will return "Hello, world!". Sounds simple, right?

But here is the limitations: you can write only 1 character per line (!!!); Code should have less than 140 lines. It means your code should be like this: (Pseudocode)
f
=
(
)
=
>
{
}
(It doesn't work)

Sooo... How can we solve that?

First off, I tried to call the constructor with

[
]
[
`
t
r
i
m
`
]
[
`
c
o
n
s
t
r
u
c
t
o
r
`
]

But it returns undefined. And it's because real code looks like

[][`\nt\nr\ni\nm\n`][`\nc\no\nn\ns\nt\nr\nu\nc\nt\no\nr\n`]
And it can't find function with name like that! But then I got amazing idea. I think if you know JavaScript, you know that it has this feature:

[a,b,c] = `abc`;
And now a === "a", b === "b" and c === "c". But also you can do this:

[,a,,b,,c,] = ` a  b  c `
With this, we can easily make a lot of letters without that \n. And after that just make constructor with returns "Hello, world!".

And after slow multiline coding the result is

[
,
H
,
,
e
,
,
l
,
,
o
,
,
c
,
,
s
,
,
w
,
,
r
,
,
d
,
,
u
,
,
t
,
,
i
,
,
m
,
,
b
,
,
n
]
=
`
H
e
l
o
,

w
r
d
!
t
i
m
b
n
`
f
=
(
[
]
+
[
]
)
[
t
+
r
+
i
+
m
]
[
b
+
i
+
n
+
d
]
(
H
+
e
+
l
+
l
+
o
+
c
+
s
+
w
+
o
+
r
+
l
+
d
+
u
)
And that's 120 lines! And if you call "f" function, you'll get "Hello, world!". Goodluck!