# Aaron WilliamsWilliams College · Department of Computer Science

Aaron Williams

Doctor of Philosophy

## About

85

Publications

39,428

Reads

**How we measure 'reads'**

A 'read' is counted each time someone views a publication summary (such as the title, abstract, and list of authors), clicks on a figure, or views or downloads the full-text. Learn more

813

Citations

Introduction

My main interests are in algorithms, combinatorics, computational complexity, and video game history.

Additional affiliations

September 2014 - August 2017

September 2011 - August 2013

May 2010 - August 2011

## Publications

Publications (85)

Mario is back! In this sequel, we prove that solving a generalized level of Super Mario Bros. is PSPACE-complete, strengthening the previous NP-hardness result (FUN 2014). Both our PSPACE-hardness and the previous NP-hardness use levels of arbitrary dimensions and require either arbitrarily large screens or a game engine that remembers the state of...

Pick a binary string of length n and remove its first bit b. Now insert b after the first remaining 10, or insert \(\overline{b}\) at the end if there is no remaining 10. Do it again. And again. Keep going! Eventually, you will cycle through all 2n
of the binary strings of length n. For example,
are the binary strings of length n=4, where
and
. And...

We develop the first universal cycle construction for strings with fixed-content (also known as multiset permutations) using shorthand representation. The construction runs a necklace concatenation algorithm on cool-lex order for fixed-content strings, and is implemented to generate the universal cycle in amortized O(1)-time per symbol. This genera...

You provide us with a matroid and an initial base. We say that a subset of the bases "belongs to us" if we can visit each one via a sequence of base exchanges starting from the initial base. It is well-known that "All your base are belong to us". We refine this classic result by showing that it can be done by a simple greedy algorithm. For example,...

Early video games didn’t have hardware support for random number generation, so developers used software-based RNG. We show that hundreds of games in the Nintendo Famicom / NES library regenerate the same pseudorandom sequence of 32,767 bits, although the machine code for doing so comes in more than one hundred variants. We identified the disparate...

We consider the problem of safely unstacking rectangular boxes through the lens of Megalit (ASCII, 1991). In this Game Boy game, the player is confronted with a pile of 1-by-k and k-by-1 megaliths (slabs). The goal is to pull and push the slabs until they reach the floor, without falling more than one cell at a time. We prove that an associated pro...

A Lukasiewicz path of length n is a lattice path from (0, 0) to (n, 0) that never goes below the x-axis, and which uses steps of the form (1, i) for integers i ≥ −1. These paths include both Dyck paths (i ∈ {−1, 1}) and Motzkin paths (i ∈ {−1, 0, 1}). A set of fixed-content Lukasiewicz paths contains all such paths in which the frequency of each st...

A flip-swap language is a set \(\mathbf{S}\) of binary strings of length n such that \(\mathbf{S} \cup \{0^n\}\) is closed under two operations (when applicable): (1) Flip the leftmost 1; and (2) Swap the leftmost 1 with the bit to its right. Flip-swap languages model many combinatorial objects including necklaces, Lyndon words, prefix normal words...

We generalize the middle levels conjecture from binary to k-ary strings. Our conjecture is equivalent to star transposition graphs on uniform-frequency multiset permutations being Hamiltonian.

We examine the computational complexity of turnstile puzzles, which are grid-based tour puzzles with walls and turnstiles. A turnstile is a wall that can be rotated in 90°increments, either clockwise or counterclockwise , around a central pivot when pushed by the player's token. In a 'thick' turnstile, the pivot and arms occupy cells of the grid, w...

We analyze the level generation algorithm in Nintendo’s Dr. Mario 64(2001). We find that its developers relied on the processing power of the Nintendo 64 to hide the algorithm’s limitations. On the hardest levels, the game (secretly) makes up to 80 attempts to randomly generate a puzzle with the desired number of viruses. Furthermore, if we artific...

The computational complexity of agent-based box-pushing puzzles on grids is well-studied. In particular, the video game Sokoban was shown to be NP-hard, and later PSPACE-complete, in the mid-1990s, and dozens of variants have since been studied. In this paper, we change the top-down perspective to a side perspective, where the player and the boxes...

How difficult is it to complete the final level in the Nintendo Game Boy game Dr. Mario? It is impossible — if you are playing the original release of the game. More specifically, there is a game breaking bug that occurs while generating any Level 28 puzzle. In this article, we provide a full technical explanation of this bug. More broadly, we prov...

We present a Hamilton cycle in the k-sided pancake network and four combinatorial algorithms to traverse the cycle. The network’s vertices are coloured permutations π=p1p2⋯pn, where each pi has an associated colour in {0,1,…,k-1}. There is a directed edge (π1,π2) if π2 can be obtained from π1 by a “flip” of length j, which reverses the first j elem...

A flip-swap language is a set S of binary strings of length n such that $S \cup 0^n$ is closed under two operations (when applicable): (1) Flip the leftmost 1; and (2) Swap the leftmost 1 with the bit to its right. Flip-swap languages model many combinatorial objects including necklaces, Lyndon words, prefix normal words, left factors of k-ary Dyck...

We develop the first universal cycle construction for strings with fixed-content (also known as multiset permutations) using shorthand representation. The construction runs a necklace concatenation algorithm on cool-lex order for fixed-content strings, and is implemented to generate the universal cycle in amortized O(1)-time per symbol. This genera...

We present a Hamilton cycle in the $k$-sided pancake network and four combinatorial algorithms to traverse the cycle. The network's vertices are coloured permutations $\pi = p_1p_2\cdots p_n$, where each $p_i$ has an associated colour in $\{0,1,\ldots, k{-}1\}$. There is a directed edge $(\pi_1,\pi_2)$ if $\pi_2$ can be obtained from $\pi_1$ by a "...

The shape of a single-walled carbon nanotube's cylinder is described by its chiral indices, (n,m), and important properties of the nanotube are determined by this pair of values. In particular, a nanotube is metallic or quasi-metallic when n-m is a multiple of 3, and is otherwise a semiconductor. This paper characterizes the conjugated π-systems th...

In this work we present a general and versatile algorithmic framework for exhaustively generating a large variety of different combinatorial objects, based on encoding them as permutations. This approach provides a unified view on many known results and allows us to prove many new ones. In particular, we obtain the following four classical Gray cod...

Knuth assigned the following open problem a difficulty rating of 48/50 in The Art of Computer Programming Volume 4A:
For odd n ≥ 3, can the permutations of { 1,2,… , n} be ordered in a cyclic list so that each permutation is transformed into the next by applying either the operation σ, a rotation to the left, or τ, a transposition of the...

In this work we present a general and versatile algorithmic framework for exhaustively generating a large variety of different combinatorial objects, based on encoding them as permutations. This approach provides a unified view on many known results and allows us to prove many new ones. In particular, we obtain the following four classical Gray cod...

We investigate the theory, practice, and history of randomly generating Dr. Mario puzzles for the Nintendo's Famicom/NES.

We present a simple framework for constructing k-ary de Bruijn sequences, and more generally, universal cycles, via successor rules. The framework is based on the often used method of joining disjoint cycles. It generalizes several previously known de Bruijn sequence constructions based on the pure cycling register and is applied to derive a new co...

In this work we present a general and versatile algorithmic framework for exhaustively generating a large variety of different combinatorial objects, based on encoding them as permutations. This approach provides a unified view on many known results and allows us to prove many new ones. In particular, we obtain the following four classical Gray cod...

We present a simple framework for constructing de Bruijn sequences, and more generally, universal cycles, via successor rules. The framework is based on the often used method of joining disjoint cycles. It generalizes four previously known de Bruijn sequence constructions and is applied to derive three new and simple de Bruijn sequence construction...

A k-ary de Bruijn sequence of order n is a circular k-ary string of length kn which contains every k-ary string of length n exactly once as a substring. It is well-known that a k-ary de Bruijn sequence of order n can be constructed by concatenating the aperiodic prefixes of the k-ary necklaces of length n in lexicographic order. In this article we...

Switches is a grid-based puzzle game invented by Jonathan Gabor and implemented using MIT's Scratch programming language in 2014. The puzzle is based on the 'switch' mechanism which allows the player to toggle the presence and absence of barriers by walking over a switch of the same color. At first glance the mechanism seems to be similar to previo...

Pencils is a paper-and-pencil puzzle created by Japanese publisher Nikoli. A puzzle is an m-by-n grid where some squares hold a number or a pencil tip that is pointed in one of the cardinal directions. The goal is to draw ‘pencils’ that partition the squares of the grid. Each pencil occupies 2k + 1 squares for some k ≥ 1. A k-pencil has a horizonta...

Sto-Stone is a paper-and-pencil puzzle created by Japanese publisher Nikoli. A puzzle consists of an m-by-n grid whose squares are partitioned into connected 'rooms' each of which may have an associated number. The solver shades in squares of the grid, which form maximal 'stones' based on orthogonal connectivity. The goal is to shade squares so tha...

The Kekulé count, Fries number, and Clar number of a benzenoid are three measurements that are positively correlated with the stability of a benzenoid hydrocarbon. In this paper, we show that these parameters can disagree for ben-zenoids. That is, there exist pairs of benzenoids of the same size (same number of hexagons and vertices) such that one...

We present the first efficient algorithm to list necklaces, Lyndon words, or pseudo-necklaces of length n in colexicographic order. The algorithm has two interesting properties. First, it can be applied to construct a de Bruijn sequence of order n in O(1)-time per bit. Second, it can easily be modified to efficiently list necklaces, Lyndon words, o...

MazezaM is a sliding block tour puzzle and popular video game. It has similar mechanics to Sokoban except that boxes only move horizontally, and every box in a row moves simultaneously. It was previously known that deciding if a given level can be solved is NP-hard (North 2008). In this paper we provide a family of levels whose shortest solutions a...

A k-ary de Bruijn sequence of order n is a cyclic sequence of length kⁿ in which each k-ary string of length n appears exactly once as a substring. A shift rule for a de Bruijn sequence of order n is a function that maps each length n substring to the next length n substring in the sequence. We present the first known shift rule for k-ary de Bruijn...

We present practical algorithms for ranking k-ary necklaces and Lyndon words of length n. The algorithms are based on simple counting techniques. By repeatedly applying the ranking algorithms, both necklaces and Lyndon words can be efficiently unranked. Then, explicit details are given to rank and unrank the length n substrings of the lexicographic...

