9
I was working on a math question with a friend of mine, and we decided to write a script that finds the answer. The original question is as follows:
The difference of two natural numbers is 2010 and their greatest common denominator is 2014 times smaller than their lowest common multiply. Find all the possible solutions.
We started writing the program independently of each other, and when it worked we decided to golf it up to get the least amount of bytes we could manage. We ended up with this beautiful line of code at a marvelous 89 bytes.
from fractions import*;print[i for i in range(10**6)if i*(i+2010)/gcd(i,i+2010)**2==2014]
We wanted to see if anyone manages to write a shorter piece of code, that enumerates the first 1 million i's. If you are brave enough to compete, you may use any language you like, but we would prefer Python 2 to be able to compare your code with ours.
Usual rules apply, shortest bytes win. The standard code golf loopholes apply. Standard "loopholes" which are no longer funny
Have fun!
@Rainbolt: the 4 and 5092 are not a single answer, they are the 'i' for 2 answers. – sammko – 2014-12-11T22:19:21.713
Oh duh. Thanks for clarifying. – Rainbolt – 2014-12-11T22:20:09.120
OK I've got a mathematical proof that 4 and 5092 are the only solutions. So the question now is relying on the standard loophole to avoid trivial answers like
p[4,5092]
. – kennytm – 2014-12-11T22:40:02.440By the way, you can get your code to 88 very easily... I'll give you a hint: multiplication is commutative ;) – FryAmTheEggman – 2014-12-11T22:49:30.830
2@Rainbolt: Ok, allowed any language. The python limitation was for comparison purposes. But just do whatever you want :D – sammko – 2014-12-11T21:47:48.847
Are there answers other than 3 and 5092? Can't find anything else before 10,000,000. – kennytm – 2014-12-11T21:59:38.560
@KennyTM: I got 4 and 5092. And yes, I dont think there are any others. – sammko – 2014-12-11T22:01:00.710
Hey, I have edited your title to better reflect what you are asking. Feel free to change it if you feel like I missed something. – FryAmTheEggman – 2014-12-11T22:06:27.637
Removed python tag by the way. – Timtech – 2014-12-11T22:08:44.867
Nice. Your edit was so fast that it didn't even get caught in the original revision. This looks like a fun combo challenge (at least until someone proves that those two numbers are the only solution to the problem). – Rainbolt – 2014-12-11T22:14:18.340
Can't wait to see all the 20b CJam or Pyth answers :D – sammko – 2014-12-11T22:17:23.517
How are 4 and 5092 a solution to the problem if the difference between them isn't 2010? 5092 - 4 = 5088. Is there a definition for "difference" that I don't know about? – Rainbolt – 2014-12-11T22:17:48.373