Alex quiz

From Testiwiki
Jump to: navigation, search



Question

First question

  1. Can you determine who keeps fish?

# : The question is not entirely specific enough to be clear. --Alexandra Kuhn 19:43, 30 August 2012 (EEST)

# : Yes, you are right. I'm sorry. The exact question is now written down. If you still have trouble, you have not identified the correct context. --Jouni 23:10, 30 August 2012 (EEST)

--# : The answer to this question is either "yes" or "no". I don't expect you wanting to have one of these answers. Thanks for the hint, but I still cannot figure out the context. --Alexandra Kuhn 22:08, 2 September 2012 (EEST)

# : The problem is that you assume that you can figure out the context by reading the question. Of course you can't. You have to find the context outside the question, and then you'll understand it. --Jouni 16:24, 3 September 2012 (EEST)

--# : Then how will I know which the context is? What do you mean by "keep"? Have and then do not give it away? I do you mean breed fisch? --Alexandra Kuhn 16:57, 7 September 2012 (EEST)

# : When you find the context, you will know that you have found it, and all the detailed questions get an answer. It is impossible to guess, but pretty easy to find if you just start searching for it. --Jouni 23:28, 11 September 2012 (EEST)

# : Thanks for this hint! I found the question :) Now it's take a while until I'll find the answer. --Alexandra Kuhn 17:08, 24 September 2012 (EEST)

Second question

48.72354, 9.117249, Fagus sylvatica.

Answer

First question

  1. The oceans. # : The question says "who", which refers to a person. --Jouni 23:10, 30 August 2012 (EEST) # : Your are right. --Alexandra Kuhn 22:08, 2 September 2012 (EEST)
  2. Douglas Adams. ;) # : The famous fish quote by Douglas Adams says: "So long, and thanks for all the fish." It is not about keeping fish, but dolphins having eaten them. --Jouni 23:10, 30 August 2012 (EEST) # : Yes, you are right. --Alexandra Kuhn 22:08, 2 September 2012 (EEST)

The German keeps Fish :)

yellow     blue     red       green    white
Norwegian  Dane     Brit      German   Swede
Dunhill    Blend    Pall Mall Prince   Blue Master
Water      Tea      Milk      Coffee   Beer
Cats       Horses   Birds     Fish     Dogs

# : Correct! Very good. It is a pity that we cannot run Matlab in Opasnet. --Jouni 00:42, 12 December 2012 (EET)

Second question

The numbers show the coordinates of the IER in Stuttgart. Fagus sylvatica is a beech. I am just not sure if the tree on the parking lot is a beech. :)

# : Well, there is a way to find out. --Jouni 17:02, 7 February 2013 (EET)

Rationale

Dependencies

Formula

--# : I was too lazy to finish this R code. But it works half way through: Einstein quiz. --Jouni 00:42, 12 December 2012 (EET)

Matlab code:

File: einstein.m

% We will code the Strings into Integers (Doubles) to be able to use Matlab
% more simply

% There are several atributes of the houses. In brackets are the coding
% numbers.
% House:			1           2           3           4               5
% Colour:			red(1),     green(2),   white(3),   yellow(4),      blue(5)
% Nationalities:	Brit(1),    Swede(2),   Dane(3),    Norwegian(4),   German(5)
% Cigar:    		Pall Mall(1), Dunhill(2), Blend(3), Blue Master(4), Prince(5)		
% Drink:    		Tee(1),     Coffee(2),  Milk(3),    Beer(4),        Water(5)
% Pet:              Dog(1),     Birds(2),   Cats(3),    Horses(4),      Fish(5)

% What we know already about the places of some attributes:
% Colours: 
% * green is left of white
% * blue is the second

% Nationality:
% * Norwegian in 1st house

% Drink:
% * Milk in the 3rd House

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

% So the idea is to build up some matrices including all possible
% permuations of the colours, the nationalities, the cigars, the drinks and
% the pets. All impossible permuations will not be allowed.

