'Mod' Challenge

User avatar
m!nus
Posts: 202
Joined: Sat Jul 28, 2007 6:49 pm
Location: Germany

'Mod' Challenge

Post by m!nus »

I wrote my code which should work, but it outputs that:

Code: Select all

5 test(s) passed
'...' is incorrect.
Is it because of a cycle limitation?



another question: the HVM used to verify the challenge solutions, is it the phyton version or is it even in php?
User avatar
adum
Posts: 392
Joined: Thu Apr 19, 2007 12:49 pm
Contact:

Post by adum »

hi m!nus -- hmmn, when you take too many cycles it should say something like:
HVM run ERROR: too many cycles: 10002 (PC=1, STACK_SIZE=1)

but yeah, you only have 10k for this one. so you have to be a little smart =)

the hvm on submission is a PHP version. it _should_ behave the same as the python, but if it doesn't, we'd like to debug that. do you see something inconsistent?

adum
User avatar
m!nus
Posts: 202
Joined: Sat Jul 28, 2007 6:49 pm
Location: Germany

Post by m!nus »

oh yeah, the HVM error is there, but it disappears in wrong interpreted html

you should do htmlspecialchars() on the output maybe
User avatar
adum
Posts: 392
Joined: Thu Apr 19, 2007 12:49 pm
Contact:

Post by adum »

mmn, good idea

thanks,
adum
tails
Posts: 191
Joined: Tue Jun 10, 2008 7:51 pm
Location: Tokyo

Post by tails »

I regularly use JavaScript version of HVM. Solving 'Fast Mod' was very hard with it. :cry:
therethinker
Posts: 144
Joined: Fri Mar 28, 2008 11:29 pm
Location: #hacker.org on Freenode

Post by therethinker »

I too use a JS version of HVM. However, I modified it so that it stored the trace in a variable then displayed them once the program finished, which drastically increased speed.

I didn't have trouble w/ Fast Mod at all. My solution to the prior challenge worked. :P
tails
Posts: 191
Joined: Tue Jun 10, 2008 7:51 pm
Location: Tokyo

Post by tails »

Great, therethinker!

It may be a spoiler, but my difficulty was that "32/" becomes 1.5 (not 1) on the JS version HVM on IE6. I tried to manage to write a floor function. :-)
palm162
Posts: 2
Joined: Mon Jul 14, 2008 5:31 am

Post by palm162 »

What is HVM i m not to smart yet
therethinker
Posts: 144
Joined: Fri Mar 28, 2008 11:29 pm
Location: #hacker.org on Freenode

Post by therethinker »

tails, as far as the JS version goes, it appears to have several implementation bugs. I know I found another earlier on, but I cannot recall. (I also think the program explanation should at least touch upon the call stack.)

I happened to get lucky w/ Fast Mod, I guess :D

palm162: http://www.hacker.org/hvm/
User avatar
m!nus
Posts: 202
Joined: Sat Jul 28, 2007 6:49 pm
Location: Germany

Post by m!nus »

i tried to convert the python HVM to PHP but it didnt work though, had no time to fix it yet
therethinker
Posts: 144
Joined: Fri Mar 28, 2008 11:29 pm
Location: #hacker.org on Freenode

Post by therethinker »

Curiously, has anyone written a higher-level language and a to-HVM compiler? Back when it was just strlen & the Small World challenges, it didn't make much sense to do it, but with newly added ones, it might not be so stupid.

(I wouldn't want your implementation, I'm just curious if its been done.)
User avatar
adum
Posts: 392
Joined: Thu Apr 19, 2007 12:49 pm
Contact:

Post by adum »

i think bok has fixed the hvm javascript bugs now.

i just got my hvm assembler working. doing the jumps by hand is such a huge pain. i know at least one other solver has written a tool. this is one thing we don't want shared on the forums. but sharing an hvm implementation in a different lang (like someone did for C#) is just fine.

adum
therethinker
Posts: 144
Joined: Fri Mar 28, 2008 11:29 pm
Location: #hacker.org on Freenode

Post by therethinker »

Oh, I agree, I know I wouldn't want my assembler public.
User avatar
m!nus
Posts: 202
Joined: Sat Jul 28, 2007 6:49 pm
Location: Germany

Post by m!nus »

therethinker wrote:Curiously, has anyone written a higher-level language and a to-HVM compiler? Back when it was just strlen & the Small World challenges, it didn't make much sense to do it, but with newly added ones, it might not be so stupid.

(I wouldn't want your implementation, I'm just curious if its been done.)
thanks for the idea, i'm gonna try making one, now that i have finally time again :)
ajay
Posts: 2
Joined: Fri Jul 25, 2008 9:36 am
Location: nashik
Contact:

Post by ajay »

tails wrote:I regularly use JavaScript version of HVM. Solving 'Fast Mod' was very hard with it. :cry:
hacking is not crime it game`
Post Reply