packing

Text packing algorithm

前提是你 提交于 2019-11-27 06:08:22
问题 I bet somebody has solved this before, but my searches have come up empty. I want to pack a list of words into a buffer, keeping track of the starting position and length of each word. The trick is that I'd like to pack the buffer efficiently by eliminating the redundancy. Example: doll dollhouse house These can be packed into the buffer simply as dollhouse , remembering that doll is four letters starting at position 0, dollhouse is nine letters at 0, and house is five letters at 3. What I've

fitting n variable height images into 3 (similar length) column layout

若如初见. 提交于 2019-11-27 04:27:08
I'm looking to make a 3-column layout similar to that of piccsy.com . Given a number of images of the same width but varying height, what is a algorithm to order them so that the difference in column lengths is minimal? Ideally in Python or JavaScript... Thanks a lot for your help in advance! Martin How many images? If you limit the maximum page size, and have a value for the minimum picture height, you can calculate the maximum number of images per page. You would need this when evaluating any solution. I think there were 27 pictures on the link you gave. The following uses the first_fit

Packing different sized circles into rectangle - d3.js

喜夏-厌秋 提交于 2019-11-26 19:47:35
I was trying to pack circles of different sizes into a rectangular container , not packing in circular container that d3.js bundled with, under d3.layout.pack . here's the layout I want to achieve: I've found this paper on this matter, but I am not a math guy to understand the article throughly and convert them into code… Anyone can suggest where I should start to convert this into d3.js layout plugin, or if you have visualized bubbles similar to this layout, please suggest any direction you took to solve that. Thank you. Here is a go at the implementation of your algorithm. I tweaked it quite

What algorithm can be used for packing rectangles of different sizes into the smallest rectangle possible in a fairly optimal way?

旧巷老猫 提交于 2019-11-26 11:27:28
Ive got a bunch of rectangular objects which I need to pack into the smallest space possible (the dimensions of this space should be powers of two). I'm aware of various packing algorithms that will pack the items as well as possible into a given space, however in this case I need the algorithm to work out how large that space should be as well. Eg say Ive got the following rectangles 128*32 128*64 64*32 64*32 They can be packed into a 128*128 space _________________ |128*32 | |________________| |128*64 | | | | | |________________| |64*32 |64*32 | |_______|________| However if there was also a

Packing different sized circles into rectangle - d3.js

给你一囗甜甜゛ 提交于 2019-11-26 07:26:31
问题 I was trying to pack circles of different sizes into a rectangular container , not packing in circular container that d3.js bundled with, under d3.layout.pack . here\'s the layout I want to achieve: I\'ve found this paper on this matter, but I am not a math guy to understand the article throughly and convert them into code… Anyone can suggest where I should start to convert this into d3.js layout plugin, or if you have visualized bubbles similar to this layout, please suggest any direction

What algorithm can be used for packing rectangles of different sizes into the smallest rectangle possible in a fairly optimal way?

孤街浪徒 提交于 2019-11-26 03:32:09
问题 Ive got a bunch of rectangular objects which I need to pack into the smallest space possible (the dimensions of this space should be powers of two). I\'m aware of various packing algorithms that will pack the items as well as possible into a given space, however in this case I need the algorithm to work out how large that space should be as well. Eg say Ive got the following rectangles 128*32 128*64 64*32 64*32 They can be packed into a 128*128 space _________________ |128*32 | |_____________

Structure padding and packing

允我心安 提交于 2019-11-25 22:15:30
问题 Consider: struct mystruct_A { char a; int b; char c; } x; struct mystruct_B { int b; char a; } y; The sizes of the structures are 12 and 8 respectively. Are these structures padded or packed? When does padding or packing take place? 回答1: Padding aligns structure members to "natural" address boundaries - say, int members would have offsets, which are mod(4) == 0 on 32-bit platform. Padding is on by default. It inserts the following "gaps" into your first structure: struct mystruct_A { char a;