Win a copy of Emmy in the Key of Code this week in the General Computing forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Junilu Lacar
  • Jeanne Boyarsky
  • Bear Bibeault
Sheriffs:
  • Knute Snortum
  • Devaka Cooray
  • Tim Cooke
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Ron McLeod
  • Carey Brown
Bartenders:
  • Paweł Baczyński
  • Piet Souris
  • Vijitha Kumara

[hard?] Modulus series

 
Rancher
Posts: 13459
Android Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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 ]
 
Rancher
Posts: 1187
16
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

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
Rancher
Posts: 1187
16
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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

Ryan
 
Normally trees don't drive trucks. Does this tiny ad have a license?
Java file APIs (DOC, XLS, PDF, and many more)
https://products.aspose.com/total/java
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!