Showing posts with label don't give up. Show all posts
Showing posts with label don't give up. Show all posts

Monday, March 7, 2016

How to Learn How to Program on Your Own Time

An observation from a girl who is trying to learn how to program in her own time

  1. Read books about programming languages
  2. Read blogs (/subreddits/forums/mailing lists) about programming
  3. Be inspired by the big picture constantly
    • Even while working on the little shit
  4. Don't get distracted
  5. Write one-off programs 
  6. Read more books about programming languages
  7. Read more blogs about projects that you are interested in
  8. Don't get distracted
  9. Read other peoples' programs
  10. LOTS of other peoples' programs
  11. Write more programs
  12. Don't get distracted
  13. Think about programming in your spare time
  14. Theorize how a bigger program might work
  15. Write said program
  16. Fix all the bugs in said program
  17. Don't give up
  18. Don't fucking get distracted
I swear, I would be a hell of a lot further along if I could stop playing the same games that are inspiring me to learn this stuff. I feel the same way about this as I have about every musical instrument I have ever tried to learn -- yeah, I know where the keys are and what they do, but not really well enough to put together anything that sounds decent. Damn practice, why u b so hard??

Tuesday, September 15, 2015

EXCITE

I got it to work!!!!!!

All I had to do was change the variable being tested for zero value, and the location of the test!!! I had designed it one way at first, and then changed a few variables around and forgotten to change that one very important detail.

The more I think about it, the more this program is probably extremely hackish. The whole point of the project was to create a program that would take a whole, non-negative, non-zero number and repeat it back in reverse order.

In the book, my hint was to use a do loop to continuously divide the input by 10 until it reached 0. That was fine and all, but every time it divided by 10, it would give me answers like 9876, 987, 98, 9. If I only used modulo to get the remainder, I would consistently get the last digit.

So I started thinking: if I needed the last digit of each result of dividing the entry, why not use mod?

From this frame of thinking, I realize that I probably went the extra mile and made this more complex than it should be. Here is my first working program, though:

#include <stdio.h>

int main(int argc, char* argv[]) {

int entry, right_digit, left_digits, MOD, DIVISOR;
// these are named to reflect the position of the digit in the input

printf("Enter a whole, non-negative number with any amount of digits: ");
scanf("%d", &entry);

MOD = 10;
DIVISOR = 10;

// This takes care of the right-most digit, and prints it on the left

right_digit = entry % MOD;
printf("%d", right_digit);

// my hint is to use a do loop for the left digits

do {
MOD *= 10;
left_digits = entry;
left_digits %= MOD;
left_digits /= DIVISOR;
if (left_digits <= 0) {
break;
}
printf("%d", left_digits);
DIVISOR *= 10;
} while (left_digits > 0);

printf("\n");

return 0;

}

Skip past all of the printf/scanf nonsense that comes before the actual maths.

The right-most digit of the entry is taken care of first, because it needs to be printed on the far left if the number is to be reversed. Assume we use the number 5932 as our entry. The remainder of 5932 % 10 is 2. 2 is printed first.

Once that's done, we move into the do loop.

MOD starts out at 10 for the first calculation. The first part of the do loop multiplies MOD by 10.

left_digits is then assigned the value of entry. I worked with the original value through this because I couldn't figure out how else to do it (granted, I also couldn't figure out what was decrementing to 0 to give me a floating point exception).

left_digits is then divided by 100 and the remainder is stored back into left_digits. Assuming the original entry is 5932, for example, the remainder is 32.

left_digits is then divided by DIVISOR, which also begins at 10. Because it is an integer, and assuming we continue using the example above, left_digits is assigned the value of 3.

There is a conditional here to end the loop prematurely if left_digits is less than or equal to 0.

left_digits is printed. Continuing with the example entry above, the value printed here is 3. So far, our reversed number is: 23

DIVISOR is then multiplied by 10, making it 100.

Since left_digits is not 0, we loop again!

MOD is multiplied by 10 again and is now 1000.

left_digits is assigned the value of entry again because of the way this works. You'll see the pattern, just hang on.

left_digits is divided by MOD, which is 1000, and the remainder is assigned back into left_digits. Using the example above, the remainder would be 932.

left_digits is divided by DIVISOR, which is 100, and assigns the value to left_digits. Using our example, the value is now 9.

