User Tools

Site Tools


opus:fall2012:mkelly23:start

Mkelly23's Opus of Epic Failure

INSERT KNOWLEDGE HERE

Introduction

Who is Matthew Kelly? He comes from the old school world of flux capacitors, cassette tapes and original Nintendo. Computer Science is new journey for mkelly23, and he wants to make the best of it.

Part 1

Entries

Entry 1: August 28, 2012

Today was very much a “deer in the headlights” day for me. I had heard legends about Discrete's level of knowledge and difficulty. As a phrase, “Discrete Mathematics” is intimidating! I worry that my lack of comfort in C programming will cause me to fall behind in the course, but will do all that I can to finish the semester with an A.

The class started with a rundown on how to use the IRC chat server. I immediately learned the ins and outs of Rollbot, and how it can be used to distract one from lecture points. The support structure in the chat room, however, should prove to be very useful. I appreciate the ability to connect with students in and out of the classroom, with the hopes of learning from their far-more-advanced skills in computer programming.

I also picked a class keyword for the semester, “Right Projection.” I had absolutely ZERO.ZERO idea what that would mean, and I was charged with the task of research and implementation of Right Projection.

Entry 2: September 4th 2012

Today's class revolved around “Logic.” A discussion was opened up as to what “Logic” means, both in formal defintion as well as in layman's terms. Ultimately, I learned that “logic” is defined as “the study of modes of reasoning.” As a class, we agreed that logic can quite simply be “stuff that makes programs work.” Without logic, our basic computers could not function.

As a class, we looked deeper into logic, and created a Truth Table. That truth table took two inputs (P and Q), and a Boolean approach to their states. Boolean reasoning states that a value can either be 0 or 1; True or False. The truth table stretched out to 16 different logic states, and we explored AND, OR, NAND, XOR, etc, including the logic of our keywords.

I was able to take the knowledge from the truth table, and begin working on a function to best represent “right projection.”

Entry 3: September 11th, 2012

I entered class, feeling confident in my right projection program. I was able to not only print a truth table, but also implement right projection. I did so in two ways; first, I showed right projection as it pertains to a truth table using P and Q, where X was the right projection of P, Q. Basically, the value of X will always output the value of Q. Secondly, I included an input parameter, that solicits values from a user for P and Q, and outputs the right projection those inputs.

We ended class by discussing the differences between Arrays and Structures. I remembered the concept of Arrays, and how to partially use them from the C/C++ Programming class I had last spring. Structures were new to me, however, and I am intrigued by the functionality and benefits of using Structures.

Entry 4: September 14th, 2012

Today we covered “the beginning of the future (which is here now)”, in dealing with Linked Lists. According to Matt, what we learned today is the “meat” of Data Structures.

We started off with Singly-Linked Lists, and discovered nodes. I learned that nodes contain a value and a pointer. Also, nodes only point to either other nodes or NULL, the list terminator. Drawing out nodes to NULL proved to be helpful, to better visualize how a list should flow.

In node-code, we use:

struct node{
    char value;
    struct node * next;
};
typedef struct node Node;

It was very helpful for me that we created a simple, singly-linked list code program in class. I struggle with how to effectively program while working on my own, but find it helpful to take bits and pieces of in-class material, and make minor changes to them.

Keywords

data Keyword - Pointers to Pointers

Definition

As we all know, a pointer is a special variable that does not hold a specific value, but rather the address of a value (or another variable). In the case of a “pointers to pointers” relationship, a pointer is used not to point to the address of another value, but to the address of another pointer.

A pointer to a pointer is written in code as

**(pointer1) = &pointer2;

where *pointer2 points to the address of another value/variable.

References

List any sites, books, or sources utilized when researching information on this topic. (Remove any filler text).

data Keyword 1 Phase 2

Function Pointers

Definition

Function Pointers are pointers that point to the memory location of a function and can be used to call and pass arguments to said function. This can be used when you might have a few functions and only one of them needs to be called but at the time of writing the program you don't know which one needs to be called.

References

Demonstration

Demonstration of the indicated keyword.

If you wish to aid your definition with a code sample, you can do so by using a wiki code block, an example follows:

/*
 * Sample code block
 */
#include <stdio.h>
 
int main()
{
    return(0);
}

