Action Items

BJ has recently gotten back into photography. It has been a while so his friend, Alysha has offered to help him improve his skills. She had him take photos and videos in a few different settings then reviewed them and gave him feedback.

The Challenge

BJ took Alysha’s email and broke it down into a KADI (Keep, Add, Delete, Improve) chart. From there he created actions that he can take to improve his photography skills.

For each action item he rated (1 - 10)them for Impact and Immediacy. Impact is how much the item will improve his skills. One means little impact and ten means high impact. Immediacy is how quickly he can engage or achieve the item. The lower the score on immediacy the sooner it can be achieved.

BJ needs for you to build an app that takes his action items in as input and then prioritize them based on how much impact they have.

Sample Action Items:
| Item | Impact | Immediacy |
| —- | —— | ——— |
| Check the ISO before increasing Shudder speed | 7 | 1 |
| Learn to use window light to siloette | 5 | 5 |
| Buy an L series lens | 10 | 9 |
| Practice detail shots with wide angle lens | 4 | 8 |
| Learn to read body language of subject | 8 | 6 |
| Be patient with unique lighting and wait for the shot | 10 | 3 |
| Buy a new camera body | 10 | 10 |
| Learn slit lighting | 4 | 7 |

Creating a Test Case

We’ll continue to use test driven development. No matter the level you choose write a test case before you start coding. Then write enough code to pass the test. Once you have a passing test write more tests and refactor you code to accommodate all possible tests.

A Step Further

Going a step further add logic to your app that will take into account the immediacy. BJ wants to be able to knock out the highest impact items first but needs to be able to make improvements quickly.

Hint: You’ll want to balance between low immediacy and high impact.

Weightlifting Warmups

Like most developers, Will has to deal with the problems of having a sedentary career. Sitting on his butt on all, he finds that it’s easier than he’d like to grow a big belly and to have pain from the way he sits. As part of a larger regimen of diet and exercise, he wants to start lifting heavy weights again.

However, like all grouchy people of a certain age, Will needs to warm up before exercising. Failing to do so really hurts and he just doesn’t recover like he used to. He needs to start with lighter weights and work upward to his goal weight before actually trying to lift something heavy. Each step up in weight should be a reasonable amount, until he reaches his goal weight.

Will also (being cranky) doesn’t particularly want to try and do math in between weight sets. He’d rather just listen to music. Towards that end, he wants an application that can figure out what his warmup sets should be.

The Challenge

For this challenge, create an application that takes in the name of the exercise, a minimum weight, and a target ending weight. The warmup weight amounts are determined by the following rules:

  • The minimum weight is the minimum amount that you can start with. For instance, for the deadlift, Will might start at 135 lbs, because the bar weighs 45 pounds and the big plates on each side weigh 45 pounds.
  • Increment the weight by up to 30 lbs at a time, starting with the minimum weight and ending with the final weight.
  • If there is less than 30 lbs between a weight and the final weight, increase by 15lbs instead before doing the final weight.
  • If the difference is less than 15 lbs, proceed directly to the final weight.
  • Display the results.

Creating a Test Case

We’ll continue to use test driven development. No matter the level you choose write a test case before you start coding. Then write enough code to pass the test. Once you have a passing test write more tests and refactor you code to accommodate all possible tests.

A Step Further

Upon thinking about it, Will needs a couple other things for this to work well.

  • First of all, he needs the program to output the weight sets in a way that allows them to quickly be imported into the task tracking application he uses so that he can quickly see the weights he needs to use on his phone.
  • He also needs to know the number of reps to use, so that will need to be added.
  • He also likes to plan a week’s worth of workouts at a time, so the date will need to be taken into account.

Thankfully these can be emailed in to the task tracker (Nozbe). A sample resulting email looks like the following (just output on the console for now):

1
2
3
4
5
6
7
8
. Deadlift 135 lbs x 5 #7/8/19
. Deadlift 165 lbs x 5 #7/8/19
. Deadlift 195 lbs x 5 #7/8/19
. Deadlift 225 lbs x 5 #7/8/19
. Deadlift 255 lbs x 5 #7/8/19
. Deadlift 285 lbs x 5 #7/8/19
. Deadlift 315 lbs x 5 #7/8/19
. Deadlift 335 lbs x 5 #7/8/19

Want to go crazy with this?

If you want to take the challenge even further, consider what would be required to do any/all of the following:

  • Allow multiple exercises in one run of the application.
  • Store configuration data about the exercises for things like the minimum weight, and goal weights.
  • Allow updating of stored configuration
  • Allow the exercises to be divided into “Leg day”, “Arm day”, and “Cardio” categories, and allow the user to pick what kind of day they are planning, then walk them through all the available exercises, and then build up the email.

Chords

Beej is learning to play the guitar. He’s not very good yet so he needs so help learning the notes in a chord. In music there are 7 lettered notes and 5 half steps between notes creating a 12 note scale. Chords are composed of three or more notes starting with the note the chord is named after. For the major chords the notes are the 1st (the name of the chord), 3rd, and 5th notes.

The Challenge

For this challenged create an app that takes in the name of the chord and returns the three notes that compose it. So if ‘G’ is entered ‘G, B, D’ will be returned. This also applies to sharps (#)and flats (b) so ‘D#’ will return ‘D#, F#, A#’.

Hint: There are two sets of notes that do not have a half step between them: B-C and E-F. For these if it is a sharp move up a to the full note and if flat stay at the lower note.

Creating a Test Case

We’ll continue to use test driven development. No matter the level you choose write a test case before you start coding. Then write enough code to pass the test. Once you have a passing test write more tests and refactor you code to accommodate all possible tests.

A Step Further

Going a step further, add in the option to return the minor chord. The minor chords are the same as the major except that the 3rd note is a half step down. So the ‘G’ minor chord contains the notes ‘G, Bb, D’. For sharps and flats the same applies so ‘Gb’ minor chord contains notes ‘Gb, A, Db’.

Hint: There are two sets of notes that do not have a half step between them: B-C and E-F. So instead of moving a half step you move a full step down.

Zones and Filters

You’ve recently taken a job in a new city called Nashtopia. You are working on a team building an app for the sales team to better find and connect with customers. You have been tasked with filtering and sorting the customer information so that the sales team can get just the customers they need.

Code Kata Format

We’ve changed the format of the challenges to be more like a code kata. So instead of three levels of varying difficulty there will be one challenge, and a step further, that you can make as difficult as you need based on where you want to place your focus on learning.

The Challenge

Nashtopia is broken up into 7 different zones. These are represented by the first digit of the CustomerId. The sales team wants to be able to select the name of the zone and print out a list of all the customers in that zone only.

Hint: You will need to get the zone number from the list of zones then compare that to the first digit in the CustomerId.

Nashtopia Zones

Zone Name
1 Downtown
2 Midtown
3 Uptown
4 NoBro
5 The Glades
6 The Narrows
7 Bakerline

Customer List

CustomerId First Name Last Name Street Address
62342 Bruce Wayne 13 Wayne Ln
48323 Bill Preston, Esq. 555 Excellent Dr
19365 Peter Lattimer 321 Leenas Pl
77314 Lex Luthor 99 High St
66376 Harvey Dent 22 Facelift Ave
46923 Ted Logan 283 Excellent Dr
74056 Clark Kent 187 Louis Ln
16842 Claudia Donovan 223 Brother St
47932 Billy Kid 423 Western Rd
68234 Alfred Pennyworth 12 Wayne Ln
72034 Jimmy Olson 32 Camera Dr
15451 Myka Bering 121 Leenas Pl

Creating a Test Case

Write a test case before you start your code. Then write just enough code to pass the test. Once you have passing code refactor to pass other test cases.

Hint: The customer list provided is just a starting point to best test your code add more to the list.

A Step Further

The sales team loves that they can print out a list of just the customers in their zone. Now they’ve asked you to add a sort feature. They want to be able to sort by street address so they can have all the customers on the same street together.

Emoji

Hieroglyphics were a form of language using images to convey ideas instead of words. Emoji help us convey meaning that may be lost in plain text messages. They are a way to showing emotion or ideas via images.

Code Kata Format

We’ve changed the format of the challenges to be more like a code kata. So instead of three levels of varying difficulty there will be one challenge, and a step further, that you can make as difficult as you need based on where you want to place your focus on learning.

The Challenge

For this challenge take an input string from the user. Then convert any words that could be emoji into their text or emoji representation. So the string “You make me smile” would return “You make me :)”

Creating a Test Case

Write a test case before you start your code. Then write just enough code to pass the test. Once you have passing code refactor to pass other test cases.

A Step Further

Going a step further reverse the process and create a translator to translate emoji back into text. So the string “You make me :)” will translate to “You make me smile.”

Membership

Anytime you sign up for a website or an email list they have to check that you are or are not already a member. Your information is compared to the information they already have to see if you already exist.

Code Kata Format

We’ve changed the format of the challenges to be more like a code kata. So instead of three levels of varying difficulty there will be one challenge, and a step further, that you can make as difficult as you need based on where you want to place your focus on learning.

The Challenge

For this challenge you’ll start with a list of names. The user will input a name and the code will check the list to see if the user is in the list or not. Check that the first and last name are in the list and that they are the same record.

If the name exists in the list inform the user that they are already on the list. This would then prompt some other process in a larger app. If it does not exist add it to the list of names so that if the user enters it again it will return that it is already on the list.

