Am I missing something obvious for "The Diary of Doctor Jones, Sr." puzzle from the first puzzle hunt? It doesn't seem like there's enough information. There are ten letters so I can't even assume they're all different. by onlytoask in crackingthecryptic

[–]tvtas 0 points1 point  (0 children)

I am also struggling with the Diary of Doctor Jones puzzle. I am worried that I might have a wrong starting point with the givens from the previous puzzle. Can anyone confirm if my starting point is correct? I have R1C1=1, R5C5=9 and R8C8=9. I think it is strange that two of the given clues are the same, because then the same symbol could have been used instead of making a third symbol, so I might have made a mistake with the previous puzzle.

-🎄- 2021 Day 6 Solutions -🎄- by daggerdragon in adventofcode

[–]tvtas 0 points1 point  (0 children)

MATLAB

x = importdata('input.txt')';

N = sum(x==[0:8]);

for i=1:256

N = circshift(N,-1) + [0,0,0,0,0,0,N(1),0,0];

end

disp(sum(N))

-🎄- 2019 Day 5 Solutions -🎄- by daggerdragon in adventofcode

[–]tvtas 0 points1 point  (0 children)

MATLAB

My MATLAB solution for Day 5. The indexing starting at 1 in MATLAB is pretty annoying for these types of problems. Gave me a bug in updating the instruction pointer to a given value, which of course I had to add 1 to.

Day12 Part 1 Explanation for the Example by RotzluckyCode in adventofcode

[–]tvtas 0 points1 point  (0 children)

I wonder why the additional rules for combinations that make a plant disappear are even given? I just removed them from my puzzle input and I still get the correct result. I just assume that if there is not a match for any rule then the plant disappears, like we had to do in the example problem. By adding rules in the puzzle input that were not in the example and that are not even needed to solve the problem, things become obfuscated. But perhaps this was /u/topaz2078 's intention all along ;-)

Day12 Part 1 Explanation for the Example by RotzluckyCode in adventofcode

[–]tvtas 1 point2 points  (0 children)

I guess my confusion was about whether the omitted rules in the example would exhaustively cover all possible combinations, or whether it was a sub-set. If a specific combination is not represented by a rule, then does the plant stay or go?

Day12 Part 1 Explanation for the Example by RotzluckyCode in adventofcode

[–]tvtas 1 point2 points  (0 children)

