Quiz #4

For quiz number 4, here is the problem Ken told us to do.

QUIZ4

For more information check out this page

Anyways this quiz was not as difficult as I thought it would be, but anyways here is my code in case you might need it.

For this code you should use (long double) instead of (int) in order to get a greater aproximation, due to the number of integers the computer will show.

Here is how the program should be seen on Cygwin when used:

Screenshot14.1

In case you don’t know what #include <iomanip> here is an explanation, basically it’s called Input Output Manipulation

During my first try I had problems with Quiz4, that’s the reason why I had to do it over again, did it twice before I got the working one.

Screenshot14.2

 

Quiz 05

My reaction when trying to find out the correct way to program the second part of this quiz:

gato duda

For this Quiz we had two assignments. In the first  one, we had to make a program that let the user know if the word submited is a palindrome or not. I used the [:: -1] to reflect the complete word and then compare the reflection with the original word. I also used the s.lower, so the program ignores capital letters. However, as a cool feature, I made the program ignore spaces since there exist palindromes with spaces. Such as the famous spanish sentence “Anita lava la tina”.

Here is how it looks, and here is how it looks in my GitHub.

quiz05part1

The next step was to do a program similar to the WSQ10. Create a list were the user submits the numbers and play with those numbers. However, the difference was that the operations would only considerate the numbers that are divisable by 3, no remainder.

(Click here for the GitHub of this part)

Several people did this by let the user submit the list as a string separated by commas. That is why I had the reaction of the picture. Yet, with the help of Arturo Fornes, I managed to make eat simplier since he assisted me by correcting what I had done. Just a simple conditional were if i % 3 = 0 then the program appends that number to a separate list.  Then I print the list to let the user know which ones are going to be used for the sum. Finally, just make a simple sum then print it. Such as this:

quiz05part2

Let’s talk about this 80’s oldie. “Maneater” by Daryl Hall & John Oates. A song I first listened to in Metal Gear

maneater

Continue reading “Quiz 05”

#QUIZ04 Euler didn´t have a girlfriend right?

Finallyyyy Euler, we know u r dead but meeeen why u did this to us? tought we were friends buddy.

Euler didn´t have a real hobbie like playing soccer, go to some ancient clubs and drink absenta with his friends(in case he had any) he used to be in his room, wondering how he could make our existence a little bit harder, you had one job Euler.

My first reaction when i saw the quiz was like: Damnnn Euler you ain´t my brotha anymore, you playin´

200_s.gif

 

Well click on the image above to get my code on GitHub.

This time i won´t make a video ´cause I´m preparing myself for the #YoSoy196 WSQ, winter´s coming so I´ll need to be ready.

Ken helped us in class, my trouble was that i didn´t know how to dictate the parameters for the factorial to indicate it when it must stop.

The Euler formula is pretty easy(but he didn´t use it lol):

f1

EXTRA STUFF

We were considering (AlexFoo, SaulTorres and I) to do a minigame for the project but we think it´s better to start doing some mecathronics stuff like using sensors and everything, we´ll see.

Check out this song, deep lyrics deep meaning

See yall, try to not die.

 

 

 

 

Quiz 04 Euler number

If x  = 5, what is the mass of the sun? escalated.jpg

That same reaction was what I had when I got in charge of doing Quiz 04. This time we had to make the sum of 1 divided by n! factorial. This until it reaches the euler number = 2.71 and it stops looping around.

quiz04.png

I broke my head constantly for several days trying to reach the answer for this equation in python3 language. This was until Ken Bauer miraculously helped me out and teached me what means each step means. I am not trying to pass the course by copy pasting codes. It is just that I have to see what is happening in a code first and then analyse it. This is in order to learn what to do and use it for future references. For instance, from the previous WSQ09 i learned to do factorials, so that was a piece of cake in this quiz. This is the code:

quiz04code

And this is how it runs:

quiz04run

When n! is 18 and n! is 19, the answer it is the same. That moment it is when it stops.

