Terrible at introductions so let's hop right to it

Post here once you join, and tell us about yourself so we have a clue who we are talking to.
Keep threads short here -- once you have something to say, there's a topic here somplace where it will fit -- and if not, let me know and I will make subforums as necessary. We want all of hard science and tech up here, and if something doesn't fit -- that's my fault and I will fix that for you. See the rules and tips in the parent forum, please.
Forum rules
This sub forum is for new menbers to announce themselves. Try not to create long threads here -- this is just for you to tell us who you are, and for us to say welcome. There are other forums to actually discuss real tech-science things here, and ask questions on. The idea hopefully is to have enough forums and subforums that nothing sci-tech related will be off-topic, there will be a place for it. If I missed something -- let me know, and I'll fix that.

Terrible at introductions so let's hop right to it

Postby Phillip Odam » Mon Oct 09, 2017 2:02 am

As Doug phrased it, I'm a late member of the flood from facebook after that vice video about him. If I haven't already lost you let's move on.

So I fell across this old post viewtopic.php?f=13&t=940 and Doug showed off the succinctness and some may say the beauty of Perl. The final, shortest solution being

#!/usr/bin/perl
$\ = $/;
for (0 .. 9) {print}

So of course I was left wondering could this be shortened. But before moving ahead, the length of that solution with all unnecessary whitespace removed is as follows

$\=$/;for(0..9){print}

My first shortening was to move the print to before the for loop (don't recall the name of this coding format, let's call it statement prior to control) so we can drop the curlies around the print and the parentheses on the for loop condition

$\=$/;print for 0..9

Remaining with this code format we can drop the assignment and instead explicitly detail what is to be printed. You'll notice the typical whitespace between print and the double qoute and between double quote and for is actually optional

print"$_$/"for 0..9

Lastly, we can save another character by dropping the quotes and concatenate the strings using period

print$_.$/for 0..9

And now in long form :-)

#!/usr/bin/perl
print $_ . $/ for 0 .. 9

Here's an attempt with an alternative approach which performs one print statement for all 10 lines by joining the range/array together with the new line character sequence. The blank string literal is included since the new line character sequence is only used to join two adjoining array elements, meaning no new line would be appended after the 9 if the blank weren't included

print join $/,(0..9,"")

However as you can see this is actually longer than what we'd started with, so much for that! Now, perhaps we get even shorter by having Perl write out and execute machine code... but can you really say that's a Perl solution
Phillip Odam
 
Posts: 4
Joined: Sun Oct 08, 2017 1:44 pm

Re: Terrible at introductions so let's hop right to it

Postby Doug Coulter » Mon Oct 09, 2017 6:28 pm

I almost beat even that, using say, but by the time you add use Modern::Perl...it's not good anymore. Maybe after installing a later version, but that's kinda cheating.
The reason many people flinch when you mention perl, and worse with golf is: https://everything2.com/title/SelfGOL
The craziest golf ever, by probably the smartest guy in the community.

While it's fun, these days I kinda strive to go the other way - un obfuscate, I type fast and neither I or my computer care much about keystrokes, just how long it takes to get the answer from here.
But it's still a fun game...

Oh, and welcome aboard!
Posting as just me, not as the forum owner. Everything I say is "in my opinion" and YMMV -- which should go for everyone without saying.
User avatar
Doug Coulter
 
Posts: 3515
Joined: Wed Jul 14, 2010 7:05 pm
Location: Floyd county, VA, USA

Re: Terrible at introductions so let's hop right to it

Postby RB Blackstone » Tue Jan 09, 2018 6:45 am

Wow. Very cool.

Tight code is fascinating, but I like to write un-obfuscated code for the next guy.

The next guy is usually me. I may not be able to build that house of cards in my head the second time.

Still, it is cool to see.

-RB
RB Blackstone
 
Posts: 10
Joined: Fri Jun 23, 2017 10:51 am

Re: Terrible at introductions so let's hop right to it

Postby Donovan Ready » Tue Jan 09, 2018 11:39 am

Ditto, RB. I don't have to edit my code very often, but when I do I like to be able to... :mrgreen:

Welcome, Phillip!
Donovan Ready
 
Posts: 239
Joined: Thu Apr 17, 2014 1:22 pm
Location: Austin, Texas

Re: Terrible at introductions so let's hop right to it

Postby Doug Coulter » Thu Jan 11, 2018 9:22 pm

Golf is fun if the goal is well-defined. I just make it up on comments...half my comments anyway are about the code that doesn't have to be there to check the stuff I know the state of anyway.
Posting as just me, not as the forum owner. Everything I say is "in my opinion" and YMMV -- which should go for everyone without saying.
User avatar
Doug Coulter
 
Posts: 3515
Joined: Wed Jul 14, 2010 7:05 pm
Location: Floyd county, VA, USA


Return to Announce yourself

Who is online

Users browsing this forum: No registered users and 2 guests

cron