Qbasicnews.com
August 26, 2019, 12:30:02 AM *
Welcome, Guest. Please login or register.

Login with username, password and session length
News: Back to Qbasicnews.com | QB Online Help | FAQ | Chat | All Basic Code | QB Knowledge Base
 
   Home   Help Search Login Register  
Pages: 1 [2] 3
  Print  
Author Topic: Challenge: Compute number of days between two dates.  (Read 12015 times)
Moneo
Na_th_an
*****
Posts: 1971


« Reply #15 on: July 18, 2003, 12:11:51 AM »

MEG,

All the implementatioms that I've seen do one of the following:

1) Ignore the year 1582 problem altogether, just like your code does.

2) Pick a pivot date like 1800 or newer, and figure cumulative days as starting on January 1st of that pivot date.

You are one heck of a programmer for doing that program in 1.5 hours. It would take me more than that just to analyse the problem.

However, I must comment on the one-liner for calculating the number of days in a month. Although it works, I think this piece of code it is excessively complex, almost Machiavellian.

By the way, a published six-line algorithm exists for converting a date to the number of days from year zero. It also is a bit complex.
*****
Logged
Meg
Ancient QBer
****
Posts: 483


« Reply #16 on: July 18, 2003, 12:27:18 AM »

yeah it prolly could be calculated a lot easier.  what that line basically says is:

m = 31
if month is > 7 and odd, subtract one
if month is < 8 and even, subtract one

so it just uses weights and multiplies them by the boolean (m%>7) and (M%< 8 )

so it looks pretty complex, but it's pretty straightforward.

there prolly is a more efficient way to calculate it tho.  I was just coding really fast Smiley

*peace*

Meg.
Logged
Moneo
Na_th_an
*****
Posts: 1971


« Reply #17 on: July 18, 2003, 12:33:50 AM »

Again, Meg, you're something special. When I have to code something in  a hurry, I code it as straightforward as possible.  It really annoying to look at piece of code later and wondering what I was trying to do. Unless of course, I heavily commented it.
*****
Logged
Meg
Ancient QBer
****
Posts: 483


« Reply #18 on: July 18, 2003, 12:36:04 AM »

I try to comment my code, but i get really lazy about it.... Smiley

p.s. thanks so much for the kind words Smiley  i've always respected the way you handle people on this forum.  you've a knack for challenging and criticizing people in a way that's not insulting Wink  And also, I like that you don't get all up in a huff if somebody criticizes you  Very professional Smiley

p.p.s. my brain doesn't seem to grasp the concept of "straightforward" from time to time...

*peace*

Meg.
Logged
Moneo
Na_th_an
*****
Posts: 1971


« Reply #19 on: July 18, 2003, 01:32:02 PM »

MEG, I certainly thank *you* for your kind words. Youˇre a gal after me own heart. Some day I'll say that I met you on this forum, and not only were you most charming, but one of the best programmers that I ever met.
*****
Logged
Meg
Ancient QBer
****
Posts: 483


...
« Reply #20 on: July 18, 2003, 06:44:29 PM »

p.p.p.s.  I use altogether too many emoticons.
Logged
Blitz
I hold this place together
*****
Posts: 853



WWW
« Reply #21 on: July 18, 2003, 08:01:03 PM »

Meg, a girl name ?
Logged

oship me and i will give you lots of guurrls and beeea
oracle
*/-\*
*****
Posts: 3652



WWW
« Reply #22 on: July 18, 2003, 08:19:01 PM »

Yes (short for Megan), but is she a girl? We don't know. That would make 1 girl in these forums Tongue

Are you working on a project, Meg?
Logged

na_th_an
*/-\*
*****
Posts: 8244



WWW
« Reply #23 on: July 18, 2003, 09:57:31 PM »

Two, in fact. We have Meg and Bannana.
Logged

SCUMM (the band) on Myspace!
ComputerEmuzone Games Studio
underBASIC, homegrown musicians
[img]http://www.ojodepez-fanzine.net/almacen/yoghourtslover.png[/i
Meg
Ancient QBer
****
Posts: 483


« Reply #24 on: July 18, 2003, 11:04:17 PM »

Look out.  We're slowly taking over.

A project?  I'm always working on something.  My long-term project is a BBS game that's been in the works for many months.  It's called "Dungeon" and you can check it out at my BBS (telnet to 68.48.142.201 port 23 with an ansi-supporting telnet client.  I like mTEL32.)

*peace*

Meg(an).

p.s. I thought na_th_an was a girl for the longest time because of the picture on his posts....
Logged
oracle
*/-\*
*****
Posts: 3652



WWW
« Reply #25 on: July 19, 2003, 01:21:23 AM »

Na_th? Nah, he told me (all of us) he had a girlfriend ages ago (probably before you came). However, his rank (the old na_th_an rank) put me off, I didn't realise you could actually get the rank he had...
Logged

Nexinarus
Wandering Guru
***
Posts: 301



WWW
« Reply #26 on: July 19, 2003, 07:39:25 AM »

lol looks like meg cleaned up this competition Smiley. Im too stupid with dates im completely lost with them, we should count in BINARY! BINARY! j/k.

"In the time of 00101110001001001011010100101010010110001001010101 there once lived a young boy..." hehe.

sorry for this random post, im up late with no caffeen in me for at least 9 hours..  im starting to go crAzy..
Logged
Meg
Ancient QBer
****
Posts: 483


hm.
« Reply #27 on: July 19, 2003, 05:47:27 PM »

That's the stupidest idea since 0000000000000000000000000000000000000000000000000000000.

*peace*

Meg.
Logged
Moneo
Na_th_an
*****
Posts: 1971


« Reply #28 on: July 19, 2003, 06:05:44 PM »

Ok guys, we have 27 posts to this challenge but only 1 solution, that is, from Meg. Her elegant solution complies with all the specifications and works 100%.  

Doesn't anyone want to submit a solution of their own?
I'm going to establish a deadline of 21-Jul-2003 ar 23:59. GMT. If there are no better solutions by that time, Meg will be declared the winner.
Since Meg's solution works, a better solution would be considered as being simpler and having less code.
*****
Logged
Moneo
Na_th_an
*****
Posts: 1971


« Reply #29 on: July 21, 2003, 09:08:44 PM »

MEG IS THE WINNER OF THIS CHALLENGE.

CONGRATULATIONS, MEG, FOR AN EXCELLENT SOLUTION AND AN EXCEPTIONAL DATE HANDLING PROGRAM.
*****
Logged
Pages: 1 [2] 3
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.21 | SMF © 2015, Simple Machines Valid XHTML 1.0! Valid CSS!