Monday, March 7, 2016

From October 2, 2015

I apparently had this written back in October of last year when I was working on a calendar program in C, but I never posted it because it was titled "To be written tomorrow..." and I obviously got fucking distracted. Anyway, here's my (very likely hackish) calendar program.

After mulling over this ALL day, here is the answer I've come up with for this programming project.

/* Write a program that prints a calendar. */

#include <stdio.h>

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

    int days_month, week_begin, var1, var2;

    printf("Enter the number of days in the month: ");
    scanf("%d", &days_month);
    printf("Enter the day of the week the first day falls upon (1=Sun, 7=Sat): ");
    scanf("%d", &week_begin);

    var2 = 1;
    while (week_begin > var2) {
        printf("   ");
        var2++;
    }

    for (var1 = 1; days_month >= var1; var1++, ++week_begin) {
        printf("%3d", var1);
        if (week_begin >= 7) {
            printf("\n");
            week_begin -= 7;
        }
    }
    printf("\n");

return 0;
}

I looked up the answer in the book answer key and 50% of my program is almost identical to the author's program. Woohoo!
Unfortunately, that last gnarly bit with the if statement is vastly different from his. He used all sorts of maths like remainder and variables - 1 * variables to get his answer. I can't see the relationships of numbers quite that easily... yet. :(

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??