Name List

First Last
Lindsey Stirling
Tom Petty
Seth Alley
Dave Grohl
Alice Cooper
Steve Turner
Kurt Cobain
Ken Casey
Eddie Vedder

Creating a Test Case

Write a test case before you start your code. Then write just enough code to pass the test. Once you have passing code refactor to pass other test cases.

A Step Further

Going a step further check for common variations of different first names. So if someone enters Thomas Petty then Tom Petty would return positive.

Hint: This may mean storing a separate list of names and their variants.

Date Reminder

February is full of important dates. Several presidents have birthdays this month. We even have a day to celebrate presidents. Even one of the organizers of this group has a birthday this month. In addition there’s a few other important days to remember, especially if you are in a relationship.

Code Kata Format

We’ve changed the format of the challenges to be more like a code kata. So instead of three levels of varying difficulty there will be one challenge, and a step further, that you can make as difficult as you need based on where you want to place your focus on learning.

The Challenge

For this challenge we will be taking in user input and storing it for later retrieval. You’ll need to create an interface that takes in dates and the details about why that date is significant such as someone’s birthday. Allow users to enter as many dates and descriptions as they want. Store those dates and descriptions and allow the user to retrieve them. Display the dates and descriptions in order so that the soonest displays first.

Example:

Date Description
2/3/19 Beej’s Birthday
2/14/19 Valentine’s Day
2/18/19 President’s Day

Creating a Test Case

Write a test case before you start your code. Then write just enough code to pass the test. Once you have passing code refactor to pass other test cases.

A Step Further

Going a step further create a reminder for dates entered that are within one week of today. So if someone enters Valentine’s Day then remind them that the event is in less than a week.

Grids and Graphs

We’ve been asked to build some easter eggs for those using our software. These are some fun things and games that those who find it can enjoy.

The Challenge

In this challenge we’ll be using nested loops, multi-dimensional arrays, matrices, and grids. Focus first on solving the problem then on optimizing it.

Creating a Test Case

No matter the level you choose to work with write a test case before you start your code. Then write just enough code to pass the test. Once you have passing code refactor to pass other test cases. You’ll notice that not all of these challenges can easily be tested. Some you will have to see in order to test it.

Level 1 Ascii Art

   _______
  |.-----.|
  ||x . x||
  ||_.-._||
  `--)-(--`
 __[=== o]___
|:::::::::::|\
`-=========-`()

jgs

Image from www.asciiart.eu

Ascii art is images created using numbers letters and characters. You’ve been asked to create some diamond out of ‘*‘. Start by taking in an integer from the user. This will be the length of on of the sides. Then create and return the diamond with that number of ‘*‘ on each side.

1
2
3
4
5
6
7
8
9
Enter side length: 4
*
***
*****
*******
*****
***
*

Hint: You may need to use nested loops. Create the top half in one outer loop and the bottom half in another.

A Step Further

Going a step further, write an app that builds a face using ascii art. If you are feeling very fancy animate the face.

Level 2 Magic Squares

A magic square is a matrix of unique numbers starting at 1 and incrementing. The sums of each row, column, and the two diagonals are the same.

For this challenge you have been asked to take in user input for each row. Then check that each number is only used once and every number from 1 to the max is used. Next check if the sum of the rows, columns, and diagonals are the same. Tell the user if they have entered a magic square or not.

1
2
3
4
16 3 2 13
5 10 11 8
9 6 7 12
4 15 14 1

Hint: This may require using nested or multi-dimensional arrays.

A Step Further

Going a step further, build a magic square generator. Have the user input the max number for the matrix.

Level 3 Sudoku Generator

If you are not familiar with it Sudoku is a game played on a 9 x 9 grid broken into 9 sections of 3 x 3 mini-grids. To solve is enter the numbers 1-9 only once per column, row, and 3 x 3 grid. Each puzzle will have enough grids filled in to be able to logically solve the puzzle.

Image from Puzzle Stream

Build an app that will randomly generate a Sudoku grid with the correct starter numbers so that there is a correct solution. Allow the users to input their solution and check that it is correct.

Hint: Each puzzle has a unique solution. The game is about pattern matching not math.

A Step Further

To really give yourself a challenge build a Sudoku solver. The user will need to enter the location and value of each number provided on the grid. Then the program will return the solved grid.

Sales Tax

We have been asked to work on a website that sells goods across the US. They need our team to build an app to calculate the sales tax for the items sold.

The Challenge

For this challenge we’ll be taking in information, running calculations, adding business logic, and then returning an output. At the basic levels it will be some mathematical calculations. At the higher levels we’ll be looking up information in tables and determining what path the app follows based on input.

Creating a Test Case

No matter the level you choose to work with write a test case before you start your code. Then write just enough code to pass the test. Once you have passing code refactor to pass other test cases.

Level 1

To start off, build an app that takes in both the cost of the item or total costs of items and the sales tax percent to calculate. It should return the total after adding taxes to the purchase.

Hint: Total = price + (price * tax percent / 100)

A Step Further

Going a step further, display the cost of the item or items, the amount of tax, and the total after tax that the customer is spending.

Output for a $10 item with an 8% tax rate:

Cost $10.00
Tax $0.80
Total $10.80

Level 2

Instead of passing in the sales tax for an area the app we are working on will be taking in the name and address, including city and state, of the purchaser. From this information look up the tax percentage from a table based on the location of the buyer. Make sure to return the item cost, tax amount, and total cost.

Use the combined rate from this website for each state. https://taxfoundation.org/state-local-sales-tax-rates-midyear-2018/

Hint: The simplest way to use this information is to copy and hard code it into your application. Worry about making it adjustable after you get the functionality working.

A Step Further

Going a step further, many larger cities have a city sales tax on top of the state sales tax. Instead of using the state’s average local tax calculate the specific taxes for the location of the buyer based on the address they input.

For simplicity of this challenge use the major cities in this link, if the one in the input isn’t listed then use the average from the previous link. https://taxfoundation.org/sales-tax-rates-major-cities-midyear-2017/

Hint: Total Tax = (State Tax + Local Tax) / 100; Total Cost = Price + Price * (State Tax + Local Tax) / 100;

Level 3

The company that hired us to create these apps has decided to give a 10% discount to their employees. They want this to be a pre-tax discount. Create a list of employee names and when the user inputs a name check it against the list. If the input is for an employee apply the discount before adding the taxes. Make sure to return the cost of the item (after discount), amount of taxes, and total cost.

Hint: Discounted = Price - (Price * Discount / 100)

A Step Further

Going a step further add the ability to enter a discount code to receive a 5% post tax discount.

Discount Code

BJ is out of town visiting family this weekend. Before flying out he went to the bookstore to purchase something to read on the flight and then drive. A lot of times bookstores will have sales or discounts that change their normal course of business.

The Challenge

For this challenge we are going to be applying various discounts based on sales criteria. We’ll be working with some math, string manipulation, and conditional logic. The goal is to interpret business requirements from the bookstore’s sales department as we build a way for them to enter the items sold and have the app use logic to know which discounts to calculate based on the input.

At each level you’ll need to take in certain information about the purchase: Book Title, Author Name, Publish Date, and Price. In addition you’ll also need to take in a coupon or discount code.

Creating a Test Case

No matter the level you choose to work with write a test case before you start your code. Then write just enough code to pass the test. Once you have passing code refactor to pass other test cases.

Level 1

For level 1 we’ll be applying a coupon or discount code to the entire purchase. The sales person will need to enter several books with full information and then be prompted to enter a coupon or discount code. Once all the details have been entered add up the cost of the books and apply the discount. Return the final cost of the books.

Hint: DiscountedPrice = Price - (Price (DiscountPercent / 100)). So a 5% discount on a $10 purchase would be: $9.50 = $10 - ($10 (5 / 100)).

A Step Further

The sales team really likes the ability to see the total with discount after they enter all the items, however customers would like to know how much they are spending while the items are being entered. They want you to provide a running total as new items are added to the purchase show the total. Then add the ability to enter the discount code at any time in the entry process and apply it to the running total.

Level 2

The sales team has mentioned that they occasionally have time limited sales. In this case the discount codes will only be valid for a certain time-frame or in certain circumstances. Check that the discount code is valid before applying it to the total.

Hint: You don’t have to know the details of the sale to know whether a code is valid. You may just have a list of valid codes to compare with the one entered.

A Step Further

The sales team has informed you that they have different sales running at the same time. Add the ability to have different percentages based on the discount code entered.

Code Discount
5PERCENT 5%
10PERCENT 10%
15PERCENT 15%

Level 3

The sales team is running a special on multiple purchases from the same author. Whenever a customer purchases more than one book from an author they will be given a discount only on the books after the first one by the same author. This is going to happening at different times at different location so the individual stores will need the ability to turn this feature on and off. Also make sure that the sales team doesn’t lose functionality by applying these new discounts. You’ll need to still show a running total with applicable discounts.

Hint: For this challenge we will assume that all author names are unique with no authors sharing the same name.

A Step Further

Based on the popularity of the same author discount the sales team has added a same series discount. This is an increasing discount so that if books from the same series by the same author are purchased they receive an increasing discount. The second book in the series will get 5% off, the third book 10%, the fourth 15% and so forth. The discount will max out at 35%.

Hint: You can put series information in the title of the books or add a field to the input that contains the series information.

Heros and Villains

