Wednesday, October 19, 2011

C-C-C-C-COMBO BREAKER

So, I am NOT going to talk about Project Euler. Instead, I'm going to simply about the HORRIBLE assembly program I've been working on for the past several hours. It's really not that difficult of a program, but our teacher did not really tell us how to do any of it, so I had to figure most of it out. Whatever, I guess I'll remember it better, but it still pisses me off. I would post the code, but I don't really want my teacher to somehow see it and think I stole it from myself (I wouldn't put it past him). Anyway, I'm out. Try not to ever take assembly if you can help it.

Peace.

Thursday, September 29, 2011

Project Euler - Problem Seven

This one took a little extra input from good ole Michael. Apparently, me and prime numbers just don't get along very well. It's like we hate each other without even knowing it. Here's the problem:
With Michael's help, I managed to get it done though. It's really fairly simple, so I'm going to just do like regular and put a few screenshots up.

After discussion with Michael, we decided that it would be best to have a list of the primes we've found so far. It'll start off primed with two and three. Everything after that will be found via the program. It'll do a number mod everything currently in the list of primes. If it isn't divisible by any of the primes, then that number is added to the list and it moves on to the next number.

This seems to work pretty well, considering that it doesn't take very long at all to run. It's pretty cool to put a little cout statement to print out primes as they're found. I've got on in my code here. It lets me know if it's working too!

So here are my functions:
primelist_zero simply zeros out the list of primes. I did this so that I can have loops that run while elements in the list are or aren't zero. There's probably a better way to do it, but this one works.
Next there's the is_prime function. The name on this one is pretty telling about its function. It just checks whether or not a number is prime.
You're starting with an increment of zero each time the function is called. This increment variable is used to know which element of primeList to mod by. If the number mod by any number in the primeList equals zero, then it exits the function call. Otherwise, it adds one to the increment variable and checks again.  It does that until it gets to an empty spot in the primeList, at which point the number has to be prime.

These functions are wrapped up in a nice little main:
If you've got any problems, feel free to ask!

Wednesday, September 28, 2011

Project Euler - Problem Six

These exercises are really helping my programming. This one took about fifty-five seconds of planning a a few minutes to write up. It's a bit spaced out to do in one screenshot, so I'll space it out a bit.

The code is fairly simple for this one. Here's the problem:
Now, I see two different functions there, but I don't know about you. I'm going to go ahead and declare them like this:
The functions themselves are very straightforward and didn't take much thinking through.
Add_squares adds the squares of all the numbers:
Square_sum adds all the numbers and then squares it:
Finally, I wrapped them all up in a nice main function:
Also....you'll notice that I got excited and forgot to change my cout statement....soooo...

So, that's it. Easier than pi!

Project Euler - Problem Five

Problem five was one of the quickest and easiest so far.  I'm pretty sure that the biggest thing that problem five did for me was  that it helped me find a really nice answer repository! So now I can easily check to make sure that I've got the right answer. Here's the link: projecteuler-solutions

Since problem five was so easy, I'm not going to even attempt to do a step by step breakdown. If anyone has any questions, just ask and I'd be more than happy to help.

Project Euler - Problem Four

OH GOD THEY JUST NEVER STOP.

So I'm on problem four.  This one is fairly simple, and is honestly a bunch easier for me than the prime numbers one was. Maybe that's just because I had an entire chemistry lecture to think about this one. Either way though, it's a fairly straightforward one.

In fact....I think I'll actually include a little lesson with this one. First, let's state the problem:

A palindromic number reads the same both ways. The largest palindrome made from the product of two 2-digit numbers is 9009 = 91 × 99.
Find the largest palindrome made from the product of two 3-digit numbers.

The first real question is how we're going to check for whether a number is a palindrome or not. Everything else just falls into place after that.
Here's how to do it!

Modulus.

Whaaaa?

Really though. Modulus is just a division's remainder. So, mod ten should remove the last digit of a number. Check it out with some sort of math machine. 987654321 % 10 yields a result of 1. This means that you're able to get the last digit of the number if you mod ten. (HINT HINT)
So if you do n%10 to get the last digit, what do you do next?
Well...you get the idea. You do this:

rev = rev * 10 + dig;               // This will add the result to a number. (HINT: This is
                                                                 // going to be the opposite of the number you put in.
        num = num / 10;         //  This part will remove the number you just put into rev
                                                           

