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; | |
package LinkedList{ | |
use boolean; | |
use Tie::RefHash; | |
use Class::Struct; | |
package Node{ | |
use Class::Struct; | |
struct( |
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 invert a binary tree. | |
## | |
use Graph; | |
use boolean; | |
use Graph::Reader::Dot; | |
use Graph::Easy::Parser; |
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; | |
## | |
# You are given an array @N of positive | |
# integers (sorted) and another non negative integer k. | |
# Write a script to find if there exists two indices | |
# i and j such that A[i] - A[j] = k and i != j. | |
# Print the pairs of indices, if any such pairs exist. | |
my @N = (2, 7, 9); | |
my $k = 2; |
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; | |
## | |
# Given an array @L of integers. Write a script | |
# to find all unique triplets such that a + b + c is | |
# the same as the given target T. Also make sure a <= b <= c. | |
## | |
use AI::Prolog; | |
use constant TARGET => 0; | |
use constant NUMBERS => "-25, -10, -7, -3, 2, 4, 8, 10"; |
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 accepts a message from the | |
# command line and prints the equivalent square secret | |
# coded message. | |
## | |
use constant SQUARE_SIZE => 8; | |
sub encode{ | |
my($message) = @_; |
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; | |
## | |
# You are given a string "123456789". Write a script | |
# that would insert "+" or "-" in between digits so | |
# that when you evaluate, the result should be 100. | |
## | |
use boolean; | |
use AI::Genetic; |
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; | |
## | |
# You are given the numbers 1, 2, 3, 4 and 6. | |
# Write a script to place these numbers in the | |
# rings so that the sum of numbers in each ring | |
# is exactly 11. | |
## | |
use AI::Prolog; | |
use Data::Dump q/pp/; |
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 decimal number 0 to 50 in octal. | |
## | |
MAIN:{ | |
for my $x (0..50){ | |
print "Decimal $x = Octal " . sprintf("%o", $x) . "\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 display attractive numbers between 1 and 50. | |
## | |
sub prime_factor{ | |
my $x = shift(@_); | |
my @factors; | |
for (my $y = 2; $y <= $x; $y++){ | |
next if $x % $y; |
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; | |
## | |
# Show multiple arrays content. | |
## | |
use Readonly; | |
Readonly::Array my @A => qw/I L O V E Y O U/; | |
Readonly::Array my @B => qw/2 4 0 3 2 0 1 9/; | |
Readonly::Array my @C => qw/! ? £ $ % ^ & */; |