Page 2 of 2

Posted: Mon Jul 04, 2011 3:49 pm
by AMindForeverVoyaging
If I remember correctly I started the program some time on June 30th during the working day, and the last change to the output file was on July 2nd, 10:10 a.m.

Posted: Sat Apr 07, 2012 2:26 pm
by guga
I did this one even more lazy...
i googled the first 10 output values to see if it could be a more or less known sequence, but instead of that I accidently found the already decompiled c#-code at ideone.com :D
So i changed it to just "calculate" the last value, compiled it again and let it run. Lazy but effective :wink:

Posted: Wed Nov 28, 2012 9:16 am
by dmgciubotaru
def calc(num):
num2 = 5
num2 = num2*10+(num2+1)*(num-10)
num2 = num2*10+(num2+num)*(num-10)
num2 = num2*10+(num2+num*num)*(num-10)
num2 = num2*10+(num2+num*num*num)*(num-10)
num2 = num2*10 + (num2+num*num*num*num)*(num-10)
num2 = (num2 + 16*num*num*num*num*num)
num2 &=0xffffffff
print(num2)

calc(99)

Posted: Thu Mar 28, 2013 7:27 pm
by nuggerator

Code: Select all

#include <iostream>
// integer length
const unsigned int il(unsigned int AValue)
{
	unsigned int c = 0;
	do
	{
		AValue /= 10;
		c++;
	}
	while(AValue);
	return c;
}

int calc(int num)
{
	int num1 = 0;	
	unsigned short int v[100];
	for (int index1 = 0; index1 < num; ++index1)
	{
		v[index1] = il(index1);
	}

	for (int index1 = 0; index1 < num; ++index1)
	{
		for (int index2 = 0; index2 < num; ++index2)
		{
			for (int index3 = 0; index3 < num; ++index3)
			{
				for (int index4 = 0; index4 < num; ++index4)
				{
					for (int index5 = 0; index5 < num; ++index5)
					{
						num1 += v[index1] + v[index2] + v[index3] + v[index4] + v[index5] + 16;
					}
				}
			}
		}
	}
	return num1;
}

int main(int ac, char** av)
{	
	std::cout << "calculating..." << std::endl;
	int num = 99;
	for (int index = num; index >= 0; --index)
	{
		std::cout << index << std::endl;
		std::cout << "val: " << calc(num - index) << std::endl;
	}
	return 0;
}

Code: Select all

$ grep "model name" /proc/cpuinfo | uniq
model name	: Intel(R) Core(TM)2 Duo CPU     P8800  @ 2.66GHz
$ time ./sharper > /dev/null
real	15m30.214s
user	15m27.970s
sys	0m0.364s

Posted: Mon Nov 30, 2015 9:08 pm
by Hippo
When I have seen this challenge I said to myself ... running windows executable ... hmm I should search for a disassembler, and than I forgot the challenge.

Today I have seen it again ... with huge amount of succesfull solvers ... so I have installed Microsoft Windows SDK. Funny that I have tried the Il Disassebler as the fist tool.

Running the code helped me to see the need for final transformation x%=2^32; x-=(x>2^31)?2^32:0;
I got f(i)=i^5*16+5*i^4*s(i), where s(i)=2i-10 for 100>i>10 is the sum of lengths of natural numbers till i.
And f(99) with the final transformation was it. (Computed in excell, starting results compared to the results got by runnig the executable).

Posted: Sat Feb 11, 2017 1:57 am
by 0x1d1aN

Code: Select all

# Formula in Python
# ((4*4+5)*(num**5)) + ((num-10)*(5*(num**4)))
((4*4+5)*(99**5)) + ((99-10)*(5*(99**4))) = 242454432924
But it took some time before I realized that C# int is 32 bit long and the answer must be truncated. :wink:
Nice challenge.