Page 1 of 2
Broken Keys
Posted: Sun Jul 19, 2009 7:17 pm
by klavierspieler21
I "solved" this by using the fact that max(a,b) = (|a-b|+a+b)/2, and Newton's method to calculate the square root of (a-b)^2. However, it shouldn't have passed when a-b = 0 because I'm dividing by 0 in newton's method.
I got error messages but I still "passed"...
Here's my code:
0<1<1^1^-0^*11^1^/+2/1^1^/+2/1^1^/+2/1^1^/+2/1^1^/+2/1^1^/+2/1^1^/+2/1^1^/+2/1^1^/+2/1^1^/+2/1vd++2/p
The repeating 1^1^/+2/ is the recursive newton's method applied enough times.
you had a good solution, but yet another
Posted: Thu Sep 03, 2009 8:30 pm
by ftfish
I used the fact: when a<b, a/b equals 0.
max(a,b)=(a/b *a + b/a *b)/(a/b + b/a)
here's my code:
Posted: Tue Dec 08, 2009 1:03 am
by livinskull
eat this:
getting divide-by-zero warnings if second is larger, but who cares as long as it works
Posted: Tue Jan 05, 2010 8:29 am
by coderT
livinskull wrote:eat this:
getting divide-by-zero warnings if second is larger, but who cares as long as it works
damn i thought that's not allowed.
Here is how I solved it:
1. except memory location 0, fill the whole memory with the content of memory location 1.
2. location = Mem[0] / Mem[1]
3. the greater number is: Mem[location]
this is stupid but worked.
Posted: Mon Mar 08, 2010 6:41 pm
by jonik555
Oh no, I found other solution, but it is solution for next challenge
Very nice one!!!!
Posted: Sun May 02, 2010 10:24 am
by OKOB
Another conventionally correct solution (All tests passed!)
111111111111111111111101<0</v<p!
Longer (1111111111111111111111101<0</v<p!) - not all tests passed
Shorter ( 11111111111111111111101<0</v<p!) - not all tests passed
Bad tests set or error in 'v' comand implementation (Longer don't work!)
Re: you had a good solution, but yet another
Posted: Sun Aug 01, 2010 3:05 pm
by arthur
ftfish wrote:I used the fact: when a<b, a/b equals 0.
max(a,b)=(a/b *a + b/a *b)/(a/b + b/a)
here's my code:
It seems not to work for negative integer. if a<0<b and |a|>|b|, a/b != 0.
my solution is
Code: Select all
0<1<-0^2/-0^2/-0^2/-0^2/-0^2/-0^2/-0^2/-0^2/-0^2/-0^2/-0^2/-0^2/-0^2/-0^2/-0^2/-0^2/-0^2/-0^2/-0^2/-0^2/-0^2/-0^2/-0^2/-0^2/-0^2/-0^2/-0^2/-1+4*g 1<p!0<p!
works for |a-b|<2^27
Posted: Mon Feb 21, 2011 3:16 am
by whattheh@ck
I sort of cheated
Code: Select all
0<1</9*0^52*/3>3<25**-3<+g1<p!000000000000000000000000000000000<p!
all of those 0's seem to be a good enough buffer to pass all the tests...
I just fixed it to be more exact:
Code: Select all
1<0<1</9*0^52*/3>3<25**-3<+0^52*/3>3<25**-3<+3/gp!00<p!
it works due to an interesting fact that the sum of the digits in a multiple of 9 is 9.
Posted: Tue Mar 08, 2011 10:16 pm
by zjorzzzey
Works because memory is initialized with zeroes by default.
Seen more beautifull solutions though...
Posted: Sun Jun 26, 2011 9:59 pm
by kalunos
here comes my (straightforward
) receipt (>0 numbers only, but passed the test) ...
0<1</2+0^1-/1-<p
which means: load the 2 nums, divide .. result is 0 (if S0<S1) or any n >0.
then calc ( (n+2) / (n+1) ) which gives "2" for n=0 only, "1" else.
looking forward for more broken keys
....
happy coding!
Posted: Thu Sep 01, 2011 6:52 pm
by AMindForeverVoyaging
0<1<-088*8*8*8*8*8*8*8*8*-2*/1+4*g0<p!1<p!
Dividing the difference of the two numbers by -(2^31) gives either -1 or 0, from there it's easy.
Now to do it without the division instruction... I really have no clue how to
Posted: Mon Sep 19, 2011 9:25 pm
by compudemon
i cheated with divide
if smallnumber > 0 and < bignumber then ( smallnumber + bignumber - 1) / bignumber = 1
else = 0
0<1</88888****1-+8/8/8/8/8/4*g1<p!0<p
yeah this wont work if the test has a big number in it but who cares
Posted: Sun Jul 08, 2012 8:56 pm
by Chnty
Math rules!
Because 2x/(x+1) is 0 for 0 and 1 for anything else
Posted: Mon Jan 28, 2013 2:48 am
by sascha27
I kind of used a shift operation, 32 times so it was big enough for integer values
0<1<-2/2/2/2/2/2/2/2/2/2/2/2/2/2/2/2/2/2/2/2/2/2/2/2/2/2/2/2/2/2/2/01-*<p
:P
Posted: Thu Mar 07, 2013 7:31 pm
by rhian
i just save the value of M1 into the result of M0/M1. if M0 < M1 then the result is 0 and higher M1 value is stored into M0 which I print in any case.