This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
use ExtUtils::MakeMaker; | |
WriteMakefile( | |
"NAME" => "Perfect", # Name of package | |
"OBJECT" => "perfect.o perfect_wrap.o" # Object files | |
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
use strict; | |
use warnings; | |
## | |
# Write a script that computes the first five perfect numbers. | |
# A perfect number is an integer that is the sum of its positive | |
# proper divisors (all divisors except itself). | |
## | |
use Thread; | |
use constant THREAD_COUNT => 4; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
use strict; | |
use warnings; | |
## | |
# Write a script that finds the first square number that has at least 5 distinct digits. | |
## | |
use boolean; | |
use constant X_0 => 100; | |
sub is_distinct_five{ | |
my($n) = @_; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
use strict; | |
use warnings; | |
## | |
# Write a script to encode/decode Roman numerals. | |
## | |
use boolean; | |
use Fstream; | |
use Parse::YYLex; | |
use RomanParser; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
use strict; | |
use warnings; | |
## | |
# Write a script that computes the equal point in the Fahrenheit and Celsius | |
# scales, knowing that the freezing point of water is 32 °F and 0 °C, and | |
# that the boiling point of water is 212 °F and 100 °C. | |
# °F = (°C * 9/5) + 32 | |
## | |
for my $c (-100 .. 100){ | |
my $f = ($c * (9/5)) + 32; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
use strict; | |
use warnings; | |
## | |
# The numbers formed by adding one to the products of the smallest primes | |
# are called the Euclid Numbers. Write a script that finds the smallest | |
# Euclid Number that is not prime | |
## | |
use boolean; | |
use LWP::UserAgent; | |
use constant PRIME_URL => "http://primes.utm.edu/lists/small/10000.txt"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
use strict; | |
use warnings; | |
## | |
# Write a script to print the date of last Friday of every month of a given year. | |
## | |
use constant YEAR => 2019; | |
use constant FRIDAY => 5; | |
use constant JANUARY => 1; | |
use constant FEBRUARY => 2; | |
use constant MARCH => 3; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
use strict; | |
use warnings; | |
## | |
# Write a script to generate Van Eck’s sequence starts with 0. | |
## | |
my $i = 1; | |
my @sequence = (0, 0); | |
print join(" ", @sequence) . " "; | |
{ | |
my $last_index = (sort { $b <=> $a} grep { $sequence[$_] == $sequence[$i] } 0..(@sequence - 2))[0]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
use strict; | |
use warnings; | |
## | |
# Write a script to generate first 10 strong and weak prime numbers. | |
## | |
use boolean; | |
use LWP::UserAgent; | |
use constant PRIME_URL => "http://primes.utm.edu/lists/small/100000.txt"; | |
sub get_primes{ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
use strict; | |
use warnings; | |
## | |
# At a party a pie is to be shared by 100 guests. | |
# The first guest gets 1% of the pie, the second | |
# guest gets 2% of the remaining pie, the third | |
# gets 3% of the remaining pie, the fourth gets 4% and so on. | |
# Write a script that figures out which guest gets the largest piece of pie. | |
## | |
use constant PIE_SIZE => 100; |