From aa2d386a863c0b3b5764ad61cd0657d40dac6819 Mon Sep 17 00:00:00 2001 From: jdmedlock Date: Tue, 23 Apr 2019 19:20:35 -0500 Subject: [PATCH] Feature: Add Bit Mask app specification Add Bit Mask app specification Resolves: N/a See also: N/a --- Projects/Bit-Masks-App.md | 76 +++++++++++++++++++++++++++++++++++++++ README.md | 1 + 2 files changed, 77 insertions(+) create mode 100644 Projects/Bit-Masks-App.md diff --git a/Projects/Bit-Masks-App.md b/Projects/Bit-Masks-App.md new file mode 100644 index 00000000..38634029 --- /dev/null +++ b/Projects/Bit-Masks-App.md @@ -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) diff --git a/README.md b/README.md index e2dac608..788afd2b 100644 --- a/README.md +++ b/README.md @@ -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 |