Wednesday, August 21, 2013

Molecules in a teaspoon? Teaspoons in the ocean?

So back in college, I had a physics professor ask the class "Is there more molecules of water in a teaspoon, or more teaspoons of water in the oceans?" I initially thought there were more molecules of water in a teaspoon, but I didn't know for certain. Today, I did the calculations. Let’s start with the teaspoon.

1 Teaspoon of water is ~5cm3
The molecular weight of water is 2*(1.00794) + 15.9994 == 18.01528 g/mole

Water is pretty convenient in that it weighs 1 gram per cm3

5 g/18.01528 g/mol == .278 moles/teaspoon

6.022e23 * .278 == 1.67e23 molecules of water per teaspoon


Next, the world's oceans.

Surface area of Earth is ~500000000km2
Roughly 70% of the earth is covered in water.
The earth's average ocean depth is 4 km
1 km3 is 1e15 cm3

500000000*.7*4*1e15 == 1.4e24 cm3 of water in the ocean

Divide that number by the size of a teaspoon, and you get
1.4e24/5 == 2.8e23 teaspoons of water in the ocean

And we have our conclusion that there are in fact more teaspoons of water in the oceans, than there are molecules of water in a teaspoon. Long story short, I was wrong.

Wednesday, June 26, 2013

Me, a shovel, and Everest

So I have asked XKCD many times to answer my what if questions... but it's not happening, so I've decided to do the research myself, and find the answers myself. The first question on my mind is...

How long would it take to flatten Mount Everest to sea level using a shovel?
-Jason Thompson

The first problem with answering this question is deciding the volume of Mount Everest. Let's assume Mount Everest is more or less, cone like, and the base of the mountain is about 5 miles across. And from a base camp altitude of roughly 17,598 ft to a peak of roughly 29,029 ft, that gives us a height difference of about 11,431 ft. So calculating the volume is fairly straight forward, 1/3 * π * r2 * h, so we can say the volume from the base camp to peak is roughly 2.09*1012 ft3 of rock and dirt, and other mountain stuff. Since we're going to making it level with the sea we now have plenty of hole digging to do. The volume of the ground beneath Everest is roughly 9.633*1012 ft3. That leaves a total of 11.723*1012 ft3 of earth that needs to be moved.

