Solving Algorithms – Bubble Sort

Why are solving algorithms Adnilson, shouldn’t you work on building applications? Yes, you are right! The thing with algorithms is that it helps you solve problems and are good to make your mind look for solutions. This way you build a blueprint and whenever you get a problem you tackle the problem instead of being tackled by it.

In Ruby things sometimes are too easy and today I will go back to school and review the bubble sort, this algorithm is not the most efficient way of sorting but is a simple and cool exercise.
In Ruby if you want to sort say, an array you can do it by doing array.sort and bam! There it is.
The code:


length = array.length - 1
loop do
  swapped = false
  (0...length).each do |i|
    if array[i] > array[i+1]
      array[i], array[i+1] = array[i+1], array[i]
      swapped = true
  break if !swapped

puts array

I guess the code speaks for itself. In a lower level language the program would have an extra variable to store the value of one of the array contents in order to swap.
The first time I did this was in Pascal, then Fortran in college.

Ruby Koans Dice Project

I finish my day with this project in the amazing Ruby Koans learning method, and had completed 216/282! Got to see the Ruby documentation and feels like I am getting more into the syntax.
Here is the code I made in the about_dice_project.rb:

# Implement a DiceSet Class here:
class DiceSet
  attr_reader :values
  def roll(num)
    @values = []
    (1..num).each { |count| @values << rand(1..6) }

Why I hate C#

It all started when I installed Visual Studio Essentials. Had a few recommendations about learning C# and that it would get me a job easily and fast! Why not give it a shot.
While installing I worked out, went shopping and when arrived the installation was on progress! So I picked my guitar. Yes! Acoustic guitar, not guitar hero… I’m done with games since these are time wasters. Keep away from them if you want to be successful! Go outside with some friends (or alone) and play sports or any other activity you like that releases your stress.
So, after a few hours it finally installed and went to learn it, I really hated it… No visceral reaction whatsoever. It is a very high level language, looked like JAVA, a terrible clone I must say. My hard drive was full of software that I didn’t even know what it did or if was useful. Maybe it is a way or “the way” that Microsoft pushes their products on people as they do in the corporate world. “Open your mouth and take another dose of our new programs. They are buggy and expensive but we promise you that they will work because we force schools and technicians to get certificates in order to have a job and earn more. Oh is it too heavy for you computer? Here, new workstations whether laptops or desktops it will run fast, just until the new release. We are Intel partners and we need to flush out these machines before a new technology 3% faster and triple of the price appears in the market.”
Needless to say that I uninstalled  but a hot load of the software suite that was installed wasn’t removed automatically, and they are tens of them. I guess Windows 10 will be reinstalled since I do not want to remove them one by one. Terrible flaw.

By the way, this blog was created after I received advice from a gentleman named Jonh Sonmez from in how to market myself. I think he is doing an amazing job by sharing his experiences and guiding young men in this masculine crisis of today.
Check his youtube channel.

Have an amazing day, afternoon, evening or night.

Back on Track

Well I have been on and off programming after leaving College.
This was rekindled after seeing my girlfriend in late 2015 doing a SQL tutorial in Khan’s Academy, which I completed in a few days.
Then restarted LPTHW book, but changed to LRTHW which I began in late in 2014 and never went back to it. I am currently in the 48th exercise and having a hard time with it. This exercise is about building a code to pass an Automated Testing done by the author named Zed A. Shaw. It is so far the hardest for me besides the one with dictionaries that made me quit twice. If I only had opened the terminal and wrote the code in a shell that wall of fire could be overcome easily.
Just to say that pushing through the exercises is making me tougher and ready to conquer the Software Development Industry in the long run. Gotta be bold!

Perhaps it’s good for today and will return tomorrow with full force.