Noob to Hacker

A narrated quest - From ignorance to bliss

Recent Posts

  • All Moves for Each Pokemon Type (Fire, Water…) in Pokemon Go

    All Moves for Each Pokemon Type (Fire, Water…) in Pokemon Go

  • The best Pokemon Go tips and advice

    The best Pokemon Go tips and advice

  • Complete List of Moves and Attacks for Each Pokemon in Pokemon Go

    Complete List of Moves and Attacks for Each Pokemon in Pokemon Go

Day 15 – Continuing with CS50

March 24, 2016 by Noobtohacker

What happens if you exceed the possible number that can be represented?  Integer overflow happens, and value changes to other values so one needs to be careful with this.

Compiler takes higher level code to lower level that machine can actually understand.

CLANG:

  • Pre-processing (Acts on the # lines)
  • Compilation
  • Assembly
  • Linker

You can tell clang to do just factions of that process by adding -E -S or stuff like that.

I have finalized Week 1 classes and I am doing the “shorts” which take about 1,30 hours , so its like two lectures again. These are now pretty hard and I have not been able to fully understand them yet. Maybe in the future I will go back to them. Basically some of the concepts of compilers, libraries etc.

Already looking into Problem Set 1 and looks pretty hard. Let’s see!

 

Filed Under: Learning Computer Science

Day 14 – Finishing Week 1 of CS50 – A real application of Modulo

March 21, 2016 by Noobtohacker

Day 14 – Finishing Week 1 of CS50 – A real application of Modulo

Today I saw the remaining 2 videos of week 1 at CS50:

  1. Learned how to use the CS 50 IDE
  2. On the software world, things take much longer than they seem.
  3. Important to learn the CMD shortcuts (tab, up and down for history etc. )
  4. “Computers always use a finite amount of information”
  5. Awesome thought learned from this video… if you have an 8 bit binary number, and you do modulo 256, you are effectively cutting off the first left 4 bits, and actually any extra bits to the left, because those are all 256*256*256*256 etc… so YourNumber % 256, will remove all those and only leave whatever was before then.

Starting with C

    • Main: Analogue on scratch is “When green flag clicked”.
    • If wanna write a program, first function has to be main
    • Curly braces encapsulates code.
    • printf – function who prints a formatted string by formatted means that you can plugin placeholder values, and can specify how many num to print after decimal points etc… and it takes different arguments or parameters… THOSE INPUTS ARE EMBRACED BY PARENTHESIS.
    • \n Means New Line. You can’t click enter to create a new line. So we use \n (escaped variable)
    • Lastly. the “;” denotes the end of the line. But we don’t put it in all end of lines.
    • C can handle different kinds of types:
      • Char: Is 8 bits (1 byte), and represents a single character.
      • Float: Usually a 32 bit (4 bytes) value, something with a decimal point.
      • Double: Twice as big as a float (More bits to store larger numbers)
      • Int: Integer Usually 32 bits (4 Bytes) – Means that in unsigned form can store a max num of 4294967295 (Which is 2 to the power of 32 , minus one). And you can basically repesent 4294967295 + 1 values, because you have 0 :).
      • Longlong: 64 bits
      • Long: Depending on hardware can change!
      • String: (Comes only with CS50 library)
      • Boolean (Comes only with CS50 library)
      • Format Codes: %s is string, %c (print char). %i (print integer), %f (floating or double), etc…
      • Escape sequences: \n is new line, \t is tab, \” (a ” when u wanna put it inside an input so that it doesn’t get confused with the ” used to make a string)
      • Functions: GetChar, GetFloat etc…
      • In C it is a pain in neck like prompt user for input from keyboard so CS50 have generated that library.
    • One tricky concept is… how many of a certain number can you store in an X amount of bits. Well , it depends. Do you want to account for negative numbers too? Or only integers? This article explains it well.
      • If only integers, you call it “binary unisgned” and you can get the usual (2^n)-1. So for example in 4 bits max num that can be stored is 2^4 minus one, which is 16-1 = 15
      • However, usually you wanna do also negative numbers right? In that case you must leave one digit for the +/- sign. Hence in this form, which can be called 2 ways depending on how exactly the negative numbers are “assigned” to each respective binary (check the link above), the max number that can be expressed is 2^(n-1) – 1, because we are missing that 1 bit that we before could use (This is both in 1-s and 2-s complement methods… the only thing that changes in those is the minimum value allowed).  This table explains it:
binary unsigned 2s-complement 1s-complement

-------------------------------------------

000    0         0             0

001    1         1             1

010    2         2             2

011    3         3             3

100    4        -4            -3

101    5        -3            -2

110    6        -2            -1

111    7        -1            -0
  • On the mario example, the coin score saved is stored in 1 byte (8 bits), hence the maximum coin store that can be saved is 2^8 – 1 = 256-1 = 255.

Some C structures (canonical constructs):

loopfilled

