QUESITI sui bit


OLICYBER 2021 – 12

Considera la seguente operazione:

(x ^ (62 & 31)) | 12

Dove ^, & e | sono rispettivamente le operazioni di xor, and e or bit a bit.

Quali dei seguenti numeri devo sostituire a x per ottenere come risultato 29?

15 | 16 | 6 | 4

SOLUZIONE

Il risultato atteso è 29 = 011101

Risolvi l’equazione

(x ^ (111110 & 011111)) | 001100 = 011101
(x ^ 011110) | 001100 = 011101
z | 001100 = 011101
z = 01..01

Risolvi l’equazione

x ^ 011110 = 01..01
x = 00..11
x = 000011 (3)
x = 000111 (7)
x = 001011 (11)
x = 001111 (15)


OLICYBER 2022 – 10

Considera la seguente operazione:

(17 | x ^ 31) & 63

Dove ^, & e | sono rispettivamente le operazioni di xor, and e or bit a bit.

Quali dei seguenti numeri devo sostituire a x per ottenere come risultato 25?

17 | 31 | 10 | 6

SOLUZIONE

Risolvi l’equazione

(010001 | x ^ 011111) & 111111 = 011001
(010001 | x ^ 011111) = 011001

Il valore di x deve essere

x = 0.011.
x = 0 0 011 0 (6)
x = 0 0 011 1 (7)
x = 0 1 011 0 (22)
x = 0 1 011 1 (23)