GAME OVER

HEY GUYS!!!

Game over? Well, this is my final post of the course because the semester is over!

I know this is sad because I really like to post about what I learn of programming but everything have a final and this is not the esception.

I really made an effort to explain… let me do this in my maternal lenguage…

Ahora si soy yo😀

Ha sido muy especial el poder compartir con ustedes mi trabajo en esta clase. En lo personal nunca había tenido un blog y me pareció una herramienta con la cual puedo expresarme y, lo que es mejor, poder compartir y enseñar un poco de lo que se.

Hice un video acerca de un pooooco de lo que fue mi curso con Ken Bauer (mi maestro) y es el siguiente:

Agradezco a todo aquellos que se tomaron su tiempo para ver los post y también a todos aquellos que comentaron y ayudaron a la creación del mismo.

Como siempre les recordaba, no dejen de practicar porque mientras más practiquen mejor sabrán como hacer los códigos y mejor aún el cómo crear códigos por ustedes mismos.

NO ES UN ADIÓS… SOLO HASTA LUEGO😉

El curso se término pero… quién dijo que hasta aquí llegó mi Blog😉

Hasta pronto. – Que estoy en finales y debo estudiar :”'(

Top image by: https://www.flickr.com/photos/70350619@N07/6389052645/in/photolist-aJzyL6-aiah4R-8D3S7v-7przr3-ePrtA1-8x2LLX-4n9UDX-5HZdaY-Dinm5-8hpMfV-e2viqr-p96d9P-6Sxsn5-kyFSuu-r48bRB-qxxHYZ-bxScT-9CeAYG-4GqhDs-6fAmda-EZ2nM-jEkYXv-4HjGzb-5Xt9sQ-6HdEDT-jp4Kfx-p8LNs9-7jMa8u-qvVufs-5zNkvU-fqmJQq-sqjZ3G-dhASy6-4LybjX-q1XPJP-5iRF66-r976Ss-6FokjK-rrayHF-khGaxH-ffYzFA-7hbRgF-4r3jkL-eW4qkZ-7ADpNK-baQTgF-pEAqUs-qzf17Z-cnNMAU-o7nkKG

Yo Soy 196 and Word Counter

I think these was the most difficult codes of the course and these are the instructions:

Yo soy 196:

Your jobs is to create a program that asks the user for two pieces of data:

  • The lower bound of the sequence
  • The upper bound of the sequence
Then you check the values from the lower bound (inclusive) to the upper bound (inclusive) and make a report of them. During the analysis of each number, if a Lychrel number is found it should be reported immediately with something like “Found a Lychrel number: 196”
The report must show:
  • The range of numbers analysed (lower to upper bound)
  • The number of natural palindromes (no addition to inverse needed)
  • The number of non-Lycherels encountered (become palindromes)
  • The number of Lycherel number candidates (that did not converge to palindrome)

Since you will not be able to prove that a number is Lycherel (since you cannot computer forever to check), our definition for a Lycherel candidate will be if a number does not converge after 30 iterations of applying the addition to the inverse.

Word Counter:

Create a program that asks the user for a word which will be your search word and the name of a file to open and search for that word. Then create a function that will receive two parameters (both string) representing those two data points. This function returns the number of occurrences of that word in that file.

You will need to open a file and read the text line by line. This is straight forward in Python since you can treat the file as a list of lines (strings) and iterate over that using a for loop. Check the section “Looping over a file object” in this link for an idea but your book also has this information

2016-05-04 (2)
2016-05-04 (3)

Continue reading “Yo Soy 196 and Word Counter”

Final Project!!!!!!

Hello and welcome back to my blog!

This post is special because is one of the last so I wanted to do something special with it and I’m going to show you in what I was working months ago with my project partner.

We were thinking about to create a code releated to the physics but in a moment of madness we change our mind and we do something releated to “video games”.

There’s a lot of topics in video games but we decide to create a space battle game and it is funy but the special thing is that we learned about programming and that is the important thing.

I’m glad to show this project!!!

2016-05-03

Thank you for see my post and as you can see it is an other level of programming but you can be sure that if you practice you can do things that you really don’t expect it and I write this for experience not only for do it.

I want to say thanks to my teacher who help me with the project.

CLICK HERE TO SEE THE CODE.

MY NEXT POST WILL BE SPECIAL SO DO NOT MISS IT PLEASE!

GAME OVER!!!

HEY GUYS!!!

Game over? Well, this is my final post of the course because the semester is over!

I know this is sad because I really like to post about what I learn of programming but everything have a final and this is not the esception.

I really made an effort to explain… let me do this in my maternal lenguage…

Ahora si soy yo😀