% Secondly, from these matrices all combinations will be testes if they
% fulfil the given conditions. If the combination fulfilling the conditions
% is found, the result is printed and the program is aborted. 

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

% Selecting all possible permuatations of the different attributes and
% saving the results in the respective matrices.

permutcol = permuatationscolours;
permutnat = permutationsnationalities;
permutcig = permutationscigars;
permutdri = permutationsdrink;
permutpet = permutationspets;

% Trying all combinations and testing the conditions. Printing the result.

solutionquiz = testingallcombinations(permutcol,permutnat,permutcig,permutdri,permutpet);

printsolution(solutionquiz);

%fprintf('\n Colours: ',solutionquiz(1,:));
%fprintf('\n Nationalities: ',solutionquiz(2,:));
%fprintf('\n Cigars: ',solutionquiz(3,:));
%fprintf('\n Drinks: ',solutionquiz(4,:));
%fprintf('\n Pets: ',solutionquiz(5,:));

disp('My true admiration for Einstein!!!')

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
File: testingallcombinations.m

function returnarray = testingallcombinations(permutcol,permutnat,permutcig,permutdri,permutpet)

% Returns the solution ;)

% We iterate through all combinations of the different matrices and look if
% all the conditions are fulfilled.

% The conditions are:
% 1) The Brit(1) lives in a red(1) house.
% 2) The Swede(2) keeps dogs(1).
% 3) The Dane(3) drinks tea(1).
% 4) The green house owner(2) drinks coffee(2).
% 5) The person who smokes Pall Mall(1) rears birds(2).
% 6) The owner of the yellow house(4) smokes Dunhill(2).
% 7) The man who smokes Blend(3) lives next to the one who keeps cats(3).
% 8) The man who keeps horses(4) lives next to the man who smokes Dunhill(2).
% 9) The owner who smokes Blue Master(4) drinks beer(4).
% 10) The German(5) smokes Prince(5).
% 11) The man who smokes Blend(3) has a neighbour who drinks water(5).

% i is the 1st place in the matrices, j the 2nd, k the 3rd, l the 4th, m the
% 5th.

% a = index going through permutcol.
% b = index going through permutnat.
% c = index going through permutcig.
% d = index going through permutdri.
% e = index going through permutpet.

%z=0; % z is a counter counting the lines of the result array


for a=1:length(permutcol); % from one to the number of lines
    for b=1:length(permutnat);
        for c=1:length(permutcig);
            for d=1:length(permutdri);
                for e=1:length(permutpet);
                    % build up the combinations
                    tmp_col = permutcol(a,:); % takes the whole line in the a'th place
                    tmp_nat = permutnat(b,:);
                    tmp_cig = permutcig(c,:);
                    tmp_dri = permutdri(d,:);
                    tmp_pet = permutpet(e,:);
                    
                    if (test1(tmp_nat, tmp_col)... %Brit red 
                        && test2(tmp_nat, tmp_pet)... % Swede dogs 
                        && test3(tmp_nat, tmp_dri)... % Dane tea 
                        && test4(tmp_col, tmp_dri)... % green coffee 
                        && test5(tmp_cig, tmp_pet)... % Pall Mall birds 
                        && test6(tmp_col, tmp_cig)... % yellow Dunhill 
                        && test7(tmp_cig, tmp_pet)... % Blend next to cats 
                        && test8(tmp_pet, tmp_cig)... % horses next to Dunhill 
                        && test9(tmp_cig, tmp_dri)...  % Blue Master beer 
                        && test10(tmp_nat, tmp_cig)... % German Prince 
                        && test11(tmp_cig, tmp_dri)... % Blend next to water 
                    )
                        returnarray(1,:) = tmp_col;
                        returnarray(2,:) = tmp_nat;
                        returnarray(3,:) = tmp_cig;
                        returnarray(4,:) = tmp_dri;
                        returnarray(5,:) = tmp_pet;
                        return
                    end   
                end
            end
        end
    end
