Mercurial > hg > aoc
annotate 2017/day16/problem @ 35:1d99d733cf13 default tip @
day08: replace static foreach with workaround
author  Jordi Gutiérrez Hermoso <jordigh@octave.org> 

date  Tue, 16 Jan 2018 11:28:55 0500 
parents  049fb8e56025 
children 
rev  line source 

34
049fb8e56025
Add problem statements and inputs
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
diff
changeset

1  Day 16: Permutation Promenade  
049fb8e56025
Add problem statements and inputs
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
diff
changeset

2 
049fb8e56025
Add problem statements and inputs
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
diff
changeset

3 You come upon a very unusual sight; a group of programs here appear to 
049fb8e56025
Add problem statements and inputs
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
diff
changeset

4 be dancing. 
049fb8e56025
Add problem statements and inputs
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
diff
changeset

5 
049fb8e56025
Add problem statements and inputs
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
diff
changeset

6 There are sixteen programs in total, named a through p. They start by 
049fb8e56025
Add problem statements and inputs
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
diff
changeset

7 standing in a line: a stands in position 0, b stands in position 1, 
049fb8e56025
Add problem statements and inputs
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
diff
changeset

8 and so on until p, which stands in position 15. 
049fb8e56025
Add problem statements and inputs
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
diff
changeset

9 
049fb8e56025
Add problem statements and inputs
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
diff
changeset

10 The programs' dance consists of a sequence of dance moves: 
049fb8e56025
Add problem statements and inputs
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
diff
changeset

11 
049fb8e56025
Add problem statements and inputs
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
diff
changeset

12 Spin, written sX, makes X programs move from the end to the front, 
049fb8e56025
Add problem statements and inputs
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
diff
changeset

13 but maintain their order otherwise. (For example, s3 on abcde 
049fb8e56025
Add problem statements and inputs
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
diff
changeset

14 produces cdeab). 
049fb8e56025
Add problem statements and inputs
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
diff
changeset

15 
049fb8e56025
Add problem statements and inputs
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
diff
changeset

16 Exchange, written xA/B, makes the programs at positions A and B 
049fb8e56025
Add problem statements and inputs
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
diff
changeset

17 swap places. 
049fb8e56025
Add problem statements and inputs
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
diff
changeset

18 
049fb8e56025
Add problem statements and inputs
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
diff
changeset

19 Partner, written pA/B, makes the programs named A and B swap 
049fb8e56025
Add problem statements and inputs
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
diff
changeset

20 places. 
049fb8e56025
Add problem statements and inputs
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
diff
changeset

21 
049fb8e56025
Add problem statements and inputs
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
diff
changeset

22 
049fb8e56025
Add problem statements and inputs
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
diff
changeset

23 For example, with only five programs standing in a line (abcde), they 
049fb8e56025
Add problem statements and inputs
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
diff
changeset

24 could do the following dance: 
049fb8e56025
Add problem statements and inputs
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
diff
changeset

25 
049fb8e56025
Add problem statements and inputs
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
diff
changeset

26 s1, a spin of size 1: eabcd. 
049fb8e56025
Add problem statements and inputs
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
diff
changeset

27 
049fb8e56025
Add problem statements and inputs
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
diff
changeset

28 x3/4, swapping the last two programs: eabdc. 
049fb8e56025
Add problem statements and inputs
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
diff
changeset

29 
049fb8e56025
Add problem statements and inputs
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
diff
changeset

30 pe/b, swapping programs e and b: baedc. 
049fb8e56025
Add problem statements and inputs
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
diff
changeset

31 
049fb8e56025
Add problem statements and inputs
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
diff
changeset

32 After finishing their dance, the programs end up in order baedc. 
049fb8e56025
Add problem statements and inputs
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
diff
changeset

33 
049fb8e56025
Add problem statements and inputs
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
diff
changeset

34 You watch the dance for a while and record their dance moves (your 
049fb8e56025
Add problem statements and inputs
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
diff
changeset

35 puzzle input). In what order are the programs standing after their 
049fb8e56025
Add problem statements and inputs
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
diff
changeset

36 dance? 
049fb8e56025
Add problem statements and inputs
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
diff
changeset

37 
049fb8e56025
Add problem statements and inputs
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
diff
changeset

38 Your puzzle answer was bkgcdefiholnpmja. 
049fb8e56025
Add problem statements and inputs
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
diff
changeset

39 
049fb8e56025
Add problem statements and inputs
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
diff
changeset

40  Part Two  
049fb8e56025
Add problem statements and inputs
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
diff
changeset

41 
049fb8e56025
Add problem statements and inputs
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
diff
changeset

42 Now that you're starting to get a feel for the dance moves, you turn 
049fb8e56025
Add problem statements and inputs
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
diff
changeset

43 your attention to the dance as a whole. 
049fb8e56025
Add problem statements and inputs
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
diff
changeset

44 
049fb8e56025
Add problem statements and inputs
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
diff
changeset

45 Keeping the positions they ended up in from their previous dance, the 
049fb8e56025
Add problem statements and inputs
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
diff
changeset

46 programs perform it again and again: including the first dance, a 
049fb8e56025
Add problem statements and inputs
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
diff
changeset

47 total of one billion (1000000000) times. 
049fb8e56025
Add problem statements and inputs
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
diff
changeset

48 
049fb8e56025
Add problem statements and inputs
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
diff
changeset

49 In the example above, their second dance would begin with the order 
049fb8e56025
Add problem statements and inputs
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
diff
changeset

50 baedc, and use the same dance moves: 
049fb8e56025
Add problem statements and inputs
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
diff
changeset

51 
049fb8e56025
Add problem statements and inputs
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
diff
changeset

52 s1, a spin of size 1: cbaed. 
049fb8e56025
Add problem statements and inputs
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
diff
changeset

53 
049fb8e56025
Add problem statements and inputs
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
diff
changeset

54 x3/4, swapping the last two programs: cbade. 
049fb8e56025
Add problem statements and inputs
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
diff
changeset

55 
049fb8e56025
Add problem statements and inputs
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
diff
changeset

56 pe/b, swapping programs e and b: ceadb. 
049fb8e56025
Add problem statements and inputs
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
diff
changeset

57 
049fb8e56025
Add problem statements and inputs
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
diff
changeset

58 In what order are the programs standing after their billion dances? 
049fb8e56025
Add problem statements and inputs
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
diff
changeset

59 
049fb8e56025
Add problem statements and inputs
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
diff
changeset

60 Your puzzle answer was knmdfoijcbpghlea. 
049fb8e56025
Add problem statements and inputs
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
diff
changeset

61 
049fb8e56025
Add problem statements and inputs
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
diff
changeset

62 Both parts of this puzzle are complete! They provide two gold stars: ** 