strlen

Discussion of challenges you have already solved
wynksaiddestroy
Posts: 4
Joined: Thu May 07, 2009 10:27 pm

Post by wynksaiddestroy »

Code: Select all

00^<8?1+07-6-gp
:idea:
User avatar
m!nus
Posts: 202
Joined: Sat Jul 28, 2007 6:49 pm
Location: Germany

Post by m!nus »

Code: Select all

00^<4?1+1cp!
Callstack abusing makes it shorter
licstar
Posts: 1
Joined: Wed Jun 09, 2010 1:05 am

Post by licstar »

00^<0:8?1+09-6-gp
chephy
Posts: 17
Joined: Sat Oct 16, 2010 4:39 pm

Post by chephy »

Oh well, I guess the solution I found is the most stupid around – but at least, I didn't need to think very hard while writing this: 02g1+0^<6?094+-gp.

Why didn't I think of doing the increment in the »loop body« -.-
CStick
Posts: 2
Joined: Fri Oct 09, 2009 6:06 am

Post by CStick »

00^<8?1+067+-gp! :shock:
compudemon
Posts: 33
Joined: Sat Aug 13, 2011 2:13 pm

Post by compudemon »

00^<8?1+076+-gp

i like to do it straight forward
horst
Posts: 24
Joined: Fri Mar 06, 2009 11:07 am
Location: Germany

Post by horst »

Somewhat long and dirty, but works and doesn't use callstack ;)

09-2-00^1+0^<0:3^*gp
rmplpmpl
Posts: 113
Joined: Sun Oct 26, 2008 10:38 am
Location: Germany

Post by rmplpmpl »

this has been the first _real_ HVM challenge I did, and I am pretty ashamed of my code. It works but it seems I have to learn a lot more comparing it to the most approaches posted here.

Anyway, I think I'll get some good ideas from here for King Rat :)

edit my code...

Code: Select all

099*>   99*<<0:6*g99*<p!199*<+99*>01-75**g
User avatar
laz0r
Posts: 290
Joined: Thu Feb 04, 2010 4:18 pm
Location: Within the depths of Unix

Post by laz0r »

My compiler gives much shorter code when I use a recursive procedure:
219*+ g0^<0:1+$1+$025*cp
(ie. strlen[startPos] := If[memory[startPos]==0,startPos,strlen[startPos+1]])
than when I use iteration:
0749*+3*>749*+3*<<0:1+1-3?11g01-3?11g01-239*+?749*+3*<1+749*+3*> 0219*+6*-g
There is no spoon.
Tabun
Posts: 17
Joined: Wed Feb 05, 2014 12:21 pm

Post by Tabun »

00<6?1+0^2cp

Note: I think it's awesome to read all the different ways people do this -- I think it's an amazing thing that such a short program in such a terse language can create this beautiful diversity. :]
zhg
Posts: 1
Joined: Thu Sep 13, 2012 2:12 pm

my version

Post by zhg »

this is my version. no stack is used

00^<0^9?d1+097+-gdp
User avatar
Hippo
Posts: 339
Joined: Sat Feb 01, 2014 12:05 am
Location: Praha 5

Re: my version

Post by Hippo »

zhg wrote:this is my version. no stack is used

00^<0^9?d1+097+-gdp
Why second 0^ when in both branches you drop it?
adark
Posts: 9
Joined: Fri Nov 20, 2015 2:04 pm
Contact:

Post by adark »

Remarkably simple. I love it!

Code: Select all

02g1+0^<0:6?09-6-gp
jaycim
Posts: 1
Joined: Thu Apr 28, 2016 6:26 am

Post by jaycim »

Never really mucked around with this machine code type stuff before, so I'm not sure if this is any good, but I got:

Code: Select all

100+<6?1+0^2cp!
User avatar
Hippo
Posts: 339
Joined: Sat Feb 01, 2014 12:05 am
Location: Praha 5

Post by Hippo »

jaycim wrote:Never really mucked around with this machine code type stuff before, so I'm not sure if this is any good, but I got:

Code: Select all

100+<6?1+0^2cp!
Yes, it looks OK and rather compact, good job.

Hmm, may be I have written too early ... it is not that much compact :P
When I am thinking about it now ... I immediately come with code shown by m!nus's ...
Post Reply