7 kyu
Going to the cinema
292 of 12,393g964
Description:
My friend John likes to go to the cinema. He can choose between system A and system B.
System A : he buys a ticket (15 dollars) every time
System B : he buys a card (500 dollars) and a first ticket for 0.90 times the ticket price,
then for each additional ticket he pays 0.90 times the price paid for the previous ticket.
Example:
If John goes to the cinema 3 times:
System A : 15 * 3 = 45
System B : 500 + 15 * 0.90 + (15 * 0.90) * 0.90 + (15 * 0.90 * 0.90) * 0.90 ( = 536.5849999999999, no rounding for each ticket)
John wants to know how many times he must go to the cinema so that the final result of System B, when rounded up to the next dollar, will be cheaper than System A.
The function movie
has 3 parameters: card
(price of the card), ticket
(normal price of
a ticket), perc
(fraction of what he paid for the previous ticket) and returns the first n
such that
ceil(price of System B) < price of System A.
More examples:
movie(500, 15, 0.9) should return 43
(with card the total price is 634, with tickets 645)
movie(100, 10, 0.95) should return 24
(with card the total price is 235, with tickets 240)
Fundamentals
Similar Kata:
Stats:
Created | Oct 27, 2015 |
Published | Oct 27, 2015 |
Warriors Trained | 36703 |
Total Skips | 4689 |
Total Code Submissions | 133864 |
Total Times Completed | 12393 |
Ruby Completions | 292 |
Python Completions | 2539 |
JavaScript Completions | 3321 |
Haskell Completions | 108 |
Java Completions | 1349 |
C# Completions | 557 |
Clojure Completions | 71 |
CoffeeScript Completions | 17 |
C++ Completions | 755 |
Elixir Completions | 145 |
TypeScript Completions | 260 |
PHP Completions | 436 |
Crystal Completions | 14 |
F# Completions | 54 |
C Completions | 485 |
Shell Completions | 91 |
OCaml Completions | 45 |
Kotlin Completions | 453 |
Fortran Completions | 27 |
Scala Completions | 166 |
Julia Completions | 28 |
R Completions | 124 |
PowerShell Completions | 93 |
Go Completions | 473 |
Nim Completions | 18 |
Rust Completions | 274 |
Reason Completions | 9 |
Racket Completions | 30 |
Forth Completions | 13 |
Dart Completions | 259 |
Haxe Completions | 14 |
Swift Completions | 419 |
Pascal Completions | 34 |
Lua Completions | 97 |
Perl Completions | 34 |
Elm Completions | 9 |
D Completions | 10 |
Erlang Completions | 18 |
Prolog Completions | 12 |
Total Stars | 502 |
% of votes with a positive feedback rating | 80% of 1843 |
Total "Very Satisfied" Votes | 1296 |
Total "Somewhat Satisfied" Votes | 373 |
Total "Not Satisfied" Votes | 174 |