 All about flooble | fun stuff | Get a free chatterbox | Free JavaScript | Avatars  perplexus dot info  Three Coin Consideration (Posted on 2023-03-03) • Jason is travelling to an exotic country which has three types of coins.
• Each coin has a different value (5, 10, or 15 units), a different color (red, green, or blue), and a different shape (round, square, and triangular).
• Jason has precisely one of each of the three types of coin in his pocket.

A) If Jason randomly selects one coin, it will either be red, a circle, or the 5 unit coin.
B) If he randomly selects another coin, it will either be blue, a triangle, or the 10 unit coin.
C) The triangular coin is worth more than the square coin.

Determine the color, shape, and value of each coin.

 See The Solution Submitted by K Sengupta Rating: 5.0000 (1 votes) Comments: ( Back to comment list | You must be logged in to post comments.) computer solution | Comment 2 of 5 | clearvars,clc

fives=char.empty(0,2);
tens=char.empty(0,2);
fifteens=char.empty(0,2);

for den=[5 10 15]
for color=['r' 'g' 'b']
for shape=['c' 's' 't']
if color=='r' && shape=='c' || ...
color=='r' && den==5 || ...
shape=='c' && den==5
continue
end
if color=='b' && shape=='t' || ...
color=='b' && den==10 || ...
shape=='t' && den==10
continue
end
disp([char(string(den)) ' ' color ' ' shape])
switch den
case 5
fives(end+1,:)=[color shape];
case 10
tens(end+1,:)=[color shape];
case 15
fifteens(end+1,:)=[color shape];
end
end
end
end

for f=1:length(fives)
for t=1:length(tens)
for ff=1:length(fifteens)
set=[fives(f,:) tens(t,:) fifteens(ff,:)];
if length(set)==length(unique(set))
disp([fives(f,:) ' ' tens(t,:) ' ' fifteens(ff,:)])
end
end
end
end

first finds valid coins (for example no coin can have any two of the characteristics among red, circle and 5-unit denomination):

`den color shape`
` 5    g     s 5    g     t 5    b     s 10    r     s10    g     c10    g     s15    r     s15    r     t15    g     c15    g     s15    g     t15    b     c15    b     s`

Then it lists combinations of three coins that don't share attributes:

`denominations------------- 5   10   15 gt   rs   bc  (color and shape of each denomination)bs   gc   rt`

In the first row, the triangle (5 units) is worth less than the square (10), violating requirement C.

The second row fits requirement C as the triangle is worth 15 units and the square is worth 5.

So there's:

a blue square 5-unit coin
a green circular 10-unit coin
a red triangular 15-unit coin.

 Posted by Charlie on 2023-03-03 13:09:56 Please log in:

 Search: Search body:
Forums (0)