https://github.com/cedrickchee/go-parkinglot
Go solution for parking lot algorithm and design problem
Science Score: 13.0%
This score indicates how likely this project is to be science-related based on various indicators:
-
○CITATION.cff file
-
✓codemeta.json file
Found codemeta.json file -
○.zenodo.json file
-
○DOI references
-
○Academic publication links
-
○Academic email domains
-
○Institutional organization owner
-
○JOSS paper metadata
-
○Scientific vocabulary similarity
Low similarity (9.7%) to scientific vocabulary
Keywords
Repository
Go solution for parking lot algorithm and design problem
Basic Info
- Host: GitHub
- Owner: cedrickchee
- Language: Go
- Default Branch: master
- Size: 23.4 KB
Statistics
- Stars: 1
- Watchers: 2
- Forks: 0
- Open Issues: 0
- Releases: 0
Topics
Metadata Files
README.md
Parking Lot Algorithm
Intro
This project describes and solves a straighforward yet intricate problem of assigning vehicle slots using the appropriate data structures and Object-Oriented Programming patterns, in Go.
Problem
John owns a multi-storey parking lot that can hold up to n vehicles at any given point in time. The parking slots are numbered, beginning at 1 and increases with increasing distance from the entry point in steps of one. John has requested your help to design an automated ticketing system for his parking lot.
When a vehicle enters the parking lot, its vehicle registration number (i.e., number plate) and colour are noted. Then, an available parking slot is allocated. Following are the rules of parking slot ticket issuance:
- Each customer should be allocated the nearest available parking slot to the entry point.
- Upon exiting the parking lot, the customer returns the ticket which marks their previously allocated lot as now available.
- Due to government regulation, the system should provide the ability to determine:
- 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.
The ticketing system should be operable via two modes of input, namely, interactive commands and commands from a file. In other words, the ticketing system should be an executable which accepts:
- Interactive commands from an interactive command prompt shell
- A filename as an input argument at the command prompt and executes the commands from the given file
Example below includes all the commands which need to be supported.
Example: File Input
Launch the command line and run the code so it accepts input from a file:
sh
$ parking_lot input_file.txt
Input (contents of inputfile.txt_ file):
sh
create_parking_lot 6
park KA-01-HH-1234 White
park KA-01-HH-9999 White
park KA-01-BB-0001 Black
park KA-01-HH-7777 Red
park KA-01-HH-2701 Blue
park KA-01-HH-3141 Black
leave 4
status
park KA-01-P-333 White
park DL-12-AA-9999 White
registration_numbers_for_cars_with_colour White
slot_numbers_for_cars_with_colour White
slot_number_for_registration_number KA-01-HH-3141
slot_number_for_registration_number MH-04-AY-1111
Output (to STDOUT):
sh
Created a parking lot with 6 slots
Allocated slot number: 1
Allocated slot number: 2
Allocated slot number: 3
Allocated slot number: 4
Allocated slot number: 5
Allocated slot number: 6
Slot number 4 is free
Slot No. Registration No Colour
1 KA-01-HH-1234 White
2 KA-01-HH-9999 White
3 KA-01-BB-0001 Black
5 KA-01-HH-2701 Blue
6 KA-01-HH-3141 Black
Allocated slot number: 4
Sorry, parking lot is full
KA-01-HH-1234, KA-01-HH-9999, KA-01-P-333
1, 2, 4
6
Not found
Example: Interactive
To run the code, launch the command line, and the program will accept interactive input:
sh
$ parking_lot
Assuming a parking lot with n=6 slots, the following commands should be run in sequence by typing them in at a prompt and should produce output as described below the command. Note that exit terminates the process and returns control to the shell.
```sh $ createparkinglot 6 Created a parking lot with 6 slots
$ park KA-01-HH-1234 White Allocated slot number: 1
$ park KA-01-HH-9999 White Allocated slot number: 2
$ park KA-01-BB-0001 Black Allocated slot number: 3
$ park KA-01-HH-7777 Red Allocated slot number: 4
$ park KA-01-HH-2701 Blue Allocated slot number: 5
$ park KA-01-HH-3141 Black Allocated slot number: 6
$ leave 4 Slot number 4 is free
$ status Slot No. Registration No Colour 1 KA-01-HH-1234 White 2 KA-01-HH-9999 White 3 KA-01-BB-0001 Black 5 KA-01-HH-2701 Blue 6 KA-01-HH-3141 Black
$ park KA-01-P-333 White Allocated slot number: 4
$ park DL-12-AA-9999 White Sorry, parking lot is full
$ registrationnumbersforcarswith_colour White KA-01-HH-1234, KA-01-HH-9999, KA-01-P-333
$ slotnumbersforcarswith_colour White 1, 2, 4
$ slotnumberforregistrationnumber KA-01-HH-3141 6
$ slotnumberforregistrationnumber MH-04-AY-1111 Not found $ exit ```
Solution
Model
TODO
Parking Lot
TODO
Slot
TODO
Vehicle
TODO
Installation Instructions
Assuming you have setup Go environment.
- Source code
- Git clone the project into a directory in your computer.
sh git clone https://github.com/cedrickchee/go-parkinglot.git cdinto the reposh cd go-parkinglot
- Git clone the project into a directory in your computer.
- Binary
- To create an executable binary in the
$GOPATH/bin/directory, executesh go install parking_lot
- To create an executable binary in the
- Unit test and functional test
- To run complete test suite, run
sh go test -v parking_lotHere,-vis the verbose command flag. - To run specific test, run
sh go test -v parking_lot -run xxxHere,xxxis the name of test function.
- To run complete test suite, run
- Running
- Launch interactive user input mode by executing
sh $GOPATH/bin/parking_lot - Launch file input mode by executing
sh $GOPATH/bin/parking_lot $GOPATH/src/github.com/cedrickchee/go-parkinglot/data/input_file.txtHere,$GOPATH/src/github.com/cedrickchee/go-parkinglot/data/input_file.txtrefers to the input file with complete path.
- Launch interactive user input mode by executing
Project Structure
TODO
API
TODO
Owner
- Name: Cedric Chee
- Login: cedrickchee
- Kind: user
- Location: PID 1
- Company: InvictusByte
- Website: https://cedricchee.com
- Twitter: cedric_chee
- Repositories: 227
- Profile: https://github.com/cedrickchee
Lead Software Engineer | LLMs | full stack Go/JS dev, backend | product dev @ startups | 🧑🎓 CompSci | alumni: fast.ai, Antler.co
GitHub Events
Total
- Watch event: 2
Last Year
- Watch event: 2
Issues and Pull Requests
Last synced: 12 months ago
All Time
- Total issues: 0
- Total pull requests: 0
- Average time to close issues: N/A
- Average time to close pull requests: N/A
- Total issue authors: 0
- Total pull request authors: 0
- Average comments per issue: 0
- Average comments per pull request: 0
- Merged pull requests: 0
- Bot issues: 0
- Bot pull requests: 0
Past Year
- Issues: 0
- Pull requests: 0
- Average time to close issues: N/A
- Average time to close pull requests: N/A
- Issue authors: 0
- Pull request authors: 0
- Average comments per issue: 0
- Average comments per pull request: 0
- Merged pull requests: 0
- Bot issues: 0
- Bot pull requests: 0