BJ’s sister is remodeling his nephew’s room. It is a super hero themed. He has been getting into comic books and super heros ever since he met Spiderman. He’s asked us to build him a way to look up superheros and the villians they’ve fought and defeated.

The Challenge

In this challenge we’ll be searching and sorting lists of objects. We have a list of heros with their villians, the last time they fought, the number of times fought, and the number of wins.

Spiderman

Villian Last Fight Number Fights Number Wins
Venom 2007-5-4 100 89
Sandman 2017-6-14 90 90
Kingpin 2018-2-6 20 18
Hobgoblin 2018-6-6 222 189
Shocker 2013-11-20 76 63

DareDevil

Villian Last Fight Number Fights Number Wins
Bulls-eye 2017-8-24 200 189
Sandman 2017-6-14 90 90
Kingpin 2018-5-16 340 318
Red Skull 2016-12-26 12 9
Shocker 2014-10-2 32 30

Captain Marvel

Villian Last Fight Number Fights Number Wins
Bulls-eye 2017-8-24 200 189
Capt Nazi 2003-6-4 190 175
Black Adam 2018-7-24 246 238
Red Skull 2016-12-26 12 9
Hydra 2017-10-22 132 128

Captain America

Villian Last Fight Number Fights Number Wins
Kingpin 2017-2-14 147 139
Capt Nazi 2013-9-24 232 175
Black Adam 2015-4-12 246 238
Red Skull 1946-2-26 412 407
Hydra 2018-10-22 132 128

Superman

Villian Last Fight Number Fights Number Wins
Lex Luthor 2018-4-12 200 198
Doomsday 1992-11-15 1 0
Bane 2017-6-12 78 72
Killer Croc 2017-3-21 123 108
Ares 2015-5-30 89 78

Batman

Villian Last Fight Number Fights Number Wins
Lex Luthor 2017-8-26 27 18
Joker 2017-11-15 431 420
Bane 2018-11-22 248 244
Killer Croc 2016-7-29 113 108
Ares 2014-3-20 24 18

Wonderwoman

Villian Last Fight Number Fights Number Wins
Capt Cold 2017-3-26 127 110
Joker 2015-1-5 31 18
Bane 2013-11-12 48 24
Killer Croc 2017-2-9 13 8
Ares 2018-3-20 324 322

Flash

Villian Last Fight Number Fights Number Wins
Capt Cold 2018-3-6 17 11
Joker 2015-12-5 21 8
Bane 2016-10-9 158 124
Killer Croc 2007-12-9 143 138
Lex Luthor 2014-3-2 34 22

Your data may look something like this:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
[
'Superman': [
{
'name': 'Lex Luthor',
'lastFight': 2018-04-05,
'numberFights': 200,
'numberWins': 198
},
{
'name': 'Doomsday',
'lastFight': 1992-11-15,
'numberFights': 1,
'numberWins': 0
}
],
'Spiderman': [
{
'name': 'Venom',
'lastFight': 2007-05-04,
'numberFights': 100,
'numberWins': 89
}
]
]

Creating a Test Case

No matter the level you choose to work with write a test case before you start your code. Then write just enough code to pass the test. Once you have passing code refactor to pass other test cases.

Level 1

Starting off in level 1 we need to be able to tell if a hero has fought a villian. Have the user input the hero’s name and the villain and then let the user know if that hero has faced that villian.

A Step Further

Going a step further allow the user to enter a hero and then produce a list of the villians they have faced and order them by the most recent time they have fought.

Level 2

For level 2 we want to allow the user to enter a villian’s name and return a list of heros they have faced.

A Step Further

Going a step further order the list of heros by number of times the villian has fought the hero. Include the number of times the villian won.

Level 3

With the information provided if given a villian determine which hero is the most likely to win in a fight with that villian.

A Step Further

Going a step further, predict the chances of hero and villian winning when the user provides a hero and a villian.

Alphabet Soup

You are working on a team that is building an app that stores information about a wocket making machines. Each wocket requires a number of widgets to be plugged into machines to make them. You have been tasked with assigning the letter associated with a plug on the wocket making machine with the widget going into it.

The Challenge

For this challenge we’ll be working with arrays and sorting. We’ll sort the array of objects with letters into alphabetical order so that we can find the next letter or any missing ones.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
[
{
"Name": "Wonky Widget",
"Color": "Brown",
"SerialNumber": "1234",
"Slot": "A"
},
{
"Name": "Wild Widget",
"Color": "Purple",
"SerialNumber": "4321",
"Slot": "B"
},
{
"Name": "Weird Widget",
"Color": "Green",
"SerialNumber": "2343",
"Slot": "C"
}
]

Creating a Test Case

No matter the level you choose to work with write a test case before you start your code. Then write just enough code to pass the test. Once you have passing code refactor to pass other test cases.

Level 1

Your task for level 1 is to take an array of letters and find then find the next letter in the array.

1
['A', 'B', 'C', 'D']

A Step Further

Going a step further add a new widget to the array of widgets. In order to add it you’ll need to find the last letter for a slot in a widget in the array of widgets and then get the next letter to

1
2
3
4
5
{
"Name": "Weeping Widget"
"Color": "Blue"
"SerialNumber": "9876",
}

Level 2

For level 2 you’ve been asked to take into account the fact that there may be more than 26 widgets on a machine. After the last letter “Z” use double letters “AA”, “AB”, “AC”, then “BA”, “BB”, “BC”, etc.

A Step Further

Going a step further make is so that it can keep going infinitely adding extra letters so that you have “AAA” or “AAAA”.

Level 3

For level 3 you find out that they may have removed some widgets from the wocket machine. So before adding a new widget find out if there are any letters missing in the sequence and fill in the missing spots with the new widget.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
[
{
"Name": "Wonky Widget",
"Color": "Brown",
"SerialNumber" : "1234",
"Slot": "A"
},
{
"Name": "Wild Widget",
"Color": "Purple",
"SerialNumber": "4321",
"Slot": "B"
},
{
"Name": "Weird Widget",
"Color": "Green",
"SerialNumber": "2343",
"Slot": "D"
}
]

A Step Further

Going a step further ensure no two widgets have the same slot letter.

March Madness

March is an exciting time for college basketball fans. Each year the best teams compete against each in a single elimination tournament to find out who is the best of the best and will be come the National Champion. The first round starts with 64 teams that are paired up and play each other. The teams are divided into four regions (East, West, Midwest, South) and given ranks within these regions.

The highest ranked team plays the lowest ranked team, the second highest plays the second lowest, and so forth for each region. The next round pits the winner of the first and last ranked teams against the winner of the two middle teams and the winner of the second and second to last against the next level out from the middle. This continues until only one team from each region remains. Then the winners of the East and West compete as well as the winners of the Midwest and South. Finally two teams compete in the National Championship game.

The Challenge

For this challenge we’ve been tasked with creating interactive ways for fans to enjoy tracking and predicting which teams will win. It has become a tradition among many fans to create “brackets” where they predict who will win each game and then compare these with their friends.

While not everyone is a sports fan this challenge involves the usage and manipulation of objects, arrays, and several other data types along with creating interactive user interfaces.

Creating a Test Case

No matter the level you choose to work with write a test case before you start your code. Then write just enough code to pass the test. Once you have passing code refactor to pass other test cases.

Level 1

Below is a list of ranking from the first round of last year’s NCAA tournament. For each region (East, West, Midwest, South) pair up the teams that will play each other and display them as a pair. For example in the East region Vilanova will play Mt. St. Mary’s in the first round.

East West Midwest South
1. Vilanova 1. Gonzaga 1. Kansas 1. N. Carolina
2. Duke 2. Arizona 2. Louisville 2. Kentucky
3. Baylor 3. Florida St. 3. Oregon 3. UCLA
4. Florida 4. W. Virginia 4. Purdue 4. Butler
5. Virginia 5. Notre Dame 5. Iowa St. 5. Minnesota
6. SMU 6. Maryland 6. Creighton 6. Cincinnati
7. S. Carolina 7. St. Mary’s 7. Michigan 7. Dayton
8. Wisconsin 8. Northwestern 8. Miami 8. Arkansas
9. Va. Tech 9. Vanderbilt 9. Michigan St. 9. Seton Hall
10. Marquette 10. VCU 10. Oklahoma St. 10. Wichita St.
11. USC 11. Xavier 11. Rhode Island 11. Kansas St.
12. UNC-Wilm. 12. Princeton 12. Nevada 12. Middle Tenn.
13. ETSU 13. Bucknell 13. Vermont 13. Winthrop
14. New Mex St. 14. FGCU 14. Iona 14. Kent St.
15. Troy 15. North Dakota 15. Jax. State 15. N. Kentucky
16. Mt. St. Mary’s 16. S. Dak. St. 16. UC Davis 16. Texas So.

A Step Further

Going a step further build a view that displays the teams playing each other in a similar fashion to the brackets in the link below.

https://i.turner.ncaa.com/sites/default/files/images/2018/01/09/mm-2018-printable-bracket.pdf

Level 2

Starting with the paired list of round one competitions build functionality to allow users to predict who will win each game. Once the predicted winners of two with the order list of paired teams and allow users to predict who will win each game.

A Step Further

Going a step further allow predictions beyond the current round so that users can make predictions based on their predicted winners.

Level 3