I am going to introduce another David Bowie’s song over here just for one reason, maybe a slowpoke one since I just realized it. This one is called Lazarus. It was released in his most recent album Blackstar in 2016. This song got his video release 3 days before he passed away in January 10th 2016. It is a really sad song. Was he saying goodbye? Who knows, but it gives this song even a bigger meaning. May he rest in peace.

lazarus.png

 

 

#WSQ7

Well fools this is my last post of this first period. and will be about making a program that add a range of numbers. For example the range is 2 to 4, so the sum will be 2+3+4=9. so this program could make the sum for any range of integers numbers.

Now I am going to explain how I did it. First, as always I declare my variables, in this case I used num1 one (for the lowest number in the range), num2 (for the highest number in the range) and sum, witch will have a value of 0 at the beginning of the program. Then I used a do while loop witch will work until num1 is >= num2. And while this condition is true, the program will do this simple math. As I said sum at the beginning will be 0, then it would do the mat and then it would have the value of the result. As you can se after we did this operation, you add 1 to num1 until the condition is true.

Here is the link for you to download my code:

https://www.dropbox.com/s/1tsc0vzsx8cp5fh/suma.cpp?dl=0

Thanks fools!!

Captura de pantalla 2016-02-18 a las 10.19.08 p.m.imagen thanks

#Quiz 3

maxresdefaultHello again. As you can see we had a third quiz. God I really hated them but that does not matter, I have to do it. So even I hated them, I did it and here is my post.

Problem 1:

  1. Write a function called distance (x1,y1,x2,y2) which receives four numbers which represent two points in the cartesian plane. The function should return the distance between the two points (x1,y1) and (x2,y2). Remember that the square of the hypotenuse of a right angle triangle is equal to the sum of the squares of the two other sides.

So that was the problem, now I am going to explain what I did in order to solved it. Well the problem was very simple, you just need to calculate the distance between to points given by the user. So first you need to have those points. You declare four variables, in this case I used x1 and y1 for the first point and x2 and y2 for the second point. Then you proceed to ask to the user the value of each variable and you stored the value in the variables you just declare. You ask for the value using a cout and then you store the value using a cin. Then what I did was to create a function for doing all the math stuff. As you can see, I write the function at the bottom of my code, just after the int main, and then I declare the function at the beginning. That is my style but you could also just write the function on top of the code (before the int main) and it would work. So in my function what I did was declaring two more variables d and c witch would be the result of x2-x1 and

Captura de pantalla 2016-02-18 a las 6.37.53 p.m.
Captura de pantalla 2016-02-18 a las 6.38.06 p.m.
Captura de pantalla 2016-02-18 a las 7.21.59 p.m.

Continue reading “#Quiz 3”

Quiz III

Brace yourselves, the partial is coming. Meanwhile, we have to answer a third quiz.

quiz3instructions.png

At the first point we had to find the distance between two points. If you represent this as an a triangle, it would be like Image 1 where A is (x1,y1) and B is (x2,y2), so we had to find the value of h.

2000px-trigonometry_triangle-svg
Image 1

At first I tried to find the distance between each axis. This means what is the difference of x1 and x2 and what is the difference between y1 and y2. This got complicated to me since distance is absolute, yet the answer was given as negative in some occasions. This got fixed when I used a conditional to multiply it by -1 to make it positive.

 

Then I got to the point to find h. I used the basic pythagoras theorem (C^2=A^2+B^2)  and then use the squareroot to get the answer. Ken teached me that there was a simplier way: use the distance command. Yet, It have me errors when running so I kept it at my mode since it works. Of course this does not means I am not going to fix what Ken helped me with. The code and how it runs looks like this:

pythagoras

For the second part of the quiz I had  a big time learning what to do. Firstly because I did not even know what the Fibonacci Numbers are. After I knew what they are, I searched all over the internet to see how to do it. Technobeans showed me 5 different methods of how to do it; however, Naren’s method in the comments helped me better.

fabonacci

Remember to keep checking my GitHub to see the code clearer.

Time for you to meet Bloc Party’s “Helicopter”. I got into this band because of

helicopter

Continue reading “Quiz III”

Quiz 3

3QFOErL.gifSimplicity is the ultimate sophistication.DaVinci

