day16: Day 16: Permutation Promenade

Description Usage Arguments Details Examples

Description

Permutation Promenade

Usage

1
2
3
dance(programs, moves)

dance_a_billion_times(programs, moves)

Arguments

programs

a string of letters to reorder

moves

a string of moves to do

Details

Part One

You come upon a very unusual sight; a group of programs here appear to be dancing.

There are sixteen programs in total, named a through p. They start by standing in a line: a stands in position 0, b stands in position 1, and so on until p, which stands in position 15.

The programs' dance consists of a sequence of dance moves:

For example, with only five programs standing in a line (abcde), they could do the following dance:

After finishing their dance, the programs end up in order baedc.

You watch the dance for a while and record their dance moves (your puzzle input). In what order are the programs standing after their dance?

Part Two

Now that you're starting to get a feel for the dance moves, you turn your attention to the dance as a whole.

Keeping the positions they ended up in from their previous dance, the programs perform it again and again: including the first dance, a total of one billion (1000000000) times.

In the example above, their second dance would begin with the order baedc, and use the same dance moves:

In what order are the programs standing after their billion dances?

Examples

1
2
3
programs <- "abcde"
moves <- "s1,x3/4,pe/b"
dance(programs, moves)

tjmahr/adventofcode17 documentation built on May 30, 2019, 2:29 p.m.