Complex IF Counting, Excel - excel

I am having a space with some defined sizes and I have item with also some sizes and I need to create something that will take item width and compare if it fits to all sizes of space, same for depth and height of the item and none of the size can't be reused, I mean you can't bend item to fit so if item Height match any size of space then width can't fit to the same side.
Here are my Sizes:
Thank you for any idea how to solve this, using formulas.

Just in case the dimensions aren't always sorted smallest to largest:

Seems to work for your example:

Related

Is there a relation between a typography's character width and character height

I encounter a problem when i use python-pptx, i need to put a line of text to a fixed width textbox and keep it in one line, so i have to calculate the proper font size manually.
The problem is that the font size is determined by character's height, not its width, and i have not found out the relation between its height and width. Can anyone help me out?
The width of a string in pixels will be approximately some value depending on the text, multiplied by the font size. Approximately, because there may be jumps. A 12 point font might have the exact same width as 11 point, and 13 point might be wider. You might be able to choose 12.4 points which depending on the implementation might be wider or not wider than 12.3 or 12 point.
I suggest that you start by making a wild guess about the best font size based on the length. Sure, WWWWW is a lot wider than iiiii, but for average text it works. You measure the width, then you make a better guess for the best font size.

Algorithm for determining LR and TB order when not uniform

wondering if anyone has any insight as to how to ascertain the order of differently sized rectangles from left to right and from top to bottom when they are not already aligned to any grid, and they are differently sized and/or rotated. Some might also be missing.
As anyone can see from the illustration, the objects should be numbered as shown. But how, mathematically or programmatically, can I determine this? What is the logic? I don't even know what words to use to describe the problem.
This looks like a rather complex problem; maybe some algorithm already exists, IDK.
Approach 1: grid positioning.
One approach could start with trying to position the rectangles on a grid whose mesh size will have to be calculated; maybe a best fit to the size of the rectangles (H & W, or surface, maybe?)
Once a reasonable grid has been determined, it must be appropriately placed over the rectangles; maybe in such a way that minimizes row overlap and column overlap of the rectangles?
The last step would consist of traversing the grid row by row, and assigning a label to each rectangle; maybe based on the max common surface shared by a grid cell and a rectangle?
There will be many edge cases to identify and resolve.
Approach 2: sweep line.
Alternatively, a sweep line numbering of the rectangles from N, S, E, and W, and an appropriate weighting/averaging of the numbering of the rectangles from each direction, might give good results?
It may require several passes, after identifying what could be rows and columns, in order to find a "best fit".
This second approach is likely easier to implement.

Masonry: Fit Width but maintain maximum container size?

Per the example in the Masonry documentation, http://masonry.desandro.com/options.html, I centre my Masonry layout by setting isFitWidth = true, and setting {margin: 0 auto} on the Masonry container.
When I have loads of items to display this is a really nice solution. For example, let's say my viewport is just over 5 columns wide, I will see all the items laid out, 5 to a row, and the whole container centred within my viewport. Lovely.
The problem arises when I have less than 5 items. In this case, the container remains centred in the viewport, but it shrinks to fit the number of items. So if I have, for example, two items, I will have two columns in the middle of the screen, with one item each.
What I would like to see is the container maintain is size (in this example, 5 columns), and remain centred, and lay the content out LTR (in my case).
I have experimented with media queries and setting a minimum width for the container based on the viewport. This looks like it will work, but it's messy - I don't fancy having to update the media queries (including recalculating all the gross container widths) each time my column size changes. (I'm sure users will want some changes).
Another solution might be to add some fake items to the content and set their visibility to hidden, but this is not exactly elegant either.
Is there a more simple solution that I'm missing?
One additional point - I am stamping some items in place too, top left and top right. I don't think this should affect any solutions.
OK, So the only way I could find to do this effectively was to use media queries. I setup a spreadsheet to help recalculate things when I changed column and gutter sizes. Here's the variables and equations, in case they are helpful:
If:
WC = Width of column
WG = Width of gutter
N = Number of columns
CON = Width of container
Then:
CON = N*WC + (N-1)*WG
You can set up a spreadsheet and experiment with WC and WG, and a range of N=1...10 This will give you the size of CON for each value of N. The width of the viewport needs to be CON plus any horizontal margin and padding on CON (or its parent).
To set media queries I took the approach that the container should be as wide as possible, but still neatly accommodate exact columns. So, for example, if the viewport can accommodate 5 columns, (but not quite 6), I set the corresponding min-width on CON. This leave the container neatly centred.
By way of example, here is one of my media queries:
#media (min-width: 996px) and (max-width: 1361px) { .content-container { min-width: 966px; } }
I hope this is helpful to someone. I'll leave the question open for a few days in case there are other solutions forthcoming.

iOS Auto Layout: Distribute remaining space of a superview to its subviews

With iOS Auto-Layout each element inside a superview can have a relative size (e.g. element A is twice as wide as element B, element C is half as wide as element A...).
What I want to do differs a bit from the approach described above.
Imagine each element has an absolute width. The sum of all widths is less then the width of their superview. According to the element's weight value (A.weight = 2; B.weight=1; C.weight = 1;), I would like to distribute the remaining space. Is their any possibility to get the remaining space, although the width of the superview is unknown?
Thanks in advance!

Summed area table vs Mipmap

Summed area table is a pre-filtering technique to avoid aliasing in texture map. I would like to know how it works and what are the advantages and disadvantages over Mipmap. Thanks
A summed area table replaces the X*Y texture, T, with an X*Y set of values, S, where entry x,y in S is the sum of all pixels of T contained in the axis-aligned rectangle from [0,0] to [x, y] inclusive.
Given that you want to compute the average of an arbitrary axis-aligned rectangle of pixels of T, you just need to sample the corner locations in S and do some trivial additions and subtractions. (Hmm. It seems that wikipedia sums (pun intended) this up quite succinctly)
The advantages of the SAT is that it will quickly give you the correct results for any arbitrary axis-aligned rectangle (rather than being limited to power-of-2 squares as in MIP mapping) but
You won't get automatic hardware support as you do with MIP maps
the SAT can be huge because, assuming you start summing from the top left texel, the bottom right needs to be able to equal the sum of all the texels. For a 1K*1K texture, you'd need 11 extra bits of precision per channel!

Resources