Boolean operations for ITE-Algorithm - decision-tree

I'm a bit confused. I need to make an example of using the ITE-Algorithm on every Boolean operation. But I actually don't know how much there are?
As an example I mean, AND, OR, XOR, XNOR, NOR, NAND, NOT. And I don't know the other ones... I at least miss one because it cannot be seven operations. (2^n)

I need to make an example of using the ITE-Algorithm on every Boolean
operation.
This is Exercise 1 from the Fascicle 1B of the Volume 4 of Knuth's The art of computer programming.
The answer is the following.
But I actually don't know how much there are?
There are exactly 16 boolean functions of two variables (and 22ⁿ functions of n variables). Just permutate rows in functions' truth tables.
| F0 | F1 | F2 | F3 | F4 | F5 | F6 | F7 | F8 | F9 | FA | FB | FC | FD | FE | FH |
|----|----|----|----|----|----|----|----|----|----|----|----|----|----|----|----|
| 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 1 | 1 | 1 | 1 | 1 | 1 | 1 |
| 0 | 0 | 0 | 0 | 1 | 1 | 1 | 1 | 0 | 0 | 0 | 0 | 1 | 1 | 1 | 1 |
| 0 | 0 | 1 | 1 | 0 | 0 | 1 | 1 | 0 | 0 | 1 | 1 | 0 | 0 | 1 | 1 |
| 0 | 1 | 0 | 1 | 0 | 1 | 0 | 1 | 0 | 1 | 0 | 1 | 0 | 1 | 0 | 1 |
F0 and FH do not depend on the values of both variables.
F3, F5, FA, FC depend on the value of only one variable.
The table below lists common names of these functions.
The above table is from the Fascicle 0B of the Volume 4.
I'd add that F8 and FE are also known as Pierce's arrow and Sheffer stroke respectively.

Related

Get the first value that is not 0 in a column

| A | B |
---|--------|--------|---------
1 | 0 | 500 |
2 | 0 | |
3 | 0 | |
4 | 500 | |
5 | 400 | |
6 | 0 | |
7 | 700 | |
8 | 300 | |
9 | | |
In Cell B1 I want to display the first value that is <> 0 in the Column A.
(in this example it would be 500)
I tried to go with something like this but could not make it work:
B1 =LOOKUP(2,1/(A1:A8<>0),A1:A8)
How do I need to modify the formula to get the needed result?
Can try FILTER().
=#FILTER(A:A,A:A>0)
Index and Match will find the next non 0 in a column
=INDEX(A:A,MATCH(TRUE,INDEX(A:A<>0,),0))

Change x:y to x ↵ y

