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
#!/usr/bin/perl -l | |
use strict; | |
use warnings; | |
sub _split { | |
my $array = shift; | |
my @half = splice @$array, 0, @$array / 2; | |
return (\@half, $array); | |
} |
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; | |
sub make_combination_lock_iterator { | |
my @disks = @_; | |
my @combination; | |
my $inc; $inc = sub { | |
return @combination = (0) x @disks unless @combination; # initial position; | |
my $n = shift; | |
$combination[$n] = ( $combination[$n] + 1 ) % @{ $disks[$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
#!/usr/bin/env perl | |
# Can Be, [Feb 25, 2017, 9:32 PM]: | |
# Числа от 1 до н подряд | |
# Два выкинули | |
# Остальные случайно перемешали | |
# Сложили в массив | |
# Найти два утерянных числа | |
# За линейное время и за константную доп память | |
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
#!/usr/bin/env perl | |
use strict; | |
use warnings; | |
die "Usage: $0 <num_tests>" unless $ARGV[0] > 0; | |
my $changed_strategy_win_count = 0; | |
my $fixed_strategy_win_count = 0; | |
for ( 1 .. $ARGV[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 POSIX; | |
sigaction( SIGINT, | |
POSIX::SigAction->new( | |
sub { print [ unpack('I*', $_[-1]) ]->[3] . " killed me\n" }, | |
new POSIX::SigSet(SIGINT), | |
SA_SIGINFO | |
) | |
); | |
sleep 30; | |
print "exit\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
-module(cf). | |
-export([compare_files/2]). | |
compare_files(FileName1, FileName2) -> | |
OS1 = ordset_from_file(FileName1), | |
OS2 = ordset_from_file(FileName2), | |
OS1_uniq = ordsets:subtract(OS1, OS2), | |
OS2_uniq = ordsets:subtract(OS2, OS1), | |
case {OS1_uniq, OS2_uniq} of |