Somewhere in upstate NY, there's a small theater that's trying to improve their software systems. There's a series of problems they need to solve though, and they want to do them all with functional solutions, involving Filter, Map, and Reduce. You'll have to deal with their Members, Big Data Scientists, and Russia to solve all the problems listed below. To make it a little easier, we've provided some sample data for you to play around with.
members = [
{name: 'Greg', age: 31, student: false},
{name: 'John', age: 21, student: true},
{name: 'Fred', age: 68, student: false},
{name: 'Beck', age: 11, student: false},
{name: 'Rick', age: 08, student: true},
{name: 'Luke', age: 09, student: true},
{name: 'Tina', age: 21, student: true},
{name: 'Stef', age: 24, student: false},
{name: 'Bell', age: 12, student: false},
{name: 'Rock', age: 25, student: true},
{name: 'Jess', age: 32, student: false},
{name: 'Fran', age: 13, student: false},
{name: 'Trey', age: 69, student: false},
{name: 'Andy', age: 75, student: true},
{name: 'Rose', age: 30, student: false},
{name: 'Alec', age: 55, student: false},
{name: 'Barb', age: 40, student: true},
]1. Members of the theater that are 60 and over, are eligible for a special
discount on their tickets. Given a list of members, return a list of members who
qualify for this special discount.
2. Members of the theater that are students are also offered a sweet discount.
Given a list of members, return a list of members who qualify for this discount.
3. The theater is thinking about showing some educational films for the large
student population. The theater also feels that members under 30 would also be
interested in these educational films. Given a list of members, return a list
of members that might be interested in watching these films.
1. The theater would like to print its entire list of members out for big data
scientists they keep in the basement. The big data people are looking into the
correlation between a member's name, and what movies they'll see. Given a list
of members, just return a list of names.
2. In a blind attempt to update all its records, the Theater would like to bump
the age of all its members one year. Given a list of members, return all the
members with an updated age.
3. Russia has recently hacked the theater's records to falsify members as being
students (they really want those sweet discounts). As a precaution, the theater
has decided to clear it's records, and make all members over 18 not students.
Given a list of members, return all the members with the modified status.
1. The Big Data folks really feel like they've struck gold now. They believe
that all the members 40 and under have similar names. Given a list of members,
return the names of all the members under 40.
2. The Theater wants to try some newfangled third party software, but it
requires handing off their current member data as a list of strings. Before all
of the members, it also wants a single line, just listing how many members the
system should expect to read in. Given a list of members, return the number of
members, and then each member's name.
3. After Russia's hacking, the Theater has also decided, that it will make all
its members under 17 students again, so that it has an effective clean slate.
Given all the members, return only the modified members, with the new student
validation.
snacks = [
{name: 'Skittles', type: 'candy', price: 2.99, brand: 'Hershey'},
{name: 'M&Ms', type: 'candy', price: 2.59, brand: 'Hershey'},
{name: 'Popcorn', type: 'popcorn', price: 3.99, brand: null},
{name: 'Soda', type: 'drink', price: 2.49, brand: 'Cola'},
{name: 'Water', type: 'drink', price: 1.99, brand: 'Cola'},
{name: 'ICEE', type: 'drink', price: 3.99, brand: undefined},
{name: 'Hot Dog', type: 'food', price: 4.99, brand: null},
{name: 'Burger', type: 'food', price: 4.99, brand: null}
]1. The Lambda Theater knows that the money is always in the concessions! They
recognize that some of their products don't have a brand yet though. Given a
list of snacks, return the list of snacks that have no brand.
2. The Theater knows they can depend on their popcorn and drinks to always sell
well, but they're not so sure about the other products. Given a list of snacks,
return only the snacks that are not popcorn or drinks.
3. Kids can be kinda cheap, but we know they'll always have at least a few
dollars worth of change. Given a list of snacks, return all the snacks that cost
less than 4 dollars.
1. The Data Scientists are really bothered that some of our data isn't quite
filled in. To appease them, the Theater has decided that for any brand that
isn't defined, use the type of the snack instead. Given a list of snacks, return
the list of snacks with the brand filled in.
2. Times are tough, and the Theater really needs to pull in some extra moolah to
keep the lights on. They want to bump up all the prices by 50 cents, just to
keep things afloat. Given a list of snacks, return all the snacks, with an
updated price.
3. The Theater plans on adding even more concessions, but they're afraid they
won't have enough room on the screens to advertise them all. Just to get some
numbers in hand, they want a count of how long the name of the product is. Given
a list of snacks, return a list of numbers with the length of the name.
1. The Theater has looked through the numbers you gave them, and has decided
that any name longer than 5 characters is going to have to change. Given a list
of snacks, return a list of snacks names that are longer than 5 characters.
2. The Theater is using yet another third party piece of software, but this the
software requires the price of each product, and then the name of the product.
Given a list of snacks, return a list with the price, and then the name (one
after the other).
3. Bumping up the price on all the products seems to have an averse affect on
sales. The Theater has decided that if it bumps up the lower costing items, that
maybe they can still get some extra cash. Given a list of snacks, return only
the list of snacks less than 4 dollars, with a 50 cent price increase.
movies = [
{title: "Pirates of Silicon Valley",
ticketPrice: 6.99, rating: 'PG13', showTimes: [5, 6]},
{title: "Jobs",
ticketPrice: 8.99, rating: 'R', showTimes: [2, 3, 5, 7]},
{title: "Steve Jobs: The Lost Interview",
ticketPrice: 7.99, rating: 'PG', showTimes: [2, 4, 6]},
{title: "Hawking",
ticketPrice: 8.99, rating: 'R', showTimes: [1, 4, 6]},
{title: "A Brief History of Time",
ticketPrice: 8.99, rating: 'PG', showTimes: [2, 4, 8]},
{title: "The Imitation Game",
ticketPrice: 6.99, rating: 'PG13', showTimes: [3, 4, 5, 7]},
{title: "The Social Network",
ticketPrice: 7.99, rating: 'PG13', showTimes: [7, 9]}
]1. The Theater feels really confident with it's PG13 selection of movies, but
isn't sure if it's scheduled them in the right spots. Given a list of movies,
return only the list of PG13 movies that run before 5.
2. The Big Data folks think that some of titles are just too long to run. Given
a list of movies, return the movies whose titles have more than 3 words.
3. The Theater is worried that some of it's younger audience members might not
pay for tickets if they're too expensive. Given a list of movies, return the
PG13 movies that are less 7 dollars.
1. The Data Scientists want all the data on the movies the Theater runs, but
doesn't care about the show times. Given a list of movies, return all the movies
with no show time information.
2. The Theater is using yet another third party software, and they need a list
of all the movies. They need the information to be in comma separated format
though, with the title, then rating, then ticket price. Given a list of movies
return all the movies in the string format.
3. In order to display the times correctly, the Theater needs to expand out its
showtimes. They want it in the format similar to "7:00pm", given a value 7.
Given the list of movies, return a list of showtimes in the expanded format.
1. The Big Data people want to search through all of the Theater's movies, just
by the title. The easiest way for them to do this is to get a long string of
movies, split by newlines. Given the list of movies, return a single string
containing all the movie titles.
2. The Theater wants to organize all their movies so it's easy for them to
access all their movies by rating. Given a list of movies, return an object,
whose keys are the ratings, and values are the list of movies with those keys.
3. The Theater is preparing to show all their movies on their website, however,
they don't want to overwhelm their members. They've decided to go the pagination
route, and only display 3 movies at a time. Given a list of movies, return
several lists, each containing up to 3 movies.