All about flooble | fun stuff | Get a free chatterbox | Free JavaScript | Avatars    
perplexus dot info

Home > Logic > Weights and Scales
Ten Box Trial (Posted on 2022-04-29) Difficulty: 2 of 5
  • There are ten boxes containing 4, 8, 27, 31, 34, 35, 44, 45, 51, and 59 balls of either red, or blue, or green in color.
  • Some boxes contain only red balls, some boxes contain only blue balls, and remaining boxes contain only green balls.
  • None of the boxes contain balls having more than one color.
One salesman sold only one box out of them and he declared, "I have the same number of red, blue, and green balls left over."

Which box is sold out?

See The Solution Submitted by K Sengupta    
Rating: 4.0000 (1 votes)

Comments: ( Back to comment list | You must be logged in to post comments.)
Solution computer solution | Comment 9 of 10 |
clearvars,clc
% ten box trial, pid 12597
set=[4, 8, 27, 31, 34, 35, 44, 45, 51,  59]
disp(' ')
removal=set(mod(set,3)==2) ;
for r=1:length(removal)
  s1=setdiff(set,removal(r));
  s=sum(s1);
  gps3=nchoosek(s1,3);
  for i=1:length(gps3)
    gp3=gps3(i,:);
    s2=setdiff(s1,gp3);
    if sum(gp3)==s/3
      gps3a=nchoosek(s2,3);
      for j=1:length(gps3a)
        gp3a=gps3a(j,:);
        s3=setdiff(s2,gp3a);
        if sum(s3)==s/3
          disp(removal(r));
          disp(gp3);
          disp(gp3a);
          disp(s3);
          disp(' ')
        end
      end
    end
    
  end
end


set =
     4     8    27    31    34    35    44    45    51    59
 
    59
     4    44    45
     8    34    51
    27    31    35
 
    59
     4    44    45
    27    31    35
     8    34    51
 
    59
     8    34    51
     4    44    45
    27    31    35
 
    59
     8    34    51
    27    31    35
     4    44    45
 
    59
    27    31    35
     4    44    45
     8    34    51
 
    59
    27    31    35
     8    34    51
     4    44    45
     
These are all permutations of the same set of sets of three.
     
This indicates that the box with 59 balls was sold, if we assume that there are three boxes of each color.  This is presumably the intended answer.   

But it also assumes that there are the same number of boxes of each color. Why must that be the case? Here's a program that doesn't make that assumption:

clearvars,clc
% ten box trial, pid 12597
global fullset goal remain ways way
set=[4, 8, 27, 31, 34, 35, 44, 45, 51,  59]
disp(' ')
removal=set(mod(set,3)==2) ;
for i=1:length(removal)
  disp(removal((i)))
  fullset=setdiff(set,removal(i)) 
  s=sum(fullset);
  goal=s/3 
  remain=goal;
  ways={}; way=[];
  findway;
  for j=1:length(ways)
    v=ways{j};
    disp(fullset(v))
  end
  disp(' ')
end

function findway()
global fullset goal remain ways way
if isequal(way,[1 7]) && goal==93
  tt=99;
end
  if isempty(way)
    st=1;
  else
    st=way(end)+1;
  end
  for i=st:length(fullset)
    way=[way i];
    remain=remain-fullset(i);
    
    if remain==0
      ways{length(ways)+1}= way ;
    elseif remain>0 && i< length(fullset)
      findway
    end
    
    way=way(1:end-1);
    remain=remain+fullset(i);    
  end
end
     
     
The program doesn't provide a list of complete sets but rather produces lists of subsets that have 1/3 the remaining balls. 

The "fullset" below refers to the set after one has been removed:
     
set =
     4     8    27    31    34    35    44    45    51    59
 
     8  removed
fullset =
     4    27    31    34    35    44    45    51    59
goal =
   110
     4    27    34    45
     4    27    35    44
    31    34    45
    31    35    44
    51    59
 
    35  removed
fullset =
     4     8    27    31    34    44    45    51    59
goal =
   101
     4     8    44    45
     8    34    59
 
    44  removed
fullset =
     4     8    27    31    34    35    45    51    59
goal =
    98
     4     8    27    59
     4     8    35    51
     4    35    59
     8    31    59
 
    59  removed
fullset =
     4     8    27    31    34    35    44    45    51
goal =
    93
     4    44    45
     8    34    51
    27    31    35

These enumerate subsets of the total used that add up to 1/3 the total contents of the unsold boxes. 


The last instance is that which was assumed in the first program, having the same three sets. with 93 balls in each box.

However if the box of 8 was sold, the remaining 330 balls could be distributed in boxes that total 110 balls each set, but each color set distributed over a different numbe of boxes, with 110 being the number of each color:


 4    27    34    45  color A
31    35    44        color B
51    59              color C
or
 4    27    35    44  color A
31    34    45        color B
51    59              color C

with of course arbitrary permutations of the colors over A, B and C.

To answer the question Which box is sold out? Either the box with 8 balls or the box with 59 balls.

  Posted by Charlie on 2022-04-29 09:36:14
Please log in:
Login:
Password:
Remember me:
Sign up! | Forgot password


Search:
Search body:
Forums (0)
Newest Problems
Random Problem
FAQ | About This Site
Site Statistics
New Comments (5)
Unsolved Problems
Top Rated Problems
This month's top
Most Commented On

Chatterbox:
Copyright © 2002 - 2024 by Animus Pactum Consulting. All rights reserved. Privacy Information