Browse by Tags

Tagged Content List
  • Blog Post: Sieving irreducible monic polynomials over a finite field

    Last time we talked about the addition and multiplication tables for GF(2²) ; GF(2 8 ) is relevant for the Rijndael encryption scheme. Joan Daemen and Vincent Rijmen use a representation of GF(2 8 ) where each element is a polynomial of the form b 7 x 7 + b 6 x 6 + b 5 x 5 + b 4 x 4 + b 3 x 3...
  • Blog Post: Perl script to parse MPEG audio header

    I've written a perl script (attached) which will parse MPEG audio headers and display them in a human-readable format. For example, if you run it on ding.mpeg (also attached) you get this output: >perl mpegaudioheader.pl ding.mpeg Frame header: 11111111 111 (should be all ones) MPEG Audio...
  • Blog Post: Perl one-liner: approximate pi via Monte Carlo method

    http://programmingpraxis.com/2009/10/09/calculating-pi/ > perl -e"print 4/(map{$n+=rand()**2+rand()**2<1}1..pop)*$n" 5000 3.1336 59 characters , plus arguments.
  • Blog Post: Bad Perl: locker problem

    Bad Perl solution to the " print the open lockers " problem: perl -e"print join', ',map{$_*$_}1..sqrt pop" 100 54 characters. I prefer this to the 53-character solution obtained by omitting the space after the first comma. EDIT: 49 characters: perl -e"print map{$_*$_,' '}1..sqrt pop...
  • Blog Post: Bad Perl: Josephus problem

    Another programming contest asks to solve the Josephus problem . Bad Perl solution (83 characters... so close...) >perl -e" @_=(1..$ARGV[0]);++$c%$ARGV[1]?$i++:splice@_,$i%=@_,1while$#_;print@_ " 40 3 28 EDIT: got it down to 80. >perl -e" @_=(1..shift);++$c%$ARGV[0]?$i++:splice...
  • Blog Post: Bad Perl: Russian Peasant multiplication algorithm

    I found this programming contest interesting: here's what I've got. perl -e " ($a,$b)=@ARGV;map{$c+=$_*$b}grep{$a&$_}map{1<<$_}(0..log($a)/log 2);print$c " 7 19 I'm calling this a one-liner because the part between the quotes is less than 80 characters (75, to be exact.) The full...
  • Blog Post: Good Perl, Bad Perl

    One of my favorite languages is Perl . Perl has an ambivalent reputation; some people take to it, some accuse it of being a syntax-complete language. ( There's some truth to this. ) My view is that Perl gives you a very direct link into the mind of the programmer - much more so than other languages...
Page 1 of 1 (7 items)