473,763 Members | 3,910 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

FINDING OUT WHAT'S LEFT

I have a scenario where I have these things that take up (x) number of
space. I know the max number of space I will ever have is 512. I am
trying to figure out a way to write a formula or whatever will make it
work to tell me how many of these things I can put in this space.

So example

I want to put 60 of these thing that take up (21) units each. Well
given that I cannot go over 512 the max I am able to put in any one
space is 29. I did the math to do that, but what sort of formula am I
looking for to do this.

I want to know how many of these things I can fit and what the next
available number for space is. I have in the worksheet a cell that
contains the number of units each different thing takes up because it
varies.

Thank you for any help.

Matt

Sep 12 '07 #1
4 1460
On Sep 12, 3:38 pm, mattG <mgohr...@gmail .comwrote:
I have a scenario where I have these things that take up (x) number of
space. I know the max number of space I will ever have is 512. I am
trying to figure out a way to write a formula or whatever will make it
work to tell me how many of these things I can put in this space.

So example

I want to put 60 of these thing that take up (21) units each. Well
given that I cannot go over 512 the max I am able to put in any one
space is 29. I did the math to do that, but what sort of formula am I
looking for to do this.

I want to know how many of these things I can fit and what the next
available number for space is. I have in the worksheet a cell that
contains the number of units each different thing takes up because it
varies.

Thank you for any help.

Matt
correction to myself. I would only fit 28 in the example

Sep 12 '07 #2
On Sep 12, 4:38 pm, mattG <mgohr...@gmail .comwrote:
I have a scenario where I have these things that take up (x) number of
space. I know the max number of space I will ever have is 512. I am
trying to figure out a way to write a formula or whatever will make it
work to tell me how many of these things I can put in this space.

So example

I want to put 60 of these thing that take up (21) units each. Well
given that I cannot go over 512 the max I am able to put in any one
space is 29. I did the math to do that, but what sort of formula am I
looking for to do this.
24, not 29.
>
I want to know how many of these things I can fit and what the next
available number for space is. I have in the worksheet a cell that
contains the number of units each different thing takes up because it
varies.
Look at integer division and mod operators.

int MaxSpace = 512;
int SpacePerItem = 21;

int itemCount = MaxSpace / SpacePerItem;
int spaceLeftOver = MaxSpace % SpacePerItem;

Sep 12 '07 #3
mattG wrote:
I have a scenario where I have these things that take up (x) number of
space. I know the max number of space I will ever have is 512. I am
trying to figure out a way to write a formula or whatever will make it
work to tell me how many of these things I can put in this space.

So example

I want to put 60 of these thing that take up (21) units each. Well
given that I cannot go over 512 the max I am able to put in any one
space is 29. I did the math to do that, but what sort of formula am I
looking for to do this.
What math did you do to figure out the 29, and what aspect of it are you
finding difficult to translate into code? Are you sure you didn't come
up with 24, but then mis-read your handwriting as 29 instead?

You should be able to do a plain integer division (ie, no fraction,
decimal, remainder, etc.) to arrive at the correct number. When I do
the math, I actually get 24 "things" that are 21 units large in a space
that is 512 units large.

The code is simple -- "int count = 512 / dxThingWidth" -- but telling
you that might not give you the tools you need to derive a similar line
of code in the future. If you can explain why you weren't able to
translate the math you did into a line of code like that, that could
help you better understand how to do it successfully in the future (for
that matter, the act of explaining it may be sufficient for you to have
that "aha!" moment yourself).

Pete
Sep 12 '07 #4

"mattG" <mg******@gmail .comwrote in message
news:11******** **************@ g4g2000hsf.goog legroups.com...
>I have a scenario where I have these things that take up (x) number of
space. I know the max number of space I will ever have is 512. I am
trying to figure out a way to write a formula or whatever will make it
work to tell me how many of these things I can put in this space.

So example

I want to put 60 of these thing that take up (21) units each. Well
given that I cannot go over 512 the max I am able to put in any one
space is 29. I did the math to do that, but what sort of formula am I
looking for to do this.

I want to know how many of these things I can fit and what the next
available number for space is. I have in the worksheet a cell that
contains the number of units each different thing takes up because it
varies.

Thank you for any help.

Matt
This is pretty simple if you think about it.

If you have x objects that take up y units then that is a total of x*y units
taken up... or x + x + x + x + ... + x where there are y x's in the sum.

To make this concrete, suppose you have 10 dollar bills and each dollar bill
is 4 quarter(or represents 4 units where are unit is the quarder), then

10 dollar bills * [4 quarters / 1 dollar bill] = 40 quarters.

notice that I used dimensional analysis here. What this means is that I
treat the "dimension"(thi s case its dollars and quarters) which represents
what type of object the number is as sorta its own "number" that can be used
like a number.

That probably doesn't make sense but realize that

4 quarters / 1 dollar bill = 1

because

