Skip to content

Instantly share code, notes, and snippets.

@chrisdolan
chrisdolan / weights.pl
Created October 31, 2011 02:09
Intentionally brute force Perl solution to http://beust.com/weblog/2011/10/30/a-new-coding-challenge/
#!perl -w
use strict;
# Solution to http://beust.com/weblog/2011/10/30/a-new-coding-challenge/
# Chris Dolan
# Iterate over all combinations of weights, rejecting cases where they don't sum to 40
for my $w1 (1..37) {
for my $w2 ($w1..37) {
for my $w3 ($w2..37) {
@chrisdolan
chrisdolan / gist:1096327
Created July 21, 2011 01:36
string regex without qr//
$rx="(?^i:(fo+))"; print "fooooobar" =~ $rx;
$rx="(?^i:(fo+))"; $qrx = qr/$rx/; print "fooooobar" =~ $qrx';