Bit of Help?

Status
Not open for further replies.

FoxMcCarther

In Runtime
Messages
186
Location
Rockford, MI / Harrisonburg, VA
Hey I am wondering af anybody on here is willing to help me a little bit. I have an assignment due in a few days (I am aware of the no homework policy, I am asking for where to look, not to have it done for me). Also, this is a "Team Project" meaning outside sources are allowed, All I can't do is take code directly from an existing script in its entirety.

Information first, question follows. I am going to give probably a bit more information than you need, but that is in case I do end up having any other questions ^_^

Basically, for my math 227 class I need to make a program in sage that will read a text file with one integer (0 or 1) per line. The document is 256 lines long. What I need to make happen is, I need it to open the file, and read 8 lines, then produce an output (if 1). It would then move onto the next group of 8.

The point is to show the Disjunctive Normal Form.

For example:
Line 1 is a 0 - (go on to line 2)
line 2 is a 1 - output a',b',c
line 3 is a 0
line 4 is a 0
line 5 is a 1 - output a,b',c'
line 6 is a 0
line 7 is a 1 - output a,b,c'
line 8 is a 1 - output a,b,c

The final output would end up looking like
11 f(a,b,c) = a'b'c | ab'c'|abc'|abc
The 11 coming from the number of operations (that being 8 and's (,) 3 or's (|).

whether it is a,b, or c (or) a',b',c' is based on the function f(a,b,c)
Here is a truth table I threw together representation of what I am talking about, with the value in the last column representing the numbers that will be listed in the 256 line document. (The truth table corresponds with the example above)
tex.jpg

I have an idea of what I want to do as far as line assignment and display goes, however I am stuck on a rather important part. Having no previous experience in programing, and him not teaching it (as it is a math class, and apparently you were expected to know it going in. Oops... Lol), I am not sure of how I should go about having sage open and interperate the value of a line (in groups of 8, then start the next group of 8, etc). I hope you can understand what I am asking, I am not sure how to phrase it.

To try to phrase it differently, I need the first character of each line, for 8 lines, that data then needs to be displayed in the above format (11 f(a,b,c) = a'b'c | ab'c'|abc'|abc ) and then I need to repeat that with the next 8 lines.

Anybody that can point me in the right direction will be appretiated ^_^. I will continue looking around Google myself.

Thanks!
 
Status
Not open for further replies.
Back
Top Bottom