Since users are allowed to predict the outcome of games they will want to know if they are correct. Assuming you will be pulling this data from a reliable source mock that with a set of winners and have your bracket periodically check it to update the with the winners of each round. Create a visual way of displaying that a team has won or lost and remove losing teams from future predictions requiring the user to create new predictions based on “actual” outcomes.

A Step Further

Add in scores from the games that have been played so that users can see the scores for each team once the have finished a game. Going even further add in scores of games being played currently with a way of identifying them as in progress vs final scores.

Mardi Gras

In Nashville you don’t hear about it as much but when BJ was living in New Orleans Mardi Gras was the big holiday. Mardi Gras is the culmination of the celebration of Carnival which begins 12 days after Christmas and ends 46 days before Easter when Lent begins. There’s parades, beads, and king cake everywhere along with lots and lots of tourists.

The Challenge

For this challenge we’ve been asked by the city of New Orleans to write a few apps to help tourists enjoy their time in New Orleans at Mardi Gras. Each level is a different challenge and they do not build on each other this time. Some are games for the tourists while others are tools to help them better use the time they have.

Creating a Test Case

A Unit Test looks at and tests a specific unit of code to see if it is returning what is expected. No matter the level you choose to work with write a test case before you start your code. Then write just enough code to pass the test. Once you have passing code refactor to pass other test cases.

Level 1

One of the more delicious parts of Mardi Gras is the King Cake. It is tradition to bake a plastic baby in the cake. Whoever finds the baby in their slice of the cake is said to have good luck for the year. Some families have a tradition where the person that finds the baby brings the King Cake the next year, others have them be the king or queen for the day.

We’re going to create a little game for our tourists to play while they are waiting on their King Cake at the bakery. Have them enter the names of their friends and family then randomly select one of the names to receive the baby.

A Step Further

Presentation is the key to making this a fun game to play. Going a step further add graphics to your game with a King Cake that gets sliced into the number of pieces matching the number of names entered. You can have each player find out if their slice of cake contains the baby then refer the winner as king or queen and their name.

Level 2

A huge New Orleans tradition around Mardi Gras and almost every other holiday is lots of parades. Though Mardi Gras is the biggest time for parades. Different Krewes put together floats to travel in their parades. Each one is unique and lots of fun to watch.

We’ve been tasked by the city of New Orleans with building an application to assist tourists in knowing when and where to attend parades. They should be able to keep track of which parades to attend. The city of New Orleans wants tourists to be able to organize the parades in order of when they occur so that tourists can map out a route to see as many as possible. Tourist should be able to select a location and see when the next parade will be or find all parade locations at a certain time.

Parade Location Date Start
Krewe of Iris Uptown 2/10/18 10:00am
Krewe of Tucks Uptown 2/10/18 11:00am
Krewe of NOMTOC Westbank 2/10/18 10:45am
Krewe of Endymnion Midtown 2/10/18 4:15pm
Krewe of Isis Metairie 2/10/18 6:30pm
Krewe of Okeanos Uptown 2/11/18 11:00am
Krewe of Mid-City Uptown 2/11/18 11:45am
Krewe of Thoth Uptown 2/11/18 12:00pm
Krewe of Bacchus Uptown 2/11/18 5:15pm
Corps de Napoleon Metairie 2/11/18 5:00pm
Krewe of Athena Metairie 2/11/18 5:30pm
Krewe of Pandora Metairie 2/11/18 6:30pm
Krewe of Proteus Uptown 2/12/18 5:15pm
Krewe of Orpheus Uptown 2/12/18 6:00pm
Krewe of Zulu Uptown 2/13/18 8:00am
Krewe of Rex Uptown 2/13/18 10:00am
Krewe of Elks Orleans Uptown 2/13/18 12:00pm
Krewe of Crescent City Uptown 2/13/18 2:00pm
Krewe of Argus Metairie 2/13/18 10:00am
Krewe of Elks Jefferson Metairie 2/13/18 12:00pm
Krewe of Jefferson Metairie 2/13/18 2:00pm
Krewe of Lyra Covington 2/13/18 10:00am

These are actual times from http://www.mardigrasneworleans.com/schedule.html

A Step Further

Going a step furhter add distances and travel times between locations so when a tourist selects a location they are provided a list of the nearest parades going on right now or the time and location of the next parade. Going all out link to something like Google maps for directions to that location.

Location Uptown Midtown Westbank Metairie Covington
Uptown 3.5mi 10min 8.3mi 20min 5.2mi 15min 41.1mi 50min
Midtown 3.5mi 10min 11.9mi 25min 4mi 10min 39.3mi 45min
Westbank 4.4mi 15min 11.9mi 25min 12.5mi 25min 49.9mi 60min
Metairie 5.2mi 20min 4mi 10min 12.5mi 25min 35.5mi 40min
Covington 41.1mi 50min 39.3mi 45min 49.9mi 60min 35.5mi 40min

Level 3

The tradition of throwing beads to the crowd began in the late 1800’s and by the 1900’s became a staple of the Carnival celebration. Traditional Mardi Gras beads are purple, green, and gold colors. The purple symbolizes justice, the green faith, and the gold power.

The city has asked us to build a simple game that tourists can play while they are waiting on the next parade to start. In this game the player will be a Knight of Endymnion (One of the most popular Krewes) on a mission to give out as many Endymnion beads as possible. As the player sees people on the screen they will need to throw beads to them. The city has left it up to the developers to determine how complicated this game will be but has asked us to add some fun graphics to increase enjoyment of the game.

A Step Further

Going a step further make your game even more involved by creating moving targets to toss your beads. In addition you can have you knight be on a float travelling along the parade route tossing beads to those in the crowd watching.

Add a points system so tourists can compare scores and challenge each other to see who makes the best Knight of Endymnion.

Bowling Scores

You are working for a company that sells bowling supplies. The marketing department has asked you and your team to design and build ways to get more customer interaction on the company’s website.

Challenge

In order to engage more bowlers we are going to build a way for them to enter and track their games. This will allow them to compare scores with friends, enter competitions, and track their own improvements.

Rules of Bowling

Bowling has 10 frames with two chances or rolls to knock down 10 pins. At the end of each frame the pins are reset for the next frame. There are different rules based around which score a person receives per a roll.

There are three basic types of scores you can receive per roll of the ball: a strike, a spare, or a number. A strike occurs when all 10 pins are knocked down on the first roll of a frame. A spare occurs when all 10 pins are knocked down on the second roll of a frame. All other scores are the number of pins knocked down in that roll.

A strike receives a score of 10 pins for the initial roll and a bonus of the next two rolls added to it. Therefore a strike followed by two rolls of 1 pin each would have a total score of 14 (10 for the strike roll, 2 bonus, and 1 for each roll of 1). Also when someone scores a strike they do not get a second roll in that frame except when that is the last frame in which case there are two bonus rolls that are only counted as bonus on the last frame but not as independent scores.

A spare receives the number of pins knocked down in that roll and a bonus of the next roll. Therefore a spare that results for a roll of 5 with the next roll being a 1 would have a total score of 11 (5 for the initial roll, 5 for the spare, 1 bonus from the next roll, 1 for the next roll). If the final frame receives a spare one more roll is allowed for the bonus.

Creating a Test Case

No matter the level you choose to work with write a test case before you start your code. Then write just enough code to pass the test. Once you have passing code refactor to pass other test cases.

Some languages and frameworks have testing suites available to help build test driven apps. Here is a simple example of a test for this challenge written in JavaScript:

1
2
3
4
5
6
7
8
9
function TestCase_1(){
var testString = "X, 4, /, 1, 1, 4, 3, 4, /, 2, 2, 2";
var result = ConverToScores(testString);
if(result[0] == 20){
console.log("Test Passed");
} else {
console.log("Test Failed");
}
}

Level 1

To start you will be receive the raw bowling data as a string of characters. “X” or “x” will represent a strike. “/“ represents a spare. The rest will be the number of pins knocked down in that roll.

You are tasked with taking that string of characters and converting it to an array of scores for each roll. So that the string “X, 4, /, 1, 1” would return the array [10, 4, 6, 1, 1].

A Step Further

Going a step further, create a user interface for your app that takes in the scores one at a time, creates the string to pass into your converter, then displays the scores for each roll.

Level 2

Now that you have an array of scores (or if you started here we’ll make one up) we’re going to calculate the total score. Remember that each strike receives a bonus of the next the number of pins knocked down in the next two rolls. So an input of [10, 1, 1, 5, 5, 1, 1] would return the score 27.

To combine Level 1 and 2 take in the string of raw bowling data input string of raw bowling data and convert to scores per frame.

A Step Further

Going a step further calculate the total score at each frame and return an array of ten frames with the last frame being the total game score.

Level 3

Create a user interface that resembles a bowling score sheet allowing multiple users to input scores as if they were putting them into the score sheet. Then have the application calculate and display the total score per frame dynamically as data is input. Compare scores with multiple users to create a leader board and have the app identify the winner once all scores are entered.

A Step Further

Going a step further, allow individual users to input multiple games. Then display them and highlight trends in teh scores such as a tendency for lower scores on frames 7-9.

Casino Night

You’ve been asked to create a suite of basic casino style mini games for a new RPG. These games will use a currency earned though doing tasks in the RPG called Locts (not real money).

Challenge

For this challenge we will be dealing with some math, random number generation, and pattern recognition. Feel free to ask for help if having trouble with the math side of any of the challenges. For simplicities sake have all players start with a set number of Locts (50 is a good start).

