2017 Day 19 Complete!
This commit is contained in:
parent
b4e0704f16
commit
32a724feb6
201
2017/day19/input
Normal file
201
2017/day19/input
Normal file
@ -0,0 +1,201 @@
|
||||
|
|
||||
+---------------+ +-------------------+ +---+ +-----------------------------------------------------------------------------+ | +-------------------+
|
||||
| | | | | | | | | | |
|
||||
+-----|---------------|-----------------------------------------|------R------|-----------+ +-----------------------+ +-----+ | | | |
|
||||
| | | | | | | | | | | | | | | | |
|
||||
| | | | +-----------------------|---+ | | +-----+ +-+ | | | | +-----|-------------------+
|
||||
| | | | | | | | | | | | | | | | | | |
|
||||
| | | | M-----------------------------------|-----+ | +-------|---------------+ | | +-+ | | +-+
|
||||
| | | | | | | | | | | | | | | | | | | |
|
||||
| | | +---------|-----------------------------+ | | +-------|-------|-------------------------|-----------------------------------|-----|---------------------+
|
||||
| | | | | | | | | | | | | | | | | |
|
||||
| +-------------------+ | +-------+ | | +---------|-------------------------|---------------|-------------------------|---+ |
|
||||
| | | | | | | | | | | | | | | | | | | | | |
|
||||
| | | | | | +---|-------------|---------|---------|-|---------------------------------|-+ +-----+ | | | | | |
|
||||
| | | | | | | | | | | | | | | | | | | | | |
|
||||
| | | | | | | | | +-|---------|-|-----|-|-------------------------|-+ | | | | | | |
|
||||
| | | | | | | | | | | | | | | | | | | | | | | |
|
||||
| | | | | | | | | | | | | | | +-+ +-----------------------------------|---------+ | | | |
|
||||
| | | | | | | | | | | | | | | | | | | | | | | | | | | |
|
||||
| | | +-----------------------|---|---|-------------|-------|-----------|-|-----|-|-------|-|-|-----------------------|-----------------|---|---|-----|---|---------------|-+
|
||||
| | | | | | | | | | | | | | | | | | | | | | | | | | | |
|
||||
| | | | | | | | | | | | | | | | | | | | | | | | | | | |
|
||||
| | | | | | | | | | | | | | | | | | | | | | | | | | | |
|
||||
| | | +-----|---------------------------+ | +-|-----------|---------------------|---------------|-+ | +-------|-------------|-+ | +-----+ +---+ | |
|
||||
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | |
|
||||
| | | +-----|-------------------|-------------+ | | | | | +---|-|-------------------------|---------|---+ | | | | +---|-+ | | | | | |
|
||||
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | |
|
||||
| | | | +-------|-----------+ | | | | | | | | | | | | | | | | | | | | | | | | | | |
|
||||
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | |
|
||||
| | | +-|-----------|---|-------|-----------------|-----------|-------+ | | | | | | | | | | | | | | | | | | |
|
||||
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | |
|
||||
| | | +-----------+ | | | | | | | | | | | +-|---------|---------|-----------------------+ | | | | | | | | | | | |
|
||||
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | |
|
||||
| | | | | | | | | | | | | | | | | | | | | | | | +-|-+ | +-|-----------|-----|---+ | | | | | | | |
|
||||
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | |
|
||||
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | |
|
||||
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | |
|
||||
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | |
|
||||
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | |
|
||||
| | | | | | | | | | | | | +---------|-|-----------------------------|-|-------------+ | | +-------|-----------------+ | | | | | | |
|
||||
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | |
|
||||
| | | | | +-|-----------------------|-------|---------|---------------------|-------|-|---+ | | | | +-+ +-------+ | | | | | | | | |
|
||||
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | |
|
||||
| | | | | +-----|-------|---------+ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | |
|
||||
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | |
|
||||
| | | +-------|-----------|-----|---------------|---|-|-----+ | +-------------+ | | | | | | | | | | | | +-----|-+ +-|-+ +-|-+ | | | | | +-----+ |
|
||||
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | |
|
||||
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | |
|
||||
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | |
|
||||
+-+ | +---|-+ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | |
|
||||
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | |
|
||||
+---------------|-|-|-----|---------+ | | | | +---------|---+ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | |
|
||||
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | |
|
||||
| | | | | | | | +-|-----|---|-|-----|-----------|-------|---|-------|-------|---|-|-----|-------|---|-|---------|-----------|-----------|---|---------|-+ | | +---------------+ |
|
||||
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | |
|
||||
+-|-|-----|---------+ +---------------|---|-|---|-|-----|---|---+ +---+ | | | | | | | | | | | | | | | +-------|---+ | | | | | | | +-|-|-------|-|-------+ | |
|
||||
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | |
|
||||
| | +-------|---------------------|---|-------|---------|---|-----|-----|---|-----|-------|-|---|---------------|-----|---------------------|-----------|-|-----------|---|---+ | | | | |
|
||||
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | H | | | | | | | | | | | | | |
|
||||
+-+ +-----|---+ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | +-+ |
|
||||
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | |
|
||||
| +---|-----|---+ | | | | | | | | +-|-------|-|-+ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | |
|
||||
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | |
|
||||
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | +-+ | | | | | | | | | | | +-+ |
|
||||
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | |
|
||||
| | | | | | | | | +-----|---------------|-----|-|-------|---|-|-------|-----|-------|---------------+ | | | | | | | | | | | | | | | | | | | |
|
||||
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | |
|
||||
| | | | | | +---|------------E----+ +-+ | | | | | | | | | | | | | | | | | | +-----------------|-----------+ | | | | | | | | | | | | | | +-|-+ | | |
|
||||
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | |
|
||||
| | | | | | | +-------|---|-----|-|-|-----------|-+ | +-|-----------------------|-----------|-|-------------|---|-------|-----|-------|-|-----------|---------+ +-------+ | | |
|
||||
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | |
|
||||
| | | | | | | +---|---|-------|-----------+ | | | | | | +-|-------------+ | | +---|---|-|---------|-+ | | | | | | | | | | | | | | | | | |
|
||||
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | |
|
||||
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | |
|
||||
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | |
|
||||
| | | | | | | +-------|-----|-|-|-----+ | | | | | | | | | | | | | | | | | | | | | | +-+ | | | | | | | | | | | | | | |
|
||||
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | |
|
||||
| | | | | +-+ | +-----|-------------|---------|---|-|---|---|-----+ | | | | | | | | | | | | | | | | | | | | | | | | | | | | |
|
||||
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | |
|
||||
| | | | | | | +-|-|-----------|-------------|-----------|---|-------|-|-|---|---|---|---|-----------+ | | | | | | | | | | | | | | | | | | |
|
||||
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | S | | | | | | | | | | | | | | | | | | | |
|
||||
+-------|-|---|---|-------------------------|-|---|-----|-----------|---|-----+ +---|-----------|-|-----|---+ | +-|-----+ +---|---|-----------|---------|-|---------|-----|-|---------+ | | | |
|
||||
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | |
|
||||
| +-|-|---|---+ | | | | | | | +-----|-------|---------+ | | | | | | +-|-|-+ | | | | | | | | | | | | | | | | +-+ | | | |
|
||||
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | |
|
||||
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | +-|-------------------|---+ +---+ | | | | | | | | | |
|
||||
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | |
|
||||
| | | | | | +-------|-|-----|-------|-------|-|-----|-----------------------|-----|---+ +---|---|-----------|---|-----|-----|-|---|---|---|-------|-|-+ | | | | | | |
|
||||
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | |
|
||||
| | | | +-|---+ | | | +-------------------|-|-|---+ | +-----+ +-|-------|---|---------------|-|-|-----------|-|-|-|---|-------|---|-|-|-----------|---+ | | | | | | |
|
||||
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | |
|
||||
| | | | | | | | | | +-----|-----|-|-----|-|-|-----|---------+ | | | | | | | +-----------|-------|-----+ +---------------|-----|---|---|-----|-----+ | | | | |
|
||||
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | |
|
||||
| | | | | | | | | | | | | | | | | | | | | | | | | | +-----|-------+ | | | | | | | | | | | | | | | | | | | | | | | | | |
|
||||
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | |
|
||||
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | |
|
||||
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | |
|
||||
+-------------|-------------------|-------|-|-------------+ | | | | | | | | | | | | | | | | | | | | | | | | | | | +---|-+ | +-|-+ | | | | | | | | |
|
||||
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | |
|
||||
| | | | | | | | | +-----------|-|-----|-+ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | +-----|-----+ | | | | |
|
||||
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | |
|
||||
+---|-|-|-----------------|-+ | | | | +---|-----|-------|---------|-------|-|---------+ | | | +-|-------|-----+ | | | | | | | | | | | | | | | | | | | | | | | | |
|
||||
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | |
|
||||
| | | | | | | | | +-------------|-----------|-------|---|-----|-------------------|---------|---|---|---------------------|----D----------------|-----|---|-------|---|---|-------|-+ | | |
|
||||
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | |
|
||||
| +-|-----------------|-|-----|-------|-------|-----------+ | | | | | | | +-----|-|-|-|-----------|-------|-------------|-----|-------|-|-----|-----|-|-----+ +-|---------------|-+ | | |
|
||||
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | |
|
||||
+-----|-|-|-----|-------|-|-------------|-|-----|-----|-------|-----------------|-|-------------|-----|---------+ | | +-|-------|-----------|---------|-|-|---+ | | | | | | | | |
|
||||
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | |
|
||||
| | | | | | | | | | | | | | | | | | | | +---------------|-|---|-----------------------|---------|-|---|-|-----|-|-----------|-|-|-------|---------------|-+ | | |
|
||||
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | |
|
||||
+-|-----+ | | | | +---|-------|-------|-|-------|---------|-|---|---------|-----|-|-------|-|---|---------------------+ | | | | | | | | | | | | | | | | | | | | |
|
||||
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | |
|
||||
| | | | | | | | | | | +-----|---------|---|-------|-----------------+ | | | | | | | +-----|---------|-+ +-----|-|---|---------------------|---|-|---------|---|---------+ | | |
|
||||
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | |
|
||||
| | | | | | | | +-|-------|-|-----|-|-------|---------|-|-|-------|---------|-|-------------|---|---------|-------|---|---------|-----|-----|-|---------------|-------|---+ | | | | | | |
|
||||
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | |
|
||||
| +-+ | | | | | | | | | | | | | | +-----|---|-----------|-------|-------|-|-|-------------|-|-------|---|-------|-|-------------|-----|-----|-|-|---+ | | | | | | | |
|
||||
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | |
|
||||
| +-+ | | | | | | | | +-|-|-----|-------------------|-----|---------------------------|-|---+ | +---+ | | | | | | | | | | | | | | | | | | | | | | | | | | | |
|
||||
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | |
|
||||
| | | | | | | | | | | | | | | | | | +-----|-|-|-|-------+ +-----|---------|---+ | +-----+ | +-+ +---|-------------|-|---+ | | | | | | | | | | | | | | | | | |
|
||||
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | |
|
||||
| | | | | | | | | | | | | | | | | | | | | | | | | | | +---|---------|---|-|-----|-----|-----|-------|-----+ | | | | +-+ | | | | | | | | | | | |
|
||||
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | |
|
||||
| | | | | | | | | | | | +-------|-|-----|-----|-----|-|---|-------|-------|-|---|-----|---|---------------|---|-|-+ | | | +-----------|-----+ | | | | | | | | | | | | | |
|
||||
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | |
|
||||
| | | | | +---|---|-|-|-|---------------|-----|-|---------|-|---|-----|-----------|-------|-----|-----|---|---------+ | | | | | | | | | | | | | | | | | | | |
|
||||
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | |
|
||||
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | +-----------|-----+ | | | +-+ | | | | | | | | | | | |
|
||||
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | |
|
||||
| | | | | | | | | | | | | | +---|---+ | | | | +-|-|-------|-|---------|---|---------|-------+ | | | | | | | | | | | | | | | | | +-+
|
||||
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | |
|
||||
| | | +---|-|-+ | | | | | | | | | | | | | | | | | | | +-+ | | | | +-|-----|-------|---------|---------------------|-----------|-|-|-|-------------|-----|-----|-+
|
||||
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | |
|
||||
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | |
|
||||
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | |
|
||||
| | | | | | | | | | | | | | | +---|-|-|---------|-|---------|-|-------------|---|-----|-----------------|---|-----|------------------U--------|-----|---|---|---|-------|-------|-|-+ |
|
||||
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | |
|
||||
| | | | | | +---|-+ | | | | | | | | | | | | | | | | | +-+ | | | | | | | | | | | | | | | | | | | | | | | | | | +-+
|
||||
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | |
|
||||
| | | | | | +-|-|-------|---|---|-----------|-|-+ | | | | | | | | | | | | | | | | | | | | | | +-----------|-|-----------|---|-------+ | | | | |
|
||||
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | |
|
||||
| | | | | | | | | | | | | | | | | | | | | | | | | +-------|-------+ | | | | | | | | | | | | | | | | | | | | | | | +-----+
|
||||
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | |
|
||||
| | | | | | +-----|-|-----------|-----|-----|-------------|-|-|-|---|-----------------------|---|-|-|---|-|-----------|---|---------|-------------------------|-|-|-|-+ | | | | |
|
||||
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | |
|
||||
| | | | | | | | +---|-|-------|-----+ | | | | | | | | | +---------|-----+ | | | | | | | | | | | | | | | +-|-|---------------|-----|-|---|---+
|
||||
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | |
|
||||
| | | | +-----+ | | | | | +-|-----------+ | | | | | | +-+ | | | | | | | | | | | +-------------+ +-+ | +-----|-|---------+ | | | +---------|-------|---+
|
||||
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | |
|
||||
| | +---------------------------|-+ | +---|---|-------------+ | | | +-------+ | | | | | | | | | | | | +-------------------------|---------|---+ | | | | | |
|
||||
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | |
|
||||
| | | | | | | | +-----|-|-------------|---------+ | | +-|-----|-|---------------|-|---|---|-|-----------|-----------------------|-------------|---|-------|-------------|-----|-|-------+
|
||||
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | |
|
||||
| | | | | | | | | | | | +---|---+ +---------+ +-------------|-------|-|---------------|-|-----------|---|-----------------------+ | | | | | | | | | | |
|
||||
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | |
|
||||
| | | | +-------|-------|-|---------------|---------------|-----------|-----------|---|-|---|---|-|-|---------|-----------------------|---|-|-------|---------|-|---|---------------+ | +-+
|
||||
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | |
|
||||
| | +-|-----|-----|-----|-----|---------|-----+ | +-------------|---|-----|-|-------|-|-|---|-|---+ | | +-|---------------------------|-------------|-----------------|---------------------|-------+
|
||||
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | |
|
||||
| | | +-----|---+ | | | | | | | | | +-|-----------+ +-+ | +-+ | | | | | | | +---|-|-----------------|-------------------+ | | | | | | | | | | | |
|
||||
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | |
|
||||
| | | +---+ | | | | | | | | | | | | | | | | +-+ | | | +---|-+ +-------------------|-------------|---------|-|-|-----|---|-----|-----------------------|-----+ |
|
||||
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | |
|
||||
| | | +-------|-------------|---------------|-----------------------|-|-|-------------|-|-----|---|---|---|-------------------------------------|-|-|--------A|-----|-|-----------+ | | |
|
||||
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | |
|
||||
+---------------|-|---------|-|-|-------|-----|-----|---------------------------------|-|-|-----|-------|---|-------------|-------------------------|-----------+ +---------------|-------|-------+
|
||||
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | |
|
||||
| | | | | | | | | +-----------|-----------------|-----|-|-----------------|-----|---|-------|-------------------------------------|-+ | | | | | | |
|
||||
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | |
|
||||
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | |
|
||||
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | |
|
||||
+-|-|-----------------------------------------------|-----------|-----|---------------|-----------|-------------------------------+ | +-+ | | | | | | | |
|
||||
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | |
|
||||
| | | +-----|-|-|---|---|---------------------------------------|-----------------|-|-|---------|---------------------|-------+ | | | | | +-----------+ | | | | |
|
||||
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | |
|
||||
| | +-----|--K--|-----------|-+ | +-----|-----|-----------|-----|-|-|---------------------+ | | | +---------------------------------|-|-------+ | | +---|---|-------|---------------+
|
||||
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | |
|
||||
| | | | +-----|-------+ | | | | | | | +-----|-|-|-------|-------|---------------|-----------------|-|-------------|-----------+ | | +-----+ | |
|
||||
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | |
|
||||
| | +-+ +-------|---|-----------------|-----------------|-----|---|-----|-----|-|-----------|-------|---------|---------+ | | | | | | | | | | |
|
||||
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | |
|
||||
| | | | +---------------------|-----+ | | | | | | | | | | | | +-|-----------------+ | | | | | +---|-----------+ | | +-----|-------+
|
||||
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | |
|
||||
| | +-------------------|-----------------|---------------------|-|-|-|-----+ | +-+ +-----|---------+ | | | | | | | | | | | | | | |
|
||||
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | |
|
||||
| | +-----------------------------------|-------------------------------------------------------------|---------|---|-----------------|-----+ | | +-------+ | | +-+
|
||||
| | | | | | | | | | | | | | | | | | | | | | | | | | | |
|
||||
| | | | | | | | | | | | +---|---|-----|---+ | | | | | | | | | | |
|
||||
| | | | | | | | | | | | | | | | | | | | | | | | | |
|
||||
+---------+ +-------|---------------------------------------------|---------------------------------|-----+ | | +-------+ | | | | +-----|-+ |
|
||||
| | | | | | | | | | | | | | | | | | | |
|
||||
+-------------------------+ | | | | +-|-----------|-----------------|-----------------|---|---+ | | +---------|-----------+ | | |
|
||||
| | | | | | | | | | | | | | | | | |
|
||||
| | | | | | +---------------------------+ +-|W--+ | +---------------------------+ | | |
|
||||
| | | | | | | | | | | | | | | | | |
|
||||
| +-------|---+ +---+ +---------------+ +---+ +---+ +-------------------------------------------+ +-+ |
|
||||
| | | | | |
|
||||
+---------+ +-------------------------------------------------------------------------------------------+ +---------------------------------+
|
||||
|
180
2017/day19/main.go
Normal file
180
2017/day19/main.go
Normal file
@ -0,0 +1,180 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"bufio"
|
||||
"fmt"
|
||||
"os"
|
||||
"time"
|
||||
|
||||
termbox "github.com/nsf/termbox-go"
|
||||
)
|
||||
|
||||
const (
|
||||
N = iota
|
||||
E
|
||||
S
|
||||
W
|
||||
ERR
|
||||
)
|
||||
|
||||
var network [][]byte
|
||||
var message string
|
||||
var ticks int
|
||||
var nodes []byte
|
||||
var width, height int
|
||||
|
||||
func main() {
|
||||
// Grab the window size
|
||||
if err := termbox.Init(); err != nil {
|
||||
panic(err)
|
||||
}
|
||||
go func() {
|
||||
for {
|
||||
event := termbox.PollEvent()
|
||||
if event.Key == termbox.KeyCtrlC {
|
||||
termbox.Close()
|
||||
os.Exit(0)
|
||||
}
|
||||
}
|
||||
}()
|
||||
width, height = termbox.Size()
|
||||
|
||||
network = StdinTo2DBytes()
|
||||
PrintMap(0, 0)
|
||||
|
||||
posX, posY, dir := FindEntry(), 0, S
|
||||
|
||||
fmt.Println(posX, posY, dir)
|
||||
for dir != ERR {
|
||||
posX, posY, dir = Move(posX, posY, dir)
|
||||
|
||||
switch network[posY][posX] {
|
||||
case '|', '-', '+':
|
||||
case ' ':
|
||||
fmt.Println("Invalid Move")
|
||||
os.Exit(1)
|
||||
default:
|
||||
if len(nodes) == 0 || nodes[len(nodes)-1] != network[posY][posX] {
|
||||
message = fmt.Sprint("Found node ", string(network[posY][posX]), "!")
|
||||
nodes = append(nodes, network[posY][posX])
|
||||
}
|
||||
}
|
||||
ticks++
|
||||
PrintMap(posX, posY)
|
||||
time.Sleep(time.Second / 10)
|
||||
}
|
||||
fmt.Println("")
|
||||
}
|
||||
|
||||
func GetNodesAsString(nodes []byte) string {
|
||||
ret := "[ "
|
||||
for i := range nodes {
|
||||
ret += string(nodes[i]) + " "
|
||||
}
|
||||
return ret + "]"
|
||||
}
|
||||
|
||||
func Move(posX, posY, dir int) (int, int, int) {
|
||||
chkX, chkY := posX, posY
|
||||
switch dir {
|
||||
case N:
|
||||
chkY--
|
||||
case E:
|
||||
chkX++
|
||||
case S:
|
||||
chkY++
|
||||
case W:
|
||||
chkX--
|
||||
}
|
||||
|
||||
if chkX < 0 || chkY < 0 || chkX > len(network[0]) || chkY > len(network) {
|
||||
// Went off the map
|
||||
return posX, posY, ERR
|
||||
}
|
||||
|
||||
if network[chkY][chkX] == '+' {
|
||||
// Which direction do we need to turn?
|
||||
switch dir {
|
||||
case N, S:
|
||||
if CanMoveTo(chkX+1, chkY) {
|
||||
dir = E
|
||||
} else if CanMoveTo(chkX-1, chkY) {
|
||||
dir = W
|
||||
}
|
||||
case E, W:
|
||||
fmt.Println(len(network), chkY+1)
|
||||
if CanMoveTo(chkX, chkY+1) {
|
||||
dir = S
|
||||
} else if CanMoveTo(chkX, chkY-1) {
|
||||
dir = N
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return chkX, chkY, dir
|
||||
}
|
||||
|
||||
func CanMoveTo(chkX, chkY int) bool {
|
||||
if chkY < 0 && chkX < 0 && chkY > len(network) && chkX > len(network[chkY]) {
|
||||
return false
|
||||
}
|
||||
fmt.Println(chkX, chkY)
|
||||
return network[chkY][chkX] != ' '
|
||||
}
|
||||
|
||||
func FindEntry() int {
|
||||
for i := range network[0] {
|
||||
if network[0][i] == '|' {
|
||||
return i
|
||||
}
|
||||
}
|
||||
return -1
|
||||
}
|
||||
|
||||
func PrintMap(posX, posY int) {
|
||||
fmt.Print("\033[H\033[2J")
|
||||
stX, stY := 0, 0
|
||||
useHeight, useWidth := height-2, width
|
||||
if posY > useHeight/2 {
|
||||
stY = posY - (useHeight / 2)
|
||||
}
|
||||
if posX > width/2 {
|
||||
stX = posX - (width / 2)
|
||||
}
|
||||
totHeight := useHeight/2 + posY
|
||||
if totHeight < useHeight {
|
||||
useHeight = useHeight + (useHeight - totHeight) + 4
|
||||
}
|
||||
totWidth := useWidth/2 + posX
|
||||
if totWidth < useWidth {
|
||||
useWidth = useWidth + (useWidth - totWidth) + 4
|
||||
}
|
||||
for y := stY; y < posY+(useHeight/2); y++ {
|
||||
for x := stX; x < posX+(useWidth/2); x++ {
|
||||
if len(network) > y {
|
||||
if len(network[y]) > x {
|
||||
if y == posY && x == posX {
|
||||
fmt.Print("*")
|
||||
} else {
|
||||
fmt.Print(string(network[y][x]))
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
fmt.Println("")
|
||||
}
|
||||
fmt.Print(ticks, " Ticks ", GetNodesAsString(nodes), "\n")
|
||||
fmt.Println(message)
|
||||
}
|
||||
|
||||
func StdinTo2DBytes() [][]byte {
|
||||
var ret [][]byte
|
||||
scanner := bufio.NewScanner(os.Stdin)
|
||||
for scanner.Scan() {
|
||||
bts := scanner.Bytes()
|
||||
t := make([]byte, len(bts))
|
||||
copy(t, bts)
|
||||
ret = append(ret, t)
|
||||
}
|
||||
return ret
|
||||
}
|
95
2017/day19/problem
Normal file
95
2017/day19/problem
Normal file
@ -0,0 +1,95 @@
|
||||
Advent of Code
|
||||
|
||||
--- Day 19: A Series of Tubes ---
|
||||
|
||||
Somehow, a network packet got lost and ended up here. It's trying to follow a routing diagram (your puzzle input),
|
||||
but it's confused about where to go.
|
||||
|
||||
Its starting point is just off the top of the diagram. Lines (drawn with |, -, and +) show the path it needs to
|
||||
take, starting by going down onto the only line connected to the top of the diagram. It needs to follow this path
|
||||
until it reaches the end (located somewhere within the diagram) and stop there.
|
||||
|
||||
Sometimes, the lines cross over each other; in these cases, it needs to continue going the same direction, and
|
||||
only turn left or right when there's no other option. In addition, someone has left letters on the line; these
|
||||
also don't change its direction, but it can use them to keep track of where it's been. For example:
|
||||
|
||||
|
|
||||
| +--+
|
||||
A | C
|
||||
F---|----E|--+
|
||||
| | | D
|
||||
+B-+ +--+
|
||||
|
||||
|
||||
Given this diagram, the packet needs to take the following path:
|
||||
|
||||
• Starting at the only line touching the top of the diagram, it must go down, pass through A, and continue
|
||||
onward to the first +.
|
||||
• Travel right, up, and right, passing through B in the process.
|
||||
• Continue down (collecting C), right, and up (collecting D).
|
||||
• Finally, go all the way left through E and stopping at F.
|
||||
|
||||
Following the path to the end, the letters it sees on its path are ABCDEF.
|
||||
|
||||
The little packet looks up at you, hoping you can help it find the way. What letters will it see (in the order it
|
||||
would see them) if it follows the path? (The routing diagram is very wide; make sure you view it without line
|
||||
wrapping.)
|
||||
|
||||
Your puzzle answer was __________________.
|
||||
|
||||
--- Part Two ---
|
||||
|
||||
The packet is curious how many steps it needs to go.
|
||||
|
||||
For example, using the same routing diagram from the example above...
|
||||
|
||||
|
|
||||
| +--+
|
||||
A | C
|
||||
F---|--|-E---+
|
||||
| | | D
|
||||
+B-+ +--+
|
||||
|
||||
|
||||
...the packet would go:
|
||||
|
||||
• 6 steps down (including the first line at the top of the diagram).
|
||||
• 3 steps right.
|
||||
• 4 steps up.
|
||||
• 3 steps right.
|
||||
• 4 steps down.
|
||||
• 3 steps right.
|
||||
• 2 steps up.
|
||||
• 13 steps left (including the F it stops on).
|
||||
|
||||
This would result in a total of 38 steps.
|
||||
|
||||
How many steps does the packet need to go?
|
||||
|
||||
Your puzzle answer was _________.
|
||||
|
||||
Both parts of this puzzle are complete! They provide two gold stars: **
|
||||
|
||||
At this point, you should return to your advent calendar and try another puzzle.
|
||||
|
||||
If you still want to see it, you can get your puzzle input.
|
||||
|
||||
References
|
||||
|
||||
Visible links
|
||||
. http://adventofcode.com/
|
||||
. http://adventofcode.com/2017/about
|
||||
. http://adventofcode.com/2017/support
|
||||
. http://adventofcode.com/2017/events
|
||||
. http://adventofcode.com/2017/settings
|
||||
. http://adventofcode.com/2017/auth/logout
|
||||
. http://adventofcode.com/2017
|
||||
. http://adventofcode.com/2017
|
||||
. http://adventofcode.com/2017/leaderboard
|
||||
. http://adventofcode.com/2017/stats
|
||||
. http://adventofcode.com/2017/sponsors
|
||||
. http://adventofcode.com/2017/sponsors
|
||||
. https://teespring.com/advent-of-code
|
||||
. https://teespring.com/advent-of-code-eu
|
||||
. http://adventofcode.com/2017
|
||||
. http://adventofcode.com/2017/day/19/input
|
7
2017/day19/testinput
Normal file
7
2017/day19/testinput
Normal file
@ -0,0 +1,7 @@
|
||||
|
|
||||
| +--+
|
||||
A | C
|
||||
F---|----E|--+
|
||||
| | | D
|
||||
+B-+ +--+
|
||||
|
Loading…
Reference in New Issue
Block a user