Example #1
0
 public void Should_Return_List_Of_Values_For_Specified_Row_In_Specified_TruthTable_Values_Without_Result_Column_Values(
     TruthTableValues tableValues,
     int row,
     List <string> expectedResult)
 {
     tableValues.GetRowValuesWithouthResultColumn(row).Should().BeEquivalentTo(expectedResult);
 }
Example #2
0
        /// <summary>
        /// Function that forms groups of number of 1s from the truth table values that need to be simplified.
        /// Ex: Group for values with only 1 positive variables, group for values with 2 positive variables and so on...
        /// </summary>
        /// <param name="reference">The values of the truth table that has to be simplified.</param>
        /// <returns>Formed gruops with keys the number of 1's in the data plus the minterms that are necessary for getting the prime implicants.</returns>
        private static Tuple <QMCGroups, HashSet <int> > FormGroupsWithMintermsForComparison(TruthTableValues reference)
        {
            // Groups with number of ones //
            var groups     = new QMCGroups();
            var minterms   = new HashSet <int>();
            var resultData = reference[reference.Keys.Last()];

            for (int i = 0; i < resultData.Count; i++)
            {
                if (resultData[i] == "1")
                {
                    minterms.Add(i);
                    var rowValues   = reference.GetRowValuesWithouthResultColumn(i);
                    int GroupNumber = rowValues.FindAll(n => n == "1").Count;
                    if (!groups.ContainsKey(GroupNumber))
                    {
                        groups.Add(GroupNumber, new List <QMCGroupData>()
                        {
                            new QMCGroupData(i, String.Join("", rowValues))
                        });
                    }
                    else
                    {
                        groups[GroupNumber].Add(new QMCGroupData(i, String.Join("", rowValues)));
                    }
                }
            }
            return(new Tuple <QMCGroups, HashSet <int> >(groups, minterms));
        }