惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
The Cloudflare Blog
有赞技术团队
有赞技术团队
H
Help Net Security
V
Visual Studio Blog
F
Fortinet All Blogs
Apple Machine Learning Research
Apple Machine Learning Research
博客园 - 司徒正美
G
Google Developers Blog
Google DeepMind News
Google DeepMind News
腾讯CDC
H
Hackread – Cybersecurity News, Data Breaches, AI and More
Stack Overflow Blog
Stack Overflow Blog
I
InfoQ
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
L
LangChain Blog
N
Netflix TechBlog - Medium
罗磊的独立博客
The GitHub Blog
The GitHub Blog
云风的 BLOG
云风的 BLOG
Hugging Face - Blog
Hugging Face - Blog
A
About on SuperTechFans
aimingoo的专栏
aimingoo的专栏
Recent Announcements
Recent Announcements

dimden

Japan Spring 2026 WebTiles: It's fine to accept user-supplied code, actually Eastern Europe Trip (Oct 2025) Optimizing rendering of 100,000+ HTML nodes Custom profile CSS in OldTwitter Making Tetris in Twitter with Node.js brainfuck.js - DIMDEN The Puzzle 3 and stuff chip8js - my first emulator Hello World! - DIMDEN
Multi Line Task∞: Hello World
dimden · 2019-05-25 · via dimden

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!