Neither is this a programming question.
-
It's an arithmetic question, and I'm feeling very dense for asking it, but I have coding to get on with and haven't time to play with arithmetic, i.e. for two columns my problem is solved, and I move on. But, let's say I have x items and y columns. How do I determine the maximum number of items per column? I said I was feeling dense. :doh: I'm just going to carry on with simple C# for the remainder of the evening. ;P
-
It's an arithmetic question, and I'm feeling very dense for asking it, but I have coding to get on with and haven't time to play with arithmetic, i.e. for two columns my problem is solved, and I move on. But, let's say I have x items and y columns. How do I determine the maximum number of items per column? I said I was feeling dense. :doh: I'm just going to carry on with simple C# for the remainder of the evening. ;P
x
If your actions inspire others to dream more, learn more, do more and become more, you are a leader." - John Quincy Adams
You must accept one of two basic premises: Either we are alone in the universe, or we are not alone in the universe. And either way, the implications are staggering” - Wernher von Braun -
x
If your actions inspire others to dream more, learn more, do more and become more, you are a leader." - John Quincy Adams
You must accept one of two basic premises: Either we are alone in the universe, or we are not alone in the universe. And either way, the implications are staggering” - Wernher von BraunThat's what I thought. I think Brady forgot to post some more info. :)
Chris Meech I am Canadian. [heard in a local bar] In theory there is no difference between theory and practice. In practice there is. [Yogi Berra] posting about Crystal Reports here is like discussing gay marriage on a catholic church’s website.[Nishant Sivakumar]
-
That's what I thought. I think Brady forgot to post some more info. :)
Chris Meech I am Canadian. [heard in a local bar] In theory there is no difference between theory and practice. In practice there is. [Yogi Berra] posting about Crystal Reports here is like discussing gay marriage on a catholic church’s website.[Nishant Sivakumar]
Sorry I was completely wrong, you need to know how many items to initialize the arrays, umm well couldn't you store in a linked list and then iterate through the entries with a counter?
-
It's an arithmetic question, and I'm feeling very dense for asking it, but I have coding to get on with and haven't time to play with arithmetic, i.e. for two columns my problem is solved, and I move on. But, let's say I have x items and y columns. How do I determine the maximum number of items per column? I said I was feeling dense. :doh: I'm just going to carry on with simple C# for the remainder of the evening. ;P
-
Sorry I was completely wrong, you need to know how many items to initialize the arrays, umm well couldn't you store in a linked list and then iterate through the entries with a counter?
Surely there must be a mathematical answer? I keep getting distracted to try and work it out anyway, so I'm trying again.
-
It's an arithmetic question, and I'm feeling very dense for asking it, but I have coding to get on with and haven't time to play with arithmetic, i.e. for two columns my problem is solved, and I move on. But, let's say I have x items and y columns. How do I determine the maximum number of items per column? I said I was feeling dense. :doh: I'm just going to carry on with simple C# for the remainder of the evening. ;P
With x total items, and y columns:
int x,y;
int items_per_column;
items_per_column = x / y;
if ((x % y) != 0) items_per_column += 1;Software Zen:
delete this;
-
Sweet, thanks! :thumbsup: Now for real man points, how do does one do that with integer arithmetic?
-
Sweet, thanks! :thumbsup: Now for real man points, how do does one do that with integer arithmetic?
-
With x total items, and y columns:
int x,y;
int items_per_column;
items_per_column = x / y;
if ((x % y) != 0) items_per_column += 1;Software Zen:
delete this;
In my columnless house your program is buggy. :rolleyes:
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler. -- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong. -- Iain Clarke
[My articles] -
Sweet, thanks! :thumbsup: Now for real man points, how do does one do that with integer arithmetic?
int x = 113;
int y = 23:// Making sure x is evenly divisable by y
// So to speak Math.Ceiling for integer division
int r = (x + (y - x % y)) / y;Cheers!
—MRB
"With sufficient thrust, pigs fly just fine."
Ross Callon, The Twelve Networking Truths, RFC1925
-
It's an arithmetic question, and I'm feeling very dense for asking it, but I have coding to get on with and haven't time to play with arithmetic, i.e. for two columns my problem is solved, and I move on. But, let's say I have x items and y columns. How do I determine the maximum number of items per column? I said I was feeling dense. :doh: I'm just going to carry on with simple C# for the remainder of the evening. ;P
The answer is always 42
No comment
-
int x = 113;
int y = 23:// Making sure x is evenly divisable by y
// So to speak Math.Ceiling for integer division
int r = (x + (y - x % y)) / y;Cheers!
—MRB
"With sufficient thrust, pigs fly just fine."
Ross Callon, The Twelve Networking Truths, RFC1925
Thank you, have some points! :rose:
-
In my columnless house your program is buggy. :rolleyes:
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler. -- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong. -- Iain Clarke
[My articles]int x,y;
int items_per_column;if (y != 0)
{
items_per_column = x / y;
if ((x % y) != 0) items_per_column += 1;
}
else
{
items_per_column = x; // for lack of anything better to do
}Bitch, bitch, bitch...
Software Zen:
delete this;
-
int x,y;
int items_per_column;if (y != 0)
{
items_per_column = x / y;
if ((x % y) != 0) items_per_column += 1;
}
else
{
items_per_column = x; // for lack of anything better to do
}Bitch, bitch, bitch...
Software Zen:
delete this;
Nope, Nope, Nope!
if (y != 0)
{
items_per_column = x / y;
if ((x % y) != 0) items_per_column += 1;
}
else if ( x != 0)
{
items_per_column = IM_SORRY_JACK_WE_NEED_MORE_MEMORY_FOR_INTEGERS;
}
else
{
items_per_column = PLEASE_PICK_ONE_OR_ANOTHER_OR;
}:laugh:
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler. -- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong. -- Iain Clarke
[My articles] -
Nope, Nope, Nope!
if (y != 0)
{
items_per_column = x / y;
if ((x % y) != 0) items_per_column += 1;
}
else if ( x != 0)
{
items_per_column = IM_SORRY_JACK_WE_NEED_MORE_MEMORY_FOR_INTEGERS;
}
else
{
items_per_column = PLEASE_PICK_ONE_OR_ANOTHER_OR;
}:laugh:
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler. -- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong. -- Iain Clarke
[My articles]int x,y;
int items_per_column;if (y > 0)
{
items_per_column = x / y;
if ((x % y) != 0) items_per_column += 1;
}
else if (y < 0)
{
throw new WTF_Exception();
}
else
{
throw new YourePissingMeOffException();
}Software Zen:
delete this;