Mysterious Riddle-Giving Wizards Hate Him!

Mysterious Riddle-Giving Wizards Hate Him!

Consider a permutation of the positive integers up to nn. This permutation is streamed one item (xix_i) at a time to an observer (you!). After observing an item, you must make two choices. First, choose whether to add xix_i to a working set (DD) or discard xix_i. Second, choose whether to observe an additional value or stop observing subsequent items.

Once you’ve stopped the stream, a (non-adversarial) wizard chooses an integer ω\omega on [1,n)[1, n). Your goal is to find some DωDD_\omega \subseteq D such that Dωdimodn=ω\sum_{D_\omega} d_i \ \operatorname{mod} \ n = \omega. A good algorithm should:

Clearly, we could view the entire stream, store all items so that |D|\lvert D \rvert = nn, and succeed all the time because ωD\omega \in D. Can we do better though?

I propose that we include the first z=log2(nln(n))z=\log_{2}\big(n\ln\big(n)) items in DD. The 2z2^{z} subsets of DD have sums that aren’t uniformly distributed, but when modn\operatorname{mod} n is applied this distribution becomes near uniform on [1,n)\big[1, n). If this distribution is in-fact uniform, then we have a success probability of 1e2z/n11/n1 - e^{-2^z/n} \approx 1 - 1/n.

𝐀𝐡𝐞𝐦, 𝐒𝐨𝐮𝐫𝐜𝐞?\textbf{Ahem, Source?} — This result re: modn\operatorname{mod} n comes from Sampling Correctors: Section 8.1. To be quite honest, I think the exact problem (i.e. sum must be ω\omega instead of kn+ωkn + \omega with k0k \in \mathbb{N}_0) is more interesting, but I liked that fact so we shoehorn it in. This post was inspired by 𝐏𝐫𝐨𝐩𝐨𝐬𝐢𝐭𝐢𝐨𝐧 𝟑.𝟏𝟗\textbf{Proposition 3.19} of Jay Cummings’ Proofs_\underline{Proofs}. In that problem, we see (via. pigeonhole principle) that for any subset of size zlog2(n)z \geq \log_2\big(n) there is at least one positive integer ωn\omega \leq n that can be constructed by at least two subsets of zz.