Now, you can apply this fairly easily into a function. I personally did mine as a Boolean function. I'll post a screenshot of my code below.

This one is the function:
This one is going to be the main loops that do the multiplication:
This one is the whole program:


Anyway, that's the solution to the fourth Project Euler problem. More to come? Maybe.



Project Euler - Problem Three

Let this be a lesson in why reinventing the wheel isn't always best.

I'll start with the problem:
The prime factors of 13195 are 5, 7, 13 and 29.
What is the largest prime factor of the number 600851475143 ?

Now, that isn't too hard.  In fact, I had code that would do it fairly quickly. My downfall, however, was that I wasn't looking for any sort of help. I'd decided that I wanted to do it completely and all by myself. That's an honorable pursuit, and one that everyone should do at some point. Always relying on other people for help gets old.

There comes a time when you've got to realize that asking for help, or at least advice, isn't always bad though. My program ran so slow. It was rather clumsy and dumb, to be quite honest. I really didn't like it at all. So I started googling. I ended up finding a website that had complete and working C++ (and Java) code for running the Sieve of Eratosthenes. I picked the code up off of here, and it runs at least a bajillion times better than mine.

Now, is it mine?  Not even a little bit. The most I put into my problem three solution was really a few lines to print out a menu, and that isn't even necessary. Was it something worth doing though?  Yeah, it definitely was. Now, I know a whole new way to do prime numbers.

And trust me. It's cool. Read the link and give it a shot.

Friday, September 23, 2011

Project Euler - Problem Two

Recursion is so much fun. It's not the easiest thing I've ever tried to wrap my mind around, but it's fun.

Okay, so here is the solution to Project Euler's second problem.

The problem is this:
Each new term in the Fibonacci sequence is generated by adding the previous two terms. By starting with 1 and 2, the first 10 terms will be:
1, 2, 3, 5, 8, 13, 21, 34, 55, 89, ...
By considering the terms in the Fibonacci sequence whose values do not exceed four million, find the sum of the even-valued terms.