You will be presented with the goal and rules of the game and left to your own devices to design your code to meet those requirements.

Creating a Test Case

We’ll continue to use test driven development. No matter the level you choose write a test case before you start coding. Then write enough code to pass the test. Once you have a passing test write more tests and refactor you code to accommodate all possible tests.

Level 1

One of the first random number generator tasks we learn is to build a game of dice or craps. In the game you have two die that can be rolled each with the possibility of rolling a number between 1 and 6.

If a player rolls a combined score of 7 on their first turn then they win. If they roll a combine score of 2, 3, or 12 then they “crap out” and lose. If they roll any other number then they keep rolling trying to hit that number again. At this point in time 7 becomes the enemy and hitting it loses the game, else they keep rolling until they hit the first number.

A Step Further

Going a step further add betting to the game. Allow players to bet their Locts on whether or not they will win. They pay out should be 2:1. So if a person bets 2 Locts they will win and then win they get 4 locts in their store. Also allow them to bet on which number will be rolled.

Level 2

Next you’ve been asked to create an in game version of blackjack (21). The idea here is to get as close to 21 without going over (busting).

For this number cards count as the number on the card 2-10. Face cards (Jack, Queen, King) count as 10 each and an Ace can count as 11 or 1.

In most casinos players play against the dealer so you’ll need to deal card not only to the player but create logic for the computer to play against them.

Initially two cards are dealt and the play may place bets before the cards are dealt. Pay out is 2:1. Once cards are dealt to both player and dealer the player may choose to remain or “hit” take another card. Keep track of the points the player and dealer has so that if they go over 21 the other wins.

A Step Further

Going even further add graphics to your game to display cards. If it is a console game use ASCII art to display cards.

Typically the top card is shown so show the dealer’s top card. Add logic for the dealer based on the player’s top card so they “hit” if it is high enough and their cards are within a certain range.

Level 3

Texas Hold-em is a variation of poker where each player is delt 2 cards then share a center group of 5 cards to make the best hand out of the 2 cards they have and 3 of the 5 shared cards.

Each player must bet the same as the other players so if one raises the bet then the other players when it is their turn must at least bet the same amount as the largest bet to stay in the game. If a player drops out all Locts previously bet in that game are forfeit to the winning player.

Play starts with an initial bet then the first two cards are dealt to each player. This is followed by a round of betting. Each player may increase the bet, stay (not increase the bet), or fold (forfeit the turn and previous bets). This continues around the group until no new bets are place or need to be met.

Next the first three community cards are placed down. After that another round of betting begins. Next the 4th community card is show followed by another round of betting. Finally the last card is shown and the final round of betting begins.

Design the game so that there are 4 computer generated players and the fifth is the player of the mini game.

A Step Further

Going a step further add on option to make the game 5 Card Draw where each player is dealt 5 cards and then a round of betting ensues. After that round each player may trade in up to 3 cards, 4 if the one they keep is an Ace. Then the final round of betting.

Let's Play A Game

BJ’s niece had a birthday this month. As a surprise treat he’s asked you to help build her some fun games to play on her computer.

The Challenge

For this challenge we’ll be building a couple different games to play on the computer. Most will be text based with little graphics but if that is your expertise feel free to add any effects you want.

Creating a Test Case

Like in past challenges we’ll be using our tests to drive our development. No matter the level you choose to work with write a test case before you start your code. Then write just enough code to pass the test. Once you have passing code refactor to pass other test cases.

Level 1 Guess The Number

Write an program that creates a random number within a specified range (e.g. 1 - 100). Have the player input a number guessing the generated number. If it is the same the player has won. If it is not have the player continue guessing until they find the correct number.

Add a bit of a challenge to the game by assigning a point value to the amount of guesses a player makes. Keep track of the points for each round.

A Step Further

Going a step further offer to let the player have a hint. Start with a simple hint such as if the number is higher or lower than the guess. You may even offer to give a reduced range that the number could be within.

To increase the game feel reduce points for each hint taken. If you have multiple hint options they could be assigned a point value.

Level 2 Hangman

Hangman is a fun game kids like to play to stump their friends by writing out a number of blanks ___ on a board along with a scaffold for hanging someone. The blanks ___ correspond with letters in a word the players are trying to guess. Players have to guess the correct letters that are associated with the word or the image of a hanging stick man gets drawn.







|—–|
|
|
|
-–

_ _ _ _

|—–|
|    O
|    \|/
|    / \
-–

_ _ _ _

Create a hangman game that tells the player how many characters need to be guessed and how many chances they have left. If possible you may include an illustration. Also show which letters go into which spots on the word to guess. Indicate the letters that have been used either correct guesses or incorrect ones. You may do this my listing out the wrong letters or by having a list of available letters.

A Step Further

Gamify it even more by offering a difficulty level that sets the number of missed letters allowed before the game is lost. (Easy = 10, Normal = 5, Hard = 3)

Level 3 20 Questions

Kids like to ask a lot of questions, especially to their “know-it-all” uncle. Someone was smart enough to turn this into a game called 20 Questions.

For this level create game that will allow the user to ask questions to determine the chosen object or word. After each question allow the player the chance to guess the object. If they get it write they win if not they are allowed to ask another question about it.

To add to the challenge each question they ask reduces the number of points they get when guessing and each wrong guess reduces it even more. When the player has run out of points they have lost the game.

A Step Further

Reverse the roles. Have the computer ask the player questions to guess an object. Maintain the same rules for the points and when the computer has lost. Have it learn new objects so that if it does get one wrong it will add that data to it’s existing knowledge base and if that object is used again will get it correct. Also have the computer take a guess at the object once a certain threshold of information is gathered.

Church Directory

You have been asked by a local church for help maintaining their directory and to build functions that will automate tasks for the church staff.

Challenge

For this challenge we will be dealing with building complex objects and manipulating them. This may involve reading and writing to a file and creating a user interface for entering data. Since the challenge is not about designing good UI your interface may be console based or a simple HTML page, but it will need to have all the functionality required for the level of challenge you choose.

Similar to last month you will be presented with what the end user wants to be able to do but the actual design and architecture is up to you to create.

Creating a Test Case

We’ll continue to use test driven development. No matter the level you choose write a test case before you start coding. Then write enough code to pass the test. Once you have a passing test write more tests and refactor you code to accommodate all possible tests.

Level 1

The first step in an active church directory is to be able to enter the information for each family in the church. Store this information to a file for future retrieval.

The secretary needs to be able to input an address with city and state along with a home phone number (if one exists) for each family. The family may only be a single person or a mother and father with children and everything in between. Each person will have a name (first, middle, last), a date of birth, and some will have a cell phone number.

A sample JSON object may be:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
family: {
address: "123 Main St",
city: "Somewhere",
state: "TN",
adults: [
{
name: "Jane Smith",
birthDate: 1987-02-27,
cellPhone: "6155551234"
},
{
name: "James Smith",
birthDate: 1983-8-21,
cellPhone: "6155551235"
}
]
children: [
{
name: "Johnny Smith",
birthDate: 2010-05-21,
cellPhone: null
}
]
}

A Step Further

Make your directory indexable. The church has asked that they be able to look up families by last name so they can quickly update their information such as change of address or new child.

Level 2

Now that you have built them a directory the youth minister wants to automate sending out flier about an upcoming event to all of the families with children between the ages of 10 and 12. He normally handwrites these invitations but asked if you could personalize them automatically.

The text of the flier should read:



[LastName] Family
[Street Address]
[City] [State]

We are having a lock in for children ages 10 - 12 at the church on September 26, 2017. The youth staff wanted to make sure that [children’s first name between ages 10 - 12] know they are invited and need to bring a sleeping bag, tooth brush/paste, pajamas, and their favorite board game.

Doors will shut at 7:30 pm and open back up at 7:30 am.

Thanks,
Vinny Youts
Church Youth Minister


A Step Further

Since your flier for the youth minister was so successful the college/singles minister has asked you to send out an invitation to a singles retreat to all adults in their 20’s that are in a single adult family. If they have children she wants it to ask them to leave the kids at home.

The invitation should read:



[Full Name]
[Street Address]
[City] [State]

You are invited to a singles retreat for young professionals at church. It will be October 15 - 17, 2017 at [Choose a location].

Please bring a sleeping bag, tooth brush/paste, pajamas, and your favorite board game. All other necessities will be provided by the church.


If they have children include the following as well:



This is an adults only event so please make arrangements for [Children’s First Names] during the retreat.


Level 3

The church secretary now wants to import the old church directory into the new one so that all the existing families do not have to be reentered. Build a process for importing the JSON file with all of the families in the old directory.

Then go through the new directory and compare it with the information in the old to make sure that families are not duplicated with new ones that have been created. If they are remove the duplicates and/or update the record to show the most current information for each family.

A Step Further

They church has other directories that are not in JSON but in XML, CSV, etc. To be completely thorough build a process for each type they may have and import the data into the JSON file.

Birthday List

Will is not here this month because he is attending his daughter’s birthday party. In light of this we are going to help another little girl named Lisa to plan out her birthday.

Challenge

For this challenge we will be reading and writing to a file, organizing the information in the file, and presenting it to the user. This will involve creating a user interface which can be done in the console or as an html page or however you decide to build it.

This will also take some planning on your part as the developer in creating an architecture for your application. Each level presents you with what Lisa wants your app to do. As the developer you decide how to design the app to accomplish these tasks.