boleans

if on C switches

Filed Under: Learning Computer Science

Day 13 – CS50 Problem set 0 – Building a game on scratch

March 19, 2016 by Noobtohacker

Day 13 – CS50 Problem set 0 – Building a game on scratch

It is crazy that the first problem set already is building a project, in this case some sort of game on Scratch.

The requirements of the first project are:

  • Need to use 2 sprites
  • 3 scripts
  • 1 Condition, 1 loop and 1 variable
  • 1 sound

What I want to do:

It will take me some time to understand exactly which thing I wanna make, but I feel I want to do:

  1.  A shooter kind of game (Maybe like asteroids?)
  2. Ideally would be nice to have some background that you can interact to!
  3.  A jetpack would be nice…
  4. Would be awesome if shooting is done with mouse pointing and space hiting
  5. shooting can have a trajectory? So it is harder to shoot! A parabole kind of thing

Will keep you updated on my project!

Breaking it into smaller parts:

  1. I want program that allows me to fly with a jetpack around the screen only. (Would be awesome if jetpack has given set of “fuel” that runs out, and you can collect more or smth)
  2.  I will add platforms
  3. I will add shootings
  4. I will add enemies

THE FINAL PRODUCT

Ok, so at the end the project came out very different from I had thought 🙂 but I am still very proud of it! Check it out :D!

https://scratch.mit.edu/projects/102379875/

It is unbelievable how easy it is to program in scratch… and it actually gives me a pretty good idea on how proper programs work. 

 

Filed Under: Learning Computer Science

Day 13 – Finishing week 0 of CS50

March 19, 2016 by Noobtohacker

Day 13 – Finishing week 0 of CS50

ASCII extras:

Interesting to understand a bit better the ASCII table.

ASCII has 7 bits, so max of 128 digits characters can be represented! 

a-z = 26, upper another 26, 10 digit characters, 32 special and 1 space… 95 total.  The rest are “instructions” meant for old needs (DEL etc…). So what about chinese characters and all? There is a new standard called Unicode, is the one that accommodates all those. 

In ASCII 0,1,2,3 are actually the numbers  48,49,50…. until 57. This is very interesting. When you check from 48/57 in binary you realize that each number maps to its binary preceded by 011! So for example 0110000 is 48, which maps to 0 etc.

bonary1

Another interesting pattern happens with the letters as you can see below. Just by flipping the 2 to the 5ths bit, you can change from Upper to Lower case :).

bonary2

 

Filed Under: Learning Computer Science

Day 12 – Just fell in Love with Harvard CS50 – Will also take it

March 18, 2016 by Noobtohacker

Day 12 – Just fell in Love with Harvard CS50 – Will also take it

Hahahah, I just discovered Harvard CS50 at this link. OMG… what a difference in style compared with the MIT course.

I feel both MIT and Harvard have strengths in so that they are both SO different. This I feel is enough reason to take both. I feel that taking both introduction to Computer Science courses will help me analyze similar problems from different angles, and if I am gonna go on my own… then I’d better have a rock solid foundation. 

So from today onwards I will also follow Harvard CS50

I feel this is… in a way… a rest for me. A way to be part of Undergrad at some universities I have not had chance to study a full undergrad, but that I would have loved to!

Lecture 1

I am pretty impressed by the speed of the lecture… it’s so quick! Already done binary numbers, ASCII, RGB (red, green, blue)… interesting that you can say… hey give me 72 red, 73 green, 33 blue…

In different situations, exact same patterns of 0 and 1’s can mean different things (Characters, colors, sounds…).

Absolutely beautiful explanation of a search algorythm. How many steps does it take me to go through a phonebook to find a name. First is searching one by one, second is going steps of 2 by 2, third is taking half, selecting right half and keep halving… The interesting thing is how to represent the increment of difficulty of the problem as n (size goes up). And how is the third method represented?

The key is to think, how many more steps will I need to take if I double my problem size? On first case, you need to take n more steps. On second case n/2. On third case… just 1 ! And even if sample gets doubled many times until it becomes massively large… still you won’t need to take many steps to reach the answer.

problemphonebook

EXTRA

At some point in the lecture he mentions that we will do cryptography! And the message below appears on the screen.

When I looked at it it was obvious to me that it was a web address starting by https. So uggct translates to https. After checking the ASCII codes of those letters, I can see that each letter translates to the correct one when you go to 13 letters further from the letter you are, and if you run out of letters you need to start counting again from the beginning.

By doing that we get: https://youtu.be/  (HERE NOT SURE)

So clearly that is a link to a video! However I have not been able to translate the same method for the rest of the URL. Not sure what I am doing wrong. Hope that I will be able to solve it in the future.

Best.

crytpto

Filed Under: Learning Computer Science

  • « Previous Page
  • 1
  • …
  • 3
  • 4
  • 5
  • 6
  • 7
  • …
  • 9
  • Next Page »