Skip to content

Instantly share code, notes, and snippets.

@brainkim
Last active November 21, 2016 12:29
Show Gist options
  • Save brainkim/96fc27c8e7a0e6212cee51fc49cf425d to your computer and use it in GitHub Desktop.
Save brainkim/96fc27c8e7a0e6212cee51fc49cf425d to your computer and use it in GitHub Desktop.
frontend-puzzle.md

Okay you have an array of concentric rectangles: each concentric rectangle has a type:

{
 outer: {
   width,
   height,
 },
 inner: {
   width,
   height,
   x,
   y,
 }
}

where outer is the outer rectangle, inner is the inner rectangle, inner's x and y are the position of the inner rectangle relative to the top left corner of the outer rectangle.

Write an algorithm that lines up rectangles horizontally based on the bottom edge of the inner rectangle, and calculates the min height of a container and x,y offsets of each rectangle within the container. Do no scale any individual rectangle, they must be kept in proportion to each other.

@brainkim
Copy link
Author

real use-case: lining up iphone mocks
screen shot 2016-11-21 at 7 18 08 am

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment