Skip to content

Instantly share code, notes, and snippets.

@SeanOC
Last active December 24, 2015 22:49
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save SeanOC/27d0816861d740d3b9a5 to your computer and use it in GitHub Desktop.
Save SeanOC/27d0816861d740d3b9a5 to your computer and use it in GitHub Desktop.
bitly Application Engineering Test

Programming Skills Test

Below are four problems (two general CS questions, and two focused on using web APIs). Please read through all of the problems and make sure you understand them. If you have any questions about the problems, please get in touch with me before starting on the test.

Please finish the test to the best of your ability. It takes most people 2-3 hours to finish.

The problems may be solved using any programming language.

Please package your submission as you would package any code that you'd like to hand off to any other developer -- obviously runnable and testable.

Thank you, good luck, and have fun!

General CS Problems

Solve these using any programming language you’d like.

1. Text Blocking

Each element of text is a line of prose from some passage. You will return a string that is read downward, as opposed to left-to-right. That is, the first element of text will correspond to the first "column" of the returned string, and so forth.

Constraints

  • text will contain between 1 and 50 elements, inclusive.

  • Each element of text will contain between 1 and 50 characters, inclusive.

  • Each element of text will contain the same number of characters.

  • Each character in text will be an uppercase letter ([A-Z]).

Examples

Input:

["AAA",
 "BBB",
 "CCC"]

Output:

["ABC", "ABC", "ABC"]

So, rows of the input become columns of the output.

Input:

["AAAAAAAAAAAAA"]

Output:

["A",
 "A",
 "A",
 "A",
 "A",
 "A",
 "A",
 "A",
 "A",
 "A",
 "A",
 "A",
 "A"]

Input:
 
["A",
 "A",
 "A",
 "A",
 "A"]

Output:

["AAAAA"]

2. Race Average

There is a sailboat race from Rhode Island to Bermuda. It takes several days. Take a list of the times when the competitors crossed the finish line and convert that into the average number of minutes to complete the race.

The race starts on day 1 at 8:00 AM.

We are given a list of finish times as a string, where each finish time is formatted as

hh:mm xM, DAY n

where hh is exactly 2 digits giving the hour, mm is exactly 2 digits giving the minute, x is either 'A' or 'P', and n is a positive integer less than 100 with no leading zeros. So each string has exactly 15 or 16 characters (depending on whether n is less than 10).

Create a class RaceAverage containing a method avgMinutes that is given a list of strings, times, and that returns the average number of minutes taken by the competitors to complete the race. Round the returned value to the nearest minute, with .5 rounding up.

Notes

  • "12:00 AM, DAY d" refers to midnight between DAY d-1 and DAY d

  • "12:00 PM, DAY d" refers to noon on DAY d

Constraints

  • times contains between 1 and 50 elements inclusive

  • each element of times is formatted as specified above, with hh between 01 and 12 inclusive, mm between 00 and 59 inclusive, and d between 1 and 99 inclusive

  • each element of times represents a time later than the start of the race.

Examples

Input:

["12:00 PM, DAY 1",
 "12:01 PM, DAY 1"]

Output:

241

From 8:00 AM to noon is 4 hours, so we have 4 hours for one competitor, and 4 hours, 1 minute for the other. These two values average to 240.5 minutes, which is rounded up.

Input:

["12:00 AM, DAY 2"]

Output:

960

The one competitor finished in 16 hours, just at the start of DAY 2.

Input:

["02:00 PM, DAY 19",
 "02:00 PM, DAY 20",
 "01:58 PM, DAY 20"]

Output:

27239

API Use Problems

Use any language to solve these problems but you should not use any bitly API specific client libraries (e.g. bitly_api).

For reference you can find the docs for the bitly API at http://dev.bitly.com/.

1. Hot Phrases

One of the more interesting API endpoints offered by bitly is the hot phrases API. This endpoint returns a list of phrases and related content which is currently receiving a significant amount of clicks.

Query this endpoint to get the current hot phrases and return the top 5 phrases based on click rate. The final values returned should just be the phrases and none of the other data returned by the endpoint.

Below is a sample of what the output should look like (your phrases will be different but format should be the same):

breaking bad
miley cyrus
government shutdown
injury status of starting cornerbacks rashean mathis and chris houston
key questions

2. High Value Links

Another interesting API endpoint that bitly provides is the high value API. Similar to the hot phrases endpoint, the high value endpoint provides bitly links that are receiving a lot of attention right now.

Use the high value endpoint along with other parts of the bitly API to return a list of 10 high value links, along with the number of clicks each link has received in the last day.

Below is a sample of what the output should look like:

http://bit.ly/15clwC2 - 432
http://bit.ly/WT7zYR - 53
http://bit.ly/15BC7mu - 143
http://bit.ly/1eNqttq - 43
http://bit.ly/16qV1yX - 98
http://bit.ly/yGi1de - 483
http://bit.ly/1beexgs - 992
http://bit.ly/1bWh15V - 102
http://bit.ly/1bHafRm - 896
http://bit.ly/162Stn - 423

Again the specific links and counts you return will be different but the format should be the same.

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