I chose to use -w and $^W=0 within the localised scope of a subroutine who's sole purpose was to avoid them, which is I think, a legimite tactic given this was golf and only keystrokes count.
As you said to me earlier
(fully tested*)
Fully tested under different terms than were specified for the challenge. Not fully tested under the terms of the challenge.
because you ran it in a context different from that in which it was designed to run and made no attempt to correct for that change of context in any meaningful way.
Im very sorry that I ran your code under the terms of the original challenge. Im very sorry I ran your code at all. (In fact I thought it was pretty neat, and tried to extend it. I now realize that I wasted my time.)
In fact you deliberately suppressed the (correct) output for reasons I can only speculate on.
What on earth are you talking about? Clearly you have completely lost the plot. I suppressed nothing. All I did was extend the test cases to handle a number of omitted difficult scenarios. Admittedly I didnt notice the rule that invalidated test case 'ii' but I apologised when you pointed out the rule (while lecturing me about changing the rules, something you seem to like to do yourself.) As for the warn=>die promotion I did that to automate the capturing and notification of warnings.
Please substantiate or retract your assertion that I suppressed something.
Even in this form, it still complies with the original spec and comes in at 83
Well, if this means that it pasess the provided test cases, then yes finally you have done it. However I dont believe that simply passing the test cases is sufficient. I believe that the spirit of the challenge was the following
Which your code DOESNT do. Consider that undef ne '' is false. However the two are clearly different. Since this is the basis of your solution it fails the challenge and its size is irrelevent.
I have added more test cases, tracked down the annoying bug in Elusions code that causes the original hash to become corrupt (I changed F($foo) to F({%$foo}) to avoid this impacting other attempts.)
So despite all of your blustering you have posted four solutions that fail the challenge. And in the process insulted someone who started out impressed and friendly. Nice work!
use warnings; use strict; use Carp; local $SIG{__WARN__}=sub {(my $str=join(" ",@_))=~s/[\n\r]//g;die("\t@ +{[(caller(1))[3]]}() => $str\n")}; my $foo = { aa => { O => 'zz', C => 'yy' }, # bb => { O => 'xx', C => 'xx' }, cc => { O => undef, C => 'ww' }, # dd => { O => 'vv', C => undef }, # ee => { O => undef, C => undef }, ff => { C => undef }, gg => { O => 0, C => 0 }, hh => { O => undef, C => 0 }, # #ii => { O => undef }, # jj => { O => 0, C => ' ' }, # kk => { O => ' ', C => 0 }, # ll => { O => undef, C => ' ' }, # mm => { O => ' ', C => undef }, # nn => { O => '', }, # oo => { O => '', C=> undef }, # pp => { O => undef, C=> '' }, # }; sub BUK{local($^W,$a)=(0,pop);grep{!exists$a->{$_}{O}or$a->{$_}{O}ne$a +->{$_}{C}}keys%$a} sub snw{no warnings qw(uninitialized);my$h=pop;grep{$h->{$_}{O}ne$h->{ +$_}{C}}keys %$h} sub sg_{my$h=pop;grep{!(defined($h->{$_}{O}&&$h->{$_}{C})&&$h->{$_}{O} +eq$h->{$_}{C}||!defined($h->{$_}{O}||$h->{$_}{C}))}%$h} sub eg_{my$h=pop;grep{!(($h->{$_}{O}||$;)eq($h->{$_}{C}||$;))}%$h} sub ddf{$a=pop;grep{$b=$$a{$_};defined$$b{O}!=defined$$b{C}||defined$$ +b{O}&&$$b{O}ne$$b{C}}keys%$a}#98 sub dex{$a=pop;grep{$b=$$a{$_};exists$$b{O}!=exists$$b{C}||defined$$b{ +O}!=defined$$b{C}||defined$$b{O}&&$$b{O}ne$$b{C}}keys%$a}#126 sub tad{my($h)=@_;grep{!exists($h->{$_}->{O})||(defined($h->{$_}->{O}) +?(defined($h->{$_}->{C})?($h->{$_}->{O}ne$h->{$_}->{C}):1):defined($h +->{$_}->{C}))}keys%$h}#162 sub ukg{local$^W=0;my$a=pop;grep{!exists$a->{$_}{O}or$a->{$_}{O}ne$a-> +{$_}{C}}keys%$a} #85 sub ukf{local($^W,$a)=(0,pop);grep{!exists$a->{$_}{O}or$a->{$_}{O}ne$a +->{$_}{C}}keys%$a} #87 sub ukh{$^W=0;$a=pop;grep{!exists$a->{$_}{O}or$a->{$_}{O}ne$a->{$_}{C} +}keys%$a} sub ukF{no warnings;$a=pop;grep{!exists$a->{$_}{O}or$a->{$_}{O}ne$a->{ +$_}{C}}keys%$a} sub mysort {return sort {$a cmp $b} @_} print " Required: aa cc dd ff hh jj kk ll mm nn oo pp\n"; print "--------------------------------------------------------------- +---------\n"; eval { print " tadman golf: ".join (" ",mysort tad({%$foo}))."\n"; } +; print $@ if $@; eval { print "BrowserUK golf: ".join (" ",mysort BUK({%$foo}))."\n"; } +; print $@ if $@; eval { print "sauoq No warns: ".join (" ",mysort snw({%$foo}))."\n"; } +; print $@ if $@; eval { print " Sauoq golf: ".join (" ",mysort sg_({%$foo}))."\n"; } +; print $@ if $@; eval { print " Elusion golf: ".join (" ",mysort eg_({%$foo}))."\n"; } +; print $@ if $@; eval { print " Demerphq defd: ".join (" ",mysort ddf({%$foo}))."\n"; } +; print $@ if $@; eval { print "Demerphq exist: ".join (" ",mysort dex({%$foo}))."\n"; } +; print $@ if $@; eval { print " browserUk f(): ".join (" ",mysort ukf({%$foo}))."\n"; } +; print $@ if $@; eval { print " browserUk g(): ".join (" ",mysort ukg({%$foo}))."\n"; } +; print $@ if $@; eval { print " browserUk h(): ".join (" ",mysort ukh({%$foo}))."\n"; } +; print $@ if $@; eval { print " browserUk F(): ".join (" ",mysort ukF({%$foo}))."\n"; } +; print $@ if $@;
Required: aa cc dd ff hh jj kk ll mm nn oo pp ---------------------------------------------------------------------- +-- tadman golf: aa cc dd ff hh jj kk ll mm nn oo pp main::BUK() => Use of uninitialized value in string ne at c:\temp\ +golf.pl line 25. sauoq No warns: aa cc dd hh jj kk ll mm main::sg_() => Use of uninitialized value in string eq at c:\temp\ +golf.pl line 27. Elusion golf: aa cc dd jj kk ll mm Demerphq defd: aa cc dd hh jj kk ll mm nn oo pp Demerphq exist: aa cc dd ff hh jj kk ll mm nn oo pp main::ukf() => Use of uninitialized value in string ne at c:\temp\ +golf.pl line 33. main::ukg() => Use of uninitialized value in string ne at c:\temp\ +golf.pl line 32. main::ukh() => Use of uninitialized value in string ne at c:\temp\ +golf.pl line 34. browserUk F(): aa cc dd ff hh jj kk ll mm
---
demerphq
You haven't lived until you've done 140mph in a Jaguar E type convertable!
In reply to Re: Re: Re: Re: Re: Re: (Golf) Warningless Comparison
by demerphq
in thread (Golf) Warningless Comparison
by tadman
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |