Broken Keys
-
- Posts: 16
- Joined: Fri Jul 13, 2007 12:21 am
- Location: Waterloo
Broken Keys
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.
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
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:
max(a,b)=(a/b *a + b/a *b)/(a/b + b/a)
here's my code:
Code: Select all
0<0<1</*1<1<0</*+0<1</1<0</+/p
- livinskull
- Posts: 22
- Joined: Fri Jun 26, 2009 12:01 pm
- Location: /dev/null
- Contact:
eat this:
getting divide-by-zero warnings if second is larger, but who cares as long as it works
Code: Select all
1<0</0^/<p
damn i thought that's not allowed.livinskull wrote:eat this:getting divide-by-zero warnings if second is larger, but who cares as long as it worksCode: Select all
1<0</0^/<p
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.
Re: you had a good solution, but yet another
It seems not to work for negative integer. if a<0<b and |a|>|b|, a/b != 0.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:Code: Select all
0<0<1</*1<1<0</*+0<1</1<0</+/p
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!
-
- Posts: 16
- Joined: Wed Jul 16, 2008 2:33 am
- Location: here
I sort of cheated
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:
it works due to an interesting fact that the sum of the digits in a multiple of 9 is 9.
Code: Select all
0<1</9*0^52*/3>3<25**-3<+g1<p!000000000000000000000000000000000<p!
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!
hack the planet
Code: Select all
0<1<1^1^10>01>/<vdp
Seen more beautifull solutions though...
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!
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!
-
- Forum Admin
- Posts: 496
- Joined: Sat May 28, 2011 9:14 am
- Location: Germany
-
- Posts: 33
- Joined: Sat Aug 13, 2011 2:13 pm
Code: Select all
1<0</0^2*1v1+/<p
Because 2x/(x+1) is 0 for 0 and 1 for anything else
Code: Select all
1<0<1</>0<p