Two Tricks

for the Art of Computing workshop @CSA, IISc · 17 Feb 2024

Neeldhara Misra

(b) The Reds Speak Up

(a) The Rigged Bits

Two Tricks

I have a function \(f\) that takes a 16-bit string as input & produces a number between 0 and 15 as output.

You give me a string \(s \in \{0,1\}^{16}\) and a number \(n \in \{0,...,15\}\).

It will turn out that \(f(s) = n\).

I have a function \(f\) that takes a 16-bit string as input & produces a number between 0 and 15 as output.

You give me a string \(s \in \{0,1\}^{16}\) and a number \(n \in \{0,...,15\}\).

It will turn out that \(f(t) = n\).

I will flip one bit in \(s\) to get \(t\).

Think of the bit string of length 16 as being written out in a \(4 \times 4\) grid.

What does the function \(f\) do?

Think of the bit string of length 16 as being written out in a \(4 \times 4\) grid.

\(f\) can be thought of as writing out four bits.

Think of the bit string of length 16 as being written out in a \(4 \times 4\) grid.

\(f\) can be thought of as writing out four bits.

Think of the bit string of length 16 as being written out in a \(4 \times 4\) grid.

\(f\) can be thought of as writing out four bits.

Think of the bit string of length 16 as being written out in a \(4 \times 4\) grid.

\(f\) can be thought of as writing out four bits.

Think of the bit string of length 16 as being written out in a \(4 \times 4\) grid.

\(f\) can be thought of as writing out four bits.

Think of the bit string of length 16 as being written out in a \(4 \times 4\) grid.

\(f\) can be thought of as writing out four bits.

Think of the bit string of length 16 as being written out in a \(4 \times 4\) grid.

\(f\) can be thought of as writing out four bits.

Think of the bit string of length 16 as being written out in a \(4 \times 4\) grid.

\(f\) can be thought of as writing out four bits.

Think of the bit string of length 16 as being written out in a \(4 \times 4\) grid.

\(f\) can be thought of as writing out four bits.

Think of the bit string of length 16 as being written out in a \(4 \times 4\) grid.

\(f\) can be thought of as writing out four bits.

Think of the bit string of length 16 as being written out in a \(4 \times 4\) grid.

\(f\) can be thought of as writing out four bits.

\(f(\)

\() = 12.\)

Think of the bit string of length 16 as being written out in a \(4 \times 4\) grid.

\(f\) can be thought of as writing out four bits.

\(f(\)

\() = 7.\)

WANT:

Think of the bit string of length 16 as being written out in a \(4 \times 4\) grid.

\(f(\)

\() = 7.\)

WANT:

\(f\) current:

\(f\) desired:

Think of the bit string of length 16 as being written out in a \(4 \times 4\) grid.

\(f(\)

\() = 7.\)

WANT:

\(f\) current:

\(f\) desired:

Any number of cut shuffles are done.

Five people pull out the top five cards in order.

A deck is given to someone in the audience.

The Reds Speak Up

The ones with red cards stand up.

All cards are identified.

The Card Identifier

X Y A B C

00 - ♣️ | 01 - ♠️ | 10 - ♦️ | 11 - ♥️

Five bits correspond to a card

A B C - value of the card (000 interpreted as 8)

The Sequence

Want: 32 bits so that each location gives us a unique read.

00000100101100111110001101110101

The Sequence

Want: 32 bits so that each location gives us a unique read.

00000100101100111110001101110101

The Sequence

Want: 32 bits so that each location gives us a unique read.

00000100101100111110001101110101

The Sequence

Want: 32 bits so that each location gives us a unique read.

00000100101100111110001101110101

The Sequence

Want: 32 bits so that each location gives us a unique read.

00000100101100111110001101110101

The Sequence

Want: 32 bits so that each location gives us a unique read.

00000100101100111110001101110101

The Sequence

Want: 32 bits so that each location gives us a unique read.

00000100101100111110001101110101

The Sequence

Want: 32 bits so that each location gives us a unique read.

00000100101100111110001101110101

The Sequence

Want: 32 bits so that each location gives us a unique read.

00000100101100111110001101110101

The Sequence

Want: 32 bits so that each location gives us a unique read.

00000100101100111110001101110101

The Sequence

Want: 32 bits so that each location gives us a unique read.

00000100101100111110001101110101

The Sequence

Want: 32 bits so that each location gives us a unique read.

00000100101100111110001101110101

The Sequence

Want: 32 bits so that each location gives us a unique read.

00000100101100111110001101110101

The Sequence

Want: 32 bits so that each location gives us a unique read.

00000100101100111110001101110101

The Sequence

Want: 32 bits so that each location gives us a unique read.

00000100101100111110001101110101