discrete Keyword : Right Projection (or q projection)

Definition

Right Projection (or Projection Q), is a part of programming logic that always returns the right-side value in a Truth table. That is to say, for values P and Q in a truth table, the right projection always reflects the value (or state, if Boolean) of q.

To put it visually, where X is the right projection of (p, q):

P Q X
T T T
T F F
F T T
F F F

References

List any sites, books, or sources utilized when researching information on this topic. (Remove any filler text).

  • Reference 1
  • Reference 2
  • Reference 3

discrete Keyword 1 Phase 2

contradiction/falsehood

Definition

Contradiction/Falsehood: Setting every bit to 0; Outputting logically false to all possible logical inputs.

References

Demonstration

Demonstration of the indicated keyword.

If you wish to aid your definition with a code sample, you can do so by using a wiki code block, an example follows:

/*
 * 
 */
#include <stdio.h>
#include <stdlib.h>
 
// program to always output false where false = 0
 
char false(char, char);
//function prototype
 
int main( )
{
 char p = 0;
 char q = 0;
 char result = 0;
 
printf("P  |   Q   |   X  \n");
printf("------------------\n");
printf("%d  |   %d   |   %d \n", p, q, false(p, q));
 
 q = 1;
 
printf("%d  |   %d   |   %d \n", p, q, false(p, q));
 p = 1;
 q = 0;
 
printf("%d  |   %d   |   %d \n", p, q, false(p, q));
 
 p = 1;
 q = 1;
 
printf("%d  |   %d   |   %d \n\n", p, q, false(p, q));
 
printf("Input P: \n");
scanf("%hhd", &p);
printf("Input Q: \n");
scanf("%hhd", &q);
 
scanf("%hhd", &q);
result = false(p, q);
printf("Result is: %hhd\n\n", result );
 
 
return(0);
 
}
 
//function definition
char false(char a, char b)
{
char x;
if(b==1)
  x=0;
else if(b==0)
  x=0;
return(x);
 
}

Experiment 1

Question

How can I create a basic Fantasy Football program?? My goal is to start the beginning parts to writing a program that will solicit a user for statistics (yards, touchdowns, turnovers, etc) and convert those stats into a point value that can be stored.

Resources

Unfortunately, there are not a lot of resources available for researching Fantasy Football program writing. Multiple searches return how to sign up for fantasy football leagues, how to draft a team and various strategies, but nothing in regards to getting start with writing your own program. I did come across one website, where a student at another school had a similar assignment. His failed code (Java) looks like this:

<code> import java.util.Scanner; public class FantasyFootball { private int numberOfTeams; private int numberOfWeeks; private String[] nameOfTeams; private int [][] weeklyScores; private int [] averageScores; public FantasyFootball(int public FantasyFootball() { Scanner keyboard = new Scanner(System.in); ask for the 2 numbers nameOfTeams = new String[]; for loops to fill the arrays with <code>

While this is Java-speak, it follows similar thoughts that I had for a C program.

Hypothesis

I'm not ENTIRELY sure of what the “powers that be” are looking for here, but here goes:

Conceptually, this task is large but shouldn't be terribly complicated. I should be able to utilize variables for each position scored, and store the values in a struct or an array. The difficulty will come from adding a second team to go head-to-head with in competition, and displaying position match ups and their point totals.

Experiment

Here is the pseudocode for my program:

<code> Start FantasyFootball

QB = Quarterback WR1 = Wide Receiver 1 WR2 = Wide Receiver 2 RB1 = Running Back 1 RB2 = Running Back 2 TE = Tight End K = Kicker

function QB

 QByards = yardsPassing() + yardsRushing() + yardsReceiving()
 QBtouchdowns = touchdownsPassing() + touchdownsRushing() + touchdownsReceiving()
 QBturnovers = interceptions() + fumbles()

index = 0 QB{0} = mod(QByards, 10) QB{1} = QBtouchdowns x 6 QB{2} = QBturnovers x 2

pointsQB = QB{0} + QB{1} - QB{2}

end function

function RB

 RB1yards() = yardsRB1( rushing + receiving + passing)
 RB1touchdowns() = touchdownsRB1( rushing + receiving + passing)
 RB1turnovers() = turnoversRB1(interceptions + fumbles)
 RB2yards() = yardsRB2(rushing + receiving + passing) 
 RB2touchdowns() = touchdownsRB2(rushing + receiving + passing)
 RB2turnovers() = turnoversRB2(interceptions + fumbles) 

index = 0 RB1{0} = mod(RB1yards(), 10) RB1{1} = RB1touchdowns() x 6 RB1{2} = RB1turnovers() x 2

RB2{0} = mod(RB2yards(), 10) RB2{1} = RB2touchdowns() x 6 RB2{2} = RB2turnovers() x 2

pointsRB1 = RB1{0} + RB1{1} - RB1{2} pointsRB2 = RB2{0} + RB2{1} - RB2{2}

pointsRBs = pointsRB1 + pointsRB2

end function

function WR

 WR1yards() = yardsWR1(receiving + rushing + passing) 
 WR1touchdowns() = touchdownsWR1(receiving touchdowns + rushing touchdowns + passing touchdowns)
 WR1turnovers() = turnoversWR1(interceptions + fumbles)
 WR2yards() = yardsWR2(receiving + rushing + passing) 
 WR2touchdowns() = touchdownsWR2(receiving + rushing + passing) 
 WR2turnovers() = turnoversWR2( interceptions + fumbles)

index = 0 WR1{0} = mod(WR1yards() , 10) WR1{1} = WR1touchdowns() x 6 WR1{2} = WR1turnovers() x 2

WR2{0} = mod(WR2yards() , 10) WR2{1} = WR2touchdowns() x 6 WR2{2} = WR2turnovers() x 2

pointsWR1 = WR1{0} + WR1{1} - WR1{2} pointsWR2 = WR2{0} + WR2{1} - WR2{2}

pointsWRs = pointsWR1 + pointsWR2

end function

function TE

 TEyards() = yardsTE(receiving + rushing + passing)
 TEtouchdowns() = touchdownsTE(receiving + rushing + passing)
 TEturnovers() = turnoversTE(interceptions + fumbles)

index = 0 TE{0} = mod(TEyards() , 10) TE{1} = TEtouchdowns() x 6 TE{2} = TEturnovers() x 2

pointsTE = TE{0} + TE{1} - {TE2}

end function

function K

 KfieldGoals() = field goals made x 3
 KextraPoints() = extra points made x 1

pointsK = KfieldGoals() + KextraPoints()

end function

index = 0 Points{0} = pointsQB Points{1} = pointsRBs Points{2} = pointsWRs Points{3} = pointsTE Points{4} = pointsK

totalPoints = Points{0} + Points{1} + Points{2} + Points{3} + Points{4} <code>

Data

Unfortunately, I was unable to get the experiment beyond pseudocode stage.

Analysis

N/A. Unable to complete experiment.

Conclusions

My conclusion is that I am biting off more than I can chew with attempting to complete a full program. I am sure there are functions that can be written and loop through each position.

Part 2

Entries

Entry 1: October 3rd, 2012

Today was the day I attempted my first “Knowledge-Based Assessment” for Data Structures. I wasn't sure what to expect, and felt relieved to see just four questions. Unfortunately, I realized that I did not know how to properly answer two of the questions. I don't remember us going over the correct answers in class, which could have benefited me greatly.

On a more upbeat note, I was able to work through my Menu-Driven, singularly linked list program in class. I try to work through what I can of the programs before asking for help, but am usually unable to get through errors properly without help.

Entry 2: October 10th, 2012

In Data Structures, today was all about “stacks.” Stacks are another data structure that can be used for storing and accessing data. As I learned, they are very similar to the linked lists that I have been working with for the past several weeks. In stacks, data is stored one node at a time and accessed from the top, down. This concept of stack management is called “FILO” or First In, Last Out.

As data is stored into a node, it becomes “pushed” onto the stack, and added on top of the node prior. In order to access a lower node in the stack, you must first “pop” the nodes above, one node at a time. Stack overflow occurs when you are trying to push a node onto a full stack, and stack underflow occurs when trying to pop a node off of an empty stack.

A heads up was given on the future assignment for stacks. The four goals were to:

1) Understand the container 2) Have a working implementation of the container (Ex. nodes) 3) Understand the data structure 4) Implement it (manipulate the append/delete functions from linked lists)

