Generate the characters of "Hello, world!" mathematically, without strings or arrays, like generating the digits of π

-2

The challenge is to come up with a mathematical way to generate each character of the exact string:

Hello, world!

(Capital letter, comma, exclamation mark.)

But you can't use any strings, arrays, or equivalents, to contain the data of the text. You must derive the characters by mathematical means.

So just a list or array of characters or ASCII codes or numbers trivially offset or inverted or shifted does not count. Nor does downloading it from an external resource or taking user input. Nor does starting with a large number which is just each ASCII codes shifted and ORed together, etc.

You can use any programming language, any mathematical functions, math libraries, etc.

The characters can of course be strings as you generate them.

Think of something like generating the digits of π.

The winner shall be the one with the most cleverness and/or elegance. The relevant weightings of cleverness and elegance are up to your peers, for the winner shall be decided by voting. (Finding a loophole in my poor problem statement shall not be regarded as clever d-:)

I think you can get the jist so don't cheat and if I should make it clearer or close some loopholes then please comment.

hippietrail

Posted 2014-01-25T20:18:16.020

Reputation: 101

Question was closed 2014-01-25T23:42:33.690

@xfix: Well why did that not show up in related or when I was looking for something similar )-: Then again there seem to be lots of strings and arrays in the previous question, so maybe mine is different enough? – hippietrail – 2014-01-25T20:42:14.247

All the answers I've check so far for the previous question don't pass my (intended) rules though it's true our question titles are very similar I think the "meat" of the questions is pretty different after all. – hippietrail – 2014-01-25T20:48:25.037

@xfix: I reworded the title to highlight that I'm looking for something like generating the digits of pi, and specifically not the packing/unpacking type of solutions submitted for the earlier question. – hippietrail – 2014-01-25T20:55:21.363

@hippietrail what makes that a programming puzzle (and not a mathematics puzzle)? And the same issues as in the question xfix linked applies, like how to encode letters etc. – FireFly – 2014-01-25T21:03:10.260

@FireFly: Would a "digits of pi" generator then also not be a programming puzzle? I endeavoured to ban entries which merely encode the letters. But if you're asking about how to encode them for output then the answer is in ASCII. – hippietrail – 2014-01-25T21:06:45.833

@hippietrail a "shortest code that generates N digits of pi" task would certainly be a programming puzzle, but your question seems to be more about finding a mathematical curiosity than the actual implementation, AFAICT (i.e., locate a sequence in the expansion of π that happens to correspond to the ASCII coding of "Hello, world!" (or parts of it)). – FireFly – 2014-01-25T21:09:17.390

Umm no I wasn't looking for "Hello, world!" within π. I'm looking for something that seems to pull the text out of nowhere due to the programmer's skill with numbers. It's about coming up with a formula or algorithm rather than the mere expressing of the algorithm in a programming language. That's just a necessary step. It would be a mathematical curiosity of course, nothing wrong with that compared to smiley faces and Olympics logos. – hippietrail – 2014-01-25T21:14:34.397

@marinus: Very nice! It still seems to be encoded in a special way in his function but it's definitely in the same vein. – hippietrail – 2014-01-25T21:58:37.350

Answers

4

HQ9+

H

If you need more mathematics, H+++++++++++++++++++++++++++++++++++++++++ should suffice.

Timtech

Posted 2014-01-25T20:18:16.020

Reputation: 12 038

The +s make it funny but the HQ9+ output doesn't match Hello, world! and is counted as trying to find a loophole outside the spirit of the question. – hippietrail – 2014-01-26T03:10:27.300

3You must use the official interpreter. – Timtech – 2014-01-26T12:58:28.190

2

Javascript

String.fromCharCode(72)+(681180).toString(36)+String.fromCharCode(44)+String.fromCharCode(32)+(54903217).toString(36)+String.fromCharCode(33)

It uses a few ASCII codes, but not for most of the text.

Remy

Posted 2014-01-25T20:18:16.020

Reputation: 183

It looks like the string is already encoded in the numeric literals, which is what I was trying to avoid, but I admit I don't fully understand it. – hippietrail – 2014-01-25T20:58:27.017

1It treats lowercase letters as digits in base 36, then converts 681180_base10 to ello_base36 and 54903217_base10 to world_base36. – Remy – 2014-01-25T21:50:37.443

Ah yes, I've been away from JS for a while and forgot about the base thing. – hippietrail – 2014-01-25T21:55:29.397

0

Brainfuck

-[------->+<]>-.-[->+++++<]>++.+++++++..+++.[->+++++<]>+.------------.--[->++++<]>-.--------.+++.------.--------.-[--->+<]>.

Timtech

Posted 2014-01-25T20:18:16.020

Reputation: 12 038

Could you include some explanation of how it works? – hippietrail – 2014-01-26T03:10:51.787

It calculates the ASCII codes of Hello, world! and outputs them. – Timtech – 2014-01-26T12:59:03.863

1Oh then I assume the calculation must be inverse hyperbolic cotangent of course. And outputs them in groups of three. – hippietrail – 2014-01-26T15:59:24.497

Yeah, just like the title says. – Timtech – 2014-01-26T18:29:53.957