Coding Challenge #17

Coding Challenge Series / Technical Interview Series

You are writing code for an embedded system. There are some restrictions on memory and I/O that you must follow.

Your challenge is to create a file search function. The function is provided an ASCII string and the name of the file. The file API follows this pattern:

array = ReadFile(filename, startindex)

Notice how there isn’t a length? :)  The ReadFile function returns 64 bytes at a time (as possible). You may not keep more than 64 bytes of the file in memory at any time. (No double buffering, etc.). The data in the file is represented as ASCII characters. Additionally, a block of memory may only be read once.

To get the file length, a function is provided:

length (integer) = FileLength(filename)

The search string may be longer than 64 characters.

Coding Challenge #16

Coding Challenge Series / Technical Interview Series

You’re given the size of a rectangle, with a width and a height. The X = 0 and Y = 0 point is located in the upper left with the width and height in the lower right. The function you must write takes an array of rectangles (left, top, width, height). Return a list of intersecting rectangle groups. If, for a example, a rectangle is not overlapping, it should be considered a group of one. If two rectangles overlap/intersect, create a rectangle which is inclusive of all points within the two rectangles, and return that as a group, and so on.

A rectangle can be in only one group/set.