The Sequence

Want: 32 bits so that each location gives us a unique read.

00000100101100111110001101110101

The Sequence

Want: 32 bits so that each location gives us a unique read.

00000100101100111110001101110101

The Sequence

Want: 32 bits so that each location gives us a unique read.

00000100101100111110001101110101

The Sequence

Want: 32 bits so that each location gives us a unique read.

00000100101100111110001101110101

The Sequence

Want: 32 bits so that each location gives us a unique read.

00000100101100111110001101110101

The Sequence

Want: 32 bits so that each location gives us a unique read.

00000100101100111110001101110101

The Sequence

Want: 32 bits so that each location gives us a unique read.

00000100101100111110001101110101

The Sequence

Want: 32 bits so that each location gives us a unique read.

00000100101100111110001101110101

The Sequence

Want: 32 bits so that each location gives us a unique read.

00000100101100111110001101110101

The Sequence

Want: 32 bits so that each location gives us a unique read.

00000100101100111110001101110101

The Sequence

Want: 32 bits so that each location gives us a unique read.

00000100101100111110001101110101

The Sequence

Want: 32 bits so that each location gives us a unique read.

00000100101100111110001101110101

The Sequence

Want: 32 bits so that each location gives us a unique read.

00000100101100111110001101110101

The Sequence

Want: 32 bits so that each location gives us a unique read.

00000100101100111110001101110101

The Sequence

Want: 32 bits so that each location gives us a unique read.

00000100101100111110001101110101

The Sequence

Want: 32 bits so that each location gives us a unique read.

00000100101100111110001101110101

The Sequence

Want: 32 bits so that each location gives us a unique read.

00000100101100111110001101110101

The Sequence

Want: 32 bits so that each location gives us a unique read.

00000100101100111110001101110101

The Sequence

Want: 32 bits so that each location gives us a unique read.

00000100101100111110001101110101

The Sequence

Want: \(2^k\) bits so that each location gives us a unique read.

De Bruijn Sequences

Goal: build these sequences by taking an Euler Tour in a graph.

Vertices: one for each bit string of length \(k-1\).

Total # of vertices = \(2^{(k-1)}\).

00

11

01

10

\(a_1...a_{k-1}\)

\(b_1...b_{k-1}\)

When should you add this edge?

\(a_2...a_{k-1} = b_1...b_{k-2}\)

[Suffix-Prefix match.]

0
1
1
1
1
1
1
0
0
0
0
0
0
1
1
1
1
1
1
0
0
0
0
0
0
1
1
1
0
1
1
0
0
0
0
0
0
1
1
1
0
1
1
0
0
0
0
0

\(a_2\)

\(b_1\)

\(b_2\)

\(b_3\)

\(\cdots\)

\(b_{k-1}\)

\(a_1\)

\(a_3\)

\(\cdots\)

\(a_{k-2}\)

\(a_{k-1}\)

\(b_{k-1}\)

Any vertex has two out-neighbors.

\(a_2\)

\(b_1\)

\(b_2\)

\(b_3\)

\(\cdots\)

\(b_{k-1}\)

\(a_1\)

\(a_3\)

\(\cdots\)

\(a_{k-2}\)

\(a_{k-1}\)

\(b_{k-1}\)

Any vertex has two out-neighbors.

\(a_2\)

\(b_1\)

\(b_2\)

\(b_3\)

\(\cdots\)

\(b_{k-1}\)

\(a_1\)

\(a_3\)

\(\cdots\)

\(a_{k-2}\)

\(a_{k-1}\)

\(b_{k-1}\)

Any vertex has two in-neighbors.

\(a_2\)

\(b_1\)

\(b_2\)

\(b_3\)

\(\cdots\)

\(b_{k-1}\)

\(a_1\)

\(a_3\)

\(\cdots\)

\(a_{k-2}\)

\(a_{k-1}\)

\(b_{k-1}\)

Any vertex has two in-neighbors.

Vertices: one for each bit string of length \(k-1\).

Each vertex will have
two in-neighbors and two out-neighbors.

Total # of edges = \(2^{(k)}\).

Total # of vertices = \(2^{(k-1)}\).

00

11

01

10

00

11

01

10

00

11

01

10

0

0

00

11

01

10

0

0

1

00

11

01

10

0

0

1

0

00

11

01

10

0

0

1

0

1

00

11

01

10

0

0

1

0

1

1

00

11

01

10

0

0

1

0

1

1

1

00

11

01

10

0

0

1

0

1

1

1

0

00

11

01

10

0

0

1

0

1

1

1

0

00

11

01

10

0

0

1

0

1

1

1

0

00

11

01

10

0

0

1

0

1

1

1

0

Two Tricks

By Neeldhara Misra