Beefy Boxes and Bandwidth Generously Provided by pair Networks Cowboy Neal with Hat
Perl Monk, Perl Meditation
 
PerlMonks  

Re: TMTOWTDI Puzzle: Generating a range of numbers

by wog (Curate)
on Dec 19, 2001 at 04:38 UTC ( #132987=note: print w/ replies, xml ) Need Help??


in reply to TMTOWTDI Puzzle: Generating a range of numbers

(update: the first one has been edited to fix problems/bad style since I first pressed submit. Oopsie.)

use strict; my @result; my $one = "a" =~ /./; sub add { my($vA,$vB) = @_; ($vA,$vB) = ($vA^$vB,($vA&$vB)<<$one) while $vB; return $vA; } my $val = $one; do { push @result, $val; $val = add($val,$one); } until $one.$one eq $val;

... or, without any lines preceeding it in the file it's in ...

sub f { die if $::f_A; die if $::f_B; die if $::f_C; die if $::f_D; die if $::f_E; die if $::f_F; die if $::f_G; die if $::f_H; die if $::f_I; die if $::f_J; } my @vars = map { "::f_$_" } qw(A B C D E F G H I J); my @result; foreach (@vars) { $$_ = "true"; eval { f() }; push @result, $@ =~ /line ([^.]+)\./; $$_ = undef; }

update: A very, very cheap solution: (doesn't work on EBCDIC systems, sorry)

my @result = split " ", "pasarauatawavayaxapq"^"AAAAAAAAAAAAAAAAAAAA";


Comment on Re: TMTOWTDI Puzzle: Generating a range of numbers
Select or Download Code

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://132987]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others studying the Monastery: (8)
As of 2014-04-24 00:13 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    April first is:







    Results (557 votes), past polls