When I was in high school I watched the movie Holes, and was so intrigued with the idea of digging a 5 ft deep hole, I went out, and spent 4 hours over a 2 day period digging a 6 ft deep hole, that was about 5 ft wide. Assuming Mount Everest is a mountain containing nothing but ideal digging dirt, and I have a conveyer belt that takes the dirt I put on it away to some faraway place, and there are no rocks larger than 1/2 a square foot, at a digging rate of 2 hours per day, 300 days a year (I need my holidays, and I'd take a break on Sundays), I've calculated the time it would take me to move Mount Everest at a quick 250.8 million years. According to this website, Mount Everest is only about 60 million years old. So it would take me 4 times its current age in order to completely remove it from its current home in Nepal.

But 2 hours a day is something I did for fun because I was intrigued. Let's say instead we sentence a single criminal to moving Mount Everest who works at the same rate per hour as me, but works longer days. We force this guy to work every day of the week, 12 hours a day, he get's 8 hours of sleep at night and can do whatever he wants (within his prison that provides him all the necessities of life) with the rest of his 4 hours a day. In these optimized conditions he would be able to work at a much quicker pace of moving all of Mount Everest and the ground below it down to sea level within 34.33 million years.

But using a single criminal is inefficient, what if we used all of the criminals today? There are approximately 9.2 million prisoners in the world. Let's get all of them to work, and we'll only use a couple of conveyer belts that take the dirt far away instead of 1 per person. That means realistically, only 5% of the prisoner population will be digging, and that's being generous, the rest are moving dirt. We'll replace people as necessary, but we'll keep the 9.2 million number for as long as they're working on Mount Everest. In this case, we can move Mount Everest in a much more reasonable 74.64 years, or 27243 days.

But using shovels are inefficient, what if we gave everyone who's digging a Caterpillar? With my shovel I move earth at a measly 471 ft3 per 4 hours. The Caterpillar I'm planning on giving to all those digging prisoners can move earth at a whopping 360 yd3 per hour. These Caterpillars are much larger than people with shovels, and we'll reduce the number of diggers down to only 1% of the prisoner population, everyone else is doing earth moving, not digging. At this rate we'll be done in as little 4.522 years, or 1650 days.

But using Caterpillars are inefficient, it is hypothesized that the Gulf of Mexico was actually created by a comet/asteroid some 66 million years ago, and that was what really ended the dinosaurs, and extinction events similar to that happen every 26 million years or so. So apparently we're due for another one of those any day now, and that would be able to remove Mount Everest for us fairly easily probably in a matter of minutes. Another problem comes in to play when we realize we would have to position either the Earth or the comet/asteroid so that Mount Everest would be decimated. But that's a topic for another discussion.

Wednesday, May 22, 2013

File compare

Today's problem must be solved in C++ without any special libraries (namely boost). There's an unknown number of  files of the format:

File1_1.txt // the files all start with File, followed by some number < 9999
followed by _1.txt
There's 5 lines of comments about this file.
These comments can contain any characters
such as `~!@#$%^&*()_+-=[]{};':",./<>? and not be disrupted
156 1.569e-1
200 0.5e+09
215 569
289 159E+009
350 150

For each of these files, there's a file with the exact same name in a folder in the parent directory of the current working directory. That file with the same name looks exactly the same, except for when we get to the numbers. Specifically the second number is different, i.e. :
156 1.568e-1
200 0.5e+09
215 569
289 159E+009
350 159

Within two same name files we will need to calculate the difference of the second number and find the largest difference in this file. Because 150 - 159 gives us abs(-9) == 9, 9 is the biggest difference for this particular file. We will not need to compare different lines.

The goal is to find the largest difference (absolute value of the difference) among all the files.

Friday, May 17, 2013

Contains Palindrome

The problem is, given any size string (has to fit in the String class) check to see if it contains a palindrome. We'll define a palindrome as longer than 2 characters. If the string contains a palindrome, print out true, otherwise print out false. I.E. abby -> false, abba -> true, repelevilasaliveleper -> true

Thursday, May 16, 2013

Next Palindrome

Given any number up to 1000000 digits long (far too large for any int double long float or any other number format common to programming languages) find the next lowest palindrome. So for example, if the number is 5, the next lowest is 6, given 9 the next lowest is 11, given 12 the next lowest is 22, given 123123 the next lowest is 123321, and the final example given 9877899835481354687 the next lowest would be 9877899836389987789. If the current number is a palindrome, find the next lowest after the current number.

Wednesday, May 15, 2013

Line Spacing?

So Irealized in my comments to my previous post, the line spacing of my code was not maintained. Does anyone know how to maintain it for comments? I supposed the same problem will occurr for the actual posts too.

Island Problem

Alright, now that that class is over I've decided that I'm actually going to keep this blog. I'm going to turn it into a programming blog of sorts, and if people start following it great. I program mainly in Java, however I'm fairly adequate in C++ as well. Let's jump straight into things, and here's the first problem that I'm trying to solve.

There's an island, and it is broken up into sections (similiar to a 2-d array). Each section is associated with a height. Unlike most islands that have mountains in the middle, this island has mountains on the edges. Assuming there's no water evaporation happening during a rainstorm the island could potentially form lakes. The problem is to be given a random island, and to calculate the maximum amount of water it can hold. Each height increment can hold 1 million gallons of water.

example:
We have the island

5 6 4
3 1 5
9 8 7

This island can hold 2 million gallons of water because the height in the middle can be raised by 2 before water starts leaking out into the ocean.

For simplicity we'll always deal with a square island (of sizes up to 20x20), and we can say that water does not leak diagonally. However the edges are not always higher than the middle spots.

Thursday, April 11, 2013

Why?

Some people do things because it helps society, and other people do things that earn them a lot of money. I was lucky in finding computer science because it allows me to do both at the same time. Technology is the future, and I don't fear what it brings. Granted it can and will be used for evil, but I am comforted knowing that I will be in that market, and I will do my best to influence it to good. It's a benefit that I will earn a decent income doing it, and if I ever feel I'm earning too much I can just give it back.

Wednesday, April 3, 2013

MMO Addiction

I'm a heavy gamer. I don't try to hide it, my wife is aware of it, yet I do not feel as if I'm addicted to video games. When my wife asks me to stop or do something else, although I would like to wait until I'm at a point where I can safely leave the game (not all games have pause options), if she truly insists, I have no quarrel hitting the "End-of-the-World" spell (alt-F4). All gamers, and especially heavy gamers, need to be able to pull the plug, and not be upset about it. Games are meant to relax and de-stress; as soon as fits are thrown, or attachments are made that are hard to be broken, the game is failing at its purpose and a new game should be found.

Wednesday, March 27, 2013

Here Comes Everybody

The news is slow. All news hits Twitter, Facebook, and other social media websites before any of the news companies report acknowledgement of it. The raid on Osama Bin Laden's compound that led to his death was reported on twitter as it was happening. The raid happened around 3 pm our time, and most news companies weren't reporting it until 11 pm. Clay Shirky, the author of "Here Comes Everybody," mentioned that the internet allowed for a change to be made, in the past there has been the idea of filter, then publish, now it's turned into publish, then filter.

It's super easy to publish now and because it's free anyone can publish anything they want. People are everywhere and they can report news far more quickly than any professional. Everything gets published now rather than what just the news people want to be published. Twitter and Facebook cover everything that all news agencies cover and there is the problem of over-crowding. Everyone paying attention to Twitter or Facebook can filter the news to decide for themselves what is important, however, they have to search through a larger amount of data before they find what they are looking for. Another problem is that there are those who use this ability to freely publish anything to their advantage and try to sabotage others. Wikipedia allows for anyone to publish any type of facts they want. Luckily there are more people out there trying to do good, and they quickly squash those looking for personal short-term gain by removing or adding to those posts for the well-being of society.

Monday, March 25, 2013

Using what we're given

I've spent a good deal of time trying to think of new technologies that only have foul uses, and I've failed to think of even one. Photography and cinematography are used for pornography, however they are also used to create beautiful photos of landscapes or movies that help teach lessons from the scriptures. Computers are powerful devices from which many uses are found, and as long as we find the right uses, such as working on family history or doing research on the Internet, they can be powerful tools for good. Our world is improving and growing; new technologies are created literally every day. There are always going to be ways to use these new technologies for evil, but we should focus on how we can use them for good.

Tuesday, March 19, 2013

Open Source

Open source projects are utterly amazing. I'm used to group projects where there's always a straggler who has to be carried along. The straggler's work always has to be double and triple checked and usually with extensive fixes. With open source programs, the world is the group and the project is nothing in comparison. It would seem that there should be a large probability that at least a few people will screw it up and write some really terrible code; however, experience has proven otherwise. I'm only experienced in school work, and, when looking at the population, there are plenty of people who just don't know how to code. When those who code poorly are forced onto a team, people have to make up for their performance. In open source, no one is forced into anything, and everyone contributes as they see fit. People don't want to code what they don't know how to code, and when people who can code want to code, things like Linux are born.

Wednesday, March 13, 2013

Family is Forever

I love my family. They are awesome and have made me who I am today; being raised in a home with eleven siblings and a mother and father who love me really helped shape my life. My parents taught me that there's no such thing as bad people, just good people making bad decisions; because of them I want to believe that everyone can change, and given proper motivation and opportunity they will. Now that I'm older and have moved away, I try to stay in contact with them so that I don't lose that relationship I have with them. I want to make that relationship last as long as possible, and through technology we have today like Facebook, email, and cell phones, I can. I was raised in the Church of Jesus Christ of Latter-day Saints, but the main reason why I continued in the faith was because it was at this church that I learned I can be with my family forever. The thought only gets better because I also learned I will not only be able to spend eternity with them, but I will be able to spend eternity with the entirety of my family tree. Now that I'm married and sealed to my wife, I will be able to spend eternity with her family as well. I've learned about life from my siblings, parents, and grandparents. They've taught me so much, and because I will be able to be with my family forever, even after this life I will be able to hear about the lives of all my ancestors, and the thought brings me so much joy.

Wednesday, March 6, 2013

Arrrrrrrrg!

Piracy is definitely one of those things that's greatly frowned upon in my family. It's been frowned upon in my family since the time it first became big. My parents never allowed it, and now I don't allow it. Other than the fact that it is wrong to steal from people, I'm deathly afraid of those companies who will go to great lengths to make sure that people suffer for their wrong doings. So afraid of them actually that I've avoided them all together, and rarely listen to any kind of new music. I'm content with my Beach Boys CDs that I've transferred to my computer, and I'll be content for many more years until those companies seem less scary, and more wanting of my money. Don't get me wrong, I know they want my money, they just don't know how to get it yet, and when enough people stop buying stuff from them, the power will return to the consumer, where it's actually been the whole time anyways.

Tuesday, February 19, 2013

RIP (rest in pieces) Hotmail

Email is such a hassle. I have four different accounts, and I only regularly check one. There's one for websites that require an email for sign-up (the kind that you know are going to send you spam), there's one for when I was in elementary/high school, there's one for when I decided to grow up, and there's one for all my Google uses. Luckily, in this modern world we live in, there's now a service that handles it for me, and I only have to go to a single place again. I don't know what's up with people and how they love to hate Microsoft, but I feel they're doing a pretty good job of staying on top of things. I tip my hat to those guys, well done.

Thursday, February 14, 2013

Cuckoo's Egg

I'm glad we've learned from our mistakes, well, relatively speaking. Hacking wasn't that big of a deal back when this book was written. The cause of this was mainly because the internet wasn't around for very long up to that point. It was still very new, and all the wonderful uses of it had yet to be determined. It's a little sad that it took 16 years before the US government enacted the FISMA of 2002, but still, progress is progress, no matter how slowly that progress is made. Now that FISMA is in place, all government agencies are required to have some sort of information security, aka cyber security. The problem still remains though that security is just that, security, and there seems to be few entities, if any (I couldn't find any online), that track down existing hackers. The hacking group known as Anonymous is possibly the largest group that I know of, and they've been around since 2003, one year after FISMA was set in place. They've shown no sign of slowing down, and I don't believe they will as long as there's no one willing to stop them, or at least someone willing to make an attempt to stop them.

The other thing that really saddens me is the fact that the method used for hacking by Hess is still largely used today. People don't put adequate passwords on their systems, and they can be easily guessed by hackers (which in that case I don't even consider them hackers, just regular people who can guess passwords). Government entities have since greatly increased their security, however most other companies have not enforced adequate passwords. Information can still be stolen through these other companies. Many government agencies allow their employees to access their non-government issued emails, and even facebook while their employees are at work, and this allows access into the government machines. Something needs to be done, but the problem is, people aren't willing to change, and that is usually a problem.

Thursday, February 7, 2013

Games and Gender

Computer gaming is a man's sport. Granted there are those few exceptions of girls playing, my sisters for some, and my mother for another, but all the professional gamers that I follow and watch regularly are all male. I don't mean to negatively stereotype, but women usually don't enjoy killing things, beating things to a pulp, or watching violent constant action. It's totally a good thing too, because if a child doesn't get that kind nurturing gentleness that women bring to families, violence and video games might actually become linked (they aren't currently). Since the video game industry is targeted for the male population, computers in general when used as a play thing, is a boy's toy.

Tuesday, February 5, 2013

Information Leak

People are stupid. Why would you share anything extremely personal with anyone other than a spouse? I wouldn't even trust my own siblings with my information. On top of that, assuming people are stupid, and they do stupid things, why would they not change their passwords after a breakup with that once significant other or some other kind of information leak? I'm a firm believer in survival of the fittest, and if people are humiliated online, they are that much less likely to be leading a company. Lots of smart people should be leading the companies of America and supporting the US economy. It works out better for everyone in the end.
http://www.cnn.com/2013/02/04/tech/mobile/breakup-data-precautions/index.html?hpt=te_t1

Tuesday, January 29, 2013

Cyber security

It's a little crazy how many jobs are opening up for cyber security. It totally makes sense but still the fact that they are making it public knowledge that they need cyber security professionals tells the world, we're too weak to handle what we've got, and we need some more people working on this. It's as if they are telling people, "We've got a lot of stuff that we need protected and we can't do it." So if you're a cyber attacker now's you chance to go get you some secret information, and after you've stolen that secret information, and sold it for whatever secret information is going for now-a-days you can probably go tell them that you hacked their system, and they need you in order to keep their stuff safe.
http://www.computerworld.com/s/article/9236289/Pentagon_to_add_thousands_of_new_cybersecurity_jobs

Thursday, January 17, 2013

Can Wikipedia be trusted?

Elder Oaks had it right when he said information is widely available for everyone. I had to do a study on Wikipedia a couple semesters ago back when I was in English 316 where we put up articles that were only 40% accurate (or roughly to that degree). By the end of the semester the articles for the class came out to be about 98% accurate, which is oddly enough more accurate than the Encyclopedia Britannica, which tends to be around 94% accurate. I totally agree that Wikipedia shouldn't be the only source used when trying to find relevant information on a certain topic, but I don't see the problem with using it as a source to find other sources. It's being updated almost constantly, and contains a ridiculous amount of information, that for the most part, is accurate and true.