Re: Christmas Coding Blues
by dws (Chancellor) on Dec 11, 2001 at 23:19 UTC
|
I re-examined my current projects here at the office, and I realize that I am only programming within my comfort zone. Nothing is challenging me, really, and although I've had some, what I think, are good ideas, none of them really motivate me to attempt anything new, or outside my current idiom. In other words, I'm in a dry spell, or maybe just the 'Code Duldrums'.
Learning isn't a linear process. It moves in fits and starts, with frequent plateaus. If you feel frustration building, that's a healthy sign that your engine is building up steam. Beware, though, that moving off of a plateau often means moving through a sudden decline in performance while you struggle with new ideas, or unlearn old ones. That, too, is normal and will pass.
Fare forward, traveler.
| [reply] |
|
|
| [reply] |
Re: Christmas Coding Blues
by scain (Curate) on Dec 11, 2001 at 23:04 UTC
|
I think I may be experiencing something similar, but I at least
know what the cause really is. I have several projects that
I have been putting off because I know they will be tedious
and not particularly challenging/interesting. But as the
end of the year approaches, I find that I have to get the things
done that I said I would get done. So grunt work it is for the
rest of the year.
Unfortunately, I don't have any suggestions for a good project
for you, but then, I don't have any for myself either.
Good luck and Merry Coding,
Scott
| [reply] |
|
|
Funny thing is, I'm really on target with everything I'm working on. I'm coasting really, and that's what has me concerned. It's just a sinewave, I suppose, and I'm on the "Suck" (trough) side of it. *shrug*C-.
| [reply] |
Re: Christmas Coding Blues
by dragonchild (Archbishop) on Dec 11, 2001 at 23:04 UTC
|
There was a golf on this earlier, on how to build a randomly-decorated tree. That was fun.
What about a golf that will tell you what day of the week Christmas will fall on, given a 4-digit year? *shrugs*
------ We are the carpenters and bricklayers of the Information Age. Don't go borrowing trouble. For programmers, this means Worry only about what you need to implement. | [reply] |
|
|
| [reply] |
|
|
my @days = qw(Sunday Monday Tuesday Wednesday Thursday Friday Saturday
+);
my $day = f($ARGV[0] || 2001);
print $days[$day], $/;
sub f {
#234567890#234567890#234567890#234567890#234567890#234567890#234567890
+#234567890
$b=1;for(1..pop){$b++;$b++if!$_%4;$b--if!$_%100;$b++if!$_%400}$b%=7
}
------ We are the carpenters and bricklayers of the Information Age. Don't go borrowing trouble. For programmers, this means Worry only about what you need to implement. | [reply] [d/l] |
|
|
sub f {
#234567890#234567890#234567890#234567890#234567890#234567890
use Time::Local;(gmtime timegm 0,0,0,25,11,-1900+pop)[6]
}
_____________________________________________________
Jeff[japhy]Pinyan:
Perl,
regex,
and perl
hacker.
s++=END;++y(;-P)}y js++=;shajsj<++y(p-q)}?print:??; | [reply] [d/l] |
|
|
|
|
|
|
37 chars.
However, I would say two things about this. First using ' istead of :: is so ugly that it isn't worth the 1 stroke saving. Secondly, although Perl Golf involves bending the rules as much as possible, using modules just goes against the spirit of the game.
# 39
sub xmas1 {
use Date'Manip;Date_DayOfWeek+12,25,pop
}
# 41
sub xmas2 {
use Date'Calc':all';Day_of_Week+pop,12,25
}
Update: I saved 2 chars by using May Day instead of Christmas. The politics of that may appeal to someone. :-)
# 37
sub xmas3 {
use Date'Manip;Date_DayOfWeek+5,1,pop
}
# 39
sub xmas4 {
use Date'Calc':all';Day_of_Week+pop,5,1
}
--
John.
| [reply] [d/l] [select] |
|
|
Some simple squishing down to 49 char:
sub f {
#234567890#234567890#234567890#234567890#234567890#
$b=1;$b+=1+!$_%4-!$_%100+!$_%400for(1..pop);$b%=7
}
UPDATE - I was just compression what the parent post had, making sure my answer gave the same as that one, but not looking at the real answer. As pointed out below, '!' binds higher than '%', and thus the answer this gives is wrong. Adding parens, and the fix that japhy adds brings this to 53:
sub f {
#234567890#234567890#234567890#234567890#234567890#23
$b=1;$b+=1+!($_%4)-!($_%100)+!($_%400)for 1..pop;$b%7
}
-----------------------------------------------------
Dr. Michael K. Neylon - mneylon-pm@masemware.com
||
"You've left the lens cap of your mind on again, Pinky" - The Brain
"I can see my house from here!"
It's not what you know, but knowing how to find it if you don't know that's important
| [reply] [d/l] [select] |
|
|
|
|
What are the golfing rules on modules? I always thought
modules were kind of cheating, but then I saw a couple of them in
the thread here. So I thought of using Date::Christmas, but that leads to an answer well
over 60 characters, but then you could really cheat and release the same module with a shorter module and function name and easily beat anything here. Which is why I always
thought using modules was sort of cheating (of course if
you could sneak in a 'christmasday' function into perl's
internals, that'd be cheating also, but impressive :-)
| [reply] |
|
|
|
|
Are you guys using another version of perl than
I am? At least here, the !-operator binds more tightly
than the %-operator, so that (!$_%4 &c) just won't work.
... or am I just giving away your joke now ... ?
Anyway, I guess this would work (checking the calendar). 65 chars; based on yours:
sub f {
#234567890#234567890#234567890#234567890#234567890#234567890#234567890
+#234567890
for(1..($b=pop)++){$b++;$b--if$_%4;$b++if$_%100;$b--if$_%400}$b%7
}
... or my best, so far, at 52:
sub f {
#234567890#234567890#234567890#234567890#234567890#2
$b+=$_%400?$_%100?$_%4?0:1:0:1for 1..($b=pop)++;$b%7
}
Update: Checking the calendar again ...
The Sidhekin
print "Just another Perl ${\(trickster and hacker)}," | [reply] [d/l] [select] |
|
|
|
|
|
|
It comes in at 66 and cheats by using a module... but it was really just so I could take Time::Piece for a spin... I *really* like it! Perhaps this snippet doesn't highlight its strong points, but you should take a look at it. I will probably be cutting way down on my Date::Manip/Date::Calc/Time::Local/POSIX::strftime usage, in favor of Time::Piece.
sub f{
#234567890#234567890#234567890#234567890#234567890#234567890#23456
use Time'Piece;(Time'Piece->strptime("25Dec".pop,"%d%b%Y"))->_wday
}
-Blake
| [reply] [d/l] |
Similar Threads
by drinkd (Pilgrim) on Dec 12, 2001 at 21:46 UTC
|
Now that I'm getting laid off in a few weeks, I have also been thinking about some perl "microprojects" to improve my skills in between reading ding letters.I have been looking through supersearch and found some similar threads in the past (without the Christmas bent, unfortunately). This and This thread are both asking for ideas on things to code, and have received more responses than your node has. A few people recommended Sourceforge, which has a list of projects requesting help. This and This node propose the idea of having a projects area on PM. Also, This node points out that the code snippets in the NIST algorithms pages include virtually no Perl, which looks bad. Last but not least, one of the Best Nodes is A plea by chromatic to get involved by writing test code for existing modules. drinkd | [reply] |
Re: Christmas Coding Blues
by dmmiller2k (Chaplain) on Dec 13, 2001 at 00:34 UTC
|
I am only programming within my comfort zone. Nothing is challenging me, really, and although I've had some, what I think, are good ideas, none of them really motivate me to attempt anything new, or outside my current idiom. In other words, I'm in a dry spell, or maybe just the 'Code Duldrums'.
Wow, I hear that! ++cacharbe !
Just as it gradually dawned on me that I too was coming to an almost identical conclusion about myself, I saw your post. If I tried, I don't think I could have described what I'm going through better than you just did. It's like you were reading my mind.
Perhaps it IS, as you suggest, seasonal. Or, perhaps further it's somehow September 11-related....
Wherever it's coming from, it's (sadly) almost comforting to see, from the other responses you've gotten, that we're not the only ones.
dmm
Just call me the Anti-Gates
| [reply] |