Re: 2014 Code Golf Challenge
by BrowserUk (Patriarch) on Jan 01, 2014 at 11:55 UTC
|
With the rise and rise of 'Social' network sites: 'Computers are making people easier to use everyday'
Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
"Science is about questioning the status quo. Questioning authority".
In the absence of evidence, opinion is indistinguishable from prejudice.
| [reply] |
|
| [reply] |
|
I've not been able to make that work in any character set supported by any of my text editors
My console defaults to code page 850 (see the pic.)
What I did was print:
[0] Perl> print ~'2014';;
═¤╬╦
And then c&p the output back inside the string:
[0] Perl> print ~'═¤╬╦';;
2014
Presumably if you do the same thing on your local console you should be able to get the same effect although the displayed glyphs will be different. (Though I guess it won't work for Unicrap consoles :)
With the rise and rise of 'Social' network sites: 'Computers are making people easier to use everyday'
Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
"Science is about questioning the status quo. Questioning authority".
In the absence of evidence, opinion is indistinguishable from prejudice.
| [reply] |
|
|
|
Re: 2014 Code Golf Challenge
by LanX (Sage) on Jan 01, 2014 at 21:27 UTC
|
well not the shortest, but funnily obfuscated and maybe an inspiration =)
DB<115> (hex hex e) . (hex e)
=> 2014
Cheers Rolf
( addicted to the Perl Programming Language)
BTW: "Hexe" means "witch"/"hag" in German, maybe an omen for supernatural things to come? :) | [reply] [d/l] |
Re: 2014 Code Golf Challenge
by ambrus (Abbot) on Jan 02, 2014 at 20:44 UTC
|
Not very short, but works:
print reverse$/,unpack HU,Ffman
Update: ok, make that
print~~reverse$/,unpack HU,Ffman
(thanks, choroba)
| [reply] [d/l] [select] |
|
$ perl -we'print reverse$/,unpack HU,Ffman'
1024
on all my current boxes, including Windows 7, and with all versions of perl from 5.6.0 .. 5.19.6. (5.005 and 5.004 don't know "U", so they print 1 and 5.003_07 prints 4)
Enjoy, Have FUN! H.Merijn
| [reply] [d/l] [select] |
|
I am getting 1024, too (reverse in list context). Fix:
perl -lwe 'print~~reverse unpack HU,Ffman'
| [reply] [d/l] |
|
| [reply] |
|
Care to explain that one? And more interestingly; how you discovered it? )
(I thought I was pretty oh-fay with un pack, but that ...? )
| [reply] |
|
unpack "C", "f" or unpack "c", "f" or unpack "U", "f" or ord "f" all give the character code of "f", which is 102. unpack "H", "A" gives "4", and you can replace the "A" with any other letter between "@" and "O". Thus, unpack "HC", "Af" returns ("4", 102). If you concatenate and reverse that list, you get "2014". From there, I just had to modify the strings until it gave something meaningful instead of random letters.
| [reply] [d/l] [select] |
Re: 2014 Code Golf Challenge
by hdb (Monsignor) on Jan 07, 2014 at 08:16 UTC
|
The source must not contain any digits, but if you name your script '2014', then the following does the job ;)
print${$|}
| [reply] [d/l] |
|
| [reply] |
Re: 2014 Code Golf Challenge
by snoopy (Curate) on Jan 01, 2014 at 21:15 UTC
|
Perl6 is unicode aware and can use character 2014 directly (N'Ko letter "ka"). 11 characters:
| [reply] |
Re: 2014 Code Golf Challenge
by rje (Deacon) on Jan 06, 2014 at 17:22 UTC
|
Mine are too long, not clever, and not obfuscated. Does participation count?
perl -e "print length(' '), length(''), length(' '), length(' ')"
or
perl -e "print length for (' ','',' ',' ')"
| [reply] [d/l] |