re: Daily Challenge #69 - Going to the Cinema VIEW POST

FULL DISCUSSION
 
#!/usr/bin/perl
use warnings;
use strict;

sub movie {
    my ($card, $ticket, $perc) = @_;
    my $reduced = my $sum = $ticket * $perc;
    my $count = 0;
    $sum += ($reduced *= $perc)
        while $ticket * ++$count < $card + int $sum;
    return $count
}

use Test::More tests => 3;

is movie(100, 200, 0.5),   1;
is movie(500,  15, 0.9),  43;
is movie(100,  10, 0.95), 24;
code of conduct - report abuse