So, you're going to need to figure out what this means.
int fib(int n) {
    if (n == 0 || n == 1) {
        return 1;
    }
    else
        return fib(n - 1) + fib(n - 2);


This is the code to find the fib of a number. If you put ten in, you'll get 89. Now, simply putting fib() of four million won't work. We want the sum of the even-valued terms.  In other words, we need something else to make it happen.

Personally, I used a do/while loop with an if statement inside of it.

You can see what I did here. The actual solution is 4613732.


Project Euler - Problem One Redux

So it's been a while. School is...well...school is hell this semester. But hey! It's all good, right? Today I decided that I'm going to sit down and relax my mind by doing some easy stuff. I couldn't let myself be unproductive though, so I decided to try and do some computer science studying. Sooooooo, I redid project Euler's problem one.  Except this time I also used recursion. It's pretty cool looking, and I'll walk you through how it works.

Okay, so instead of putting a big ole block of code, I just took a screenshot. Project One is simple enough, and if you actually want a big block explaining exactly what's going on, check out my first post.  Instead of the code itself, I took a screenshot.

You can see pretty much everything there. I tried to be all studious and comment it nicely.

Now, that works pretty darn well. Recursion makes it even cooler looking though.

Recursion is used whenever you can see that the answer to a problem is really just a smaller version of the problem.  Now, my computer science professor did say that it's not always best to use recursion.  It takes a lot of stuff to make a recursive call, so it probably shouldn't be used for just everything you've got.  As it is though, this function is so small that it really doesn't matter. PLUS IT IS SO COOL.

So, how does it work?

It's as simple as a function that calls itself.  To get to that point though, we need to figure out what the simplest case is. In the implementation that I'm using, the reasoning goes like this:
  1. We'll pass in the current position (a default of one) and the upper limit (which is 1000 for Project Euler).
  2. The simplest case, the base case, is if these two numbers are equal to each other.  That would mean that the number we are currently working with is the upper limit.
  3. Otherwise, we want to find out whether the number we're currently working with is a multiple of three or five. 
    • We can do this using the modulus  (%)  operator. It is the remainder of division between two numbers. If number A is a multiple of number B, then A%B should be zero (since it should divide evenly, thus without a remainder).
  4. Once we've establised that a number IS a multiple of three or five, we want to add it to the total. 
  5. Now we want to do the same thing again, except on a number that is one higher than our current number.
So, in pseudo-code:
If the current number is equal to the upper limit, return from the function. Else, we want to check whether the current number modulus three or five is equal to zero. If so, then we know it is a multiple of either three or five and should therefore be added to the total, so we return it AND we call the function again.

Now, think over that and see what you get. Here's mine!



If you've got any questions, please ask! This isn't exactly a tutorial on how to program, but it should guide you into how to do at least this problem recursively.


Monday, July 11, 2011

Google+ - Why It's Cooler Than You Think

Google, despite being the slightly evil quasi-ruler of the internet, is a pretty cool entity. Most things done by Google turn out well:  Chrome, Gmail, YouTube, AdSense, Blogger, Google Calendar, Google search, Books, Labs, Documents, et cetera.  It's a simple fact of the modern Internet that if you use the Internet, you use Google.

Google+ is the newest introduction to Google's impressive lineup. It is designed to be a competitor to Facebook, despite Google's previous failed attempts at social networking.

Google+ is "real-life sharing rethought for the web." Now, Google+ sounds pretty stupid really. Most Facebook wannabe's are dumb. It's hard to copy something as unique as Facebook and not either make it dumb or too much like Facebook. I'm pretty sure that Google+ has managed to find the right balance of sameness and differences.

Google+ has all of the standard stuff that you expect from a Facebook clone. Everything that you want from Facebook is there. But! There are other features that Google+ has that make it just a cut above the rest:
Circles
     Circles are pretty cool for the following reason:
Everyone has a Facebook nowadays. My mom, my girlfriend's mom, my bosses, and tons of other people important to my life are all watching me on Facebook. Now, I'm a good little boy. I don't do much that is too bad to be on Facebook. Sometimes though, I just want to say something that I'd really rather them not know. I can't differentiate who I let see stuff on Facebook without a lot of hassle, even with their Lists or Groups or whatever they're called.
Circles solve this problem. I can add people to certain circles, and then share stuff to certain circles. I've got people in circles that lets me share just certain stuff with them. That means that the status "I just hit a tree in my dad's truck" can be hidden from my family but seen by my friends who are good at fixing trucks. Or trees, depending on the situation. EITHER WAY THOUGH, the important thing is that I can have different people see different things.

Spark
    Sparks are just really cool little boxes full of interests. It's like you Google stuff from within Google+ and are able to share the link to your...Wall. I just realized that I don't really know what the Google+ Wall thing is called exactly. Anyway, Sparks lets you search for certain stuff and see just snapshots of it that will let you be able discover and share things easier. They're also cool because you can pin an interest to your Sparks page.

Viewing Your Profile as Someone Else
    Have you ever wondered how someone else views your profile? I have. Especially since Google+ has the Circles feature that lets you change who sees what, the ability to see how each person views your page is beyond valuable.




Now, I've got to go fry fish and read Eldest. (The final book in the cycle is coming out soon!) So I'll finish this post once I have time and know a bit more. As you can already see though, it's got some NICE features.

Plus, your mom isn't on it playing Mafia Wars. That's enough to make me love it already.

Saturday, July 2, 2011

A Laid-Back Post

So, I'm feeling pretty chilled out right about now. You know that feeling where you're kind of at peace with reality and just feel like kicking back for awhile? I'm there. So this post is not really going to be very long; I don't have a lot to say. I just kind of wanted to post a bunch of music that helps me stay stress free. So if want to be chill and remember that the world can sometimes be a pretty cool place, listen to the following, in order:






(P.S. If you aren't happy after this song, there's something wrong with you...)








Peace.

Friday, June 24, 2011

LeBlanc, The Deciever: A Review

Hello, friends. It's time again for a League of Legends Champion review. This time I have decided to review "LeBlanc, the Deceiver," a mage/assasin champion from Noxxus.


My first impression of LeBlanc was not as high as one might expect. I had heard several of my friends mention how amazing she was, so, when I logged in this week and saw her on rotation, I decided I might as well give her a shot. I started up a custom game and began by carefully reading her abilities and deciding how I wanted to build her. At first glance, her abilities did not really seem that useful to me, especially her ult, "Mimic" which cast a version of her last spell cast that does more damage. For me, this seemed like a rip off. I played for the first six levels with a growing sense of dislike for the champion, then I had to quit for reasons I cannot recall. However, I decided to give her another chance, and that was possibly the best decision I've ever made regarding this game. This time, I played past level 6, as well as studied her abilities a bit more closely. I began to realize how they could combo together, as well as a better order to purchase them in. It was at level 8, with nothing more than a Tear of the Goddess and a Blasting Wand, that I realized exactly how beastly she really was. I was able to nuke a Nasus three levels higher than me, and I had only one AP item. Soon, I came to understand EXACTLY how useful her ult is. So, without further ado, here is my guide to one of the most impressive champions I've ever played.

As I said LeBlanc's abilities are quite deadly, if you know how to use them. Her first ability, Sigil of Silence, deals magic damage to the enemy and places a mark on him/her for 3.5 seconds. If the target is affected by another of LeBlanc's spells while the mark is active, that enemy is silenced for 2 seconds and takes additional magic damage. Her Distortion ability allows her to teleport to a target location, dealing magic damage to nearby enemies. In the three seconds following the use of Distortion, she can teleport back to wherever she originally cast it from. Her third ability, Ethereal Chains, is a skill shot ability that, if it hits an enemy, deals magic damage and slows him/her. If LeBlanc stays within ranged of the enemy for 2 seconds, the enemy becomes unable to move and takes additional magic damage. Her ultimate, Mimic, allows her to cast a improved version of the spell she last cast, which does improved damage. Her passive, Mirror Image, causes her to become instantly stealthed for 0.5 seconds if she falls below 40% health. When she exits stealth, she creates a clone of herself that deals no damage and lasts for up to 6 seconds. However, this effect can only happen once a minute, but that is a ridiculously short cooldown for this ability,

When I play LeBlanc, I generally prioritize leveling her Sigil of Silence. Of all her abilities, save her ult, this one has the highest damage potential. Next I focus on Etheral Chains, as this ability allows her to slow an enemy and snare him/her. This is better then Distortion for chasing early game, in my opinion, as it allows her teammates to help, and it also allows her or her allies to escape more easily. It also helps later in team fights. So, my initial skill selection goes Sigil, Chains, Sigil, Distortion, Sigil, and Mimic. After this, I max out Sigil of Silence, and then focus on Etheral Chains. I don't generally start leveling Distortion until I have five ranks in Sigil and at least three ranks in Chains, but this my change with each game.

Her Mimic ability is really where LeBlanc shines. All of her abilities deal a high amount of damage, but with Mimic maxed, it does 40% more damage. That's a lot considering how much damage a Sigil of Silence can do. What's most impressive about Mimic is its cooldown time. At the start, it takes about 30 seconds until you can use it again. However, with the way I build her, I have it so that at level 18, it's only 15 seconds. That means every 15 seconds, she can kill almost anyone at full health. However, often it does not take her ult to be able to take someone down; her other abilities do quite well on their own.

LeBlanc is very dependent on understanding exactly what her abilities do and when to use them. One of her most used combos is to throw a Sigil on an enemy, and then hit him/her with Ethereal Chains. What happens is the Sigil deals damage, the become activated by the Chains dealing more damage and silencing the enemy for two seconds. As that happens, the enemy takes damage from the Chains, as well as becomes slowed. The silence from Sigil lasts 2 seconds, which is exactly how long it takes for the Chains to activate again, dealing more damage and rooting the enemy for two more seconds. This whole combo prevents the target from using any means of escape for four seconds, as well as significantly damaging him/her, making this a great combo for chasing.

Another deadly combo, the one I use to kill, is Sigil>Mimic>Distortion>Chains. The initial Sigil deals damage. The Mimic: Sigil of Silence deals 40% more damage and activates the initial sigil, dealing damage and silencing. At this point, the target is probably running, but in vane. Distortion teleports you to the target, dealing damage and activating the Mimic Sigil, which stuns and deals more damage (still 40% more than the other Sigil). At this point, even if the target is still alive and manages to throw of an escape ability (which is impossible as he/she is silenced), you can easily finish him/her off with Chains, since this deals damage and slows. Even the hardiest of tanks, who might SOMEHOW survive the initial damage of the Chains, cannot survive once they become activated, rooting the enemy, dealing damage, and allowing you to finish the job with auto-attacks or a now-useable Sigil if need be. The best part is, it will generally have taken you longer to read the first sentence of this paragraph than to kill the target.

I can honestly say I see no drawbacks to LeBlanc. There is nothing about her I dislike. Even her passive, which on many champions is often unimpressive, has helped me out many times. Often I have been close to death, and losing a third of my stacks on Mejai's Soulstealer, when my passive kicks in and allows me to escape.

Finally, I will finish off this guide by discussing how I build LeBlanc. The first ten or so games I played as her, I followed my generic build guide for mages: Archangel's Staff followed by Sorcerer's Shoes and Rabadon's Deathcap, which is generally where the game ends. However, I soon began to realize that this build was not fully capitalizing on her killing ability. She is an Assassin, and should be treated as such. So, I played around with a build, and this is what I settled on:

Start by choosing a Meki Pendant and two Health Potions. Because I normally choose Teleport and Clarity as my Summoner Spells, I don't have to get Mana Potions, as I generally do not run out of mana before I would normally recall. Getting Health Potions allows me to stay in lane against more harrasing opponents long enough to get the money for my next item. Next, I get a Tear of the Goddess and Teleport back into my lane. This is by far one of my favorite items, and I always get it first on any mage. Next, I get an Amplifying Tome and upgrade it to Mejai's Soulstealer as fast as possible. Generally, I avoid Soulstealer on Mages, just because it is such a risky item. However, LeBlanc can gain 20 stacks in a heartbeat, and keep them. After this I buy Boots of Speed, upgrade my Tear of the Goddess into a Archangel's Staff, finally grab Sorcerer's Shoes. Now I have three slots left, and the order in which I fill them differs depending on the situation. My three final items are Rabadon's Deathcap, Abyssal Scepter, and Morello's Evil Tome. Generally, I like to get Rabadon's first, then grab Morello's and finish with Abyssal Scepter, but sometimes I need the cooldowns from Morello's sooner, or I might need the magic resistance reducing aura of Abyssal Scepter first. Generally speaking, though, the order of these items is not that important, so just go with what you like best.

In addition to Rabadon's, Morello's, and Abyssal Scepter, you might consider the following items:

1. Banshee's Veil: If you're going up against people like Ashe, Ryze, or Annie, Banshee's Veil is almost a must have item. While the magic resist, health, and mana are always nice to have, they are nowhere near as important as the passive. Banshee's Veil prevents the next harmful spell that would be used against you. This means Ashe's ult, Ryze's snare, or Annie's stun, all of which can completely ruin your assassination, are blocked, allowing you to finish them off happily.

3. Rod of Ages: This is definitely useful if you seem to be targeted a decent amount and are unable to get your kills because of it. It comes with a nice amount of base AP, but also gives you some good health, as well as mana, which can work with your Archangel's Staff for more AP. These bonuses also increase for the next ten minutes. Generally, I avoid this item simply because it has to be built early to fully utilize it, which interferes with my other build. Also, I am generally able to get kills without having to worry too much about my health. Remember, only get this if taking damage is preventing you from getting kills. If you routinely get down to low health, but still kill your opponents, don't worry about it.

2. Zhonya's Hourglass: Generally, this shouldn't be necessary, but it might be at times. 100 AP is nothing to sneeze at, and the armor is always helpful. The only time I would see getting this is if you are constantly being targeted in team fights and are being killed before you can do anything. The activated ability of this item makes your opponents target someone else with their abilities, allowing you to drop back in once it's over and finish them off. However, if you know what you're doing, this shouldn't be necessary.

And finally, here's a few items you may think about getting, when you really shouldn't:

1. Void Staff: Under no cicrumstances should you get this item. Abyssal Scepter is an all around better item, having the same AP boost plus granting some magic resistance. And while Void Staff may grant a higher amount of magic penetration, Abyssal Scepter has an aura, making it apply to multiple enemies AND allowing those weaknesses to be utilized by your team as well. Always be a team player.

2. Rylai's Crystal Scepter: This item looks deceivingly useful, and on most mages, it is. However, on LeBlanc, it's pointless. If you're playing right, you should never need to have your spells slow the target. You already have a silence, a slow, and a snare, as well as the ability to teleport to your target. If you are still unable to catch people, you need to play someone else.

And that, my dear readers, is it for my second League of Legends champion review. I bid you all a good day and good luck.