function returnRow = place_check(row, rule)

newRow = zeros(1,length(row));
binary_rule = dec2bin(rule);
rule_length = length(binary_rule);

for x=1:(8-rule_length)
    binary_rule = strcat('0',binary_rule);
end


for i=1:length(newRow)
    left = 0;
    right = 0;
    own = 0;
    
    if row(i) == 1
        own = 1;
    end
    if i > 1
        if row(i-1) == 1
            left = 1;
        end
    end
    if i < length(newRow)
        if row(i+1) == 1
            right = 1;
        end
    end
    

    if ((left == 1) && (own == 1) && (right == 1) && (binary_rule(1) == '1'))
        newRow(i) = 1;
    end
    if ((left == 1) && (own == 1) && (right == 0) && (binary_rule(2) == '1'))
        newRow(i) = 1;
    end
    if ((left == 1) && (own == 0) && (right == 1) && (binary_rule(3) == '1'))
        newRow(i) = 1;
    end
    if ((left == 1) && (own == 0) && (right == 0) && (binary_rule(4) == '1'))
        newRow(i) = 1;
    end
    if ((left == 0) && (own == 1) && (right == 1) && (binary_rule(5) == '1'))
        newRow(i) = 1;
    end
    if ((left == 0) && (own == 1) && (right == 0) && (binary_rule(6) == '1'))
        newRow(i) = 1;
    end
    if ((left == 0) && (own == 0) && (right == 1) && (binary_rule(7) == '1'))
        newRow(i) = 1;
    end
    if ((left == 0) && (own == 0) && (right == 0) && (binary_rule(8) == '1'))
        newRow(i) = 1;
    end
    
end

returnRow = newRow;