FCC algorithm solutions

The following algorithms are my solutions to Free Code Camps javascript algorithms and data structures certification (300 hours).

Verify certification - link

View my certificate - image

Certificate

Palindrome Checker

A palindrome is a word that stays the same whether it is read forwards or backwards e.g. level.



See the original, warts and all code - (including debugging notes).

palindrome related image palindrome related image palindrome related image

Roman Numeral Converter

Remember your roman numerals from school? This converts our regular numbers (actually known as the Hindu-Arabic system) into roman numerals.



See the original, warts and all code - (including debugging notes).

roman related image roman related image roman related image

Caesars Cipher

When Julius Caesar wanted to send secret messages he encrypted them. One method of doing this is by shifting each letter of the message along a certain number of places in the alphabet. The original FCC test required that the text to be encoded was uppercase, though I have changed this here to make the demonstration more user friendly.



See the original, warts and all code - (including debugging notes).

roman related image

Telephone number validator

This checks if the telephone number is valid based on the differents formats it might be typed in. Number entered here must be a valid US number. The following are examples of valid formats for US numbers:



See the original, warts and all code - (including debugging notes).

phone related image phone related image phone related image

Cash Register

This works like a till - input the price of an item and the cash given, and the algorithm calculates the most efficient change to be returned from the available change in the till. This will also return "open" if the till still contains change, "closed" if the transaction requires exactly all of the available change in the till, or "insufficient funds" if the change available is insufficient.

At the time this was by far the most challenging of the algorithms to build, as is reflected in the complexity (and perhaps inefficiency) of the orignial code.

Note: This is not the most user friendly test, as this algorithm works with a variable amount of "cash in draw", however to save you the effort of filling in lots of boxes I've preset it here to one of the original values used to pass the certification. The maximum change available is $335.41

Change in till set to: [["PENNY", 1.01], ["NICKEL", 2.05], ["DIME", 3.1], ["QUARTER", 4.25], ["ONE", 90], ["FIVE", 55], ["TEN", 20], ["TWENTY", 60], ["ONE HUNDRED", 100]]


See the original, warts and all code - (including debugging notes).

till related image till related image till related image


Some notes on the algorithms

I have avoided making additional changes to the algorithms in order to accurately demonstrate the requirements of the Free Code Camp certification. As such there is room for improvement in these algorithms e.g. the cash register is not designed to respond appropriately if cash recieved is lower than the price, the palindrome checker will treat an empty string as a palindrome, etc. These algorithms passed all the required tests in order obtain certification, in a "real-world" setting they would benefit from refactoring.

I wanted to show case here the requirements of the certification, demonstrate the skills gained during the study, and incorperate the solutions into a working webpage allowing user interaction.