Ha sido muy especial el poder compartir con ustedes mi trabajo en esta clase. En lo personal nunca había tenido un blog y me pareció una herramienta con la cual puedo expresarme y, lo que es mejor, poder compartir y enseñar un poco de lo que se.

Hice un video acerca de un pooooco de lo que fue mi curso con Ken Bauer (mi maestro) y es el siguiente:

Agradezco a todo aquellos que se tomaron su tiempo para ver los post y también a todos aquellos que comentaron y ayudaron a la creación del mismo.

Como siempre les recordaba, no dejen de practicar porque mientras más practiquen mejor sabrán como hacer los códigos y mejor aún el cómo crear códigos por ustedes mismos.

NO ES UN ADIÓS… SOLO HASTA LUEGO😉

El curso se término pero… quién dijo que hasta aquí llegó mi Blog😉

Hasta pronto. – Que estoy en finales y debo estudiar :”'( –

 

 

 

 

 

 

 

 

 

Scilab

Hello!

Welcome again to my blog! Today we are going to play with an awesome program called Scilab .

First of all you need to know what is Scilab.

Scilab is an open source, cross-platform numerical computational package and a high-level, numerically oriented programming language. It can be used for signal processing, statistical analysis, image enhancement, fluid dynamics simulations, numerical optimization, and modeling, simulation of explicit and implicit dynamical systems and (if the corresponding toolbox is installed) symbolic manipulations (https://en.wikipedia.org/wiki/Scilab)

This is a small view of the program:

pro

It is a complex program, so, I’m going to write about the principal areas of the program and in fact the most common. Lets start!

First you need to open the program and when you do it you will see a console and in that place is where you are going to write all.

Common Operators

pro1

And the other common operators…

pro12

 

(4*atan(1) se usa para obtener PI)

And obvious you can mix it…

pro123

Vector and matrix

Define a column vector:

pro12345

Define a row vector:

pro123456

Define a matrix:

pro1234567

A little of programming!!!!!!!!!!!!!

Variables

In Scilab you can also asign a value to a variable…

pro1234

Functions

Now we know how to define variables and the next step is functions in where variables are used. 

This is an example of a function:

pro12345678

 

Graphic

An other cool tool that Scilab has is the option to create graphics. It isn’t hard and below I show you an example:

pro123456789

YOU CAN DO A LOT OF THINGS WITH THIS PROGRAM YOU CAN GET IT HERE FOR FREE!

I GET INFO FROM THIS PAGES ABOUT SCILAB:

PAGE 1

PAGE 2 

PAGE 3

REMEMBER TO PRACTICE AND FEEL FREE TO COMMENT!

SEE YOU IN MY NEXT POST!!!!😉

 

 

 

 

 

 

 

 

 

Quiz #7

Hello everyone!

I’m glad to tell you that I finished the quiz #7 and as every quiz I want to share it with you.

Here are the instructions:

Create a function called dot_product that receives two lists of numbers (say list1 and
list2). The function returns what is the dot product of the two lists.

For full marks, if the lists are not the same size, then the function should return the
special value of NaN (which represents not a number).

Example. If the input is [2,4,5,6] and [1,2,3,4] the result will be 49 since (2*1)+(4*2)+(5*3)+(6*4) = 49

First of all, let me explain you what is the dot product.

dot

(https://www.mathsisfun.com/algebra/vectors-dot-product.html)

 

So, here is the code of the dot product:

2016-04-24 (1)

dot1

First, I create the function of the dot product wich make the product of the numbers depending in which site of the list the number is.

Then in the main function I ask how many numbers the list is going to have then the user type those numbers.

It is not a difficult code because we only use typical arranges, for loops, accumulators. If you can see my past post and study it, you will be able to make this without problems, remember to practice and do it by your own.

It wasn’t difficult but if you need more info you can go to this site which help me a lot.

Here is the code!

 

Thank you for visit my blog and see you in next post😉

 

Top image: flickr photo by Kaboedel https://flickr.com/photos/nerina/268955686 shared under a Creative Commons (BY-NC) license

 

 

 

 

EXAAAAAAM!!!!

Welcome back to my blog!

Today I’m going to show you my second partial exam of my course. It was not a very hard exam and I’m proud of my work in it.

Lets start!

The exam said that we need to write four differents codes and these are the instructions for each code:

  1.  Write a function called triangles which receives a single parameter (int) which represents the size of a triangle as explained below. The function should print a triangle using loops (for or while). The only characters printed here are ‘T’ and the new-line character. The first line is length one, the middle line is length size and the last line is length one.

    The example below is for size 6:

    tes

Here’s my code:

2016-04-15 (1)

tes1

NEEEEEXT!

2. Write a function called superpower that has two parameters of type long and returns a long which is first parameter raised to the power of the second, which is to say it returns a b So, superpower(3,4) would return 81.

long superpower(long a, long b){

}

Here’s the code:

2016-04-15 (3)

tes12

NEEEEXT!

3. NOTE: for full 5 points, use a loop (not recursion). Write a function called fibonacci which receives a long “n” and returns a long which is the value of 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.

Here’s my code:

2016-04-15 (5).png

tes123

THE LAST ONE!!

4. . Write a function called isPalindrome which receives a string “x” and returns true if the string x is a palindrome, otherwise false.

I had problems creating this one but yet at home I complete it and here is:

 

2016-04-15 (8).png

tes1231

Continue reading “EXAAAAAAM!!!!”

Quiz #6

Hello I’m back!

I’m back with my quiz number six and I’m so excited because it was a ver easy one and I’m glad to tell you that you can practice with it and of course is free😀

Lets start!

Instructions:

  1. Write a function to calculate the greatest common denominator of two positive integers using Euclid’s algorithm. The function should receive two integers and return an integer.Obviously you should test your function, so create a main program that asks the user for two values, calculates the gcd and displays that.

First of all we need to know what is the Euclid´s algorithm so if you want more info about it you can check this web.

Here’s my code:

2016-03-30.png

We have to create a function and in it write the process, it isn´t hard you just need to think logically and try to understand why all the stuff is on that order. I posted about in my last posts and like always you can check it everytime you want to.

I read about the topic and one post of my colleagues was a great help (check him blog here).

See you in my next post!

Top image by: https://www.flickr.com/photos/waxesstatic/2335673197

Quiz #5

Hello everyone,

Today I am going to show you my quiz number five. Lets start!!!

Instructions:

  1. Create a function called is_palindrome which receives a string as a parameter and returns true if that string is a palindrome, false otherwise. Remember that a palindrome is a word that is the same forward or backward. For full points your function must ignore case and must work with any character (not just letters). So (“Dad$dad” is a palindrome even though the D is capital and d is lower case).
  2. Create a function called find_threes that receives as a parameter a list (or Vector or array for C++ students) of numbers and returns the sum of all numbers in that list that are evenly divisible by 3. Note if using vectors, you will need an additional parameter to represent the number of numbers in the array. So if the list was [0,4,2,6,9,8,3,12], the function would return 30 (0+6+9+3+12)

FIRST CODE:

2016-03-29 (2)

First, we have to know what a palindrome is. A palindrome is a word, phrase, number, or other sequence of characters which reads the same backward or forward (https://en.wikipedia.org/wiki/Palindrome). We have to create a function which can detect if the word that we introduce is a palindrome or not.

The code is easy but the new thing is that we need to use two iterators: RBEGIN and REND -for more info you can check this web-. In fact the propose of those vectors is to flip the word then we have to check if the new word is the same as the first word that we introduced.

Another new thing is that we are using STRING and a string is variable made by characters. Here you can get more info abou a string and iterators.

 

SECOND CODE:

2016-03-29 (3)

This code doesn’t

Continue reading “Quiz #5”

Quiz #4

Hello everyone,

Today I’m going to share with you my quiz #4.

Instructions: 

The number e is an important mathematical constant that is the base of the natural logarithm. It is approximately equal to 2.71828,[1] and is the limit of (1 + 1/n)n as n approaches infinity, an expression that arises in the study of compound interest. It can also be calculated as the sum of the infinite series.

Create a function called euler_calc with a single parameter precision. The value of precision is used to determine when to stop calculating. Your calculation will stop when the two consecutive values estimating e differ by less than precision (remember to use absolute value when calculating the difference between two values here).

 

And here is my code:

2016-03-21 (3)2016-03-21 (4)

The Euler number is very important in the math area and we can calculate it with this formula:

e =  displaystylesumlimits_{n = 0}^{ infty} dfrac{1}{n!} = 1 + frac{1}{1} + frac{1}{1cdot 2} + frac{1}{1cdot 2cdot 3} + cdots

Image link

All the stuff is the same as the last posts but the new thing here is that we are including a new library for us.

With the <iomanip> library  we can use SETPRECISION. It can help us to give an answer exactly with the precision that the user wants and that is what I made with the code. An example of SETPRECISION is:

// setprecision example
#include <iostream>
#include <iomanip>
using namespace std;

int main () {
  double f =3.14159;
  cout << setprecision (5) << f << endl;
  cout << setprecision (9) << f << endl;
  return 0;
}

The execution of this example shall display:
  3.1416
3.14159

Example Link

It is a great tool for the one that really are especial with the specific results in math. Practice and it’ll become easier for you.

This other web site help me to know more about euler number.

See you

Continue reading “Quiz #4”