This repository contains the solutions to three technical assessment tasks. Each solution is provided in a separate folder with the associated code and test cases.
- Task 1: Contains the implementation of the Train Composition problem using a doubly linked list.
- π
trainComposition_linkedlist.js
: The JavaScript code that implements the Train Composition. - π
trainComposition.test.js
: The test file with several test cases to validate the implementation.
- π
- Task 2: Contains the SQL queries for two questions.
- π
queries.txt
: A text file with SQL queries.
- π
- Task 3: Contains the implementation of the Tic-Tac-Toe game.
- π
tic-tac-toe.js
: The JavaScript code that implements the Tic-Tac-Toe game. - π
tic-tac-toe.test.js
: The test file with several test cases to validate the game implementation.
- π
The Train Composition problem is implemented using a doubly linked list. The Train
object has two methods attachWagonFromLeft
and attachWagonFromRight
, which take an integer (the wagon ID), and attach it to the left or right side of the train, respectively. It also has methods detachWagonFromLeft
and detachWagonFromRight
which remove and return the wagon ID from the left or right side of the train, respectively.
The tests ensure that the Train
object behaves correctly when attaching and detaching wagons.
This task involves writing SQL queries for a relational database containing the tables CUSTOMER
, SALES
, and VIP
. The queries are stored in a text file (queries.txt
) and include:
- A query that shows total sales by customer.
- A query that creates a list of customers that are not VIPs.
This task involves implementing a Tic-Tac-Toe game in JavaScript. The Game
class is able to keep track of a game's state and tell you if the game has been won or not. The game can be played on a board of any size. The move
method allows a player with a given ID to make a move at specified x and y coordinates.
The tests ensure that the game behaves correctly when making moves, and that it correctly identifies winning conditions or a tie.
To run the tests for Task 1 and Task 3, follow these steps:
- Open a terminal or command prompt.
- Navigate to the directory containing the repository.
- Run
npm install
to install the necessary dependencies. - Navigate to the specific task directory where you want to run the tests (e.g.,
Task 1
orTask 3
). - Run
npm test <test-filename>
to run the tests for that task. Replace<test-filename>
with the appropriate test file name (e.g.,trainComposition.test.js
ortic-tac-toe.test.js
).
Chinmay Tagade