Skip to content

Instantly share code, notes, and snippets.

@adamcrussell
adamcrussell / LinkedList.pm
Last active May 9, 2020 23:39
Perl Weekly Challenge 059
use strict;
use warnings;
package LinkedList{
use boolean;
use Tie::RefHash;
use Class::Struct;
package Node{
use Class::Struct;
struct(
@adamcrussell
adamcrussell / ch-1.pl
Created April 26, 2020 21:44
Perl Weekly Challenge 057
use strict;
use warnings;
##
# Write a script to invert a binary tree.
##
use Graph;
use boolean;
use Graph::Reader::Dot;
use Graph::Easy::Parser;
@adamcrussell
adamcrussell / ch-1.pl
Created April 19, 2020 22:42
Perl Weekly Challenge 056
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;
@adamcrussell
adamcrussell / ch-1.pl
Created March 10, 2020 17:14
Perl Weekly Challenge 051
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";
@adamcrussell
adamcrussell / ch-1.pl
Created February 2, 2020 23:48
Perl Weekly Challenge 045
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) = @_;
@adamcrussell
adamcrussell / ch-1.pl
Last active January 26, 2020 21:35
Perl Weekly Challenge 044
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;
@adamcrussell
adamcrussell / ch-1.pl
Created January 19, 2020 06:59
Perl Weekly Challenge 043
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/;
@adamcrussell
adamcrussell / ch-1.pl
Created January 12, 2020 17:19
Perl Weekly Challenge 042
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";
}
}
@adamcrussell
adamcrussell / ch-1.pl
Created January 5, 2020 21:17
Perl Weekly Challenge 041
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;
@adamcrussell
adamcrussell / ch-1.pl
Created December 29, 2019 21:51
Perl Weekly Challenge 040
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/! ? £ $ % ^ & */;