This file contains hidden or 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
| # "Currently it takes each of the three files, shoves it into a big array, reverses the whole mess, then prints it backwards. How would I make this flip each file and print it before moving to the next?" -Malfeas | |
| # Solution by jeek, obv | |
| # Improved by Malfeas | |
| foreach (@ARGV) { | |
| open CURRENT, $_; | |
| @backwards=reverse <CURRENT>; | |
| foreach (@backwards) { | |
| chomp; | |
| print "$_\n"; | |
| } |
This file contains hidden or 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; | |
| my @map=( | |
| [split (//,"###############")], | |
| [split (//,"# # #")], | |
| [split (//,"# #")], | |
| [split (//,"# ### ####")], | |
| [split (//,"#### ### # #")], | |
| [split (//,"# # #")], | |
| [split (//,"# # #")], |
This file contains hidden or 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
| $total=0; | |
| for ($trial=1;$trial<=10000;$trial++) { | |
| $answer=1+int(rand()*52); | |
| print "Trial: $trial\tAnswer: $answer\tGuesses: "; | |
| $guess=-1; $tries=0; | |
| while ($guess != $answer) { | |
| $guess=1+int(rand()*52); | |
| $tries++; | |
| } | |
| print "$tries\n"; |
This file contains hidden or 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
| $|=1; | |
| for ($n=1;$n<=7;$n++) { | |
| print "-\n"; $answer=""; | |
| @set=(); | |
| %bad=(); %good=(); | |
| $max=10**10; | |
| for ($i=1;$i<=$n;$i++) {push @set,$i;} | |
| while ($count<$max) { | |
| increment(); |
This file contains hidden or 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
| $\="\n"; sub ct {($_[0]+$_[0]*int(999/$_[0]))/2*int(999/$_[0]);} print (ct(3)+ct(5)-ct(15)); |
This file contains hidden or 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 | |
| sub generate { | |
| return int(rand() * 6 + 1) . int(rand() * 6 + 1) . int(rand() * 6 + 1) . int(rand() * 6 + 1); | |
| } | |
| $solution=generate(); | |
| for ($x1 = 1 ; $x1 < 7 ; $x1++) { | |
| for ($x2 = 1 ; $x2 < 7 ; $x2++) { |
This file contains hidden or 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
| A little bit of code I wrote involving Swiss tournaments with four participants in each match |
This file contains hidden or 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 | |
| # MediaWikiToTiddlyWiki.pl | |
| # tossed together by T.J. Eckman on October 16th, 2009 | |
| use warnings; | |
| use strict; | |
| use DBI; | |
| my $db = ''; # The name of the database | |
| my $dbhost = 'localhost'; # Where the Wiki is hosted |
This file contains hidden or 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
| sum = 0 | |
| for i in range(0,1000): | |
| if (i % 3 == 0 or i % 5 == 0): | |
| sum += i | |
| print sum |
This file contains hidden or 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
| import unittest | |
| from time import time | |
| class Memoize: # stolen from http://code.activestate.com/recipes/52201/ | |
| """Memoize(fn) - an instance which acts like fn but memoizes its arguments | |
| Will only work on functions with non-mutable arguments | |
| """ | |
| def __init__(self, fn): | |
| self.fn = fn | |
| self.memo = {} |
OlderNewer