Creating a Test Case

Like in past challenges we’ll be using our tests to drive our development. No matter the level you choose to work with write a test case before you start your code. Then write just enough code to pass the test. Once you have passing code refactor to pass other test cases.

Level 1

To make sure she gets the toys she wants and cloths that fit Lisa has asked you to create an app that lets her enter and store a birthday wish list. She wants to be able to enter the items she wants, their type (toy, clothes, supplies, etc.) and any relevant information like size or color.

A Step Further

Once the wish list is created she needs to be able to print it out for her friends and family to see what she wants. If you have time Lisa would like for the toys to be listed on top, but don’t tell her mom that.

Level 2

Lisa needs your help to organize who she is inviting to her party. She will need to enter their name, address to send the invitation, relationship (family or friend), and their RSVP.

Once the table is created she’ll need to be able to print it out so that her mom can mail the invitations. Lisa’s mom told her that family comes first but it would be easier to mail if they are organized by city and state.

A Step Further

At the party Lisa needs to be able to track the gifts she has received and information about those gifts such as type of gift (toy, cloths, etc.). She also wants to know who gave her which gifts.

Hint: Adding a unique index to these tables will help track which records are associated.

Level 3

Now that the party is over Lisa doesn’t would rather play with her toys than write the thank you cards. She asked you to help her out by creating an app that will write the thank you card for her and include the name of the person attending along with the gift they gave.

Since her mom said family comes first have the family members thank you cards display first then the friends that gave her toys. Don’t forget about the friends and family that came to the party but didn’t bring a gift.

Sample Thank You Text

1
2
3
4
5
6
7
8
Grandma Ester
123 Main Street
Somewhere, TN 38583
Thank you Grandma Ester for coming to my birthday party and for the pink socks you gave me. I really like them.
Love,
Lisa

Hint: Use the information about the gift such as color to add more personalization to the message. This works with some types but not others.

A Step Further

Lisa really liked the wish list you helped her create but wants to know who gave her items from her list so that she knows who to send the list to next year. Also now that her birthday is over she wants to save the list for next year but remove the items she’s already received.

Ticket to Ride

BJ is down in Florida this week with his family visiting Disney and the beach. He’s a big kid and really gets along with his nieces and nephew. They all have rides they want to go on while at Disney but don’t like standing in line. We’re going to help them choose which rides to get Fast Pass tickets on.

The Challenge

For this challenge the family will be at Disney for 2 days. Each person gets 4 Fast Passes to skip the lines and they want to all ride together as much as possible.

Each of the kids and the big kid (BJ) have listed out their favorite rides in the table below. They have prioritized the rides (1 being top priority).

Name Ride Priority Park
BJ Space Mountain 1 Magic Kingdom
BJ Mad Tea Party 3 Magic Kingdom
BJ Peter Pan 4 Magic Kingdom
BJ Kali River Rapids 2 Animal Kingdom
John Peter Pan 1 Magic Kingdom
John Triceritop Spin 2 Animal Kingdom
John Wildlife Express Train 3 Animal Kingdom
John Dumbo 4 Magic Kingdom
Addie Small World 3 Magic Kingdom
Addie Kali River Rapids 2 Animal Kingdom
Addie Finding Nemo 1 Animal Kingdom
Addie Splash Mountain 4 Magic Kingdom
Kinley Small World 1 Magic Kingdom
Kinley Kilimanjaro Safaris 2 Animal Kingdom
Kinley Dumbo 3 Magic Kingdom
Kinley Wildlife Express Train 4 Magic Kingdom

Creating a Test Case

Like in past challenges we’ll be using our tests to drive our development. No matter the level you choose to work with write a test case before you start your code. Then write just enough code to pass the test. Once you have passing code refactor to pass other test cases.

Level 1

From the table of everyone’s favorite rides create a list of rides to get fast pass tickets so that each person gets to ride at least one from their list.

A Step Further

For each ride on the list of fast pass rides also print the names of the people wanting to go on that ride.

Level 2

Prioritize the rides based on how many people want to go on that ride. If more than one person wants to go on a ride it becomes a higher priority. Make sure everyone gets to go on at least one from their list.

A Step Further

If only one person wants to go on a ride they can go through the single rider line and not spend a fast pass ticket. Create a list of single rider rides and exclude these from the list of fast pass rides.

Level 3

The rides are spread between two parks. The family is spending two days at Disney going to one park each day. Create a list of 3 rides per park so that all members get to ride at least one on their list of rides.

Anagrams: Raga Mans

Anagrams are words or phrases that are created from the letters of another word or phrase. They are useful in games like Scrabble or Boggle as well as being a fun way to show your skill in coding.

The Challenge

This challenge was inspired by a code kata from Dave Thomas that can be found here. We’re taking his kata and making it our own. Though since he’s already created a thorough word list we’ll be using that as part of this challenge.

Dave Thomas Word List

In the challenge we’ll be looking at the characters in a word, counting them, and manipulating them. We’ll even turn it into a fun text based game. For each level you may use the command line for input and output or create a view to display on the web.

Creating a Test Case

Like in past challenges we’ll be using our tests to drive our development. No matter the level you choose to work with write a test case before you start your code. Then write just enough code to pass the test. Once you have passing code refactor to pass other test cases.

Level 1

For level 1 we’ll build a useful tool for counting the number of characters in a word or phrase. Start out by taking in a word or phrase as input. Then ignoring the spaces return the total number of characters in that word or phrase. Write unit tests for both words and phrases. Next return only the letters. Finally return the number of punctuation marks (.:;,!?)

Input:

1
2
Input a word or phrase:
This is a test.

Output:

1
2
3
Characters: 11
Letters: 10
Punctuation: 1

A Step Further

Going a step further we’ll add some math into the mix. Calculate the possible number of combinations of the letters in the phrase.

Input:

1
2
Input a word or phrase:
Test!

Output:

1
2
3
4
Characters: 5
Letters: 4
Punctuation: 1
Combinations: 24

Hint: The formula for calculating the possible combinations is n! or n(n - 1)(n - 2)…

Level 2

Instead of looking for the number of possible combinations of letters from the input create a list of combinations and then check that on the word list provided to see if the combination is an anagram or just gibberish.

Input:

1
2
Input a word to find it's anagrams:
start

Output:

1
2
tarts
trats

A Step Further

Going a step further include in your results phrases or multiple words with the same set of characters.

Input:

1
2
Input a word or phrase to find it's anagrams:
start

Output:

1
2
3
4
5
tarts
trats
rat St
art St
tar St

Level 3

Now the fun begins. We are creating a game of anagrams. Instead of taking in a word or phrase have the player input the number of characters for the word with a minimum of three characters. Next randomly select a word from the word list with that number of characters and display it to the player.

Allow the player to input different anagrams for the word selected. Calculate points based on the following scheme:

Input Points
Correct +2
Incorrect -1

Display the player’s score after they input their anagrams.

The display should look something like this:

1
2
3
4
5
6
7
8
Enter the number of characters for the word:
5
Your word is 'start' enter anagrams separated by a comma:
tarts, ratts, trats, rat st
Score: 5
Total Possible: 10

A Step Further

Make the game more interesting by adding a timer to limit the amount of time the player has to enter anagrams. If you have time make the game multiplayer and track scores for each player in the round.

Word Wrapper

Will has been having lots of trouble with the word wrapper in his favorite text editor. He complains about it all the time. So to help him out we are going to be writing some custom word wrapping.

The Challenge

For this challenge we will be writing a custom word wrapper to display formatted text when entered into an input. First you will take in the text as one long string then adjust it with word wrapping before displaying it.

You can do this in any language you choose but if possible display it so that it can be used on a website. Use whatever html and css you choose to write. If you complete one level and move to the next you’ll be able to reuse your html and css.

Creating a Test Case

Unit testing for this challenge will be a bit different than the testing we’ve done in past challenges. You will also need different types of tests for each level. As part of the challenge find a way to test the code before you write it. Let the tests drive your development.

Level 1

Start by creating an input field to take in the text as a string. Then create a break at each sentence so that each one displays on a different line.

Input

1
This is a test of the word wrapping system. Had this been a real word wrap someone else would have written it.

Output

1
2
3
This is a test of the word wrapping system.
Had this been a real word wrap someone else would have written it.

A Step Further

In college Will dated a girl that wrote long emails with run-on sentences and no capitalizations. It really annoyed him so let’s help out by capitalizing only the first letter in a sentence when we break them up or an ‘I’ in the middle of a sentence.

Input

1
i really enjoyed the movie last night. it was great. do you want to get lunch before class tomorrow? dana said you and i could meet them at noon.

Output

1
2
3
4
5
6
7
I really enjoyed the movie last night.
It was great.
Do you want to get lunch before class tomorrow?
Dana said you and I could meet them at noon.

Level 2

Instead of breaking at each sentence we want our app to function more like a word wrapper in a text editor so we will break at the end of the screen with some padding.

You can do this by taking in the number of columns with your text input or by determining the size of the screen and how many characters will fit on it. Remember to leave some space at the ends for padding.

Make sure you break at the end of a word and not in the middle of a word as in Example A not in the middle of a word as in Example B. Though you may break in a hyphenated word on the hyphen as in Example C.

Example A

1
2
This is a very long sentence that just keeps
going and going and going.

Example B

1
2
This sentence is also a long one but it doesn't bre
ak at the right place so looks funny.

Example C