end   
           
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

File: printsolution.m

function printsolution(solutionquiz)

colours = solutionquiz(1,:);
disp('\n Colours: ');
for i=1:5
    switch colours(i)
        case 1
            disp('red ')
        case 2
            disp('green ')
        case 3
            disp('white ')
        case 4
            disp('yellow ')
        case 5
            disp('blue ')
    end
end

nationalities = solutionquiz(2,:);
disp('\n Nationalities: ');
for i=1:5
    switch nationalities(i)
        case 1
            disp('Brit ')
        case 2
            disp('Swede ')
        case 3
            disp('Dane ')
        case 4
            disp('Norwegian ')
        case 5
            disp('German ')
    end
end

cigars = solutionquiz(3,:);
disp('\n Cigars: ');
for i=1:5
    switch cigars(i)
        case 1
            disp('Pall Mall ')
        case 2
            disp('Dunhill ')
        case 3
            disp('Blend ')
        case 4
            disp('Blue Master ')
        case 5
            disp('Prince ')
    end
end

drinks = solutionquiz(4,:);
disp('\n Drinks: ');
for i=1:5
    switch drinks(i)
        case 1
            disp('Tea ')
        case 2
            disp('Coffee ')
        case 3
            disp('Milk ')
        case 4
            disp('Beer ')
        case 5
            disp('Water ')
    end
end

pets = solutionquiz(5,:);
disp('\n Pets: ');
for i=1:5
    switch pets(i)
        case 1
            disp('Dogs ')
        case 2
            disp('Birds ')
        case 3
            disp('Cats ')
        case 4
            disp('Horses ')
        case 5
            disp('Fish ')
    end
end

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

File: permutationspets.m

function returnarray = permutationspets

% Returns in a matrix all the possible permutations of the pets.
% We don't konw anything about the pets being kept in any of the
% houses.
% Each pet only occurs once.

% We iterate through all permuations and pick only those ones which are
% possible according to the given conditions.

% i is the 1st place in the matrix, j the 2nd, k the 3rd, l the 4th, m the
% 5th.


z=0; % z is a counter counting the lines of the result array

for i=1:5;
    for j=1:5;
        for k=1:5;
            for l=1:5;
                for m=1:5;
                    % no figure is allowed to occur twice;
                    if (j~=i) && (k~=i) && (k~=j) && (l~=i) && (l~=j) && (l~=k) && (m~=i) && (m~=j) && (m~=k) && (m~=l);
                        z = z+1;
                        returnarray(z,1)=i;
                        returnarray(z,2)=j;
                        returnarray(z,3)=k;
                        returnarray(z,4)=l;
                        returnarray(z,5)=m;
                    end    
                end
            end
        end
    end
end   
                

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

File: permuatationscolours.m

function returnarray = permuatationscolours

% Returns in a matrix all the possible permutations of the colours.
% We know that the green(2) house is left of the white(3) house and that
% blue(5) is the second house. Each colour only occurs once.

% We iterate through all permuations and pick only those ones which are
% possible according to the given conditions.

% i is the 1st place in the matrix, j the 2nd, k the 3rd, l the 4th, m the
% 5th.

j=5; % the 2nd house is blue(5)
z=0; % z is a counter counting the lines of the result array

for i=1:5;
    for k=1:5;
        for l=1:5;
            for m=1:5;
                % no figure is allowed to occur twice; green(2) is left of
                % white(3), so they must either be on the 3rd and 4th place
                % or on the 4th and 5th place
                if (j~=i) && (k~=i) && (k~=j) && (l~=i) && (l~=j) && (l~=k) && (m~=i) && (m~=j) && (m~=k) && (m~=l) &&...;
                        (((k==2) && (l==3)) || ((l==2) && (m==3)));
                    z = z+1;
                    returnarray(z,1)=i;
                    returnarray(z,2)=j;
                    returnarray(z,3)=k;
                    returnarray(z,4)=l;
                    returnarray(z,5)=m;
                end
            end
        end
    end