left_digits is printed, as long as it is not 0. So far in this loop, our reversed number is: 239

DIVISOR is multiplied by 10 again, making it 1000.

So, you see??? I got it to work!! Is there a better way to do it??? Probably!! But it does work, hahahaha.

I wonder when it will be that I look back at this little fragment and say, "What was I thinking??"

Oh, and I wonder if it's worth noting that I also hand-calculated the entire loop path to see exactly what it was doing, and that's exactly how I found out why I was getting a floating point exception error.

Sunday, October 26, 2014

Anecdotal Advice



My tunes for the night. This soundtrack is so amazing. The game is great, too. I thoroughly enjoyed it, and I look forward to playing the second game the same studio produced and released recently, called Transistor.

I promise I didn't come here to babble about video games, much as I'd like to. Instead, I want to babble about the furthering of ones' knowledge and skill.

This has been a recent discovery for me. I described it when I first felt it as "a desire so strong to achieve a goal that the relatively unenjoyable steps that need to be taken along the way are no longer unenjoyable". When I questioned my fiancé on what a feeling like that could possibly be, he merely named it "motivation". That's when I realized that I had not been truly motivated to do something for a very long time. Long enough to forget what it felt like.

That was in 2011. At the time, the feeling applied to my artwork, which I was using as an outlet for brainstorming a story that Andrei and I were working on together. I became enamored with the concept of MUDs after being introduced to one, and in 2012, I spent all of my time learning as much as I could about them. The desire I had to learn about them made me voracious for any information I could find, though it was quite thin by the time I started looking (most MUD information was out-of-date by 2007, with the massive popularity of emerging MMOs at the time). As I learned more about MUDs, I only became more fascinated by them. The majority of the old codebases were written in C, so I took the natural next-step and picked up C to try to fully understand them. The knowledge certainly helped when I started trying to script short programs into the MUD I build for!

Progress on that front has been halting, thanks to several projects I have on my plate that have been vying for priority. Now that I've made the overall decision to focus on HTML/CSS, I feel the same motivation driving me forward when I get stuck. I've grown to call it "possibility", personally. If I give up on whatever I'm working on, the possibility of anything coming of it will die. And, really... Anything is possible.

But, enough broad anecdote. What does that kind of motivation look like? Outside of the forward-driving force that is ones' own motivation, it looks something like this:


  • Scouring shelves at bookstores for used and new books that could hold useful information
  • Hunting for online resources; magazines, white papers, newsletters, blogs... anything.
  • Stepping away from the games or TV shows a little earlier at night to fit a little bit of reading in before bed
  • Keeping a digital copy open on the phone/tablet/computer on the off-chance that a 15-minute span of time pops up to allow for some quick reading
  • Writing a lot of code
  • Making lots of mistakes
  • Reading or talking about those mistakes and finding industry advice on how to avoid them
  • Making more mistakes, and hopefully, some visible progress

At least, that's what it looks like for me. I was lucky enough to stumble upon a used book published in 2004 for $6 that focuses on web standards for HTML and CSS. Inside, the author made heavy reference to his blog, so I went to see what he had to say. The blog hadn't been updated in a year or so, but even so... Thankfully, HTML and CSS haven't changed too much in the past 10 years, and the changes that have been made are very helpfully documented on the W3Schools Website. With that being the case, this blog is a fount of information. Additionally, the author often references a great deal of other resources. While reading through his blog, I found myself bookmarking every other page I visited for the quality of content I read. Some things were a little confusing, being marketed to web designers who have been in the industry for years. But, that unenjoyable feeling of being confused? It didn't last long when I reached a point in those articles when things began making sense. If I had given up and decided to come back when I had more experience, I'd have robbed myself of the opportunity to understand. It took more effort to continue reading something I legitimately didn't get, but the payoff was far greater.

This has been an incredibly rambly way of explaining why it's a bad idea to give up. If something seems out of reach, there are times that you give yourself an excuse to not work as hard. It is tough to keep the motivation going. But to throw the towel in because something is too hard or you don't get it is the wrong approach -- instead, figure out why it's too hard or why you don't understand, and go from there. And if that is way too much work, then start asking yourself if you've chosen the right thing to take up your time.

Some of the HTML/CSS references I found are listed below, for anyone interested. I wish all a wonderful night or day, whichever the case may be.