User Tools

Site Tools


opus:fall2012:mkelly23:part1

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.

opus/fall2012/mkelly23/part1.txt · Last modified: 2012/10/18 12:43 by wedge