Devising an algorithm based on a pattern in a number series.
Hello folks,
My name is Skyliner, I'm a computer science student and I'm making a very small program that performs some calculations based on a series of numbers.
My problem comes from trying to improve the original algorithm used to generate such numbers. I won't go into details, suffice to say that it involves as much as 10 conditional checks modifying values arbitrarily, in order to obtain the desired numbers.
I believe such a rudimentary approach is not only brute and inefficient, it is unnecessary. As you'll see there is a simple pattern in these numbers, a much simpler generation algorithm is bound to exist. My inferior, or rather non-existant mathematical skills, however, do not allow me to find it. Still, by pure stubbornness, I've come close to a correct formula, which sadly is not precise enough.
I was hoping you guys could help me out.
Thank you.
The problem goes like this: for every given seed (level) a number must be generated that corresponds exactly to a specific value. If we increase the seed sequentially, it is easy to identify a pattern in the generated numbers. I'm looking to create a formula, that returns the appropriate value (basePrecision) for whichever level is given.
Here are the numbers:
This is the formula I came up with:
(level * .1 + 3.2) * level + 20
It works, but it's completely off in some cases. So much that even playing around with approximation will not yield accurate results.
PS:The seed can only be in the range 1-80.
Re: Devising an algorithm based on a pattern in a number series.
Here is some pseudo-code that should work:
basePrecision=20
for n = 1 to level
basePrecision = basePrecision + 2*int(n/10)+4
next n
Re: Devising an algorithm based on a pattern in a number series.
Well that works quite alright.
I was expecting a complicated math algorithm and yet you hit me with this... simple no brainer solution. I feel ashamed.
Thank you!
Re: Devising an algorithm based on a pattern in a number series.
Someone more knowledgeable about recursions involving the floor function may be able to provide you with a closed-form solution, but that was the best I could do in a reasonable amount of time. :)