The RPG Maker Resource Kit

RMRK General => General Chat => Topic started by: ahref on July 29, 2011, 11:18:41 PM

Title: Programming/Maths Problem
Post by: ahref on July 29, 2011, 11:18:41 PM
Hi,

Was wondering if anyone could help me with a mathsy programmy problem. Its been driving me nuts:

Given an infinite number of colums, where odd numbered columns have x cells and even numbered columns have y cells. Each cell can hold one object, how do i figure out the column number of the nth item.

For further clarification and example;
x = 4
y = 3
(https://rmrk.net/proxy.php?request=http%3A%2F%2Fimg810.imageshack.us%2Fimg810%2F8158%2Fselection014.png&hash=f5342dd7271dad9bb67b24d84abd8df131fbc60a)

At the moment i do some stupid while loop to work this out, Id love it if there was a one liner, or simple maths formula. Speed is essential here :(

Thanks for your help guys :)
Title: Re: Programming/Maths Problem
Post by: Night_Runner on July 30, 2011, 12:25:34 AM
You could do something like this http://ge.tt/8F1qJO6?c (http://ge.tt/8F1qJO6?c)
Title: Re: Programming/Maths Problem
Post by: ahref on July 30, 2011, 12:41:40 AM
How the hell did you figure that out :D?