Gunning down 195 numbers

Finally I got to the final task of the first partial: the 196 activity. This activity consisted in creating a program to find possible Lychrel numbers in a specific range of data. Lychrel numbers are natural numbers that do not form palindromes after adding their inverse several times.

As usual, I asked for help to my new best friend Alex, and here is what he did: obviously (like in every previous programs) I created two classes, the main class and an additional class called ‘Range’. In my main class, I used a new thing (well, new for me) called JOptionPane to collect inputs given by the user. I had two of this so that the user could enter the lower and the upper limits of the range of numbers. In Range, I defined 5 variables: low, high, natural=0, non=0, and yes=0. I also created two methods: the first one called ‘rango’ (I’m Mexican so don’t nag me) that has two parameters a and b where a is defined as the lower bound, and b as the upper bound; the second one was the method where all the math calculations were made, this one was called ‘types’.

In main, I created one new object, and called method rango for it, passing the two inputs provided by the user as parameters.  In types, I defines two variables (both strings): palin, and palinInverse, both variables were empty. I also defines 4 varibales as long: p1, p2, suma, and n. Finally I created a For loop with the condition that x=lower bound, and it iterate until x=upperbound. In the for loop, I made three conditions: one if that add one to my variable ‘natural’ if the number was a natural palindrome; another for loop to iterate thirty times to find Lychrel candidates, if there were palindromes in the way, it add one to ‘non’, and if not, it print an “Alert message” and add one to ‘yes’ meaning that it had found a Lychrel candidate.

I had a little problem with this code because first I defined my variables as float, but after just 10 iterations the numbers were incredibly huge, and the float variables couldn’t support it. So I had to change my variables to long, and then the program could successfully run.

Here I leave screens of my program in Github:



Babylonian Territory

Down in Babylonian Territory, I successfully implemented the Babylonian Method to find the square root of a number. Again, I received help from Alex ( the same guy I talked about in my most recent post).

The structure of this program is very similar from the GCD because this one also has two classes: the main class and a ‘Number’ class. In the number class, again, there are two methods: one called ‘setValue’, that assign a value to the objects created in the main class; and another called ‘squareRoot’, in this one there are performed the mathematical calculations. In the main class, there are created two objetcs: val1 and val2. Then it is called the method squareRoot for val1, passing as parameter val2. In this method, there are four variables declared: a, b, div, and ave. Variable a is assigned the value of val1, and b is the parameter. Then there is a for iteration to perform the process of the Babylonian method three times. The variable div gets the value of a/b, and ave gets the value of the average of b and div. Finally b gets the value of ave to perform the next iteration.

I tried the code assigning a the value 7, and b the value 4, and the output I get was 2.6457672, a very accurate square root of number 7.

The reasoning for doing this code was based in this link.

Here I also leave the link and screens of my GitHub account where you can see my code. Greetings from the Babylonian Territory!



GCD reflective post

Here is the very first coding activity of this semester (except for the HelloWorld activity), and is a program that outputs the greatest common divisor of two given numbers. The challenge of this assignment was to create the most objected-oriented code as possible. So that instead of doing a simple iterative solution, one number (defined as an object) would receive a message to give the greatest common divisor of it and another number passed as parameter.

In order to accomplish the task, I asked for help to a friend of my mom (she works at IBM and knows plenty of coding nerds). Her friend is teacher in ITESO, and he assigned me one of his best students to help with Java, his name is Alex Ramirez. I met Alex one Saturday morning, and he taught me a lot of basic stuff of Java.

The way we addressed this problem was basing our thoughts in Euclid’s algorithm. I created a main class, and another public class call ‘Number’. In Number, I created two different methods: the first was a void type named ‘setValue’, to assign a value to both of my objects; and another void type called ‘max’, this was the important method where all of the math operations were going to be made. In my main class, I created two objects, val1 and val2, and by using setValue, I assigned a quantity value to both objects (in this case 1160 and 2013 respectively). With my two objects, I called the method max in val1 passing as parameter val2. In max, I declared 3 variables: a (val1), b (parameter), c (remainder of a/b)… And thathaa… When running the code, the output was 29, and I had a big smile drawn in my face.