1
2
3
This sentence is a rather long sentence that is a run-
on sentence with the word sentence in it way too much
when will it ever end?

A Step Further

Going a step further make your word wrapper dynamic so that as the screen size changes so does your end point for wrapping.

Level 3

For some reason Will doesn’t want his html or xml elements to be wrapped but he wants the text within them to be wrapped. So for Level 3 wrap only the text that is not contained within <>.

Input

1
<html-element class="theClass anotherClass makingItLonger" name="longElement">This is a really long html element, well not really as I just say that because I want you to think of it as long.</html-element>

Output

1
2
3
4
<html-element class="theClass anotherClass makingItLonger" name="longElement">
This is a really long html element, well not really as
I just say that because I want you to think of it as long.
</html-element>

A Step Further

Instead of taking in a string receive a file as your input (html, xml, or txt) and read the information on the file only adding the wrapper to the txt files and not the html or xml.

Music Cart

Here in Nashville we have a lot of musicians trying to make it big and some bigger ones continuing or changing their careers. Many of them do so using social media and even have their own websites while they are trying to get picked up by a record label. As the experts in computers we are here to help them out.

The Challenge

For this challenge we are going to be working on a variant of the shopping cart code kata. In it we will apply business logic to determine discounts and pricing for the items in our shopping cart.

In this case we are working with Lindsey, a local musician who needs a shopping cart built for her website. Lindsey currently has 3 self published album she is selling for $10 each.

If a fan purchases two different albums they will receive a 10% discount on the second album and if they purchase all three albums they get a 15% discount on the third but only if they purchase each of the three albums not three of the same album.

Creating a Test Case

A Unit Test looks at and tests a specific unit of code to see if it is returning what is expected. No matter the level you choose to work with write a test case before you start your code. Then write just enough code to pass the test. Once you have passing code refactor to pass other test cases.

Level 1

Start by creating a simple view allowing users to select the album or albums they want to purchase. Then write a function that calculates the total cost for the purchase. Assuming that all sales are made here in Nashville now apply a 9.25% sales tax to the purchase. Finally display for the user the total amount of the purchase, the sales tax, and the amount after tax.

A Step Further

Remember if a fan purchases a second album different from the first there is a 10% discount on that album and if they purchase all three albums there is a 15% discount on the third album. However if they purchase two or three copies of album 1 the discount does not apply.

Level 2

Lindsey has produced another album and is going on tour to promote her new album. As a thank you to her fans and to encourage more purchases she wants to give anyone that purchases the new album at full price 5% discount on any other albums they purchase on top of any other discounts that might apply.

A Step Further

As a special thanks to her fans who attend the concerts in her tour Lindsey is including with the ticket a discount code (LINDSEYROCKS!) for 4% off her fourth album. Add an input field for users to input the discount code if they have it. Then apply this discount only to album 4 along with the previous discounts.

Level 3

Lindsey also wants to include t-shirts at $20 each, sheet music at $15 each, and individual songs at $2 each. Add these to the shopping cart. Each album contains 8 songs, if a person buys all 8 songs on an album they should be charged the album price of $10 instead of the cost of all 8 individual songs. If a person purchases all of the individual songs of an album the same album rules apply so far as discounts are concerned. Including the 5% off with purchase of the fourth album at full price in Level 2.

A Step Further

Going all out for her superfans Lindsey is giving a discount to those that purchase only the songs from the set list of her tour concerts. If the fan purchases all of these songs individually each song is $1 instead of $2.

Lindsey’s Set List

Album Song
album 3 song 4
album 4 song 2
album 4 song 4
album 1 song 8
album 2 song 3
album 4 song 5
album 1 song 1
album 3 song 8
album 4 song 1
album 2 song 6

Date Time

Formatting data can be tricky especially when dealing with dates and times. Sometimes you’ll need to format the data to present just a month or year to the user other times you’ll need to format the user input to store in a database.

The Challenge

For this challenge we are working with dates and times. We’ll be formatting them to present to a user or display on a website. Many frameworks have tools to do this functionality for you but understanding the basics of how to format a date can help when your preferred framework doesn’t offer the functionality that you need.

The pattern for date time may vary depending on your language and framework. The universal sortable date time pattern is “yyyy’-‘MM’-‘dd HH’:’mm’:’ss’Z’”. Where ‘yyyy’ is year, ‘MM’ is month, ‘dd’ is day, ‘HH’ is hours, ‘mm’ is minutes ‘ss’ is seconds, and ‘Z’ is the offset from UTC. For example 2017-02-25 08:30:00-6:00 is the time and day this meet up started February 25, 2017 at 2:30 pm CST.

Creating a Test Case

A Unit Test looks at and tests a specific unit of code be it a controller testing if it calls the right functions or a converter service. Writing Unit Tests can be broken down into three areas Arrange, Act, and Assert. The three A’s of unit testing. When you Arrange you set up your test cases for testing. This could be as simple as setting a variable to be passed in or complex like creating a large object or calling the database to get an existing item to update. When you Act you are doing the functionality that you are testing. This could be calling a method or checking that your database connections exist or your converter service is functioning. Finally you need to Assert that what you are doing is actually working.

No matter the level you choose to work with write a test case before you start your code. Then write just enough code to pass the test. Once you have passing code refactor to pass other test cases.

Some languages and frameworks have testing suites available to help build test driven apps. Here is a simple example of a test for this challenge written in JavaScript:

1
2
3
4
5
6
7
8
9
10
11
12
function TestCase1(){
//Arrange
var dateTime = "2017-02-25T08:30:00-06:00"
//Act
var month = getMonth(dateTime);
//Assert
if (month === "Feb"){
return "Test Passed"
} else {
return "Test Failed"
}
}

Level 1

Given a specific date write a function to return the month as a string. If the month is ‘02’ then the function should return ‘Feb’ or ‘February’. Next write a function to return the day of the week. So if the input is ‘2017-02-25’ the function will return Saturday.

A Step Further

Going a step further write a function that returns the time of day using the following table.

Time Ranges Time of Day
6am - 12pm Morning
12pm - 5pm Afternoon
5pm - 7pm Evening
7pm - 12am Night
12am - 6am Early Morning

Level 2

Given a task and how long it will take to complete write a function that returns the time or day and time the task will be complete if started immediately. For example if given the task ‘clean the kitchen’ and time ‘25 minutes’ return the current time plus 25 minutes.

A Step Further

Going a step further add another function for the user to note the time they finished the task. Then return the difference in how long it took to actually do the task as opposed to the predicted time.

Level 3

Given user input as a string with date information write a function to standardize the date information and return it in a format of your choice. The date could be represented in different ways. For example:

  • 25-Feb-2017
  • Feb,25,2017
  • 25/Feb/17
  • February 25, 2017
  • FEB/25/2017
  • 02/25/2017
  • 2017-02-25

A Step Further

Going a step further add a function to standardize the time then combine it with the standardized date to return a date time in the format of your choice. The time could be represented in different ways. For example:

  • 12pm
  • 2:30pm
  • Seven in the Morning
  • 12 noon
  • 1430
  • 08:30

Numbers to Strings

A Unit Test looks at and tests a specific unit of code be it a controller testing if it calls the right functions or a converter service. Writing Unit Tests can be broken down into three areas Arrange, Act, and Assert. The three A’s of unit testing. When you Arrange you set up your test cases for testing. This could be as simple as setting a variable to be passed in or complex like creating a large object or calling the database to get an existing item to update. When you Act you are doing the functionality that you are testing. This could be calling a method or checking that your database connections exist or your converter service is functioning. Finally you need to Assert that what you are doing is actually working.

The Challenge

Last month we took numbers and converted them into roman numerals and then back. While testing along the way. Keep letting your tests drive your development as you work.

Data manipulation is a core part of programming. Many times this manipulation has to do with business logic such as converting one type or value to another. Some times this is because of what the customer wants such as seeing the words true and false in a database instead of 1 and 0. You might also need to convert a sum of money from a number into a string to automate writing checks.

This month’s challenge involves numbers and strings. We will be finding the numbers in strings converting them into text and then converting them back into numbers.

Creating a Test Case

No matter the level you choose to work with write a test case before you start your code. Then write just enough code to pass the test. Once you have passing code refactor to pass other test cases.

Some languages and frameworks have testing suites available to help build test driven apps. Here is a simple example of a test for this challenge written in JavaScript:

1
2
3
4
5
6
7
8
9
10
11
12
function TestCase1(){
//Arrange
var testNum = 3;
//Act
var result = ConvertToString(testNum);
//Assert
if(result == "three"){
console.log("Test Passed");
} else {
console.log("Test Failed");
}
}

Level 1

Create a simple converter to convert the numbers 1-10 to the text for that number so that if the number 2 is passed into the converter it returns “two”.

Next add to your converter service to allow numbers up to 1,000. If you have time you can keep going as high as you like.

A Step Further

Going a step further reverse the functionality of level one. This time write a service to convert a string representation of a number into the actual number. If the string “two” is passed into your service is should output the number 2.

Level 2

So far we’ve been working with just integers in this level convert numbers with decimals. If pass 2.5 into the converter it should output “two point five” or “two dot five”.

A Step Further

Going a step further instead of stating the decimals as “point” or “dot” convert them to fractions so that 2.5 will output “two and five tenths”. For a fun challenge try reducing the fractions so that 2.5 instead outputs “two and one half”.

Level 3

