Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Easter Sunday computation
#11
Quote:what I saw on the website weren't specifications but ALMOST code.

Had to replace x with * and set all vars to integers..

2003 = 4, 20.

Code:
CLS
DIM year AS INTEGER, a AS INTEGER, b AS INTEGER, c AS INTEGER
DIM d as integer, e AS INTEGER, f AS INTEGER, g AS INTEGER
DIM h AS INTEGER, i AS INTEGER, j AS INTEGER, k AS INTEGER,
DIM l AS INTEGER, m AS INTEGER, n AS INTEGER, o AS INTEGER

INPUT year

a = year MOD 19
b = year \ 100
c = year MOD 100
d = b \ 4
e = b MOD 4
f = (b + 8) \ 25
g = (b - f + 1) \ 3
h = ((19 * a) + b - d - g + 15) MOD 30
i = c \ 4
j = c MOD 4
k = (32 + 2 * e + 2 * i - h - j) MOD 7
l = (a + 11 * h + 22 * k) \ 451
m = (h + k + 7 * l + 114)
n = m \ 31
o = m MOD 31 + 1
PRINT n; o

Hmmmmmmmmm...... "Mexico QB Central" or "QB Mexico Central"
**************************************************
Ok, you now have some virgin code for an intricate problem. Get youself a copy of The Farmer's Almanac, which has a long list of dates for Easter Sunday, and check out about 50 random years, going back about 200 years and forward for about 200 years. Make sure to select a good number of leap years. When you've done this, and the dates check out exactly, you can consider that the routine works in general. When you get to this point, let me have a crack at testing it.
P.S. While testing my version, I discovered that the MOD instruction in QB does not work on negative number. I had to do this function the long way.
Have fun!
P.S. This "QB Central" guy now lives in Mexico City but was born and learned how to program in New York, New York.
*****************************************************
Reply
#12
Mr moneo, you may find turning BBCode on a good idea, because your posts, no matter how insightful, look frighteningly ugly.

Quote:P.S. This "QB Central" guy now lives in Mexico City but was born and learned how to program in New York, New York.

Only an american could write new york twice like the rest of the world was ignorant Tongue
Reply
#13
There is Buffalo, New York, too......

Well, the website seems like it's good..

Anyways, you put [/quote] instead of [/code]......
Peace cannot be obtained without war. Why? If there is already peace, it is unnecessary for war. If there is no peace, there is already war."

Visit www.neobasic.net to see rubbish in all its finest.
Reply
#14
Quote:Mr moneo, you may find turning BBCode on a good idea, because your posts, no matter how insightful, look frighteningly ugly.

moneo Wrote:P.S. This "QB Central" guy now lives in Mexico City but was born and learned how to program in New York, New York.

Only an american could write new york twice like the rest of the world was ignorant Tongue
**************************************************
Oracle, Thanks for your personal comments:
1) I joined this forum only yesterday and don't know what BBCode is, nor where to read about it --- please advise.
2) I said New York, New York to indicate New York City, specifically Manhattan, just like the song "New York New York". Ok?
**************************************************
Reply
#15
Moneo-- BBCode is the code used to format text in this forum. They're the little tags like [url], [quote], [b]etc.

To enable it when you post, look at the first checkbox right under the textbox where you enter text. If there's a check in it, uncheck it.

More about BBCode:

http://forum.qbasicnews.com/faq.php?mode=bbcode
size=9]"To announce that there must be no criticism of the president, or that we are to stand by the president, right or wrong, is not only unpatriotic and servile, but is morally treasonable to the American public." -- Theodore Roosevelt[/size]
Reply
#16
Progger: Thanks for the help re BBCode. I'll try it on my next coding example.
Reply
#17
it also fixes the messed up quoteing
[Image: sig.php]
Back by popular demand!
I will byte and nibble you bit by bit until nothing remains but crumbs.
Reply
#18
Agamemnus,...you can save some typing if you replace this with:

defint a-z

since *all* your variables are intergers...cheers

Code:
CLS
DIM year AS INTEGER, a AS INTEGER, b AS INTEGER, c AS INTEGER
DIM d as integer, e AS INTEGER, f AS INTEGER, g AS INTEGER
DIM h AS INTEGER, i AS INTEGER, j AS INTEGER, k AS INTEGER,
DIM l AS INTEGER, m AS INTEGER, n AS INTEGER, o AS INTEGER
Reply
#19
During my testing of a similar algorithm, I discovereed that ALL the variables dar to be defined as LONG, otherwise it didn't work for large year numbers. So, the original definitions should be changed from INTERGER to LONG. It's like chicken soup --- it wouldn't hurt.
Reply
#20
oh... but then what about really REALLY large years....... :lol:
Peace cannot be obtained without war. Why? If there is already peace, it is unnecessary for war. If there is no peace, there is already war."

Visit www.neobasic.net to see rubbish in all its finest.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)