end   
                

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

File: permutationscigars.m

function returnarray = permutationscigars

% Returns in a matrix all the possible permutations of the cigars.
% We don't konw anything about a cigar brand being smoked in any of the
% houses.
% Each cigar brand only occurs once.

% We iterate through all permuations and pick only those ones which are
% possible according to the given conditions.

% i is the 1st place in the matrix, j the 2nd, k the 3rd, l the 4th, m the
% 5th.


z=0; % z is a counter counting the lines of the result array

for i=1:5;
    for j=1:5;
        for k=1:5;
            for l=1:5;
                for m=1:5;
                    % no figure is allowed to occur twice;
                    if (j~=i) && (k~=i) && (k~=j) && (l~=i) && (l~=j) && (l~=k) && (m~=i) && (m~=j) && (m~=k) && (m~=l);
                        z = z+1;
                        returnarray(z,1)=i;
                        returnarray(z,2)=j;
                        returnarray(z,3)=k;
                        returnarray(z,4)=l;
                        returnarray(z,5)=m;
                    end    
                end
            end
        end
    end
end   
                

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

File: permutationsdrink.m

function returnarray = permutationsdrink

% Returns in a matrix all the possible permutations of the drinks.
% We know that the person living in the 3rd house drinks milk. 
% Each drink only occurs once.

% We iterate through all permuations and pick only those ones which are
% possible according to the given conditions.

% i is the 1st place in the matrix, j the 2nd, k the 3rd, l the 4th, m the
% 5th.

k=3; % the person living in the 3rd house drinks milk(3)
z=0; % z is a counter counting the lines of the result array

for i=1:5;
    for j=1:5;
        for l=1:5;
            for m=1:5;
                % no figure is allowed to occur twice;
                if (j~=i) && (k~=i) && (k~=j) && (l~=i) && (l~=j) && (l~=k) && (m~=i) && (m~=j) && (m~=k) && (m~=l);
                    z = z+1;
                    returnarray(z,1)=i;
                    returnarray(z,2)=j;
                    returnarray(z,3)=k;
                    returnarray(z,4)=l;
                    returnarray(z,5)=m;
                end
            end
        end
    end
end   
            
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

File: permutationsnationalities.m

function returnarray = permutationsnationalities

% Returns in a matrix all the possible permutations of the nationalities.
% We know that the Norwegian lives in the first house. 
% Each nationality only occurs once.

% We iterate through all permuations and pick only those ones which are
% possible according to the given conditions.

% i is the 1st place in the matrix, j the 2nd, k the 3rd, l the 4th, m the
% 5th.

i=4; % the Norwegian(4) lives in the 1st house
z=0; % z is a counter counting the lines of the result array

for j=1:5;
    for k=1:5;
        for l=1:5;
            for m=1:5;
                % no figure is allowed to occur twice;
                if (j~=i) && (k~=i) && (k~=j) && (l~=i) && (l~=j) && (l~=k) && (m~=i) && (m~=j) && (m~=k) && (m~=l);
                    z = z+1;
                    returnarray(z,1)=i;
                    returnarray(z,2)=j;
                    returnarray(z,3)=k;
                    returnarray(z,4)=l;
                    returnarray(z,5)=m;
                end
            end
        end
    end
end   
                

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

File: test1.m

function bool = test11(tmp_cig, tmp_dri)

% Blend(3) NEXT To water(5)

        if ((find(tmp_cig == 3) == (find(tmp_dri == 5)-1)) ||...
            (find(tmp_cig == 3) == (find(tmp_dri == 5)+1))   ) 
            bool = 1; % represents 'true' in Matlab
        else
            bool = 0; % if true wasn't returned
        end


%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

File: test2.m

function bool = test11(tmp_cig, tmp_dri)

