Skip to content

Instantly share code, notes, and snippets.

@AlessandroMinali
Last active October 21, 2023 02:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save AlessandroMinali/f61197377f1db1ce24dc724ef6104658 to your computer and use it in GitHub Desktop.
Save AlessandroMinali/f61197377f1db1ce24dc724ef6104658 to your computer and use it in GitHub Desktop.
Interview Question Sample - I/O, DB, Data Structs, Algorithms

You are tasked with writing the code that generates license plates for the province of Ontario.
You can use any language and tools you are comfortable with to accomplish the task.

Here are some examples of valid plate numbers:

skfz 597
lxgq 621
lxna 211
uixq 289
boiq 999

A valid plate number has the following properties:

  1. 4 letters followed by 3 digits
  2. Letters must be from the english alphabet

Running your program should produce a valid plate number. The following features must be implemented:

  1. Your program must not return a plate number that has been previously returned(hint: use a DB)
  2. Your program must not return a plate number that contains the same three letter times in a row(ie. AAA, BBB, etc)
  3. Your program must not return a plate number that contains any explicit english word(you may use dict.txt for this purpose)
  4. Your program, if given a valid plate number, must be able to return the next valid plate number in the alphanumeric sequence that has not yet been seen(ie. given "uixq 289" it returns "uixq 290" or given "boiq 999" it returns "boir 000")

You program should gracefully handle any input from a user.
You should be writing tests to confirm that your program is working as intended.

Questions

  1. How many plate numbers can be generated with this scheme?
  2. How should the Ontario government handle the problem when all plate numbers have been taken?

Answer 1:

(26**4 * 1000) - # normal plates
(26 * 2 * 1000) - # minus triples
218 # minus words 3 or 4 letters long =>
456_923_782

Answer 2:

Allow the first digit also be alpha char

Discussion

What part did you find hard to implement? Why?

What parts of your program are inefficient? How could we make it faster? How could we make it use less memory?

How did you ensure there are no duplicates? What storage solution did you use and why? Did you enforce anything via the DB?

What happens if I give your program an invalid plate number? What happens if I give your program "zzzz 999"?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment