 |
|  |
 | Math riddles |  |
  
| CT Rank: Not Ranked |
| Field's place: support |
| Grid Name: CT×W124 |
| GID: P4@ct/jedi |
| CT Wild Fort Rank: na |
| Joined: 20 Jun 2006 |
| Posts: 22Y362698 Posts |
Location: 50°17'50.79"N 18°41'04.70"E
|
|
Posted: Wed Apr 11, 2007 9:37 am |
|
I got some math tasks too
1)
Using only addition (+) write number 28 with five 2's and number 1000 with eight 8's.
2)
We got 3 identical bottles. One of them consider 2/3 liters of water and rest is empty. How to measure exactly 1/2 liters of water?
3)
How to write number 1 using all decimal integers (0-9)? |
|
_________________ P4
|
|
Wacko
| CT Rank: Not a CTer |
| Field's place: |
| Grid Name: |
| GID: wrtlprnft@ct/public |
| CT Wild Fort Rank: |
| Joined: 06 Oct 2006 |
| Posts: 5Q36206 Posts |
Location: 0x08048000
|
|
Posted: Wed Apr 11, 2007 10:04 am |
|
Got another riddle, too, and this one isn't easy
- N people, standing in a straight line, get different colored hats put onto their heads (at random).
- They can only see the hats of the people in front of them, not their own (ALL hats in front of them, so the last guy sees all hats but his)
- They know what different colors the hats can have, say red, green and blue
- They do not know how many hats of which color they are, they just know that everybody gets one
- Before they get their hats put on they can decide on a strategy to use
- Once they get their hats put on they're not allowed to say anything but one color (so only “red”, “green”, or “blue” in this case).
- Once they said that color they have to be silent
- Everybody hears everything
- The goal is to have as many people say their own hat's color as possible
What is that strategy? Hint: The optimal strategy still works if you change the number of people or the number of colors. |
Last edited by wrtlprnft on Wed Apr 11, 2007 10:28 am; edited 1 time in total _________________ Want to know how addicted you are? Here's the answer!
I hacked 127.42.3.141!
|
  
| CT Rank: 6 |
| Field's place: def-sweep |
| Grid Name: CT~Voodoo |
| GID: Voodoo@ct/jedi |
| CT Wild Fort Rank: na |
| Joined: 05 May 2006 |
| Posts: YK361244 Posts |
Location: somewhere on earth
|
|
Posted: Wed Apr 11, 2007 10:11 am |
|
Have no idea !
Well let's start by the last one who have nobody behind him :
-He says the color of the guy hat in front of him,
- the next one of course now know is color hat, so he says it,
- next one don't know so, he says the color of the guy in front of him,
- etc ...
N/2 people will give the good answer ...
That's the only strategy I can think of ... Dunno if it is the optimal one  |
|
|
|
Wacko
| CT Rank: Not a CTer |
| Field's place: |
| Grid Name: |
| GID: wrtlprnft@ct/public |
| CT Wild Fort Rank: |
| Joined: 06 Oct 2006 |
| Posts: 5Q36206 Posts |
Location: 0x08048000
|
|
Posted: Wed Apr 11, 2007 10:15 am |
|
So N/2 people will say the correct color for sure, and of the other N/2 people, on average 1/3 will be lucky and say their own color simply because they've got the same color as the guy in front of them.
That'd make for 2/3 of all saying their own color.
Not bad, but the optimal strategy results in N-1 people saying the correct color and the remaining one having a 1/3 chance  |
|
|
|
Wacko
| CT Rank: Not a CTer |
| Field's place: |
| Grid Name: |
| GID: wrtlprnft@ct/public |
| CT Wild Fort Rank: |
| Joined: 06 Oct 2006 |
| Posts: 5Q36206 Posts |
Location: 0x08048000
|
|
Posted: Wed Apr 11, 2007 11:21 am |
|
No. They're only allowed to say “possible” colors (so they can't say purple with a shade of red or something like that).
Anyways, here's the solution: #include <iostream>
#include <stdlib.h>
#define NUM_COLORS 3
#define NUM_PEOPLE 10
class Hat {
public:
typedef enum {
COLOR_RED = 0,
COLOR_GREEN = 1,
COLOR_BLUE = 2
} color;
color m_color;
Hat(void) {
m_color = (color)(random() % NUM_COLORS);
}
Hat(color theColor) : m_color(theColor) {}
void Print(std::ostream &s) const {
switch (m_color) {
case COLOR_RED : s << " red"; break;
case COLOR_GREEN: s << "green"; break;
case COLOR_BLUE : s << " blue"; break;
default: s << "BUG!";
}
}
};
std::ostream &operator<< (std::ostream &s, Hat const &hat) {
hat.Print(s);
return s;
}
class Guy {
int m_SaidColors;
int m_HeardFirstColor;
Hat::color m_FirstColor;
public:
Hat m_hat;
Guy *m_next;
Guy() : m_SaidColors(0), m_HeardFirstColor(false) {}
void HearAColor(Hat::color color) {
if(!m_HeardFirstColor) {
m_HeardFirstColor = true;
m_FirstColor = color;
} else {
m_SaidColors += color;
m_SaidColors %= NUM_COLORS;
}
}
Hat::color SayYourColor() {
int colorsInFront = 0;
for(Guy *guy = m_next; guy != 0; guy = guy->m_next) {
colorsInFront += guy->m_hat.m_color;
colorsInFront %= NUM_COLORS;
}
if(!m_HeardFirstColor) {
return (Hat::color)(colorsInFront);
}
int totalColors = (m_SaidColors + colorsInFront) % NUM_COLORS;
int myColor = m_FirstColor - totalColors;
if(myColor < 0) myColor += NUM_COLORS;
return (Hat::color)(myColor);
}
};
int main(int ac, char **av) {
srand(time(0));
Guy guys[NUM_PEOPLE];
guys[NUM_PEOPLE - 1].m_next = 0;
for(int i = NUM_PEOPLE -2; i>=0; --i) {
guys[i].m_next = guys + i + 1;
}
std::cout << "Colors :";
for(Guy *guy = guys; guy != 0; guy = guy->m_next) {
std::cout << " " << guy->m_hat;
}
std::cout << std::endl;
std::cout << "Guesses:";
for(Guy *guy = guys; guy != 0; guy = guy->m_next) {
Hat::color color = guy->SayYourColor();
for(Guy *guy2 = guy->m_next; guy2 != 0; guy2 = guy2->m_next) {
guy2->HearAColor(color);
}
std::cout << " " << Hat(color);
}
std::cout << std::endl;
} |
|
|
|
|
Wacko
| CT Rank: Not a CTer |
| Field's place: |
| Grid Name: |
| GID: wrtlprnft@ct/public |
| CT Wild Fort Rank: |
| Joined: 06 Oct 2006 |
| Posts: 5Q36206 Posts |
Location: 0x08048000
|
|
Posted: Fri Apr 20, 2007 5:36 am |
|
1113213211 |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
All times are GMT
Page 1 of 3
|
|
|
|
|  |