V
V
Valentine2018-01-29 13:26:26
IT education
Valentine, 2018-01-29 13:26:26

I can not solve the task in the exam. Typo?

Task with Yandex USE. Claimed to be a CAB answer, but I've double-checked and can't seem to get that solution. Am I missing something or is this a typo?5a6ef6c83b9a9212760706.jpeg

Answer the question

In order to leave comments, you need to log in

2 answer(s)
L
longclaps, 2018-01-29
@val_gr

You don't understand something. Or you can't.

from itertools import product

def f(a, b, c):
    return int(a and not b and not c or a and c)

print("A B C F")
for abc in product((0, 1), repeat=3):
    print(*abc, f(*abc))

We look at the output
A B C F
0 0 0 0
0 0 1 0
0 1 0 0
0 1 1 0
1 0 0 1
1 0 1 1
1 1 0 0
1 1 1 1

there are only 3 ones in column F, 2 of them got into the task. We look at the lines with ones
A B C F
1 0 0 1
1 0 1 1
1 1 1 1

A and C seem to be suitable for the role of column No. 2 - they give 2 necessary units,
but C disappears - acc. rows of our table are columns A and B contain
1 0
1 1

and in the task
1 0
0 0

we try to match 2 of the three lines, so the middle column is A, and B and C will give the required 3 zeros and one
, here they are:
A B C F
1 0 0 1
1 0 1 1

you just need to rearrange the columns and rows
C A B F
1 1 0 1
0 1 0 1

make sure that the first line from the task, the one where F == 0, is found,
for this we rewrite it in the correct order
C A B F    ->   A B C F
0 1 1 0    ->   1 1 0 0

- there is such a line, penultimate in the table.
PS for those who find it difficult Akram : I don’t like to think myself, let the computer think)
ABCF = [(a, b, c, f(a, b, c))
        for a, b, c in product((0, 1), repeat=3)]

data = ((0, 1, 1, 0),
        (1, 1, 0, 1),
        (0, 1, 0, 1))

for x, y, z in permutations((0, 1, 2)):
    crossdata = [(r[x], r[y], r[z], r[3]) for r in ABCF]
    if all(r in crossdata for r in data):
        print("ABC"[x], "ABC"[y], "ABC"[z])

A
Akram, 2018-01-29
@Akram

something a bit complicated))
A*~B*~C+A*C = A*(~B*~C+C)=A*(~B+C)
final operation = conjunction, check by result units.
so A is the second column, since there is only 1 for rows 2 and 3.
similarly, (~B+C) should also give 1 for these rows, so B is in column 3 (negating 0 = 1, 1+1 = 1).
for C, column 1 remains.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question