DEV Community

Discussion on: Advent of Code 2019 Solution Megathread - Day 8: Space Image Format

Collapse
 
fossheim profile image
Sarah

Such a big contrast with yesterday and especially friday.

Quick and dirty Python solution:

# Get the input
from input import puzzle_input

# Set the width and height
width = 25
height = 6

# Split the input up in layers
layers = []
layer = ""
for index in range(0,len(puzzle_input) + 1):
    if index % (width * height) == 0:
        if layer:
            layers.append(layer)
        layer = ""

    if index < len(puzzle_input):
        layer += puzzle_input[index]

# Loop through the colors
index = 0
colors = ""
while index < len(layers[0]):
    for layer in layers:
        if layer[index] != "2":
            if layer[index] == "0":
                colors += " "
            else:
                colors += "1"
            break
    index += 1

    if index % width == 0:
        colors += "\n"


print(colors)
Collapse
 
robertcram profile image
RobertCram

Hi Sarah,

this one is driving me crazy. I've got exact the same solution you have, but I don't know how to submit it.

I've tried submitting the solution as a string of "0" and "1", but that doesn't work. Same for a string of spaces and "1".

Is there something I'm not seeing?

Any help would be appreciated :)

Collapse
 
fossheim profile image
Sarah

If you print it like in my example, it should display letters. For example

 11    
1  1 
1      
1      
1  1 
 11   

Would be a C. Just type the letters in as a solution :)

Thread Thread
 
robertcram profile image
RobertCram

Thanks Sarah. That did the trick. Glad to be past this one. Lots of catching up to do :)

Thread Thread
 
fossheim profile image
Sarah

Glad I could help :) I’m very far behind as well, have been out sick the past week and a half so didn’t get much done lately. Good thing I have two weeks of vacation coming up.

Collapse
 
jbristow profile image
Jon Bristow • Edited

Part 1:

is the number of 1 digits multiplied by the number of 2 digits

Should be an integer number. Mine was in the 10e4 range.

Part 2

What message is produced after decoding your image?

This answer should be a string of capital letters. (Regex: [A-Z]+) Mine was 5 letters long

You’ll have to use your monkey meat based ocr system unless you’re a maniac who has a python one on hand.

Thread Thread
 
robertcram profile image
RobertCram

Thanks Jon. A bit of squinting helped :)