tags:

views:

81

answers:

1

The problem is to split a list of items into a variable number of columns to maximize the display on the web page ( note, they are displayed from left to right )

If there are 15 items in the list, they go in one column if there are 20 items on the list, they go in two columns if there are 30 items on the list, they go in two columns there can be max 8 columns to eliminate horiz. scrolling

again, the goal is to maximize the display which accounts for the slight inconsistency above to determine the # of columns, i could use a variation of the code if ( cnt > 100, col = 8 ) else if ( cnt > 60 col = 5 ).... etc. but i hope there's a better formula for determing the column count ?

the output would be of the form

1   2 3 4 5 6 7
8   9 10 11 12 13 14
15  16 17 18 19 20 21
22  23 24 25 26 27 28
29  30 31 32 33 34 35
36  37 38 39 40 41 42
43  44 45 46 47 48 49
50  51 ........

hope the problem is clear, any questions let me know

A: 
if count > 15
   cols = count / ITEMS-PER-COL
if cols > 8
   cols = 8

does this seem like it ??

nairdaen
hmm, this looks goodguess i was *too* focused on finding a fancier way !