> ## Content Index
> Fetch the complete content index at: https://developerinsider.co/llms.txt
> Use this file to discover other available public pages before exploring further.

# GoJek Parking Lot Assignment using Python
- URL: https://developerinsider.co/gojek-parking-lot-assignment-using-python/
- Published: 2019-09-20T18:30:00.000Z
- Updated: 2021-12-26T16:06:26.000Z
- Author: Guest
- Tags: Interview, Python, GoJek

## 1\. Problem Statment

Design a Parking lot which can hold `n` Cars. Every car been issued a ticket for a slot and the slot been assigned based on the nearest to the entry. The system should also return some queries such as:

- Registration numbers of all cars of a particular colour.
- Slot number in which a car with a given registration number is parked.
- Slot numbers of all slots where a car of a particular colour is parked.

#### Disclaimer

This solution is for reference purpose. Please, do not copy-paste it. Companies are smart enough to catch if you are cheating. If your solution got rejected due to this we're not responsible for it.

## 2\. Solution Approach

A car consist of Registration number, slot number and it's colour. Likewise our Parking Lot consist slots. For not making it too complicated, I choose a python dictionary for storing cars on slots and implemented the functionalities as accordingly.

The solution of above problem statement is available [here](https://github.com/developerinsider/InterviewAssignments/tree/master/Go-Jek/Go-Jek-Parking-Lot-Assignment-Python?ref=developerinsider.co). You can directly download this solution from [here](https://developerinsider.co/downloading/?download=https://github.com/developerinsider/InterviewAssignments/releases/download/v1.0.1/Go-Jek-Parking-Lot-Assignment-Python.zip?raw=true&after=https://developerinsider.co/ios-insider/).

## 3\. Supported Commands

- `create_parking_lot` <`n`\>  
To create a Parking lot. Where `n` is the size of the parking lot
- `park` <`registration_number`\> <`colour`\>  
To park the car in the parking lot and prints the allocated slot in the parking lot. Where `registration_number` is given registration number for the car and `colour` is given colour for the car
- `leave` <`slot`\>  
To leave the parking lot from desired slot and prints the leaving slot. given slot number. Where `slot` is given sloat number
- `status`  
To check the status of Parking Lot
- `slot_numbers_for_cars_with_colour` <`colour`\>  
To prints the registration number of the cars for the given colour. Where `color` is given colour
- `slot_number_for_registration_number` <`registration_number`\>  
prints the slot number of the cars for the given number. Where `registration_number` is given registration number.
- `registration_numbers_for_cars_with_colour` <`colour`\>  
To prints the slot number of the cars for the given colour. Where `colour` is given colour.

## 4\. Running Application

#### 4.1 Running the application in File mode:

```python
./ParkingLot.py input.txt

```

#### 4.2 Running the application in Interactive mode:

```python
./ParkingLot.py

```

## 5\. Test Cases

- Total number of test cases - 14
- Code coverage - 86%

#### 5.1 For running the tests

```python
python Tests.py

```

#### 5.2 For calculating code coverage

```python
coverage run Tests.py 
coverage report

```

![](https://github.com/developerinsider/InterviewAssignments/blob/master/Go-Jek/Go-Jek-Parking-Lot-Assignment-Python/docs/CodeCoverage.png?raw=true)

## 6\. Running the application in a Docker Container

#### Build the image:

```python
docker build -t parkinglot:1.0 .

```

#### 6.1 Running the application in Interactive mode:

```python
docker run -it parkinglot:1.0 ./ParkingLot.py

```

#### 6.2 Running the application in File mode:

```python
docker run -it parkinglot:1.0 ./ParkingLot.py input.txt

```