% Blend(3) NEXT To water(5)

        if ((find(tmp_cig == 3) == (find(tmp_dri == 5)-1)) ||...
            (find(tmp_cig == 3) == (find(tmp_dri == 5)+1))   ) 
            bool = 1; % represents 'true' in Matlab
        else
            bool = 0; % if true wasn't returned
        end

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

File: test3.m

function bool = test11(tmp_cig, tmp_dri)

% Blend(3) NEXT To water(5)

        if ((find(tmp_cig == 3) == (find(tmp_dri == 5)-1)) ||...
            (find(tmp_cig == 3) == (find(tmp_dri == 5)+1))   ) 
            bool = 1; % represents 'true' in Matlab
        else
            bool = 0; % if true wasn't returned
        end


%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

File: test4.m

function bool = test11(tmp_cig, tmp_dri)

% Blend(3) NEXT To water(5)

        if ((find(tmp_cig == 3) == (find(tmp_dri == 5)-1)) ||...
            (find(tmp_cig == 3) == (find(tmp_dri == 5)+1))   ) 
            bool = 1; % represents 'true' in Matlab
        else
            bool = 0; % if true wasn't returned
        end

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

File: test5.m

function bool = test5(tmp_cig, tmp_pet)

% Pall Mall(1) birds(2)

        if (find(tmp_cig == 1) == find(tmp_pet == 2)) 
            bool = 1; % represents 'true' in Matlab
        else
            bool = 0; % if true wasn't returned
        end


%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

File: test6.m

function bool = test5(tmp_cig, tmp_pet)

% Pall Mall(1) birds(2)

        if (find(tmp_cig == 1) == find(tmp_pet == 2)) 
            bool = 1; % represents 'true' in Matlab
        else
            bool = 0; % if true wasn't returned
        end

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

File: test7.m

function bool = test5(tmp_cig, tmp_pet)

% Pall Mall(1) birds(2)

        if (find(tmp_cig == 1) == find(tmp_pet == 2)) 
            bool = 1; % represents 'true' in Matlab
        else
            bool = 0; % if true wasn't returned
        end


%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

File: test8.m

function bool = test8(tmp_pet, tmp_cig)

% horses(4) NEXT To Dunhill(2)

        if ((find(tmp_pet == 4) == (find(tmp_cig == 2)-1)) ||...
            (find(tmp_pet == 4) == (find(tmp_cig == 2)+1))   ) 
            bool = 1; % represents 'true' in Matlab
        else
            bool = 0; % if true wasn't returned
        end

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

File: test9.m

function bool = test11(tmp_cig, tmp_dri)

% Blend(3) NEXT To water(5)

        if ((find(tmp_cig == 3) == (find(tmp_dri == 5)-1)) ||...
            (find(tmp_cig == 3) == (find(tmp_dri == 5)+1))   ) 
            bool = 1; % represents 'true' in Matlab
        else
            bool = 0; % if true wasn't returned
        end

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

File: test10.m

function bool = test11(tmp_cig, tmp_dri)

% Blend(3) NEXT To water(5)

        if ((find(tmp_cig == 3) == (find(tmp_dri == 5)-1)) ||...
            (find(tmp_cig == 3) == (find(tmp_dri == 5)+1))   ) 
            bool = 1; % represents 'true' in Matlab
        else
            bool = 0; % if true wasn't returned
        end


%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

File: test11.m

function bool = test11(tmp_cig, tmp_dri)

% Blend(3) NEXT To water(5)

        if ((find(tmp_cig == 3) == (find(tmp_dri == 5)-1)) ||...
            (find(tmp_cig == 3) == (find(tmp_dri == 5)+1))   ) 
            bool = 1; % represents 'true' in Matlab
        else
            bool = 0; % if true wasn't returned
        end

See also

Keywords

References


Related files

<mfanonymousfilelist></mfanonymousfilelist>

Alex quiz. Opasnet . [1]. Accessed 20 Apr 2024.