Later in class, my teammate Dustin (alias Finn) helped me with the synchronization of Eclipse and GitHub showing me an excellent video that clearly explain the steps to follow to achieve the synchro.  As you can see, I’m very good at getting help of others!

Here a I leave some screens of my code in GitHub:

GDC class

GDC main


Last week my team and I (Luis, David, and Dustin) defined what our final project will be. We found a project on the internet about a platform controlled by a Raspberry Pi that is mobilized by some motors with the objective of carrying a camera device which takes photos in defined periods of time.

This project may sound difficult, but the truth is that we have everything we need to completed. David owns a Raspberry Pi, the components are not expensive, and the library that we need is already included in Java’s library.

Here I leave some web pages that show a similar project, and some advice that are needed to perform this project in the Raspberry Pi.


Flipped Learning

Flipped learning is an innovative, revolutionary way of ‘teaching’ that is having its bum in universities all around the world. For the wsq04, I read Afraj Gill´s blog post about the way that A´s grades spoiled his learning process. Afraj blames the educational system based in obtaining the highest possible grade at all price for mispricing the real goal of education: implementing the acquired knowledge in real life. Afraj says that although he always obtained the highest grades, and he was priced with a lot of scholarships and rewards, he realized that he had never used his knowledge in real life situations. He thinks that grades are the biggest obstacles for trully learning because students memorize big quantities of information in their short-term memory, causing that all those concepts are not ‘fully digested’ by the brain, and finally forgotten.

I agree with Afraj´s point of view. I’m used to obtain the highest grades, but I have always thought that someone´s intelligence isn’t based in answering a sheet of paper nor ‘macheteando’ (colloquial way in Mexico to describe the action of memorizing a big quantity of data) every single word that the teacher says in a class. I reflected about the part where Afraj talks about Finnish educational system (the best in the world) where people don’t attend school until 7 years old, and don’t present tests until their teenagers. In my point of view, Mexico needs to change something in its educational strategy (because it sucks!).

I searched for additional information about this topic and found an article of the University of Queensland, Australia that describes a little more how Flipped classrooms works, but the really interesting part of this article is that in the end, there are shown some benefits of the flipped learning style. I specially liked two of them: curate content, students gathering their own sources, and providing opportunities for discourse, the fact that an independent learning brings a bunch of different points of views of the students resulting in an enriching dialogue because they not only talk about what the professor said but also their own ideas.

Here I leave the link to that Queensland article; it is very interesting, and I expect that it gives more information of this revolutionary topic to my classmates:



OO Basics

Today we finally finished seeing the video of Object Oriented Basics. Due to the amount of work I had to do, and the fact that my attention wasn’t the best in class, I had to take a second look to my video at my house.

I think that there were two crucial things that the video pointed out: static/dynamic objects or programming and the terms that I had already discuss in past posts such as inheritance and encapsulation.

Beginning with static and dynamic programming, the video said that there are static programming languages such as java, c++ and c#; in the other hand there are dynamic languages like javascript, python, and ruby. The difference between this two terms resides in whether the code need to be compiled before running. If the platform has a compiler then we’re talking about a static programming type because the program needs to be checked for correctness. In languages like Python, there is no compiler because it is a interpreted language, or in our terms, a dynamic language type because the code is not checked before running and if there’s a mistake the output would show it.

The other important stuff is the inheritance between classes, and I specially liked this video because it uses excellent examples that clearly shows how objects relate and can inherit methods and fields.

With this video, the topic of Object Oriented Programming seems to be clearer, so I think it’s a good moment to go and have some fun giving a try to the wsq’s that involves coding!

Google Image photo by Brian Will shared under reutilization license.




Eclipse Essential Training

Jajajaja many people would think that I’m a lazy person because I have just seen the Lynda videos on Eclipse Essential Training, but actually a was not aware of those videos until this weekend, and I install and practice in Eclipse on my own.

The series of videos that the website Lynda shows about the essential training of Eclipse are just for getting started, giving some format to the code, and the use of some practical tools that the platform offers.

I think that the information in those videos is going to be useful in the future when the things in Eclipse start getting a little bit more serious and complicated. I specially liked the video on Formatting because sometimes I struggle with the indentation and braces/brackets of the codes, so is good to know that I can adjust my own format and ensure all my codes have the same indentation and stuff.