WeBWorK Problems

Difficulties creating digital logic problems

Re: Difficulties creating digital logic problems

by Andrew Parker -
Number of replies: 2

The warning messages occur because of some error in the construction of `@boolArray`, and can be confirmed by adding a warn statement to the answer block as follows:

for (my $r = $numInputs; $r < $numInputs + $numOutputs; $r++) {
    for (my $c = 0; $c < $numRows; $c++) {
        warn("not found at $r, $c") if !defined($boolArray[$r][$c]);
        ANS(Compute($boolArray[$r][$c])->cmp());
    }
}

I did not attempt to trace back the issue, but did notice that there are other issues with `@boolArray` -- e.g. the first two correct answers are 2 and 3 (not very boolean), and other correct answers do not match the solution table.

In WW2.19, a booleanContext.pl macro was added, which may address your request for entering boolean expressions. I have attached a modified version of your provided problem which uses the new context -- though the context would be more relevant for entering logical expressions. I'd be happy to share more examples as well.

In reply to Andrew Parker

Re: Difficulties creating digital logic problems

by Sean Fitzpatrick -

Thanks! That helped her with the debugging. I think the boolean context doesn't quite fit her use case, because she's working in a context where she needs more than 0 and 1. For digital logic there is also X and I. (X means you don't care if it's 0 or 1. I forget what I means.)

In reply to Sean Fitzpatrick

Re: Difficulties creating digital logic problems

by Nicole Wilson -

I is for indeterminant and is only used in state tables, but I'd rather not have a special case for state tables since they are so similar to truth tables, in terms of creating/marking the table in a webwork question.

Thanks for your help with data validation and for the version you shared. I clearly need to figure out how to write subroutines!