Entry 3: October 11, 2012

TThe class started off with a polite “coming to Jesus” talk from Matt, in regards to proper code indentation. I knew that indenting was something that I struggled with, oftentimes mixing up the indenting guidelines for my Java class with those of C programming language. Thankfully, Matt also introduced me to his indenting program, that I am now able to use to properly indent code (for the ever-important grading purposes).

We also dipped into understanding functions and their involvement in C. Matt informed us that functions will play a crucial role in Recursion (to be learned at a later date). I have struggled with functions (parameters, calling functions, etc) since my days in C/C++. I learned to take a different/more mathematical approach to functions, which helped me grasp a better understanding. Just as in math, all functions return one value. Procedures, on the other hand, return zero values.

Entry 4: October 24th, 2012

The friendly, neighborhood ungraded Knowledge Assessment made another appearance today. The questions were very similar to the first assessment taken at the first of the month, with slightly different data and results. Going into this “test,” I felt somewhat better about how to break down the code to find an answer close to what is deemed “correct.” I still do not have a firm understanding of the basics of C, in my opinion, which causes a great concern for me.

At this point in the semester, I am still unable to complete assignments out of the classroom, as I have a disconnect with the language. Matt and Jacob continue to be my lifesavers, and try their best to not just give me the answer. My in-class neighbor certainly means well, but I find myself struggling with keeping up in class and trying to help him on his assignments concurrently. I worry that I will finish the semester with a slightly-above-amateur level understanding of C programming, leaving me missing a vital job skill for the workforce I hope/need to enter in May.

Keywords

data Keyword 2

stack (LIFO or FIFO?)

Definition

LIFO is an acronym that stands for “Last In, First Out.” When it comes to stacks, functions and procedures that are running become stacked on top of one another in memory (called a “push”). When an item is removed from the stack (or “popped”), it is removed from the top down. This computing action allows for stack integrity, and limits access/insertion.

FIFO means “First In, First Out.” In this regard, data and processing are handled on a first come, first serve basis through usage of a queue (or linear data structure). The first process in line is handled before any others are, and then the next, and so on.

References

List any sites, books, or sources utilized when researching information on this topic. (Remove any filler text).

data Keyword 2 Phase 2

doubly linked list

Definition

A doubly linked list a a method of storing data.
The manner in which the data is stored is by a series of structs. There will be a variable that will always point to the first struct, and if you want there can be one to always point to the last struct.
Every struct has a minimum of three variables contained within - the data value, a pointer to the struct after it, and a pointer to the struct before it. These pointers is how one will navigate these structs, it is how they are linked together.

References

No references for this keyword.

Demonstration

Demonstration of the indicated keyword.

If you wish to aid your definition with a code sample, you can do so by using a wiki code block, an example follows:

/*
 * Sample code block
 */
#include <stdio.h>
 
int main()
{
    return(0);
}

Alternatively (or additionally), if you want to demonstrate something on the command-line, you can do so as follows:

lab46:~$ cd src
lab46:~/src$ gcc -o hello hello.c
lab46:~/src$ ./hello
Hello, World!
lab46:~/src$ 

discrete Keyword 2

union

Definition

A union, when referred to in Computer Science, is defined as a value that can have several formats. Also, a union can be a data structure that contains a variable holding a union value.

A union's primary function is to conserve space in both code and in memory. As is the case with data structures, unions are not limited to one primitive data type at a time.

References

List any sites, books, or sources utilized when researching information on this topic. (Remove any filler text).

discrete Keyword 2 Phase 2

mutual exclusion

Definition

Mutual Exclusion is the method by which one can ensure that a region of memory cannot be accessed by two processes at the same time.
In logic terms, it can described as possibilities where you cannot have more than one be true at a time.

References

Demonstration

Demonstration of the indicated keyword.

If you wish to aid your definition with a code sample, you can do so by using a wiki code block, an example follows:

/*
 * Sample code block
 */
#include <stdio.h>
 
int main()
{
    return(0);
}

Alternatively (or additionally), if you want to demonstrate something on the command-line, you can do so as follows:

lab46:~$ cd src
lab46:~/src$ gcc -o hello hello.c
lab46:~/src$ ./hello
Hello, World!
lab46:~/src$ 

Experiment 2

Question

