Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>I use the following notation for the position of the bits. </p> <pre><code> B CAD E </code></pre> <p>This gives me a 2^5 possibilities (32) which I write down. I found 3 cases out of all the possibilities where A is 1 but the output must be 0. I could of written down the Karnaugh table, but since I've got only 3, I do a direct function:</p> <p>IsZero = (!A | ((B &amp; A &amp; E &amp; !C &amp; !D) | (C &amp; A &amp; D &amp; !E &amp; !B) | (A &amp; B &amp; C &amp; D &amp; E)))</p> <p>If you need IsOne, it is simply !IsZero.</p> <p>C# code to verify this follows: </p> <pre><code>class Program { static void PrintFunction(int[,] myArray, int yMax, int xMax) { for (int y = 0; y &lt; yMax; y++) { for (int x = 0; x &lt; xMax; x++) { Console.Write(myArray[y, x]); } Console.WriteLine(); } } static bool A(int x, int y) { if (Input[y, x] == 1) return true; else return false; } static bool B(int x, int y) { try { if (Input[y - 1, x] == 1) return true; else return false; } catch { return false; } } static bool C(int x, int y) { try { if (Input[y, x - 1] == 1) return true; else return false; } catch { return false; } } static bool D(int x, int y) { try { if (Input[y, x + 1] == 1) return true; else return false; } catch { return false; } } static bool E(int x, int y) { try { if (Input[y + 1, x] == 1) return true; else return false; } catch { return false; } } static int[,] Input = { { 1,0,0,1,1,1,0,0 }, {1,0,0,0,0,1,0,0}, { 1,1,1,1,1,1,0,0 }, {1,0,0,0,0,0,1,1} , {1,0,1,0,0,0,1,0} }; static int[,] OutputVH = new int[5, 8]; static int[,] Solution = { { 1,0,0,1,0,1,0,0}, { 0,0,0,0,0,0,0,0}, { 1,0,0,0,0,1,0,0}, { 0,0,0,0,0,0,1,1} , {1,0,1,0,0,0,1,0} }; static int xMax = 8; static int yMax = 5; static void Main(string[] args) { Console.WriteLine("Both Filterings"); for (int y = 0; y &lt; yMax; y++) { for (int x = 0; x &lt; xMax; x++) { bool isZero = (!A(x, y) | ((B(x, y) &amp; A(x, y) &amp; E(x, y) &amp; !C(x,y) &amp; !D(x,y)) | (C(x, y) &amp; A(x, y) &amp; D(x, y) &amp; !E(x,y) &amp; !B(x,y)) | (A(x, y) &amp; B(x, y) &amp; C(x, y) &amp; D(x, y) &amp; E(x, y)))); OutputVH[y, x] = (isZero ? 0 : 1); } } PrintFunction(OutputVH, yMax, xMax); bool SolutionFound = true; for (int y = 0; y &lt; yMax; y++) for (int x = 0; x &lt; xMax; x++) if (OutputVH[y, x] != Solution[y, x]) SolutionFound = false; if (SolutionFound) Console.WriteLine("Found solution!"); } } </code></pre> <p>I'll leave it to you to simplify this further using boolean logic, if needed.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload