Traversing Shape Up Components

In an earlier post,

Minimizing a Large Shape Up Component
, I mention that I can get a shape smaller by traversing the array from different directions.

I have developed a package dedicated to handling all of my traversing, available on github. All of the core patterns are shown on the official traverse-grid page.

I am going to skip a lot of these methods and focus on the methods that work best for optimizing a Shape Up component.

Alternate

Alternate is a simple mutation that horizontally flips every other row. Applied to a horizontal pattern, it creates a pattern that moves back and forth.

00
01
02
03
04
05
06
13
12
11
10
09
08
07
14
15
16
17
18
19
20
27
26
25
24
23
22
21
28
29
30
31
32
33
34
41
40
39
38
37
36
35
42
43
44
45
46
47
48

It is the best method for traversing our pacman (actually a three way tie):

alternate, rotated_waterfall, rotated_watertile 28.05% 23 characters /shapeup/>>dc44317c2216359machbb95

Reposition

The reposition method only iterates even indices in the first iteration, and then odd indices in the second.

00
25
01
26
02
27
03
28
04
29
05
30
06
31
07
32
08
33
09
34
10
35
11
36
12
37
13
38
14
39
15
40
16
41
17
42
18
43
19
44
20
45
21
46
22
47
23
48
24

It works really well if your data looks like our waffle:

reposition 14.06% 9 characters /shapeup/_]]Abb6-$035-

Bounce

The bounce method bounces back and forth between two indices, both from the beginning incrementing forward and from the end decrementing backward, meeting in the center. It works well on data that has some symmetry. It is the best method for traversing our dollar sign:

00
02
04
06
08
10
12
14
16
18
20
22
24
26
28
30
32
34
36
38
40
42
44
46
48
47
45
43
41
39
37
35
33
31
29
27
25
23
21
19
17
15
13
11
09
07
05
03
01

Smooth

00
02
04
06
08
10
12
13
01
03
05
07
09
11
15
14
17
19
21
23
25
26
16
28
18
20
22
24
30
27
32
29
34
36
38
39
31
41
33
43
35
37
45
40
46
42
47
44
48

Smooth looks at all adjacent spaces and tries moves toward the next closest index. It can also be straightened.

Smooth (straight)

00
02
04
06
08
10
12
01
03
05
07
09
11
13
14
16
18
20
22
24
26
15
17
19
21
23
25
27
28
30
32
34
36
38
40
29
31
33
35
37
39
41
42
43
44
45
46
47
48

It is the best method for traversing our bee:

Waterfall

00
14
28
42
35
21
07
01
15
29
43
36
22
08
02
16
30
44
37
23
09
03
17
31
45
38
24
10
04
18
32
46
39
25
11
05
19
33
47
40
26
12
06
20
34
48
41
27
13

The waterfall is the best method for traversing our chair:

waterfall 26.55% 30 characters /shapeup/]]Hobd9gd4kb4i9+4g7+6f3435+5{949o

Diagonal

The diagonal method does not win out very often, but when it does it can be very effective.

21
28
34
39
43
46
48
15
22
29
35
40
44
47
10
16
23
30
36
41
45
06
11
17
24
31
37
42
03
07
12
18
25
32
38
01
04
08
13
19
26
33
00
02
05
09
14
20
27

It works very well when traversing our knife:

Spiral

The spiral method is fairly effective as most data is off around the border and on in the center.

00
01
02
03
04
05
06
23
24
25
26
27
28
07
22
39
40
41
42
29
08
21
38
47
48
43
30
09
20
37
46
45
44
31
10
19
36
35
34
33
32
11
18
17
16
15
14
13
12

It is the best method for traversing our yin yang:

Diamond

The diamond method is harder to implement than the others. It helps to visualize the entire diamond first:

                  06                  
               05 29 07               
            04 28 48 30 08            
         03 27 47 63 49 31 09         
      02 26 46 62 74 64 50 32 10      
   01 25 45 61 73 81 75 65 51 33 11   
00 24 44 60 72 80 84 82 76 66 52 34 12
   23 43 59 71 79 83 77 67 53 35 13   
      22 42 58 70 78 68 54 36 14      
         21 41 57 69 55 37 15         
            20 40 56 38 16            
               19 39 17               
                  18                  

In actuality, we trim off the triangles and we get this:

03 27 47 63 49 31 09
26 46 62 74 64 50 32
45 61 73 81 75 65 51
60 72 80 84 82 76 66
59 71 79 83 77 67 53
42 58 70 78 68 54 36
21 41 57 69 55 37 15

And we have to reduce our values to account for all of those gaps:

00
05
14
27
15
06
01
04
13
26
38
28
16
07
12
25
37
45
39
29
17
24
36
44
48
46
40
30
23
35
43
47
41
31
18
11
22
34
42
32
19
08
03
10
21
33
20
09
02

It works really well if you want to make a diamond:

The entire url for this diamond is /shapeup/]99EF because it is just 1 on value and 1 off value. The raw data is simply 9,9,40,41.

It is also the best way to traverse our moon:

diamond 29.49% 23 characters /shapeup/]edB+312148989n{335hhda4

Snake

The snake method is a 2x2 alternated vertical variation of the Tile method. It works like the horizontal method but instead of always moving to the right, it wiggles down and up throughout the process covering two rows at a time. It is the best method for traversing our dolphin.

00
03
04
07
08
11
12
01
02
05
06
09
10
13
14
17
18
21
22
25
26
15
16
19
20
23
24
27
28
31
32
35
36
39
40
29
30
33
34
37
38
41
42
43
44
45
46
47
48

Stitch

00
07
14
21
28
35
42
08
01
22
15
36
29
43
02
09
16
23
30
37
44
10
03
24
17
38
31
45
04
11
18
25
32
39
46
12
05
26
19
40
33
47
06
13
20
27
34
41
48

Stitch zig zags in pairs along two cell columns until it fills a space. It is the best method for traversing our note (at a two-way tie):

stitch, vertical 17.42% 27 characters /shapeup/]]Iog>iki2g2g*+<24>>ic|}8^um6_

Watertiletiled 1xwidth waterfall

00
02
04
06
05
03
01
07
09
11
13
12
10
08
14
16
18
20
19
17
15
21
23
25
27
26
24
22
28
30
32
34
33
31
29
35
37
39
41
40
38
36
42
44
46
48
47
45
43

Watertile (2)tiled 2xwidth waterfall

00
04
08
12
10
06
02
01
05
09
13
11
07
03
14
18
22
26
24
20
16
15
19
23
27
25
21
17
28
32
36
40
38
34
30
29
33
37
41
39
35
31
42
44
46
48
47
45
43

Triangle

The triangle method is pretty similar to the diamond method:

                           09                           
                        08 27 10                        
                     07 26 43 28 11                     
                  06 25 42 57 44 29 12                  
               05 24 41 56 69 58 45 30 13               
            04 23 40 55 68 79 70 59 46 31 14            
         03 22 39 54 67 78 87 80 71 60 47 32 15         
      02 21 38 53 66 77 86 93 88 81 72 61 48 33 16      
   01 20 37 52 65 76 85 92 97 94 89 82 73 62 49 34 17   
00 19 36 51 64 75 84 91 96 99 98 95 90 83 74 63 50 35 18

Trimmed:

06 25 42 57 44 29 12
24 41 56 69 58 45 30
40 55 68 79 70 59 46
54 67 78 87 80 71 60
66 77 86 93 88 81 72
76 85 92 97 94 89 82
84 91 96 99 98 95 90

And reduced:

00
03
08
15
09
04
01
02
07
14
22
16
10
05
06
13
21
29
23
17
11
12
20
28
36
30
24
18
19
27
35
42
37
31
25
26
34
41
46
43
38
32
33
40
45
48
47
44
39

It works better than anything else if your shape is this exact type of triangle

The entire url for this triangle is /shapeup/--+9h$0{0i because it is just 1 on value and 1 off value. The raw data is simply 9,17,72,81.

However none of the shapes in my library are smallest using this exact triangle. It's a good thing we can flip the pattern and try the same thing upside down.

33
40
45
48
47
44
39
26
34
41
46
43
38
32
19
27
35
42
37
31
25
12
20
28
36
30
24
18
06
13
21
29
23
17
11
02
07
14
22
16
10
05
00
03
08
15
09
04
01
/shapeup/~~+9h$0{0i

The upside down triangle method is the best method for traversing our checkmark (at a two-way tie).

triangle_flipped, vertical 19.35% 24 characters /shapeup/~~gkU{9bd^3899<87G<<8hh|}7