Find a series that will produce the numbers (in order) - 5,1,1,4,6,2,4,0,3,5,1,3

I'm thinking it may be possible using the modulus operator, and I'm about to thrw some brute force at it.

eg given a gemetric progression x, a+x, 2a+x and some modulus y, and some starting point n (ie an+x, a(n+1)+x...) find a, x, y, n such that the series from n to n+11 produce the series above. Extra points if n=1! (or zero, as the case may be)

It may be necessary (and I consider it acceptable and even necessary) to pop off just the last number of the modulus. eg if the result is 51 it counts as '1'. [ March 07, 2005: Message edited by: David O'Meara ]

Originally posted by David O'Meara: Related to this question:

Find a series that will produce the numbers (in order) - 5,1,1,4,6,2,4,0,3,5,1,3

I'm thinking it may be possible using the modulus operator, and I'm about to thrw some brute force at it.

eg given a gemetric progression x, a+x, 2a+x and some modulus y, and some starting point n (ie an+x, a(n+1)+x...) find a, x, y, n such that the series from n to n+11 produce the series above. Extra points if n=1! (or zero, as the case may be)

It may be necessary (and I consider it acceptable and even necessary) to pop off just the last number of the modulus. eg if the result is 51 it counts as '1'.

[ March 07, 2005: Message edited by: David O'Meara ]

If you don't mind using the absolute value operator, the solution is fairly straightforwrd.

Given a set of points, (x0, y0) through (xn, yn) where all the x's and y's are integers, a function that will map the x's to y's and has a value of 0 for other integers is...

Since you don't care about the value everywhere else, you could simplify a little...

In the case where x0 through xn are consecutive integers, there will, for the most part, be three terms of the form ABS(x-i) for each each value of i. Collecting them together into one term will make the overall expression a touch simpler.

I let you push numbers around.

Ryan

Ryan McGuire
Ranch Hand

Joined: Feb 18, 2005
Posts: 1013

3

posted

0

Wait, it gets even better. How about...

...where m ranges from 0 to 11. And of course (int)x gives you FLOOR(x). e.g. (int)2.9 = 2