tag:blogger.com,1999:blog-7963792203425657974.post8143689763956241818..comments2023-11-03T09:11:57.033-04:00Comments on 19 Bernard: Nerd Quest For GloryWoody Esplanadehttp://www.blogger.com/profile/05876564000863863065noreply@blogger.comBlogger5125tag:blogger.com,1999:blog-7963792203425657974.post-61383874113800872012011-03-27T16:02:38.057-04:002011-03-27T16:02:38.057-04:00and shit... an iterative solution like this is not...and shit... an iterative solution like this is not gonna give me less processing time... what I was looking for was a way to calculate it with one mathematical function. I'm not sure if its even possible.<br /><br />Oh what the hell. Thanks anyways man.Dementorhttps://www.blogger.com/profile/02495036198956848139noreply@blogger.comtag:blogger.com,1999:blog-7963792203425657974.post-52290141283177316652011-03-27T15:59:48.594-04:002011-03-27T15:59:48.594-04:00Excellent ideas!
Although plugging in numbers doe...Excellent ideas! <br />Although plugging in numbers doesnt seem to give the right answer.<br />Ex: 10x10 matrix, items visited : 3, visit 4 should give me i:1, j:5 (starting from line 0 and visit 0)<br /><br />but this algorithm is giving me i:1 j:3... because your skipped items are not adding the lower triangle skipped items! adding them should do the trick.<br />Thanks man. I think I should manage from there on. 7 glory points for giving me the bigger part of the solution. (its still an awful lot of glory points)Dementorhttps://www.blogger.com/profile/02495036198956848139noreply@blogger.comtag:blogger.com,1999:blog-7963792203425657974.post-19077169075938583792011-03-27T14:01:26.655-04:002011-03-27T14:01:26.655-04:00typedef struct Coord2D
{
Coord2D(int x, int y): x...typedef struct Coord2D<br />{<br /> Coord2D(int x, int y): x(x),y(y){}<br /> int x;<br /> int y;<br />};<br /><br />/*<br />the number of items to the right of the diagonal at row i are n-i (assuming a nxn matrix)<br />*/<br />Coord2D function(int visit, int itemsPerVisit, int n)<br />{<br /> int itemsToSkip = visit*itemsPerVisit;<br /> int row = 0;<br /> int itemsInRow = n-1;<br /><br /> while (itemsToSkip > itemsInRow)<br /> {<br /> itemsToSkip -= itemsInRow;<br /> --itemsInRow;<br /> ++row;<br /> }<br /> <br /> return Coord2D(row, itemsToSkip);<br /><br />}Master of the Crawhttps://www.blogger.com/profile/10193515962306860345noreply@blogger.comtag:blogger.com,1999:blog-7963792203425657974.post-14020789961105744752011-03-27T13:04:45.070-04:002011-03-27T13:04:45.070-04:00the function needs to know which visit it is (nth ...the function needs to know which visit it is (nth visit), and it needs to know the size of the block of values to be visited by each visit.<br />Say I visit 10 values at a time, and I want to know the line and column of the first value of the 25th visit in a 1000 x 1000 matrix, only visiting the upper triangle.Dementorhttps://www.blogger.com/profile/02495036198956848139noreply@blogger.comtag:blogger.com,1999:blog-7963792203425657974.post-86007065670997755772011-03-27T12:55:14.066-04:002011-03-27T12:55:14.066-04:00You're looking for any and all values above th...You're looking for any and all values above the diagonal of the matrix? And you only want to grab the first k values?<br />you can calculate this in a straight forward way, you just need the dimensions (in this case it's a square matrix). It's not a formula more than algorithm.<br /><br />coordinate getNextForItem(int i, int j)<br />//i = current row<br />//j = col<br />int nextrow = (j+1) mod n;<br />if (nextrow < j){ i = i+1; nextrow = i + 1;}<br />return new coordinated(i,j);<br /><br />something like that. this works because the next value in a given row will always be the value to the right of the diagonal (aii is the diagonal value so ai(i+1) is the next value to the right.<br /><br />You'll have to include a bounds check obviously but that's pretty much it.Master of the Crawhttps://www.blogger.com/profile/10193515962306860345noreply@blogger.com