What's here today
What's
Here Today:
Home
ABGoStop
Use a Microwave
Halloween 2011
New Year 2011
Dial-up Debian
Bison & Jr.
Cheezburger
New Town: Yellow River?
SuperMegaTroise
New Year 2010
Chocolate
Algebra
Sigs of the Intertubes
Convert with VLC
Vidork
The Bad Guy
Frozen
Boxer Song
The
Time-Shift Theory
Tekalja
Lame
Jokes
Pi Day
Old Stuff
Christmas
Countdown
My Thoughts
Cool Links
McCullaugh.com
Get the ParrotCattle Newsletter and check out what's up!
Or go to our Google+ page to have a flash back to the small time when we used Google+!
Privacy Policy
|
|
jawsh.mccullaugh.com -- Marry Chris, miss!
The jawsh.mccullaugh.com Christmas Countdown
Now that Christmas is getting near, I thought it would be great to post
a Christmas countdown in celebration of the season. Of course,
since I'm just a little bit odd (okay, I'm weird and a geek), I thought
it would be great to put a do it yourself Christmas countdown.
So, I sat down to lunch with one of my best friends who just happens to
be someone who really loves math and we (okay, mostly she... okay, she
did all of the work) came up with this equation to calculate how long
it would take until Christmas. Now, how this works is you put the
current date (just the date, not month or year) into the i variable. Then you set c=h=r=i=s=t=m=a=s. The output you get is the
amount of days until Christmas.
Here's the equation:
3Πc + 4Πh - 7Πr - i + 25 - t + m + a + s = Number of days till christmas
I also made a computer program that does the same thing. I'm not
currently distributing a binary version (one that just runs) right now
because there are probably many programs and websites out there that
have something like this. The point of this program is the code
itself so I'm giving you the source code in C. (That means you
have to get a C compiler and compile it yourself).
Here it is: (and yes, I've tested it and it works)
#include <stdio.h> #include <stdlib.h> #include <string.h> #include <time.h>
int getmonth(char thetime[]){ char tempy[4]; tempy[0] = thetime[4]; tempy[1] = thetime[5]; tempy[2] = thetime[6]; tempy[3] = NULL; if (strcmp(tempy,"Dec") == 0) return 12; else return 0; }
int getdate(char thetime[]){ char temp[3];
temp[0] = thetime[8]; //get the first number of the date temp[1] = thetime[9]; //get the second number of the date temp[2] = NULL; //end the string
return atoi(temp); }
int main(int argc, char *argv[]){ char thetime[28]; int month; int date;
if (argc == 1) { //first we get the time time_t rawtime; //making somewhere to store the time time(&rawtime); //getting the current time strcpy(thetime,ctime(&rawtime)); //putting the full time in a string
//now we're going to fetch the date from thetime to an int month = getmonth(thetime); //used to make sure it's december date = getdate(thetime); //used to calculate how many days till christmas }
else{ char datething[2]; strcpy(datething,argv[1]); month = 12; date = atoi(datething); }
//I stop commenting here so as not the ruin the fun if (month == 12) { if (date > 25) printf("It's after christmas. Sorry you missed it.\n"); else if (date == 25) printf("It's christmas!\n"); else { float c,h,r,i,t,m,a,s; i = (float)date;
c = i; h = c; r = h; i = r; s = i; t = s; m = t; a = m; s = a;
float pi = 3.141592653589793; //I know it's not terribly accurate but it should work for what we need.
float days_till_christmas;
days_till_christmas = 3*pi*c+4*pi*h-7*pi*r-i+25-t+m+a-s;
printf("Only %f days until christmas.\n", days_till_christmas); } } else printf("It's not December. This program only works in december. Sorry.\n"); return 0; }
Here it is in a .c file: christmas.c
Update:
The program used to segfault at the end but I fixed it so that it
won't. Another update to this page may be coming soon (hopefully
sometime tomorrow).
|
|
ads
JMC and the
Disenchantors
(songviper)
Break free to FrillerWorks
Quilts, doll clothes, and more at Susan's Sweaters.
Check out the other site: ArkwoodPond.info
Subscribe to the ParrotCattle
newsletter.
|