4 quarters = 1 dollar bill. (dividing both sides by the same amount is a
valid mathematical operation)
So essnetially what I did was start with

10 dollar bills = 10 dollar bills * 1

(multiplying by 1 doesn't change it)

but now I used

4 quarters / 1 dollar bill = 1

to get

10 dollar bills * [4 quarters / 1 dollar bill]

but then the dollar bill(s) cancel each other because have something like 10
* x * 4 * y / x = 10*4*y.

Which results in 40 quarters.

What that means is that

10 dollar bills = 40 quarters.
----------

Thats kinda a long explination but hopefully you understand it. (trying to
make it very simple so you can learn how to do this yourself)

If your a computer guy and know about bits and bytes you can do the same,

1000 bytes * [8 bits / byte] = 8000 bits

i.e., 1000 bytes is the same as 8000 bits.
-----------
Your problem is the exact same but a different perspective

x objects * [y space / object] = x*y space [for x objects]

i.e., x objects is the number of objects we are talking about
y space / object or y space / one object is the space taken by one object,
which is y.

The we multiply them and the units cancel and we are left with the total
space.
-----
For your specific problem

its 60*21 = 1260 units of space. (I left out the units in the product but I
know they are implicitly there)

Now if you have a max of 512 then you went over. By how much?

Well, its simple, we are looking for how many objects we can put into 512
because that would be our max.

i.e., x * 21 = 512. This gives us x = 24.123... but since x has to be an
integer(because we can't have partial objects), it means that we can have a
max of 24 units.

Notice that x = 512/21... but you can generalize this to be "Max
space"/"Size of one object".

Since you have 60 objects and 24 was the max then you are over by 60 - 24 =
36.

You can replace numbers with variables to make the equations more abstract
but more useful. If you don't know algebra then its about time to start
because this is what algebra is all about.


Sep 12 '07 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
4217
by: Erich | last post by:
I have a company table and I would like to write a query that will return to me any duplicate companies. However, it is a little more complicated then just matching on exact company names. I would like it to give me duplicates where x number of letters at the beginning of the company name match AND x number of letters of the address match AND x number of letters of the city match. I will be doing this in batches based on the first letter of...
0
952
by: sat | last post by:
Hi, I am facing problem while finding a text (Ctrl + F). In a Web Application, data is displayed in grid form and the left column is locked in the display. when i try to search for a text by opening Find window (Ctrl + F) on the page, it searches fine. But if i keep pressing the Find Next button ( it is fine until cursor reaches the end of the page) then the
2
3309
by: B Moor | last post by:
I have a database with 100,000's records, each with a unique reference, eg A123BNK456 I would like to generate a search facility whereby we can choose an exact match or partial match, where the partial match could be any of the following:- Partial match 1: 1 character maybe wrong Partial match 2: 2 characters maybe wrong Partial match 3: 3 characters maybe wrong
1
3185
by: Doug | last post by:
The html below shows DataList "DiscountList" nested within DataList "EventItemList". DiscountList contains a Label control. I'm trying to find the label, using FindControl, during EventList_ItemCreated (below the html), but it's always <undefined value> (null). Everything else works fine. Eventually I need to set the value of the label depending up the Count of the DataView "dvDiscount". For now I'll settle for just finding the damn...
4
6359
by: spivee | last post by:
I'm having an odd type of issue. I want to be able to pass an element name in my javascript event and find the location of the element, be it a div, span, img whatever, specifically the top and left attributes. I have defined my element like so... ### .css file... #mydiv { position:absolute;
6
1749
by: Anca Floria | last post by:
Hi there! I am trying to find out what is wrong with the following code: SELECT Investor.Company, Investor.ID, Investor.Country FROM Investor WHERE ((( Investor.Company) In ( SELECT FROM As Tmp GROUP BY Left(,3) HAVING Count(*)>1
10
3700
by: sklett | last post by:
I have a situation where I'm getting in Image that has a gray (solid, same color) background with a smaller white rectangle inside. The position is not always the same. What I need to do is locate the postion and determine the size fo the white rectangle and then crop the image to leave only the white rectangle remaining. I'm very new to GDI+ and have really no idea where to start. Can anyone suggest a good way to accomplish this? ...
15
1973
by: rhino | last post by:
I've put together a prototype of two-tiered CSS tabs that works really well in IE6, IE7, and FF2. It also works very well in Opera 9.27 _except_ that the placement of the lower tier of tabs is messed up. Both the XHTML and CSS validate without any errors or warnings. Can anyone help me figure out what is wrong? I'd be especially interested in the technique you used to figure out where the problem was. I still struggle a lot when I try to...
275
12377
by: Astley Le Jasper | last post by:
Sorry for the numpty question ... How do you find the reference name of an object? So if i have this bob = modulename.objectname() how do i find that the name is 'bob'
0
9997
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
9937
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9822
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
7366
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6642
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5405
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3917
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
3522
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2793
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.