Hello people. I made my third and the last one of the first partial. We have to create two programs: the first program, may calculate the distance between two points (x1,y1) & (x2,y2). In the second one, we have to create the Fibonacci sequence on C++ and ask to the user for the value that he/she wants. To make that, we use our previous knowledge about it, like conditionals, loops, functions, etc. so it wasn’t difficult.

The instructions were:

1. Write a function called distance(x1, y1, x2, y2) which receives four numbers which represent two points in the cartesian plane. The function should return the distance between the two points (x1,y1) and (x2,y2). Remember that the square of the hypotenuse of a right angle triangle is equal to the sum of the squares of the two other sides. Also, don’t forget to declare the variables with FLOAT to use decimal numbers.

**The new thing here, was the use of the math library, to can execute the square (SQRT in C++). The math library is using like this:

#include <cmath>

And now you can use the formula of the Pitagoras Theorem :

Distance= sqrt((x2-x1)^2+(y2-y1)^2)

Here my code with comments to make it understandable.

dis

And the program running:

disc

2. Write a function called fibonacci which receives a single parameter “n” (a non-negative integer) and returns the nth number in the fibonacci series which is: 0, 1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89………… So, fibonacci(0) would return 0. fibonacci(5) would return 5 fibonacci(8) would return 21. Note that the first two fibonacci numbers are 0 and 1. All others are the sum of the previous two fibonacci numbers. int fibonacci(int n){ }

Here I got a headache with the Fibonacci Formula, but once

fibc.png
dancing-banana
3QFOErL.gif

Continue reading “Quiz 3”

Challenge accepted, Quiz 2.

giphy

Hello my friends. I had to mention that we made this quiz some weeks ago, and here is my post about it. I fell nervous when we made the quiz, but after doing my WSQ09 I learned how to use the for Loop and it safe my life. Also lynda (A platform where you can search for information about everything -www.lynda.com-). And if you want to learn more, I suggest to visit this page who helps a lot with C++ (and obviusly to make the programs of this quiz) http://www.cplusplus.com/doc/tutorial/control/ ; on this link, you can find useful information about the loops, who are always necesary, and here another link to understand the functions (I have to read it sometimes because I really get in trouble with it, but now I’m a master on functions ;D). The links:

http://www.lynda.com/C-tutorials/Creating-user-defined-functions/167922/181569-4.html

http://www.cplusplus.com/doc/tutorial/functions/

But well, let’s go to the important think, the quiz.

The instructions were:

1. Create a program with the following function. Write a function called superpower that has receives two parameters (ints) and returns an integer which is first parameter raised to the power of the second, which is to say it returns a b . There are many ways to do this, but the intent is for you to use a loop or recursion.

So to do that, at first, we have to use the function SUPERPOWER and inside of it, we have to do the operation (a^b) -I had a headache doing that- because it wasn’t too difficult but i had my for loop wrong so I had to start again and make it functional. So, here my code with some comments to make it easier.

spp

And the exe.

sppc

2. Create a program with the following function. Write a function called

sts
stsc
giphy-3.gif

Continue reading “Challenge accepted, Quiz 2.”

Quiz 3

Now we have the Quiz number 3.

In this quiz, first we have to create a program that calculates the distance between two point in a graph using the coordinates (X, Y).

The user has to introduce the two points (X1, Y1) and (X2, Y2).

Captura de pantalla 2016-02-12 a las 10.49.21 a.m.Captura de pantalla 2016-02-12 a las 10.49.44 a.m.

In the second program we have to do the Fibonacci sequence using just one input.

The Fibonacci sequence are the numbers in the following integer sequence.

0, 1, 1, 2, 3, 5, 8, 13, 21, …

By definition, the first two numbers in the Fibonacci sequence are either 1 and 1, or 0 and 1, depending on the chosen starting point of the sequence, and each subsequent number is the sum of the previous two.

Captura de pantalla 2016-02-14 a las 5.51.40 p.m.

Also, the program ask the user if he wants another number of the sequence.

Captura de pantalla 2016-02-14 a las 5.52.20 p.m.

PRoPBdo_700wa_0

TC101

Quiz 3