How to implement a basic scoring program for Fantasy Football?

Resources

Collect information and resources (such as URLs of web resources), and comment on knowledge obtained that you think will provide useful background information to aid in performing the experiment.

Hypothesis

In a continuance of my first experiment, I have decided to work on just a small portion of the overall goal. My intentions are to create a short program that will accept a player's statistics, and perform a quick mathematical computation. The result of the computation will be a point value which represents the player's overall performance in that field.

Experiment

To test my hypothesis, I will input the following data into the program for a particular player:

RB1 Stats - 150 yards rushing, 1 TD, 1 fumble.

The scoring is as follows:

For every 10 yards rushing = 1 point For every touchdown (TD) = 6 points For every turnover (fumble) = 2 points

Expected output: 19 points

Data

I entered the data into my FantasyFB program, as specified in my Experiment. The expected end result was:

150 yards rushing = 15 points 1 touchdown = 6 points 1 fumble = -2 points

Total points: 15

Analysis

Based on the data collected:

  • My hypothesis was correct. I was able to quickly (and linearly) write a simple program to calculate point totals for a particular player's stats. Moving forward, I will need to adjust my program to accept more than one player's statistics and calculate multiple point values. Those values will need to be stored in an array or structure that can easily be accessed for comparison against an opposing player's numbers.

Conclusions

As stated earlier, I was able to quickly and effectively calculate a point value from inputting one player's stats. My next goal is to build on this program, to accept more players input. Eventually, I hope that my program can be used to calculate a winner between two users and their team's overall point total.

Part 3

Entries

Entry 1: November 8th, 2012

Today in Discrete, we were introduced to a program that Matt created to draw an image in C. To do so, we had to utilize the gd library, compiling against -lgd to output a viewable image in a web browser.

In order to correctly draw the image, we had to first know the dimensions of our viewable window. Individual colors were set through distinct bit patterns. The image placement and shape formation, however, relied solely on mathematic algorithims. Equations were used to obtain the desired output for the x and y coordinates, causing the image to be placed where and how we wanted it to.

Entry 2: November 9th, 2012

At the start of Data Structures, a formal due-date for “Binary Trees” was set for the first week of December. The idea is to utilize a variation of a linked-list to implement the tree. The class lecture was focused on a review of Makefiles. Some of the class had been using Makefiles throughout the semester, while others (including myself) had not.

I learned that a Makefile was, in essence, a program within itself. Makefiles consist of variables (ALL CAPS) and CFLAGS placed to invoke the compiler. The language standards are supported by GCC. A great length of time was spent reviewing the manual page for GCC, where we learned the different ways that GCC can be used, and most of its attributes.

Entry 3: November 14th, 2012

In Data Structures today, we took a look at a program that Matt had written to implement stacks. This program was meant to bridge the gap amongst the class, and give everyone a solid program to base future work off of. In comparison to my working stack program, I found a lot of similarities. That was a good indication to me that I was learning more and more about how to program in C!

Matt's hope was that we would utilize his stacks program in building our binary trees. To this point, I was still unsure of how to best tackle the assignment. I did a lot of research online, and looked at sample code that others had posted. Unfortunately, I found that I didn't gain as much from this as I had anticipated.

Entry 4: November 29th, 2012

Dr. Marian Eberly graced us with her presence today. She came to observe Matt's teaching techniques, and to see what happens in the Almighty LAIR.

The class was focused on a revisiting of the gd library, and creating images in C programming. The goal of the day was to create an accurate Corning Community College logo. I found this assignment a nice change of pace, and the perfect balance of difficulty and entertainment.

We first reviewed how to access images, and output into a format that could be viewed on a web page. The discussion then shifted into how to properly place the CCC logo on the screen. When broken down, the logo is nothing more than a series of three half circles. Our first step was to determine where the first “C” needed to be placed, and how to avoid the image from overlapping a 12% border that we chose to implement.

As we worked through an equation to set the margins and place the first half circle, we found that the “C” displayed properly, but significantly smaller than intended. The rest of class time was spent working independently, trying to rectify the issue.

I found this class time to be one of the more rewarding classes of the semester, where I was able to find a practical application for C (different from making stacks, linked lists, etc).

Keywords

data Keyword 3

Identification of chosen keyword.

Definition

