Hello World

Discussion of challenges you have already solved
Post Reply
A.Polke
Posts: 2
Joined: Tue Oct 28, 2008 10:05 am

Hello World

Post by A.Polke »

My solution

88+g1v2v2*5*+2*5*+P$0724c1014c1084c1084c1114c0444c0324c0874c1114c1144c1084c1004c!

uses a subroutine starting at position 4 expecting
1
2
3
on the stack, transforming it to
3
2
1
changing it to decimal number
123
print via P and returning to caller.

The program starts with a jump over the subroutine to the sequence printing the characters.
The first character, H, is printed this way:
0 \
7 } ASCII representation of H
2 /
4 \_ subroutine call
c /

Is there a way to make it shorter?
Mon Jun 15, 2009 8:39 am View user's profile Send private message
tails
Posts: 191
Joined: Tue Jun 10, 2008 7:51 pm
Location: Tokyo

Post by tails »

Cool code. And nice explanation.
As you go on, you'll find challenges that require making short HVM codes. Have fun! :)
User avatar
teebee
Posts: 89
Joined: Mon Nov 10, 2008 3:21 pm
Location: Germany

Re: Hello World

Post by teebee »

A.Polke wrote:Is there a way to make it shorter?
You can simply omit the trailing `!' which is not required at a program end. Moreover, you could think about avoiding the reversal of your coding or using a loop instead of linear sub routine calls. However, you will surely find some more improvements while solving the following HVM challenges.
megabreit
Posts: 141
Joined: Sat Jan 03, 2009 3:33 pm

Post by megabreit »

I'll not post my code this time... it was my first HVM program ever and, as of today, I'm not proud of it. :shock: I was simply calculating numbers and printing the corresponding ASCII... like probably most others did. Your solution is very creative!

But don't expect shorter examples here... there is (at least) one similar challenge (It's a Small World) which exactly asks to do it shorter.
Stay tuned for more HVM challenges, you're well prepared!
Post Reply