-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathProgram.cs
More file actions
115 lines (106 loc) · 3.67 KB
/
Copy pathProgram.cs
File metadata and controls
115 lines (106 loc) · 3.67 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace TabularMethod
{
class Program
{
//Written by mohammad ebrahim pooya
//Student code : 97411315
//Copyrights C(with a circle) 2021 Ebrum Ir, Inc. All rights reserved.
static void Main(string[] args)
{
var input = new Input();
List<string> minterms = new List<string>(Tools.Convert2Bin(input.Minterms));
//Adding zeros at the start of numbers to have the same number of characters for each number
for (int i = 0; i < minterms.Count(); i++)
{
while (minterms[i].Length < minterms[minterms.Count() - 1].Length)
{
minterms[i] = new string(minterms[i].Insert(0, "0").ToCharArray());
}
}
List<string> mintermsCopy = new List<string>(minterms);
List<string> PIs = new List<string>();
while (true)
{
var comp = new Comparison(minterms);
foreach (string item in comp.LeftMinterms)
{
PIs.Add(item);
}
minterms.Clear();
foreach (string item in comp.ChangedMinterms)
{
minterms.Add(item);
}
if (comp.IsNew == false)
{
break;
}
}
PIs = PIs.Distinct().ToList();
bool IsFinished = false;
var Final = new List<string>();
while (IsFinished == false)
{
var EPIRecognizer = new EPIrecongition(mintermsCopy, PIs);
var EPIlist = new List<string>(EPIRecognizer.EPIs);
//Going for the SEPIs
var LeftMinterms = new List<string>();
var LeftPIs = new List<string>();
foreach (List<string> list in EPIRecognizer.CheckList)
{
LeftMinterms.Add(list[0]);
}
foreach (string item in PIs)
{
if (!EPIlist.Contains(item))
{
LeftPIs.Add(item);
}
}
var Sepi = new SEPIrecognition(LeftMinterms, LeftPIs);
foreach (string item in EPIlist)
{
Final.Add(item);
}
//Repopulating the enteries.
mintermsCopy.Clear();
foreach (string item in LeftMinterms)
{
mintermsCopy.Add(item);
}
PIs.Clear();
foreach (string item in Sepi.SEPIs)
{
PIs.Add(item);
}
Final = Final.Distinct().ToList();
if (LeftMinterms.Count() == 0)
{
IsFinished = true;
}
else
{
IsFinished = false;
}
}
var Out = new Output(Final);
Console.WriteLine();
Console.WriteLine();
Console.WriteLine("The Minterms are :");
Console.WriteLine(Out.result);
Console.WriteLine();
Console.WriteLine("And their binary form is:");
foreach(string item in Final)
{
Console.WriteLine(item);
}
Console.WriteLine("Please press enter to exit the program");
Console.ReadLine();
}
}
}