Definition (in your own words) of the chosen keyword.

References

List any sites, books, or sources utilized when researching information on this topic. (Remove any filler text).

  • Reference 1
  • Reference 2
  • Reference 3

data Keyword 3 Phase 2

Valgrind

Definition

A suite of tools used for debugging an existing program. Like Gcc, it uses a powerful debugging tool used by programmers to find breakpoints in their code.

References

Demonstration

Demonstration of the indicated keyword.

If you wish to aid your definition with a code sample, you can do so by using a wiki code block, an example follows:

/*
 * Sample code block
 */
#include <stdio.h>
 
int main()
{
    return(0);
}

Alternatively (or additionally), if you want to demonstrate something on the command-line, you can do so as follows:

lab46:~$ cd src
lab46:~/src$ gcc -o hello hello.c
lab46:~/src$ ./hello
Hello, World!
lab46:~/src$ 

discrete Keyword 3

Identification of chosen keyword.

Definition

Definition (in your own words) of the chosen keyword.

References

List any sites, books, or sources utilized when researching information on this topic. (Remove any filler text).

  • Reference 1
  • Reference 2
  • Reference 3

discrete Keyword 3 Phase 2

Permutation

Definition

A way, esp. one of several possible variations, in which a set or number of things can be ordered or arranged

References

Demonstration

Demonstration of the indicated keyword.

If you wish to aid your definition with a code sample, you can do so by using a wiki code block, an example follows:

/*
 * Sample code block
 */
#include <stdio.h>
 
int main()
{
    return(0);
}

Alternatively (or additionally), if you want to demonstrate something on the command-line, you can do so as follows:

lab46:~$ cd src
lab46:~/src$ gcc -o hello hello.c
lab46:~/src$ ./hello
Hello, World!
lab46:~/src$ 

Experiment 3

Question

Building On the CCC Logo:

How can I adjust the size of the Corning Community College logo to properly fit on the screen, with respects to the pre-determined margins?

Resources

For this experiment, there is no need to utilize web resources. I intend to use the image program (graph.c) that Matt had given us earlier in the month, as well as my understanding of Mathematics to properly create the Corning Community College logo.

Hypothesis

Can applying the rules of Mathematics help with creating a properly-sized logo?

To test my hypothesis, I will implement a value for pi. In Mathematics, pi has a set value; in C Programming, however, pi is not inherently recognized. Pi is useful in determining the size of circular shapes, and will be utilized in my program.

Experiment

I will test my experiment for creating a variable called pi, and assigning a rounded value of 3.14. I will then place pi into the equation for caluclating the radius of a circle in C, in order to return the optimum result.

Data

After initiating the variable pi to 3.14, I placed pi into the three half circle equations, multiplying each radius by the value of pi.

<code>

      gdImageFilledArc(img, ((rm-lm)/3+lm), ((bm-um)/2 + um), ((**pi***(rm-lm)/3+lm)/2),
      ((**pi***(rm-lm)/3+lm)/2), 90, 270, color[RED], gdArc);
      gdImageFilledArc(img, (((rm-lm)/3+lm)+((**pi***(rm-lm)/3+lm)/2)/2), ((bm-um)/2 + um),$
      ((**pi***(rm-lm)/3+lm)/2), 90, 270, color[RED], gdArc);
      gdImageFilledArc(img, ((rm-lm)/3+lm)+((**pi***(rm-lm)/3+lm)/2), ((bm-um)/2 + um), ((p$
      ((**pi***(rm-lm)/3+lm)/2), 90, 270, color[RED], gdArc);
      

Analysis

Based on my data, I was able to properly replicate the Corning Community College logo. Each “C” was properly placed on the screen, and at the appropriate size. The image stayed balanced within the 12% margins that we had designated in class yesterday.

Unfortunately, it is difficult to tell if my implementation of pi into the radius algorithim will work in all cases. It is quite possible that I was scientifically “lucky” in this instance. Given time constraints (and the need to focus on other assignments), I was unable to test another instance of using pi to create other circles.

Conclusions

What can you ascertain based on the experiment performed and data collected? Document your findings here; make a statement as to any discoveries you've made.

opus/fall2012/mkelly23/start.txt · Last modified: 2012/12/31 09:33 by 127.0.0.1