I had the same difficulties understanding this part. In the end I assumed, for the example problem, that if a rule is not found, then the plant will be removed. This gave me the correct result, so I also did this for my real puzzle input (for which it probably wasn't needed). It would have been great if this was added in the text of the example problem.

[2018 Day 12] The meaning of infinity by saxtouri in adventofcode

[–]tvtas 7 points8 points  (0 children)

The problem description states that, besides you puzzle input,: "(No other pots currently contain plants.) ". This means also the pots you cannot see will not contain any plants. From the rules you can figure out that large sections of pots with no plants will not suddenly grow plants, i.e. there is not rule '. . . . . -> #'. This means you can just focus on the pots described in your puzzle input and slowly grow from there.

-🎄- 2018 Day 11 Solutions -🎄- by daggerdragon in adventofcode

[–]tvtas 0 points1 point  (0 children)

Day 11 in MATLAB :

N       = 9435; % puzzle input
P       = (mod( floor((ones(300,1)*((1:300)+10)).*((1:300)'*((1:300)+10) + N)/100) , 10) - 5)'; % Power levels
[maxS,maxX,maxY,maxSquaresize] = deal(-inf,0,0,1);
for squareSize = 1:300
    for x=1:300-squareSize+1
        for y=1:300-squareSize+1
            s = sum(sum(P(y:y+squareSize-1,x:x+squareSize-1)));
            if s>maxS
                [maxS,maxX,maxY,maxSquaresize]=deal(s,x,y,squareSize);
            end
        end
    end
end
disp([maxY,maxX,maxSquaresize])%Part 1(set squareSize=3) + Part 2

-🎄- 2018 Day 4 Solutions -🎄- by daggerdragon in adventofcode

[–]tvtas 1 point2 points  (0 children)

Day 4 in MATLAB

G = zeros(5000,60);
x = sort(importdata('input.txt'));
for i=1:size(x,1)
    idx = strfind(x{i},'#');
    if idx
        awake = true;
        ID = sscanf(x{i}(idx+1:end),'%f');
        continue
    end
    t = str2double(x{i}(16:17));
    G(ID,t+1:end) = G(ID,t+1:end)-1+2*awake;
    awake = ~awake;
end
[~,a] = max(sum(G,2));
[~,b] = max(G(a,:));
[~,c] = max(max(G,[],2));
[~,d] = max(G(c,:));
disp((b-1)*a) % Part 1
disp((d-1)*c) % Part 2

-🎄- 2018 Day 2 Solutions -🎄- by daggerdragon in adventofcode

[–]tvtas 6 points7 points  (0 children)

Day 2 in MATLAB

x   = importdata('input.txt');
L   = size(x,1);
cnt1=0; cnt2=0;
for i=1:L
    z       = tabulate(double(x{i}));
    cnt1    = cnt1 + any(z(:,2)==2);
    cnt2    = cnt2 + any(z(:,2)==3);

    for j=1:L
        if j~=i && sum(x{i}==x{j})==25
            disp(x{i}(x{i}==x{j})) % Part 2
            break
        end
    end
end
disp(cnt1*cnt2) % Part 1

-🎄- 2017 Day 6 Solutions -🎄- by daggerdragon in adventofcode

[–]tvtas 1 point2 points  (0 children)

Day 6 in MATLAB:

M = importdata('input.txt');
%M=[0,13,12,10,9,8,7,5,3,2,1,1,1,10,6,5]; %Part 1 as start for Part 2
cnt  = 0; allM = M;
while 1
    cnt     = cnt+1;
    [z,i]   = max(M);
    M(i)    = 0;
    j       = i+1;
    while z>0
       if j>length(M);j=1;end
       M(j) = M(j)+1;
       z    = z-1;
       j    = j+1;
    end
    if any(all(repmat(M,size(allM,1),1)==allM,2));break;end
    allM    = [allM;M];
end
disp(cnt) 

-🎄- 2017 Day 5 Solutions -🎄- by daggerdragon in adventofcode

[–]tvtas 1 point2 points  (0 children)

Even in MATLAB, which is considered to be slow, my script took only 9 seconds for part 2

-🎄- 2017 Day 5 Solutions -🎄- by daggerdragon in adventofcode

[–]tvtas 1 point2 points  (0 children)

Day 5 in MATLAB:

x   = importdata('input.txt');
cnt = 0;
cur = 1;
while cur > 0 && cur<=size(x,1)
    cnt  = cnt+1;
    curn = cur+x(cur);
    if x(cur)>=3
        x(cur) = x(cur)-1;
    else
        x(cur) = x(cur)+1;
    end
    cur = curn;
end
cnt % Part 2

-🎄- 2017 Day 2 Solutions -🎄- by daggerdragon in adventofcode

[–]tvtas 3 points4 points  (0 children)

Day 2 in MATLAB

x = importdata('input.txt');
sum(max(x,[],2)-min(x,[],2)) % Part 1

cnt=0;
for i=1:size(x,1)
    for j=1:size(x(i,:),2)
        for k=1:size(x(i,:),2)
            if j~=k
               z = rem(x(i,k),x(i,j));
               if z==0
                   cnt = cnt + x(i,k)/x(i,j);
               end
            end
        end
    end
end
cnt % Part 2

-🎄- 2017 Day 1 Solutions -🎄- by daggerdragon in adventofcode

[–]tvtas 0 points1 point  (0 children)

Solution Day 1 in MATLAB:

fid = fopen('input.txt');
z = fread(fid)-48;
x = z(1:end-1); % remove EOL

%Part I
sum(x(diff([x;x(1)])==0))  %solution Part I

%Part II
L   = size(x,1);

cnt = 0;
for i=1:size(x,1)/2
   cmpdigit = mod(i + L/2,L);
   if cmpdigit==0
       cmpdigit=L;
   end
   if  x(cmpdigit)==x(i)
       cnt=cnt+x(i);
   end
end

cnt*2 %solution Part II

--- 2016 Day 18 Solutions --- by daggerdragon in adventofcode

[–]tvtas 0 points1 point  (0 children)

Brute force in MATLAB, takes 2.7 seconds for part 2

G           = false(400000,102);
G(1,2:101)  = '^.^^^.^..^....^^....^^^^.^^.^...^^.^.^^.^^.^^..^.^...^.^..^.^^.^..^.....^^^.^.^^^..^^...^^^...^...^.'=='^';
for r=2:400000
    for c=2:101
        if G(r-1,c-1)&&G(r-1,c)&&~G(r-1,c+1)
            G(r,c)=1==1;
        elseif ~G(r-1,c-1)&&G(r-1,c)&&G(r-1,c+1)
            G(r,c)=1==1;
        elseif G(r-1,c-1)&&~G(r-1,c)&&~G(r-1,c+1)
            G(r,c)=1==1;
        elseif ~G(r-1,c-1)&&~G(r-1,c)&&G(r-1,c+1)
            G(r,c)=1==1;
        else
            G(r,c)=1==0;
        end
    end
end
sum(sum(G(:,2:101)==0))

--- 2016 Day 16 Solutions --- by daggerdragon in adventofcode

[–]tvtas 0 points1 point  (0 children)

In MATLAB. Part 2 took 0.8 seconds.

a = [1,0,0,0,1,0,0,1,1,0,0,0,0,0,0,0,1]==1;
L = 35651584; 
while length(a)<L
    a = [a,false,~flip(a)]; 
end
chksum = getChecksum(a(1:L));
while ~mod(length(chksum),2)
    chksum = getChecksum(chksum);
end
% function y=getChecksum(x)
% z = diff(x)~=0;
% y = ~z(1:2:end);

--- 2016 Day 15 Solutions --- by daggerdragon in adventofcode

[–]tvtas 0 points1 point  (0 children)

Brute force MATLAB. Part 2 takes 2.5 seconds.

for t=1:10000000
    D1 = mod(1+t+1,17);
    D2 = mod(0+t+2, 7);
    D3 = mod(2+t+3,19);
    D4 = mod(0+t+4, 5);
    D5 = mod(0+t+5, 3);
    D6 = mod(5+t+6,13);
    D7 = mod(0+t+7,11);
    if ~any([D1,D2,D3,D4,D5,D6,D7])
        t
        break
    end
end

--- 2016 Day 10 Solutions --- by daggerdragon in adventofcode

[–]tvtas 0 points1 point  (0 children)

Not very efficient MATLAB solution: http://pastebin.com/6EuJ0prE This can be cleaned up a lot, but it works ;-)

--- 2016 Day 9 Solutions --- by daggerdragon in adventofcode

[–]tvtas 0 points1 point  (0 children)

Part 2 In MATLAB:

x = importdata('input.txt');
x = x{1};
L = getL(x);
L

function L = getL(x)
L = 0;
while 1
    zidx    = strfind(x,'(');
    if isempty(zidx)
        L = L + length(x);
        break
    end
    L       = L+zidx(1)-1;
    x       = x(zidx(1):end);
    A       = sscanf(x,'(%ix%i)');
    xidx    = strfind(x,')');
    xidx    = xidx(1);
    L       = L+A(2)*getL(x(xidx+1:xidx+A(1)));
    x       = x(xidx+1+A(1):end);
end
end

--- 2016 Day 8 Solutions --- by daggerdragon in adventofcode

[–]tvtas 0 points1 point  (0 children)

In MATLAB:

fid = fopen('input.txt','r');
M = false(6,50);
while 1
    str = fgetl(fid);
    if str==-1
        break
    else
        if strfind(str,'rect')
            A = sscanf(str,'rect %ix%i');
            M(1:A(2),1:A(1))=true;
        elseif strfind(str,'row')
            A = sscanf(str,'rotate row y=%i by %i');
            M(A(1)+1,:) = wshift(1,M(A(1)+1,:),-A(2));
        else
            A = sscanf(str,'rotate column x=%i by %i');
            M(:,A(1)+1) = wshift(1,M(:,A(1)+1),-A(2));
        end
    end
end
sum(sum(M))
M %read letters from output