Blog

JavaScript – Binary Search

The following is an implementation of a binary search for arrays which gives you the ability to do fuzzy matches (default), exact matches, or specify your own comparison function: I used the following to test the normal execution of this binary function:

By Chris West, ago
Blog

POW – Disarm A Bomb with Water

You are police officer who just showed up to a crime scene where the instructions for disarming a bomb are left.  The bomb is sitting in front of a large fountain of water.  Also, two large bottles are near the bomb.  One bottle has a capacity of 5.2 gallons while Read more…

By Chris West, ago
JavaScript

POW Answer – Unnamed Function #1

The answer to last week’s Problem of the Week is that the following definitions represent the factorial of the given non-negative integer: Mathematical Definition Function Definition Condition unnamed(n) = 1 if n = 0 n × unnamed(n – 1) if n > 0 JavaScript Definition Although it may have been Read more…

By Chris West, ago
Blog

POW – Unnamed Function #1

This Problem of the Week involves determining the identity of a well-known mathematical function by examining the algorithm used on the input number to produce the output.  The function will only accept integers that are greater than or equal to zero. The following is the mathematical definition of the function: Function Definition Condition Read more…

By Chris West, ago
Blog

POW – Working Together

Both Don and Juan and are given a task on which they must work together to complete in a timely fashion. It takes Don 75 minutes to do the job by himself. It takes Juan 60 minutes to do the job by himself. At their speed, how long would it Read more…

By Chris West, ago
Blog

Quick JavaScript Encryption Method

Recently, I have been interested in creating a quick one-way encryption method. After playing around with a lot of different variations, I settled on the following: One nice thing about this function is the fact that you can restrict the encrypted message to a certain length. Another interesting thing is Read more…

By Chris West, ago