This level deals with strings that contain numbers in them. Start by finding the numbers in a string then convert them to a text representation of the number. If your input is “We have 2 dogs and 1 cat.” the output should be “We have two dogs and one cat.”

Start with the integers then add decimals and fractions into the mix so that “I ate 1.5 cookies” will output “I ate one point five cookies” or even “I ate one and one half cookies”.

A Step Further

Just like in level 1 going a step further involves reversing the conversion so that if the string “I drank eight cups of water today.” is passed into the converter it will output “I drank 8 cups of water today.”

Roman Numerals

Test Driven Development (TDD) is the concept of first writing a failing test for your code then coding to pass then test and refactoring to meet all possible test cases.

The challenge used to practice TDD focuses on loops and iteration with some simple math and string manipulation. Included in each level is a basic solution, look to it if you get stuck.

The Challenge

This is a simple variant of the Roman Numerals Code Kata where we will be taking arabic numbers and converting them to roman numbers (I, V, X, L, C, D, M).

The Romans developed a numbering system using letters. They were clever about this with rules so that you will not see more than three of the same letter together. Therefore 3 in roman numerals is “III” and 5 is “V” and then added these together to get higher numbers like 7 which is “VII”. To get 4 they had to subtract one from 5. They did this by placing the “I” to the left of the “V” so 4 is “IV”.

1
2
3
4
5
6
7
I = 1
V = 5
X = 10
L = 50
C = 100
D = 500
M = 1,000

Creating a Test Case

No matter the level you choose to work with write a test case before you start your code. Then write just enough code to pass the test. Once you have passing code refactor to pass other test cases.

Some languages and frameworks have testing suites available to help build test driven apps. Here is a simple example of a test for this challenge written in JavaScript:

1
2
3
4
5
6
7
8
9
function TestCase() {
var testNum = 3;
var result = ConvertToRoman(testNum);
if (result == "III"){
console.log("Test Passed");
} else {
console.log("Test Failed");
}
}

Your initial failing code would look as follows:

1
2
3
function ConvertToRoman(num){
return "";
}

In this case your initial passing code before refactoring would look as follows:

1
2
3
function ConvertToRoman(num){
return "III";
}

Why would we write such a useless function just to pass the test when we know we will have to refactor? In a way it tests the test to show that we are testing what we think we are testing. In this example it seems silly but with some of the testing available for advanced frameworks this is good because you may not be testing what you think and your passing code that will does not do what it is supposed to do.

Level 1

Create a simple tick counter so that if the number 3 is entered the output will be “///“. Then group the ticks into sets of five so that if 15 is entered the output will look like “///// ///// /////“.

A Step further

Going a step further replace the “/////“ with a simpler way of recognizing a unit of 5 ticks. For example if 12 is entered the output would be “V V //“. Don’t forget to adjust your test case to accommodate the change in output.

Solution

Level 2

Start out writing a simple function to pass your test case. So for the example test case the following code would pass just the test case:

1
2
3
function ConvertToRoman(num){
return "III";
}

Next refactor convert any number up to 3. Then add logic to convert 5 through 7. Next have your function determine if a number is between 5 and 3 and add the appropriate amount of “I” to the left of the “V” to subtract down. Continue refactoring to add 10’s, 50’s and 100’s. If you have time try to get any number up to 3,000.

A Step Further

Now that you’ve written your code to accept any number up to 3,000 go back and look at your code. You probably used a lot of if statements. Refactor your code to use less if statements and make it more legible to someone looking at it for the first time.

Solution

Level 3

In this level we are doing the reverse of the kata. Take an input of a roman numeral and convert it back to an arabic number.

Start with writing a test case. Then code to the test and refactor to accept any test case. A sample in JavaScript will be:

1
2
3
4
5
6
7
8
9
function TestCase(){
var testRom = "III";
var result = ConvertToArabic(testRom);
if (result == 3){
console.log("Test Passed");
} else {
console.log("Test Failed");
}
}

In this case the return value is an integer but you can have it return a string just set your test case up for the return type.

Hint

The only characters allowed are I, V, X, L, C, and M. Also romans did not have a concept of zero so you will not return that number.

A step further

Taking this a step further write your code so that it will return an error if the characters are not roman numerals or in the correct order of roman numerals but allow for both upper and lowercase on the characters allowed.

Solution

All Levels Bonus

If you have extra time build a user interface so that numbers can be entered byt he user then converted via your code then displayed in the new format.

Grocery List

These Challenges will help you learn some of the basic problems you might see on a white board in an interview. This challenge builds partly on some of the skills used last month but instead of manipulating arrays and strings we will manipulate objects and lists.

The Challenge

For this challenge we will begin with a grocery list. You will be manipulating this list to help buy groceries.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
{
"milk": "false",
"eggs": "false",
"batteries": "false",
"bread": "false",
"orange juice": "false",
"grape juice": "false",
"bananas": "false",
"pears": "false",
"apples": "false",
"American cheese": "false",
"Cheddar cheese": "false",
"Shredded cheese": "false"
}

Level 1

Each of the items in the grocery list has a boolean value of false. Write an app to help a shopper keep track of their items. Allow a shopper to change the value to true when they have selected the item. A value of false means they do not have the item and a value of true means it is in their cart.

Level 2

Adding to level 1 sort the items by the boolean value so that the items left (false) are at the top of the display and the items obtained (true) are at the bottom. Update the list as the shopper selects changes a value.

Level 3

Help the shopper further by grouping the items so they can find them easier in the store. Create a nested list or object with values for cheeses, fruits, etc. Then sort the items in the nested lists to only show the items not in the cart (false).

A step further

Add prices to the items and track the amount for the shopper. To really be impressive calculate the taxes as well.

String Manipulation

This CodeNewbie Challenge will help you learn some of the basic problems you might see on a white board in an interview. This challenge was based on some of the white board problems we’ve seen throughout interviews. The goal here is to familiarize yourself with the types of white board challenges you might face in an interview.

The Challenge

For this challenge we will begin with an array of strings:

1
["apple", "banana", "orange", "pear", "grape"]

In this challenge you will be manipulating this array and the strings within it.

Level 1

In the first level you will start by reversing the order of the strings in the array. Your output should look as follows:

1
2
3
4
5
grape
pear
orange
banana
apple

Level 2

The second level starts with reversals in mind but instead of reversing the list you are now to reverse the strings themselves. Your output will look as follows:

1
2
3
4
5
elppa
ananab
egnaro
raep
eparg

Next you will take a user input string and reverse it. The input should look like:

1
Input a string to reverse:

With user input:

1
Input a string to reverse: antidisestablishmentarianism

And your output will look as follows:

1
msinairatnemhsilbatsesiditna

Level 3

The third level takes a user input and reverses it to determine if it is a palindrome or a word or phrase that is the same forward as backward. Your input screen will look as follows:

1
2
Palindrome Check:
Enter a word or phrase:

If the user enters the word “aibohphobia” your output will be as follows:

1
aibohphobia is a palindrome

If the user enters the phrase “Are we not drawn onward to new era” your output will be as follows:

1
Are we not drawn onward to new era is a palindrome

If the user enters the word banana your output will be as follows:

1
banana is not a palindrome

Hint:

You’ll need to remove the punctuation on phrases.

A step further

Going a step further with string manipulation try taking two strings and checking to see if they are anagrams (words or phrases with the same characters but in a different order). Your output should state the two strings and if they are or are not anagrams.

1
2
3
Torchwood and Doctor Who are anagrams
bicycle and acyclic are not anagrams

Hint

An easy way to do this is to check character count for each string. If they match they are anagrams.

Happy Primes

Given the numbers 313, 331, 367 what comes next? Doctor Who fans will know.

This CodeNewbie Challenge is about finding Happy Primes. A prime number is one that is only divisible by itself and one. A happy number is a number that reduces to one when you take the sum of the squared digits and continue iterating it. An unhappy or sad number will continue iterating indefinitely.

For example 19 is a happy number:

12 + 92 = 82

82 + 22 = 68

62 + 82 = 100

12 + 02 + 02 = 1

A happy prime is a number that is both happy and prime.

The Challenge

The challenge is a math based coding and testing challenge. Your job is to find numbers that are happy primes.

Level 1

In the first level you will start by producing a list of the happy primes below 100 from a list of primes and a list of happy numbers. Then take a user input and determine if that number is a happy prime or not.

Prime Numbers Below 100:

[2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97]

Happy Numbers Below 100:

[1, 7, 10, 13, 19, 23, 28, 31, 32, 44, 49, 68, 70, 79, 82, 86, 91, 94, 97, 100]

Level 2

The second level starts where the first leaves off. You now need to find the happy primes from 0 - 500. Your challenge is to write code that generates a list of happy prime numbers between 0 and 500.

List of happy primes from level 1 (0-100) as a starting point:

[7, 13, 19, 23, 31, 79, 97]

Continue this list out to have all the happy primes from 0-500.

Level 3

The third level puts components of levels one and two together to determine if a number entered is a happy prime and if not what the nearest happy prime is to that number.

Your challenge is to write code that will determine if a given number is a happy prime or not. If it is not give the nearest happy prime to the given number.

List of happy primes 0-500:

[7, 13, 19, 23, 31, 79, 97, 103, 109, 139, 167, 193, 239, 263, 293, 313, 331, 367, 379, 383, 397, 409, 487]

A step further

Write your code so that any number may be tested even above 500.