From davidb-0fm0 at rcpt.to Fri Mar 28 00:04:59 2008 From: davidb-0fm0 at rcpt.to (David Basden) Date: Fri, 28 Mar 2008 00:04:59 +0900 Subject: [lore] [ucc] Murphy's Lore: Call for submissions In-Reply-To: References: Message-ID: <20080327150459.GB20212@wilfred.rcpt.to> On Thu, Mar 27, 2008 at 10:51:09PM +0900, Grahame Bowland wrote: > Hey guys > > For those of you that don't know, Murphy's Lore is that UCC's > occasionally published magazine. The last one we put out was jam > packed with quality journalism, delay slots, and pheromones. > > If you want to see the last edition published, grab it here: > http://grahame.ucc.asn.au/lore_2006.pdf > > I'm after articles for the next edition. If you've got something you'd > like to write about, please, contribute. Articles accepted in any > format I can read, and please let me know when you submit that the > article that you're happy to license it under the following license: > http://creativecommons.org/licenses/by-nc-sa/2.5/au/ > (or something more permissive if you like..) > > Some ideas for articles: > - write about an upcoming event > - write about an event that just happened, and how awesome it was > - how to commit evil in your favourite programming language (perl, > python, C, ML, ...) > - an article about a feature others might not know about in a language > - make a sudoku, crossword, where's Zanchey, etc > - hardware! computer architectures! something cool you learnt! > - ... whatever, I'll read it and might even print it :-) > > If you've already sent in articles, please send them again or at least > let me know you sent them so I know to look for them. > > I'll be at UCC next Friday night (the 4th) - I'll shout pizza for > people that want to do some Lore type stuff. > > Anyway, have fun > Grahame Friends don't let friends do PERL. use Term::ReadKey;use vars qw($XW $XH $FX $FY @W @X $D $GBy);sub Wc{return (rand($XW),rand($XH));}sub tZ{my($NX,$NY)=Wc();while($X[$NY]->[$NX]ne' '){ ($NX,$NY)=Wc();}$X[$FY]->[$FX]=' ';$X[$NY]->[$NX]='%';$FY=$NY;$FX=$NX;}sub MoK{print "\nThe dungeon collapses. You die.\n";print "Your score was ". scalar(@W)."\n";exit(0);}sub BgK{my($OX)=$W[0]->[0];my($OY)=$W[0]->[1];my( $NX)=$OX;my($NY)=$OY;D:{if($D==8){$NY--;last D;}if($D==2){$NY++;last D;}if ($D==4){$NX--;last D;}if($D==6){$NX++;last D;}}if(($NX<0)||($NX>=$XW)){MoK() ;}if(($NY<0)||($NY>=$XH)){MoK();}my($N)=$X[$NY]->[$NX];C:{if($N eq '%'){$GBy +=3;tZ();last C;}if($N ne ' '){MoK();}}$X[$NY]->[$NX]='@';unshift(@W,[$NX, $NY]);if(scalar(@W)>1){$X[$OY]->[$OX]='*';}if($GBy){$GBy--;}else{my($w,$wx, $wy);$w=pop(@W);$wx=$w->[0];$wy=$w->[1];$X[$wy]->[$wx]=' ';}}sub ae{my($w, $h,$g)=@_;$XW=$w;$XH=$h;print '^[[H^[[J';@W=();push(@W,[0,0]);my($fT,$lYH, $Zm);for $lYH(1..$XH){$Zm=[];for $fT(1..$XW){push(@$Zm,' ');}push(@X,$Zm); }$X[0]->[0]='@';$D=6;$GBy=$g;$FX=$XW/2;$FY=$XH/2;$X[$XH/2]->[$XW/2]='%';} sub pR{my($bH);print '^[[H';for(1..($XW*2+1)){$bH.='#';}print $bH."\n"; foreach(@X){print '#'.join(' ',@{$_})."#\n";}print $bH."\n";}sub mW{my($iL );ReadMode 4;while(defined($iL=ReadKey(-1))){K:{if(($iL eq '4')||($iL eq 'h')){$D=4;last K;}if(($iL eq '6')||($iL eq 'l')){$D=6;last K;}if(($iL eq '8')||($iL eq 'k')){$D=8;last K;}if(($iL eq '2')||($iL eq 'j')){$D=2;last K;}if($iL eq '5'){$D=2;last K;}}}ReadMode 0;}sub pH{ae(35,22,10);pR();for(; ;){select(undef,undef,undef,0.15);mW();BgK();pR();}}pH(); From davidb at ucc.gu.uwa.edu.au Fri Mar 28 00:50:11 2008 From: davidb at ucc.gu.uwa.edu.au (David Basden) Date: Fri, 28 Mar 2008 00:50:11 +0900 Subject: [lore] C hacks Message-ID: <20080327155011.GC20212@wilfred.rcpt.to> I was thinking that maybe people are just writing C that is either too readable, too inefficient or both. Maybe a connect-the-equivilent- code puzzle or something? Here is just a quick one 'cause I'm beyond tired, but please add to it; I don't know if the third works, and might not be a good idea to let out in public even if it does... while (*a++ == *b++); strcpy(b,a); a ^= b ^= a; int tmp = a; a = b; b = a; a >> 1; a = a / 2; b = (((a - b) & (1<<(sizeof(int)-1))) && b) || a; if (a > b) b = a; a << 3; a = a * 8; 1 << a; (int) pow((int) a, 2); a & 1; a % 2; a & 7; a % 8; (a & 15) || ++b; if (a % 16 == 0) b = b + 1; From adrian at ucc.gu.uwa.edu.au Fri Mar 28 10:33:50 2008 From: adrian at ucc.gu.uwa.edu.au (Adrian Chadd) Date: Fri, 28 Mar 2008 10:33:50 +0900 Subject: [lore] C hacks In-Reply-To: <20080327155011.GC20212@wilfred.rcpt.to> References: <20080327155011.GC20212@wilfred.rcpt.to> Message-ID: <20080328013350.GJ11451@ucc.gu.uwa.edu.au> And on that note, I can quote some passages from CPU optimisation guides - explaining how modern intel-based architectures differ from what you're being taught in introductory CS, and what you can do to fix it. Hm, an article on modern CPU architectures .. how many pages do I get? Is 2 ok? Adrian On Fri, Mar 28, 2008, David Basden wrote: > I was thinking that maybe people are just writing C that is either > too readable, too inefficient or both. Maybe a connect-the-equivilent- > code puzzle or something? > > Here is just a quick one 'cause I'm beyond tired, but please add to it; > I don't know if the third works, and might not be a good idea to let out > in public even if it does... > > while (*a++ == *b++); strcpy(b,a); > > a ^= b ^= a; int tmp = a; > a = b; > b = a; > > a >> 1; a = a / 2; > > b = (((a - b) & (1<<(sizeof(int)-1))) && b) || a; if (a > b) b = a; > > a << 3; a = a * 8; > > 1 << a; (int) pow((int) a, 2); > > a & 1; a % 2; > > a & 7; a % 8; > > (a & 15) || ++b; if (a % 16 == 0) > b = b + 1; > > _______________________________________________ > lore mailing list > lore at ucc.gu.uwa.edu.au > http://lists.ucc.gu.uwa.edu.au/mailman/listinfo/lore