Wow. I cant believe you're still pursuing this. Your code didnt do what it was supposed to. You can mumble about "the context it was written in" all you like. The rules said "Since warnings are supposed to be avoided, use strict; use warnings;". And your code fails this part of the specification.

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

and So you have changed the terms of the challenge to suit yourself. Very sportsmanlike. Not.

(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

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.