Posted by Abel Gancsos on Jan 16, 2012 in
Blog
Today, we celebrate the birthday of Martin Luther King Jr. In honor of what he has done, I wish to talk about him a little bit.
Martin Luther King Jr. was a great minister, but he wasn’t just a minister, he was also looked at as a great philosopher, at least in the ethics department. He wanted to start a revolution by changing the way that we thought at the time, but he also wanted to go back to the original set up of the government. In other words, he wanted us to go back to the original set up of the government, knowing what we know now.
He was a minister during times of great struggle for minorities. Minorities were constantly getting abused and mistreated, but MLK wanted to stand up for what is right. His “I have a dream” speech speaks of society’s progression and the development of equality and even though we still have issues with this topic today, I believe that he would have been proud of what’s going on because there is so much more equality now than he could have dreamt of during his time.
Sadly, not everyone supported his fight for equality. On April 4, 1969, he was assassinated. Later on, an organization was created in response to this, known as The Martin Luther King Jr. Center for Nonviolent Social Change.
MLK and Descartes are my two favorite thinkers because they have similar views, especially when it comes to equality. Both dealt with the idea that it’s not the outside that make a person and MLK taught us that we shouldn’t judge others just because they are a little different. Heck, if we were all the same in any way, that would make society completely boring and there would be no such thing as personality in the human race. In other words, we’d be just like any other animal, but we’re fortunate enough to have many different types of people.
It would be hard to talk about the end of abuse/disrespect of any group and not mention Martin Luther King Jr because he essentially spoke for every group, even though he focused on segregation issues, but his views weren’t limited to just one group.
Let me take this time to explain LRP by saying that it’s actually very closely related to MLK’s views. R stand for respect, respect being mutual understanding for each other. In other words, the golden rule. L stand for love and by respecting one another, you therefore show love. And finally, P stand for peace, because if you want peace, you need to have love, which you can get by respecting one another. When you put it together you get:
R
L P
That being finally explained, I have a great respect for MLK because he show that no matter what way a person is different, there is no justifying hurting/mistreating that person.
Compared to the past, I think we’re doing a great job with physical differences, even though we still need to work on it, but there’s another category we have to work on as a society-beliefs. The biggest differences we have now a days is the things we believe and see that world. For some reason, we can’t accept other people’s opinions and sometimes it gets so bad that it ends up in a war. Be it about religion, politics, or anything else, there has to be some way that we can accept other people’s opinions and not have to change ours. I think the thing is that we have to try and prevent making more of our opinions that what they are. In other words, your opinions, unless based on science or fact, is not truth, so you shouldn’t judge others based on your own opinion.
In conclusion, let me say that even though I don’t know you and you may not agree with my opinions, I still love you as a fellow human being and I wish you all the best. Happy MLK Day!
Posted by Abel Gancsos on Dec 31, 2011 in
Blog
Since it’s New Years Eve and people are making resolutions, but I don’t like making resolutions, I’d rather make a list of all the lessons learned over this past year:
1) Never go into business with a friend. Never go into business with a friend no matter how much you want to help each other because chances are the money will change one of you and your friendship will end up in the dumpster.
2) Friends are great, but family will always be there. Sometimes because they have to, sometimes because they want to, but they’re just always there. Depending on what type of a family, for emotional support or to help you with whatever needs you have that they can provide with.
3) Don’t try to do more than you think you can. No matter how smart you think you are or how good you may be, there is always something that you are unable to do. This one was very hard for me to accept with my ego, but it’s a fact of reality. Ironically enough, it’s at that point when you think that you are the best at what you do that something unexpected happens. Yes, you should always try to be the best at what you do, but when you think you ARE the best, you essentially set yourself up for a great fall and also in a way set yourself up to lose purpose of what you’re doing.
4) Live and learn. It would be unprofessional of me to say that it’s okay to make mistakes, even though we all do at times, but the point is to learn from them for the future. Along with that, try to be productive and learn to prevent the mistakes. It’s always better to think before jumping in. A job should be 90% analysis and 10% action, even though in many cases you only get paid for that 10% percent. Let me also mention that bad times will come and the best thing to do is take it slow, be aware of your surroundings, and learn something from it. No matter what the topic is, there is always so much to learn from it.
5) Be prepared to be humbled. Enjoy the times when you feel on top, but consider staying humble because there WILL come a time when you will hit rock bottom and you might want to keep some friends around for support. What I mean by this is don’t depend solely on friends to get back, but it’s easier to move on when you don’t feel alone.
6) Work smarter. Though hard work does seem professional and shows a person’s commitment, it’s all about getting the most things done as best as possible as quickly as possible. Hard work tends to wear you out, therefore smart working or thinking before doing an action, can easily accomplish this goal.
7) Relativity strikes again. When it comes to development, it’s okay for code not to work the same on ALL systems. Heck, since each system is different, that’s how it’s suppose to be. This shouldn’t give you an excuse to give out code that crashes though, so do the best you can with the knowledge of what the majority uses. There’s no point in waisting more resources for the minimum people that would get affected.
Thank you for reading. Thank you for your support during the past year. I hope you continue to give your support and have a happy New Year.
Posted by Abel Gancsos on Dec 29, 2011 in
Blog
Any time I go through the internet seeking more knowledge, something miraculous happens. I see answers that don’t make sense to me as to why they were posted. I have 2 main pet peeves when it comes to the internet and I’ll explain why these two pet peeves make sense.
The first pet peeve of mine is when people answer on a question forum, to those that are not familiar with Yahoo Answers and such, these are little communities where you can ask your legitimate question and someone should be able to answer it for you. This is great because out of all the billions of people on Earth, at least one person is bound to know the answer to your question. What’s my issue with this? Sometimes I see answers that should be deleted. For example, “Oh, I don’t know, sorry”. Why would you put that? If you don’t know the answer to a question, why would you want to put a comment like that? This to me is a deadly sin of the internet.
The second sin of the internet, so far, is when people ask a question and then someone tries to answer it, but they have absolutely no idea what they’re saying, leading to bad advice. Now, I’ve given some bad advice and I acknowledge that, nobody’s perfect, but I still believe that anything is possible with technology as long as you put enough time into it. Keep in mind technology isn’t perfect so each senario is different. Another issue I have with this is that they want to give a major, un-needed remedy to the simplest things.
Now, the reason why I believe these are rational pet peeves is because when I look at these, I’m sure I’m not the only one thinking, “Wow…these people should shut their mouths”. Course, I shouldn’t be talking, but at least I try to reason through the situation, not just say something completely asinine. I’m sure that the aliens are looking down on us and thinking, “Wow, what are we going to do with them” because since those comments are out in the open for billions to see, that automatically stereotypes us humans as idiots. And let me not even mention the furutre robots.
In conclusion, and I say this to myself too, when putting text online, be aware that if you put that on, everyone will be able to see it. And that’s not something that you can undo. Keep using the internet, but be careful what type of content you put on it.
Thanks for reading
Posted by Abel Gancsos on Dec 26, 2011 in
Blog
Have you ever heard or seen the words Intel, AMD, Quad Core, Core Duo, i5, i7? Well, those are all signs of the type of processor one has. In today’s post, I would like to approach one of the biggest questions today in the computer world-should I get an i5 or an i7? To the average person, it would sound logical to say i7, but that is not 100% true. It actually depends on so much, which we will go over in this post.
First off, what exactly is a processor? Contrary to what many people think, the CPU (central processing unit) is not the whole desktop computer. The CPU is actually a small 2 by 2 chip in the middle of the inside of the motherboard. The CPU is exactly what the name says-it deals with the processes that the computer does. In other words, it’s the brain of the machine. Therefore, the type of processor you choose is actually quite important. Now a days, there are 3 main levels of CPU’s-Core Duo, Core 2 Duo, and Quad Core. The names themselves give more information to the advanced users. The names can describe how many cores and how many processors are included. For example, Core Duo means that there is one CPU with 2 cores in it. What exactly is a core? A core is essentially the space where it is able to do a task. The more cores you have, the more you can do with ease. Most processors are able to do multiple things at once, but the older processors can only do so much at one time and the more you do, the less ease it will do it with. In other words, it will take up more resources, slowing the computer, and eventually crashing the machine. Just to clarify, in this case when I say “crash” I am referring to the need to reboot the machine. It is still functional, but since it used up all of it’s temporary resources, it needs to rest (reboot). Then you are given another information-the raw speed of the computer or cycles. This is usually measured in megahertz or some might even be measured in gigahertz. Since this is the raw speed, this can not be used to give an exact amount of speed of each process, but what you can do with this information is to pick the one with more potential speed. When choosing from two processors with the same amount of cores, you might want to consider the greater speed, depending on your need and budget. To help older computers run faster, you can always first try tweaking the machine with the settings and also the anti-virus programs running. Stay away from Norton only due to the way it scans the computer, it drastically slows down the processor. I’ve personally seen Norton CRASH machines, in this case where the computer was using up all of it’s resources by the time it completed booting up. It is a very messy program, but it is mandatory now a days to have some sort of protection. I highly recommend AVG because it is free, efficient, and it helps protect you a lot better than Norton. McAfee is also acceptable, but I would still recommend AVG. Even though there are more things involved with the CPU, what I’ve mentioned are the most important and efficient enough for you to pick a new computer.
Now that we have some of the basics down, I want to focus on the difference between i5′s and i7′s. Based on what we’ve learned earlier, i7′s would be the best, correct? But this is not always true. First off, since i processors are very messy to deal with, you need to understand the whole model number of the CPU. The basic difference is that in this case, the speed and quantity of processes that can be done vary GREATLY. So it’s very important to understand what you want-more speed or do more things at once. For example, an i5-650 is much faster than an i7-950/740QM, but with the i7′s, you are able to do a lot more at once. Therefore, when talking about i processors, the name is no longer enough to describe how good/bad it is. An understanding of the model number is greatly needed. So how to I pick the correct i processor? For the average person, it shouldn’t really matter because there are only certain things that the average person does with a computer. When it comes to gamers, you want to find an i7 with plenty of cycles. In other words, you want to be able to do as many processes at once, but also as quick as possible. When it comes to editing, I would assume that you would want a computer that is able to do more things at once since you would be working with many different tools. I’m not an editor, so I’m not sure what you would need, but from my understanding you would want to be able to do more things rather than quickly. When it comes to developers, well, I honestly believe that for developers a Core 2 Duo should be more than enough.
So, that all being said, which computer should you get? Well, the answer to that depends on other factors not mentioned in this post, but what we can answer is what “processor” should you look for. As mentioned earlier, there are two BRANDS of processors-AMD and Intel. The main difference is that AMD is cheaper, but has the same quality as Intel, which is why it’s a preferred part when it comes to building a computer. I personally prefer Intel mostly because it’s been around longer, which tells me that they have more expertise on the topic.
The next thing is how many cores. As mentioned before, there are three main quantities of cores-Core Duo, Core 2 Duo, and Quad Core. If you do not have one of these, you should strongly consider upgrading your computer. Core Duo’s are the minimum you should have, but I recommend at least a Core 2 Duo. Many technicians will be completely against the idea of Core 2 Duo’s, but that’s because they assume that Intel was trying to make a quad core computer, which is false. Core 2 Duo’s are specially Core Duo’s where instead of just one duo processor, there are two. Quad Core computers are a different story. This is where you can get into questions about i5′s and i7′s, which from the previously mentioned, you can now distinguish which one to choose. Quad Core computers should only be chosen by those doing powerful processes for example editing music/video/photos or gamers. Let’s just say that I have 3 Core 2 Duo computers and as a developer, I am very happy with them.
In conclusion, I sure hope that this brought some insight into computers, especially with sales around this time. My last advice for the season is to try and avoid Dell machines because even though they do use the same parts as the rest of them, it’s the way that they put it together that makes it inefficient and annoying to work with. Also, be careful when someone is selling you one processor over the other for much more money.
Thanks for reading.
Posted by Abel Gancsos on Dec 24, 2011 in
Blog
For tradition sake:
“Twas the night before Christmas, when all through the house
Not a creature was stirring, not even a mouse.
The stockings were hung by the chimney with care,
In hopes that St Nicholas soon would be there.
The children were nestled all snug in their beds,
While visions of sugar-plums danced in their heads.
And mamma in her ‘kerchief, and I in my cap,
Had just settled our brains for a long winter’s nap.
When out on the lawn there arose such a clatter,
I sprang from the bed to see what was the matter.
Away to the window I flew like a flash,
Tore open the shutters and threw up the sash.
The moon on the breast of the new-fallen snow
Gave the lustre of mid-day to objects below.
When, what to my wondering eyes should appear,
But a miniature sleigh, and eight tinny reindeer.
With a little old driver, so lively and quick,
I knew in a moment it must be St Nick.
More rapid than eagles his coursers they came,
And he whistled, and shouted, and called them by name!
“Now Dasher! now, Dancer! now, Prancer and Vixen!
On, Comet! On, Cupid! on, on Donner and Blitzen!
To the top of the porch! to the top of the wall!
Now dash away! Dash away! Dash away all!”
As dry leaves that before the wild hurricane fly,
When they meet with an obstacle, mount to the sky.
So up to the house-top the coursers they flew,
With the sleigh full of Toys, and St Nicholas too.
And then, in a twinkling, I heard on the roof
The prancing and pawing of each little hoof.
As I drew in my head, and was turning around,
Down the chimney St Nicholas came with a bound.
He was dressed all in fur, from his head to his foot,
And his clothes were all tarnished with ashes and soot.
A bundle of Toys he had flung on his back,
And he looked like a peddler, just opening his pack.
His eyes-how they twinkled! his dimples how merry!
His cheeks were like roses, his nose like a cherry!
His droll little mouth was drawn up like a bow,
And the beard of his chin was as white as the snow.
The stump of a pipe he held tight in his teeth,
And the smoke it encircled his head like a wreath.
He had a broad face and a little round belly,
That shook when he laughed, like a bowlful of jelly!
He was chubby and plump, a right jolly old elf,
And I laughed when I saw him, in spite of myself!
A wink of his eye and a twist of his head,
Soon gave me to know I had nothing to dread.
He spoke not a word, but went straight to his work,
And filled all the stockings, then turned with a jerk.
And laying his finger aside of his nose,
And giving a nod, up the chimney he rose!
He sprang to his sleigh, to his team gave a whistle,
And away they all flew like the down of a thistle.
But I heard him exclaim, ‘ere he drove out of sight,
“Happy Christmas to all, and to all a good-night!”
”
There is also this one:
”
Mary, a virgin, was living in Galilee of Nazareth and was engaged to be married to Joseph, a Jewish carpenter. An angel visited her and explained to her that she would conceive a son by the power of the Holy Spirit. She would carry and give birth to this child and she would name him Jesus.
At first Mary was afraid and troubled by the angel’s words. Being a virgin, Mary questioned the angel, “How will this be?” The angel explained that the child would be God’s own Son and, therefore, “nothing is impossible with God.” Humbled and in awe, Mary believed the angel of the Lord and rejoiced in God her Savior.
Surely Mary reflected with wonder on the words found in Isaiah 7:14 foretelling this event, “Therefore the Lord himself will give you a sign: The virgin will be with child and will give birth to a son, and will call him Immanuel.” (NIV)
The Birth of Jesus:
While Mary was still engaged to Joseph, she miraculously became pregnant through the Holy Spirit, as foretold to her by the angel. When Mary told Joseph she was pregnant, he had every right to feel disgraced. He knew the child was not his own, and Mary’s apparent unfaithfulness carried a grave social stigma. Joseph not only had the right to divorce Mary, under Jewish law she could be put to death by stoning.
Although Joseph’s initial reaction was to break the engagement, the appropriate thing for a righteous man to do, he treated Mary with extreme kindness. He did not want to cause her further shame, so he decided to act quietly. But God sent an angel to Joseph in a dream to verify Mary’s story and reassure him that his marriage to her was God’s will. The angel explained that the child within Mary was conceived by the Holy Spirit, that his name would be Jesus and that he was the Messiah, God with us.
When Joseph woke from his dream, he willingly obeyed God and took Mary home to be his wife, in spite of the public humiliation he would face. Perhaps this noble quality is one of the reasons God chose him to be the Messiah’s earthly father.
Joseph too must have wondered in awe as he remembered the words found in Isaiah 7:14, “Therefore the Lord himself will give you a sign: The virgin will be with child and will give birth to a son, and will call him Immanuel.” (NIV)
At that time, Caesar Augustus decreed that a census be taken, and every person in the entire Roman world had to go to his own town to register. Joseph, being of the line of David, was required to go to Bethlehem to register with Mary. While in Bethlehem, Mary gave birth to Jesus. Probably due to the census, the inn was too crowded, and Mary gave birth in a crude stable. She wrapped the baby in cloths and placed him in a manger.
The Shepherd’s Worship the Savior:
Out in the fields, an angel of the Lord appeared to the shepherds who were tending their flocks of sheep by night. The angel announced that the Savior had been born in the town of David. Suddenly a great host of heavenly beings appeared with the angels and began singing praises to God. As the angelic beings departed, the shepherds decided to travel to Bethlehem and see the Christ-child.
There they found Mary, Joseph and the baby, in the stable. After their visit, they began to spread the word about this amazing child and everything the angel had said about him. They went on their way still praising and glorifying God. But Mary kept quiet, treasuring their words and pondering them in her heart. It must have been beyond her ability to grasp, that sleeping in her arms—the tender child she had just borne—was the Savior of the world.
The Magi Bring Gifts:
After Jesus’ birth, Herod was king of Judea. At this time wise men (Magi) from the east saw a star, they came in search, knowing the star signified the birth of the king of the Jews. The wise men came to the Jewish rulers in Jerusalem and asked where the Christ was to be born. The rulers explained, “In Bethlehem in Judea,” referring to Micah 5:2. Herod secretly met with the Magi and asked them to report back after they had found the child. Herod told the Magi that he too wanted to go and worship the babe. But secretly Herod was plotting to kill the child.
So the wise men continued to follow the star in search of the new born king and found Jesus with his mother in Bethlehem. (Most likely Jesus was already two years of age by this time.) They bowed and worshipped him, offering treasures of gold, incense, and myrrh. When they left, they did not return to Herod. They had been warned in a dream of his plot to destroy the child.
This is how the birth of Jesus Christ came about: His mother Mary was pledged to be married to Joseph, but before they came together, she was found to be with child through the Holy Spirit. Because Joseph her husband was a righteous man and did not want to expose her to public disgrace, he had in mind to divorce her quietly.
But after he had considered this, an angel of the Lord appeared to him in a dream and said, “Joseph son of David, do not be afraid to take Mary home as your wife, because what is conceived in her is from the Holy Spirit. She will give birth to a son, and you are to give him the name Jesus, because he will save his people from their sins.”
All this took place to fulfill what the Lord had said through the prophet: “The virgin will be with child and will give birth to a son, and they will call him Immanuel”—which means, “God with us.”
When Joseph woke up, he did what the angel of the Lord had commanded him and took Mary home as his wife. But he had no union with her until she gave birth to a son. And he gave him the name Jesus. (KJV)
Luke 2:1-14
In those days Caesar Augustus issued a decree that a census should be taken of the entire Roman world. (This was the first census that took place while Quirinius was governor of Syria.) And everyone went to his own town to register.
So Joseph also went up from the town of Nazareth in Galilee to Judea, to Bethlehem the town of David, because he belonged to the house and line of David. He went there to register with Mary, who was pledged to be married to him and was expecting a child. While they were there, the time came for the baby to be born, and she gave birth to her firstborn, a son. She wrapped him in cloths and placed him in a manger, because there was no room for them in the inn.
And there were shepherds living out in the fields nearby, keeping watch over their flocks at night. An angel of the Lord appeared to them, and the glory of the Lord shone around them, and they were terrified. But the angel said to them, “Do not be afraid. I bring you good news of great joy that will be for all the people. Today in the town of David a Savior has been born to you; he is Christ the Lord. This will be a sign to you: You will find a baby wrapped in cloths and lying in a manger.”
Suddenly a great company of the heavenly host appeared with the angel, praising God and saying,
“Glory to God in the highest, and on earth peace to men on whom his favor rests.” (KJV)
The Visit of the Shepherds
Luke 2:15-20
When the angels had left them and gone into heaven, the shepherds said to one another, “Let’s go to Bethlehem and see this thing that has happened, which the Lord has told us about.”
So they hurried off and found Mary and Joseph, and the baby, who was lying in the manger. When they had seen him, they spread the word concerning what had been told them about this child, and all who heard it were amazed at what the shepherds said to them.
But Mary treasured up all these things and pondered them in her heart. The shepherds returned, glorifying and praising God for all the things they had heard and seen, which were just as they had been told. (KJV)
”
No matter what story you believe, if either of them, memories are important to have. Do you have any Christmas Eve memories? Are any of them good? Do you remember when kids would wake up bright and early, rush into the parents room and start a bunch of noise because of all the excitement? All of these memories are very important to keep because eventually you may experience trials during the holidays and it may very well cause difficulties to enjoy them in the future. It’s up to all of those great memories to help you through those Christmases. We all know the secret of Christmas, but let’s not ruin anything for those that still don’t know. I wish all of you the best of Christmases and for those that don’t really enjoy the holidays, know that you are not alone. You are not crazy and there is nothing seriously wrong with you. You simply had too many bad Christmases and that’s understandable. Whatever your reason, I hope you get through it as smooth as possible.
Posted by Abel Gancsos on Dec 23, 2011 in
Blog
function NOW(){
return date(“Y-m-d H:i:s”);
}
Posted by Abel Gancsos on Dec 19, 2011 in
Blog
Here are all the programs you should make on your TI scientific calculator for prob and stats:
Uniform dist:
Prompt A,B
Disp B+A/2
Disp A-B/12
Confidence Interval:
Prompt X,N,V,T
Disp (X+T((V)/sqrt(N)))
Disp (X-T((V)/sqrt(N)))
Hypothesis Testing Value:
Prompt X,N,A,V
Disp ((X-A)/((V/sqrt(N)))
Posted by Abel Gancsos on Dec 19, 2011 in
Blog
Here is a compiled header file for the most used sorting algorithms. Feel free to edit it to your needs:
#include
#include
using namespace std;
void quickSort(int a[],int left,int right);
void restoreup(int a[],int i);
void restoredown(int a[],int i,int n);
char *mergeSort(char letters[], char temp[], int array_size);
char *mSort(char letters[], char temp[], int left, int right);
char *merge(char letters[], char temp[], int left, int mid, int right);
void charBubbleSort(char a[],int max);
void bubbleSort(int a[],int max);
void restoreup(int a[],int i)
{
int value=a[i];
while((i>1)&&(a[i/2]{
a[i]=a[i/2];
i=i/2;
}
a[i]=value;
}
void restoredown(int a[],int i,int n)
{
int value=a[i],j=i*2;
while(j{
if((j j++;
if(a[j]break;
a[j/2]=a[j];
j=j*2;
}
a[j/2]=value;
}
void quickSort(int a[],int left,int right){
int pivot=a[(left+right)/2],tmp;
int i=left,j=right;
while(iwhile(a[i] i++;
}
while(a[j]>pivot){
j–;
}
if(itmp=a[i];
a[i]=a[i+1];
a[i+1]=tmp;
i++;
j–;
}
}
if(leftquickSort(a,left,j);
if(iquickSort(a,i,right);
//return a;
}
char *mergeSort(char letters[], char temp[], int array_size)
{
return mSort( letters, temp, 0, array_size – 1);
}
char *mSort(char letters[], char temp[], int left, int right)
{
int mid;
if (right > left)
{
mid = (right + left) / 2;
mSort( letters, temp, left, mid);
mSort( letters, temp, (mid+1), right);
merge( letters, temp, left, (mid+1), right);
}
return letters;
}
char *merge(char letters[], char temp[], int left, int mid, int right)
{
int i, leftEnd, elements, tmpPos;
leftEnd = (mid – 1);
tmpPos = left;
elements = (right – left + 1);
while ((left {
if ( letters[left] {
temp[tmpPos] = letters[left];
tmpPos += 1;
left += 1;
}
else
{
temp[tmpPos] = letters[mid];
tmpPos += 1;
mid += 1;
}
}
while (left {
temp[tmpPos] = letters[left];
left += 1;
tmpPos += 1;
}
while (mid {
temp[tmpPos] = letters[mid];
mid += 1;
tmpPos += 1;
}
for (i=0; i < elements; i++)
{
letters[right] = temp[right];
right -= 1;
}
return temp;
}
void bubbleSort(int a[],int max){
for(int i=0;ifor(int j=0;jif(a[j]>a[j+1]){
int temp=a[j];
a[j]=a[j+1];
a[j+1]=temp;
}
}
}
}
void charBubbleSort(char a[],int max){
for(int i=0;ifor(int j=0;jif(a[j]>a[j+1]){
char temp=a[j];
a[j]=a[j+1];
a[j+1]=temp;
}
}
}
}
You can download it from http://foxwebhosting.dyndns.org/lioncage/Packages/sort.h
Posted by Abel Gancsos on Dec 14, 2011 in
Blog
//$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$
//$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$
//$$Name: n-queens.cpp $
//$$Author: Abel Gancsos $
//$$Date: 12-15-2011 $
//$$Description: Solve the n-queens problem. $
//$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$
//$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$
#include
#include
#include
using namespace std;
int count2=0;
bool attack(int i,int j,int hist[],int col); //Checks the current values
void solve(int n,int col,int hist[]); //Solves the n-queens problem
int main()
{
int n,again=1;
timeval time;
double total,start,end;
//Loop until ready to quit
while(again==1){
cout<<"Enter number of queens: ";
cin>>n;
int hist[n];
gettimeofday(&time,NULL);
start=time.tv_sec+(time.tv_usec/1000000.0); //get start time in nanoseconds
solve(n, 0, hist);
gettimeofday(&time,NULL);
end=time.tv_sec+(time.tv_usec/1000000.0); //get end time in nanoseconds
total=end-start; //calculate total time
//Print out ellapsed time
cout<<"Elapsed time: "<
cout<<"1-Again 2-Close: ";
cin>>again;
}
return 0;
}
void solve(int n, int col, int hist[])
{
if (col == n) {
cout<<“\nNo. “<< ++count2<
for (int i = 0; i < n; i++, putchar(‘\n’))
for (int j = 0; j < n; j++){
//if is a queen, print out “Q”, otherwise print out “.”
putchar(j == hist[i] ? ‘Q’ : ((i + j) & 1) ? ‘ ‘ : ‘.’);
}
return;
}
//continue until complete
for (int i = 0, j = 0; i < n; i++) {
for (j = 0; j < col && !attack(i, j, hist, col); j++);
if (j < col) continue;
hist[col] = i;
solve(n, col + 1, hist);
}
}
bool attack(int i, int j,int hist[], int col){
if(hist[j]==i||abs(hist[j]-i)==col-j){
return true;
}
else{
return false;
}
}
Posted by Abel Gancsos on Dec 12, 2011 in
Blog
<html>
<head>
<style type="text/css">
span{
color:blue;
font-family:chalked,cracked,comic sans ms,chiller;
font-size: 120pt;
}
</style>
<script type="text/javascript" src="../jquery-1.6.4.min.js">
</script>
<script type="text/javascript">
function update ( )
{
var now = new Date ( );
var hours = now.getHours ( );
var minutes = now.getMinutes ( );
var seconds = now.getSeconds ( );
// Pad the minutes and seconds with leading zeros, if required
minutes = ( minutes < 10 ? "0" : "" ) + minutes;
seconds = ( seconds < 10 ? "0" : "" ) + seconds;
//
var month=now.getMonth()+1;
var day=now.getDate();
var year=now.getFullYear();
// Compose the string for display
var currentTime = "Months: " + (12-month)+" Days: "+ (23-day)+" Hours: "+(24-hours)+ " Minutes: "+(60-minutes);
// Update the time display
document.getElementById("time").firstChild.nodeValue = currentTime;
}
</script>
<title>Christmas Timer</title>
</head>
<body onload="update(); setInterval('update()', 1000 )" bgcolor="red">
<center>
<br/><br/><br/><br/>
<font color="green" face="Arial"><h1>Christmas Timer</h1><br/><br/>
<span id="time">
</span>
</center>
</body>
</html>