Broken Key

Discussion of challenges you have already solved
Post Reply
dotme
Posts: 10
Joined: Sun Nov 16, 2008 6:45 pm

Broken Key

Post by dotme »

Hmm, I expected this to be harder.

My 1st idea was to decrement both values in a loop and break out when the first number falls to zero. But before testing this solution I thaught about the cycle limit and potentially negative values and discarded that idea.

But as I didn't had an idea how to test for signedness with the limited instruction set, I tried my first idea.

Fortunately, it seems that the solution isn't tested with big or negative values. :lol:
wrtlprnft
Posts: 28
Joined: Sun Nov 09, 2008 4:48 pm

Post by wrtlprnft »

EDIT: removed because it sort of solves the follow-up challenge, broken keys (didn't know it existed, sorry)
therethinker
Posts: 144
Joined: Fri Mar 28, 2008 11:29 pm
Location: #hacker.org on Freenode

Post by therethinker »

I was pleasantly surprised when I found out my code worked the very first time I ran it! I couldn't believe it!

Its not great code, but it's easy to follow

Code: Select all

0<1<1-1v1-1v1^1^2?4g0<p!2?4g1<p!4c
User avatar
livinskull
Posts: 22
Joined: Fri Jun 26, 2009 12:01 pm
Location: /dev/null
Contact:

Post by livinskull »

therethinker wrote:I was pleasantly surprised when I found out my code worked the very first time I ran it! I couldn't believe it!
lol same here :D

Code: Select all

0<2>1<3>0<92*2+?1<92*?0<1-0>1<1-1>8c3<p!2<p
arthur
Posts: 21
Joined: Fri Jul 23, 2010 12:44 pm

Post by arthur »

My solution

Code: Select all

0<1<-0^1+99+?0^1-8?0^4?2/5c0<p!1<p!
whattheh@ck
Posts: 16
Joined: Wed Jul 16, 2008 2:33 am
Location: here

Post by whattheh@ck »

it turns out that the HVM doesn't store decimal numbers so i just used division to see which was bigger...

Code: Select all

0<1</4?0<p!1<p!
hack the planet
User avatar
zjorzzzey
Posts: 11
Joined: Fri Oct 30, 2009 7:31 pm
Location: NL

Post by zjorzzzey »

... so i just used division
Nice one!
nuggerator
Posts: 3
Joined: Tue Jun 28, 2011 12:37 pm
Location: Germany

Post by nuggerator »

Code: Select all

Warning: Division by zero in /home/hacker_apache/html/hacker/html/hvm/hvmchallenge.php on line 88
17 test(s) passed
'0<1<-0^0^*/4?1<p!0<p' is incorrect.
Next input:

Code: Select all

0<1<-0^1-26*?0^0^*/4?1<p!0<p

Code: Select all

Warning: Division by zero in /home/hacker_apache/html/hacker/html/hvm/hvmchallenge.php on line 88
'All tests passed' is correct.
Just wanted to mention, don't know if it is important.

regards
compudemon
Posts: 33
Joined: Sat Aug 13, 2011 2:13 pm

Post by compudemon »

lol seems i got the same idea as another, hurrah division

0<1</4?0<p!1<p
desert77
Posts: 2
Joined: Sun Jun 22, 2008 3:54 pm

Post by desert77 »

I used division too, but i considered negative numbers too...

0<1<-0^2?4g1<p!0^1+2?4g1<p!0^1^*0^2^-1^3^+/4?1<p!0<p!
exomo
Posts: 3
Joined: Wed Jun 27, 2012 3:21 pm

Post by exomo »

My solution works on all numbers, negative, zero whatever and is not too long. So I wanted to share it:
1<0<-0^1+2/8?2/028*-g1+<p
trofi
Posts: 23
Joined: Mon Oct 14, 2013 7:20 pm

Post by trofi »

Mine happened to be 13-ops long:

Code: Select all

0<1<0<1</1?dp
The same idea as others'.
User avatar
yes-man
Posts: 32
Joined: Fri Jan 30, 2009 5:14 pm

Incomplete

Post by yes-man »

I consider the task (or more the text) to be imcomplete.
The fact that there are only positive integers should be mentioned!
Post Reply