In Flight Entertainment
This is a problem set. Some of these are easy, others are far more difficult. The purpose of these problems sets are:
- to build your skill applying computational thinking to a problem
- to assess your knowledge and skills of different programming practices
What is this problem set trying to do[edit]
In this problem set, we are thinking computationally
The Problem[edit]
I found this problem on interview cake, and use it with gratitude[2].
You've built an inflight entertainment system with on-demand movie streaming.
Users on longer flights like to start a second movie right when their first one ends, but they complain that the plane usually lands before they can see the ending. So you're building a feature for choosing two movies whose total runtimes will equal the exact flight length.
Write a function that takes an integer flight_length (in minutes) and a list of integers movie_lengths (in minutes) and returns a boolean indicating whether there are two numbers in movie_lengths whose sum equals flight_length.
When building your function:
- Assume your users will watch exactly two movies
- Don't make your users watch the same movie twice
The collection of movies length in minutes:
#
# Movie length in minutes
#
movieLength = [110,150,159,180,100,145,185,90,93,98,102,122,120]
Unit Tests[edit]
- User Input: 252
- Expected output: True
- User Input: 90
- Expected output: False
- User Input: 120
- Expected output: False
Hacker edition[edit]
In the hacker version:
In addition to the output above, your program should calculate how many movies a user can watch on a very long flight.
How you will be assessed[edit]
Your solution will be graded using the following axis:
Scope
- To what extent does your code implement the features required by our specification?
- To what extent is there evidence of effort?
Correctness
- To what extent did your code meet specifications?
- To what extent did your code meet unit tests?
- To what extent is your code free of bugs?
Design
- To what extent is your code written well (i.e. clearly, efficiently, elegantly, and/or logically)?
- To what extent is your code eliminating repetition?
- To what extent is your code using functions appropriately?
Style
- To what extent is your code readable?
- To what extent is your code commented?
- To what extent are your variables well named?
- To what extent do you adhere to style guide?
References[edit]
A possible solution[edit]
Click the expand link to see one possible solution, but NOT before you have tried and failed!
not yet!