Skip to content
This repository has been archived by the owner on Jun 15, 2020. It is now read-only.

Latest commit

 

History

History
66 lines (48 loc) · 1.56 KB

task.org

File metadata and controls

66 lines (48 loc) · 1.56 KB

Coding Challenge

Overview

Create a service which fetches data from an endpoint (provided by our challenge docker container) at x second intervals and caches the newest result in memory.

Run the challenge docker container

docker run -p 8080:80 21re/coding-challenge

Our Endpoint

GET / on the docker container returns a list of items separated by a \n character.

» curl localhost:8080 | head
   N
   N
   N
   N
   A
   A
   A
   A
   A
   ...

Service Endpoint

Your App should expose an HTTP endpoint that allows clients to access the cached data at a given index

  • use HTTP framework of your choice
  • GET /$index return an item at a given index (start at 0 or 1)
  • Please provide instructions in a README file explaining how to run your server locally
    » curl localhost:1337/1
       N
    » curl localhost:1337/7
       A
        

Compression

Items returned by endpoint A will contain repeated characters at high frequencies. Your cache should use Run-length encoding (RLE) compression for internal storage in memory.

You can use this code as a starting point:

trait Compressor {
 def compress[A]: ??? => Seq[Repeat[A]]
}

case class Repeat[A](count: Int, element: A)

Constraint

Please use a statically typed language adequate for the position you are applying to.