I have the following problem: In my very large excel spreadsheet, I have a few rows that look like this:
Memo: IBRD
0
0
0
0
0
0
0
0
0
0
IDA
0
0
0
0
0
0
0
0
0
0
and a few others that look like this:
Memo:
IBRD
0
0
0
0
0
0
0
0
0
0
IDA
0
0
0
0
0
0
0
0
0
0
I want them to be uniform and change all those that exhibit the first format to the SECOND one (where Memo: empty; and the next row is IBRD with the data entries).
I have found the following VBA code that might do the trick but I am not 100% how to apply this to my problem here.
Sub splitOneCellIntoMore()
Dim R As Range
Dim I As Range
Dim O As Range
wTitle = "splitOneCellIntoMoreCells"
Set I = Application.Selection.Range("B")
Set I = Application.InputBox("Select the Cell B1 that contains the text you want to split:", wTitle, I.Address, Type:=8)
Set O = Application.InputBox("Select destination cell you want to paste your split data:", wTitle, Type:=8)
A = VBA.Split(I.Value, ":")
O.Resize(UBound(A) - LBound(A) + 1).Value = Application.Transpose(A)
End Sub
(I took the code from: https://www.excelhow.net/split-one-cell-into-two-or-more-cells.html)
This is the table I am using.
| DEBT OUTSTANDING(LDOD) | | | | 36 | 330 | 405 | 412 | 527 |
| ------------------------------------------------------------------- |--|---|---|---|---|---|---|---|
| Public and publicly e;uaranteed | | | | 36 | 330 | 405 | 412 | 506 |
| Official creditors | | | | 2 | 305 | 376 | 385 | 480 |
| Multilateral | | | | 0 | 115 | 151 | 164 | 242 |
| Concessional                                                      I | | | | 0 | 110 | 142 | 155 | 232 |
| Bilateral | | | | 2 | 190 | 225 | 221 | 238 |
| Concessional | | | | 2 | 151 | 189 | 190 | 212 |
| Private creditors | | | | 34 | 25 | 29 | 27 | 26 |
| Bonds | | | | 0 | 0 | 0 | 0 | 0 |
| Commercial banks | | | | 0 | 0 | 0 | 0 | 0 |
| Other private | | | | 34 | 25 | 29 | 27 | 26 |
| Privatenone;uaranteed | | | | 0 | 0 | 0 | 0 | 21 |
| Bonds | | | | 0 | 0 | 0 | 0 | 0 |
| Commercial banks and other | | | | 0 | 0 | 0 | 0 | 21 |
| Memo: IBRD | | 0 | 0 | 0 | 0 | 0 | 0 | 0 |
| | | | | | | | | |
| IDA | | 0 | 0 | 0 | 109 | 137 | 148 | 220 |
| DISBURSEMENTS | | | | 33 | 70 | 90 | 52 | 89 |
| Public and publicly e;uaranteed | | | | 33 | 70 | 90 | 52 | 89 |
Screenshot/link refer:
Use FilterXML to split cells as follows:
=IFERROR(TRANSPOSE(FILTERXML("<x><y>"&SUBSTITUTE(A2,"|","</y><y>")&"</y></x>","//y")),"")

Excel lookup upwards

I am trying to lookup data that is the first occurrence of an ID looking upwards in excel. I would like to stop looking upwards when the cell value is ID is 0.
I have used the following to find the first occurrence when looking upwards:
In Cell D8:
=LOOKUP(2,1/($A$2:A8=C8),$B$2:B8)
In Cell D9:
=LOOKUP(2,1/($A$2:A9=C9),$B$2:B9)
For the case of desired outcome = 13 this works, however when there are consecutive IDs I would like to return the top most non-zero data field. Example desired outcome = 15 with the current formula returns 0.
How can I continue looking upwards until the top most ID = 2 before ID =0?
+----+------+--------------+-----------------+
| ID | Data | Lookup Value | Desired Outcome |
+----+------+--------------+-----------------+
| 2 | 18 | 1 | No Formula |
+----+------+--------------+-----------------+
| 1 | 25 | 2 | No Formula |
+----+------+--------------+-----------------+
| 0 | 0 | 0 | 0 |
+----+------+--------------+-----------------+
| 1 | 13 | 0 | 0 |
+----+------+--------------+-----------------+
| 2 | 15 | 0 | 0 |
+----+------+--------------+-----------------+
| 2 | 0 | 0 | 0 |
+----+------+--------------+-----------------+
| 2 | 0 | 1 | 13 |
+----+------+--------------+-----------------+
| 1 | 0 | 2 | 15 |
+----+------+--------------+-----------------+
| 0 | 0 | 0 | 0 |
+----+------+--------------+-----------------+
| 0 | 0 | 0 | 0 |
+----+------+--------------+-----------------+
Put this in D4 and copy down:
=IFERROR(LOOKUP(2,1/(($A$2:A4=C4)*($B$2:B4<>0)),$B$2:B4),0)
Put this in D4 and copy down:
=IFNA(LOOKUP(9^9,1/B$2:B4^-1/($A$2:A4=C4)),)

Multiple Lookup Criteria

I have this data below in Excel. What I want is to return the No.of Inactive months and the Inactive months themselves.
ACTIVITY MONTH
Jan17 Feb17 Mar17 Apr17 Reg Month No.Inactive months Months Inactive
User ID
1 5 38 0 60 Jan17
2 0 242 203 20 Feb17
3 30 0 0 30 Jan17
4 0 0 0 40 Apr17
5 0 0 16 0 Mar17
To count the inactive months you can use the following.
+---+------+--------+--------+--------+--------+--+-----------------+
| | A | B | C | D | E | F| G |
+---+------+--------+--------+--------+--------+--+-----------------+
| 1 | User | Jan 17 | feb-17 | mar-17 | apr-17 | | Inactive months |
| 2 | 1 | 5 | 38 | 0 | 60 | | 1 |
| 3 | 2 | 0 | 242 | 203 | 20 | | 1 |
| 4 | 3 | 30 | 0 | 0 | 30 | | 2 |
| 5 | 4 | 0 | 0 | 0 | 40 | | 3 |
| 6 | 5 | 0 | 0 | 16 | 0 | | 3 |
+---+------+--------+--------+--------+--------+--+-----------------+
where in cell G2 the is this formula =COUNTIF(B2:E2,0)
To show the list of inactive months it's a little bit harder.
The point is that you have to explain how you want to see these results.
The easier way is to use the conditional formatting anc color the cell with zero (but this is not so useful). Others way could be to traspose the table and filter the column with zero. Another one could be to use a VBA macro....

How to get the cell with the highest number, work with it, get the next highest and so on in excel?

I'm trying to get a cell with value BBBBBBBGGGGGJJJJCCCCDDDDAA from these cells:
-----------------------------------------
| 2 | 7 | 4 | 4 | 0 | 0 | 5 | 0 | 0 | 4 |
-----------------------------------------
So it gets the highest value and writes the cell's horizontal address (that might have an offset) that many times. Then gets the next highest and does the same thing until it reaches the zeroes. Is that possible in excel?
additional samples:
------------------------------------------------------------------------------------
| 2 | 0 | 0 | 3 | 0 | 0 | 5 | 0 | 0 | 0 | GGGGGDDDAA |
------------------------------------------------------------------------------------
| 0 | 0 | 2 | 0 | 0 | 0 | 5 | 0 | 0 | 0 | GGGGGCC |
------------------------------------------------------------------------------------
| 0 | 7 | 2 | 2 | 4 | 3 | 3 | 0 | 0 | 0 | BBBBBBBEEEEFFFGGGCCDD |
------------------------------------------------------------------------------------
| 4 | 7 | 0 | 7 | 7 | 0 | 0 | 0 | 8 | 7 | IIIIIIIIBBBBBBBDDDDDDDEEEEEEEJJJJJJJAAAA |
------------------------------------------------------------------------------------
| 0 | 2 | 0 | 2 | 8 | 0 | 8 | 0 | 7 | 10| JJJJJJJJJJEEEEEEEEGGGGGGGGIIIIIIIBBDD |
------------------------------------------------------------------------------------

Resources