Skip to content

Commit

Permalink
Merge pull request florinpop17#61 from florinpop17/feature/bit-masks-app
Browse files Browse the repository at this point in the history
Feature: Add Bit Mask app specification
  • Loading branch information
florinpop17 authored Apr 24, 2019
2 parents fa5386d + aa2d386 commit 1ea3aa0
Show file tree
Hide file tree
Showing 2 changed files with 77 additions and 0 deletions.
76 changes: 76 additions & 0 deletions Projects/Bit-Masks-App.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
# Bit Masks

**Tier:** 2-Intermediate

It's difficult to find an app that doesn't rely on some form of conditional
logic to implement its functionality. This is almost always performed using
statements like:
```
if (processAccount === true) {
/* do something */
}
```
If and switch statements work well for a limited number of conditionals, but
what if your app had 10's or 100's of conditionals to evaluate? Luckily, there's
another way.

The goal of the Bit Masks app is demonstrate how to use bit masks to evaluate
longer sequences of switches without having to rely on long strings of
conditional statements.

## User Stories

- [ ] User can see a vertical list of checkboxes with the following cities
and their timezones:
- Moscow: GMT +3
- Paris: GMT +2
- Berlin: GMT +2
- Brussels: GMT +2
- Amsterdam: GMT +2
- Rome: GMT +2
- London: GMT +1
- Dublin: GMT +1
- New York: GMT -4
- Washington, DC: GMT -4
- St. Louis: GMT -5
- Los Angeles: GMT -7
- Tokyo: GMT +9
- Beijing: GMT +8
- Ho Chi Mihn City: GMT +7
- Mumbai: GMT +5
- [ ] User can see a GMT search box that an integer representing a GMT offset
can be entered into and a 'Find Cities' button.
- [ ] User can click the 'Find Cities' button to display the names of the
cities in that GMT offset in an output area.

### Developer Notes

For this exercise the developer should use sequences of 24
binary bits, each corresponding a GMT time zone from +12 to -12 to map cities
to their timezones.

Searches should be conducted by combining a bit mask for the desired time zone
against the city-specific bit sequences to identify matches. Determining if a
city meets the search criteria shouldn't rely on a statement such as
```
if (city[i].gmtOffset === searchOffset ) {
/* Found it! */
}
```
It should instead rely on a bitwise operation.

## Bonus features

- [ ] User can search for cities NOT in the GMT offset entered in the
search box.
- [ ] User can see a summary count of the number of cities that met the
search criteria.

## Useful links and resources

- [World Time Zones](https://greenwichmeantime.com/time-zone/definition/)
- [Bitwise Operators (MDN)](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Bitwise_Operators)

## Example projects

[Bitwise Operation](https://codepen.io/Lunoware/pen/XBWEPY)
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ required to complete them.

| Name | Short Description | Tier |
| ------------------------------------------------------------------ | -------------------------------------------------- | -------------- |
| [🌟Bit Masks](./Projects/Bit-Masks-App.md) | Using Bit Masks for Conditions | 2-Intermediate |
| [Book Finder App](./Projects/Book-Finder-App.md) | Search for books by multiple criteria | 2-Intermediate |
| [Card Memory Game](./Projects/Card-Memory-Game.md) | Memorize and match hidden images | 2-Intermediate |
| [🌟Drawing App](./Projects/Drawing-App.md) | Create digital artwork on the web | 2-Intermediate |
Expand Down

0 comments on commit 1ea3aa0

Please sign in to comment.