Two tasks were given to me from Adludio to evalutate my technical skills as a junior developer.
I was given three days to complete the tasks:
- Task 1: Mainly Front End - see related repository Adludio client
- Task 2: Backend - this repository
- "ODIDULA" That's a string of letters. If we were to create an array of all the possible permutations of these letters, sort them alphabetically and remove repetitions, which index would ADLUDIO be at? :)
Create a single REST JSON endpoint that solves that puzzle GET /permutation-index/{someStringHere}
The endpoint will respond with a json object with one key:
{ "indexOfGivenPermutation": 34 }
And the value 34 above is an example of the position of the given permutation in a sorted array of all permutations (when repetitions are omitted)
For example:
Request GET /permutation-index/LABA
Response { "indexOfGivenPermutation": 11 }
- Express, Sequelize, bcrypt, cors, pg
Note You will need to create a container on your computer for the database. I've used Docker
- Clone this repo
git clone https://github.com/evelinawahlstrom/ad-assignment-server
-
cd into adludio-server
-
In your terminal, run the following command to install all the dependencies
npm install
- To start the terminal with nodemon, use the following command (assumes nodemon is installed globally)
nodemon index
- To start the code without tracking saved changes, you can simply run:
node index
As a standard I'm using port 4000 for this server.
- Start the database
With the help of docker, connect with the password 'secret'
- router.post/'register' for registering, the password will be encrypted with the help of bcrypt
- router.get/'/permutation-index/ADLUDIO' will create an array of all possible combinations, sort them alphabetically and then find the index of ADLUDIO leading to a response as a json object (see gif below)