We study the computational complexity of the Buttons & Scissors game and obtain sharp thresholds with respect to several parameters. Specifically we show that the game is NP-complete for \(C=2\) colors but polytime solvable for \(C=1\). Similarly the game is NP-complete if every color is used by at most \(F=4\) buttons but polytime solvable for \(F...

We study the computational complexity of the Buttons \& Scissors game and obtain sharp thresholds with respect to several parameters. Specifically we show that the game is NP-complete for $C = 2$ colors but polytime solvable for $C = 1$. Similarly the game is NP-complete if every color is used by at most $F = 4$ buttons but polytime solvable for $F...

We prove that a stack of pancakes is rearranged in all ways by repeatedly applying the following rule: Flip the maximum number of pancakes that gives a new stack. This complements the previously known pancake flipping Gray code (Zaks, 1984) which we also describe as a greedy algorithm: Flip the minimum number of pancakes that gives a new stack. Sur...

A de Bruijn sequence is a binary string of length 2 n which, when viewed cyclically, contains every binary string of length n exactly once as a substring. Knuth refers to the lexicographically least de Bruijn sequence for each n as the " granddaddy " and Fredricksen et al. showed that it can be constructed by concatenating the aperiodic prefixes of...

We present a class of languages that have an interesting property: For each language L in the class, both the classic greedy algorithm and the classic Lyndon word (or necklace) concatenation algorithm provide the lexicographically smallest universal cycle for L. The languages consist of length n strings over {1, 2,..., k} that are closed under rota...

Pick any length n binary string b1b2⋯bn and remove the first bit b1. If b2b3⋯bn1 is a necklace, then append the complement of b1 to the end of the remaining string; otherwise append b1. By repeating this process, eventually all 2n binary strings will be visited cyclically. This shift rule leads to a new de Bruijn sequence construction that can be g...

The Buttons & Scissors puzzle was recently shown to be NP-hard. In this paper we continue studying the complexity of various versions of the puzzle. For example, we show that it is NP-hard when the puzzle consists of C = 2 colors, and polytime solvable for C = 1. Similarly, it is NP-hard when each color is used by at most F = 4 buttons, and polytim...

A stack of n pancakes can be rearranged in all n! ways by a sequence of n! - 1 flips, and a stack of n 'burnt' pancakes can be rearranged in all 2(n)n! ways by a sequence of 2(n)n! - 1 flips. In both cases, a computer program can efficiently generate suitable solutions. We approach these tasks instead from a human perspective. How can we determine...

Fredricksen, Kessler and Maiorana discovered a simple but elegant construction of a universal cycle for binary strings of length n : Concatenate the aperiodic prefixes of length n binary necklaces in lexicographic order. We generalize their construction to binary strings of length n whose weights are in the range c,c+1,…,nc,c+1,…,n by simply omitti...

We give the n! permutations of [n]={1,2,…,n}[n]={1,2,…,n} a cyclic order inspired by the childrenʼs game of Hot Potato. Our order is a transposition Gray code, meaning that consecutive permutations differ by a single transposition. Furthermore, each transposition is restricted in two ways: (1) It must transpose value n (the “hot potato”); (2) It mu...

We prove that a stack of pancakes can be rearranged in all possible ways by a greedy process: Flip the maximum number of topmost pancakes that gives a new stack. We also show that the previous Gray code for rearranging pancakes (S. Zaks, A New Algorithm for Generation of Permutations BIT 24 (1984), 196-204) is a greedy process: Flip the minimum num...

This paper develops a constant amortized time algorithm to produce a cyclic cool-lex Gray code for fixed-density binary necklaces, Lyndon words, and pseudo-necklaces. It is the first Gray code for these objects that achieves this time bound. The algorithm is applied: (i) to develop a constant amortized time cyclic Gray code for necklaces, Lyndon wo...

We reinterpret classic Gray codes for binary strings, permutations, combinations, binary trees, and set partitions using a simple greedy algorithm. The algorithm begins with an initial object and an ordered list of operations, and then repeatedly creates a new object by applying the first possible operation to the most recently created object.

We present an efficient universal cycle construction for the set of binary strings of length n with weight (number of 1s) in the range c,c+1,⋯,d where 0≤c<d≤n. The construction is based on a simple lemma for gluing universal cycles together, which can be implemented to generate each character in constant amortized time using O(n) space. The Gluing...

The symmetric group is generated by {\sigma} = (1 2 ... n) and {\tau} = (1
2). We answer an open problem of Nijenhuis and Wilf by constructing a Hamilton
path in the directed Cayley graph for all n, and a Hamilton cycle for odd n.

The set of permutations of 〈n〉={1,…,n} in one-line notation is Π(n). The shorthand encoding of a
1⋯a
n
∈Π(n) is a
1⋯a
n−1. A shorthand universal cycle for permutations (SP-cycle) is a circular string of length n! whose substrings of length n−1 are the shorthand encodings of Π(n). When an SP-cycle is decoded, the order of Π(n) is a Gray code in wh...

For any given k, the sequence of k-ary Catalan numbers, Ct,k=1kt+1(ktt), enumerates a number of combinatorial objects, including k-ary Dyck words of length n=ktn=kt and k-ary trees with t internal nodes. We show that these objects can be efficiently ordered using the same variation of lexicographic order known as cool-lex order. In particular, we p...

Pick a binary string of length n and remove its first bit b. Now insert b after the first remaining 10, or insert \(\overline{b}\) at the end if there is no remaining 10. Do it again. And again. Keep going! Eventually, you will cycle through all 2n
of the binary strings of length n. For example,
are the binary strings of length n = 4, where 1 =
and...

A bubble language is a set of binary strings with a simple closure property: The first 01 of any string can be replaced by 10 to obtain another string in the set. Natural representations of many combinatorial objects are bubble languages. Examples include binary string representations of k-ary trees, unit interval graphs, linear-extensions of B-pos...

In the classic Josephus problem, elements 1, 2,..., n are placed in order around a circle and a skip value k is chosen. The problem proceeds in n rounds, where each round consists of traveling around the circle from the current position, and selecting the kth remaining element to be eliminated from the circle. After n rounds, every element is elimi...

De Bruijn sequences are circular strings of length 2 n whose length n substrings are the binary strings of length n. Our focus is on creating circular strings of length n w for the binary strings of length n with weight (number of 1s) equal to w. In this case, each fixed-weight string can be encoded by its first n−1 bits since the final bit is redu...

The nodes of a rotator graph are the permutations of n, and an arc is directed from u to v if the first r symbols of u can be rotated one position to the left to obtain v. Restricted rotator graphs restrict the allowable rotations to r ∈ R for some R ⊆ {2,3,...,n}. Incomplete rotator graphs only include nodes whose final symbol is i ≤ m for a fixed...

The rotator graph has vertices labeled by the permutations of n in one line notation, and there is an arc from u to v if a prefix of u's label can be rotated to obtain v's label. In other words, it is the directed Cayley graph whose generators are $\sigma_{k} := (1 \ 2 \ \cdots \ k)$ for 2≤k≤n and these rotations are applied to the indices of a per...

A binary string B of length n = k
t is a k-ary Dyck word if it contains t copies of 1, and the number of 0s in every prefix of B is at most k−1 times the number of 1s. We provide two loopless algorithms for generating k-ary Dyck words in cool-lex order: (1) The first requires two index variables and assumes k is a constant; (2) The second requires...

A de Bruijn sequence is a circular binary string of length 2
n
that contains each binary string of length n exactly once as a substring. A maximum-density de Bruijn sequence is a circular binary string of length
\binomn0 + \binomn1 + \binomn2 + ¼+ \binomnm\binom{n}{0} + \binom{n}{1} + \binom{n}{2} + \cdots + \binom{n}{m} that contains each binary...

This paper develops a constant amortized time algorithm to produce the cyclic cool-lex Gray code for fixed-density binary necklaces, Lyndon words, and pseudo-necklaces. It is the first Gray code for these objects that achieves this time bound. The algorithm is applied: (i) to develop a constant amortized time cyclic Gray code for necklaces, Lyndon...

Given a string α = 1 s 0 t γ in a binary language L, the bubble lower bound is the smallest non-negative integer j such that 1 s−1 0 t−j 10 j γ ∈ L. We present an efficient oracle, which is a function that returns the bubble lower bound, for a number of fixed-density languages including: k-ary Dyck words, connected unit interval graphs, linear-exte...

A universal cycle for the k-permutations of h ni = {1,2,...,n} is a circular string of length nk that contains each k-permutation exactly once as a substring. Jackson (Discrete Mathematics, 149 (1996) 123-129) proved their existence for all k ≤ n − 1. Knuth (The Art of Computer Program- ming, Volume 4, Fascicle 2, Addison-Wesley, 2005) pointed out...

Conventional wisdom suggests that O(k)-time is required to reverse a substring of length k. To reduce this time complexity, a simple and unorthodox data structure is introduced. A boustrophedon linked list is a doubly-linked list, except that each node does not differentiate between its backward and forward pointers. This lack
of information allows...

We present a practical and elegant method for generating all (s,t)-combinations (binary strings with s zeros and t ones): Identify the shortest prefix ending in 010 or 011 (or the entire string if no such prefix exists), and rotate it by one position to the right. This iterative rule gives an order to (s,t)-combinations that is circular and genlex....

This paper creates a simple Gray code for fixed-density binary necklaces and Lyndon words. The Gray code is simultaneously a left-shift Gray code and a 2-transposition Gray code and is cyclic with these prop-erties. It also has the advantage of using canonical representations (lexicographically minimum rotations) yielding the first known Gray code...

This paper answers the following mathematical question: Can multiset permutations be ordered so that each permuta- tion is a prefix shift of the previous permutation? Previously, the answer was known for the permutations of any set, and the permutations of any multiset whose corresponding set contains only two elements. This paper also answers the...

Gray codes are typically defined in terms of bit complements or individual symbol changes. This thesis instead investigates Gray codes based on prefix-shifts (or rotations). In particular, it introduces and investigates "cool-lex order" and "bubble languages" which have since appeared in a variety of publications.

We show that the set Bn of balanced parenthesis strings with n left and n right parentheses can be generated by prefix shifts. If b1,b2,...,b2n is a mem- ber of Bn, then the k-th prefix shift is the string b1,bk,b2,...,bk−1,bk+1,...,b2n. Prefix shift algo- rithms are also known for combinations, and per- mutations of a multiset; the combination alg...

We show how to construct an explicit Hamilton cycle in the directed Cayley graph Cay({\sigma_n, sigma_{n-1}} : \mathbb{S}_n), where \sigma_k = (1 2 >... k). The existence of such cycles was shown by Jackson (Discrete Mathematics, 149 (1996) 123-129) but the proof only shows that a certain directed graph is Eulerian, and Knuth (Volume 4 Fascicle 2,...

International audience
We study the Hamming distance from polynomials to classes of polynomials that share certain properties of irreducible polynomials. The results give insight into whether or not irreducible polynomials can be effectively modeled by these more general classes of polynomials. For example, we prove that the number of degree $n$ po...

We prove that the minimum weight of a dicycle is equal to the maximum number of disjoint dicycle covers, for every weighted
digraph whose underlying graph is planar and does not have K
5–e as a minor (K
5–e is the complete graph on five vertices, minus one edge). Equality was previously known when forbidding K
4 as a minor, while an infinite number...

We present a new Gray code for combinations that is practical and elegant. We represent combinations as bitstrings with s 0's and t 1's, and generate them with a remarkably simple rule: Identify the shortest preflx ending in 010 or 011 (or the entire bitstring if no such preflx exists) and then rotate (shift) it by one position to the right. Since...