i like your reasoning relix, there indeed couldnt not be more than one person famous person for the reasons u stated. something similar happened to me in high school when i walked around the place everyone said hi to me but i didnt know them at all hehe was quite funny
This is incorrect because: If as you say the value CurrentPerson is the position of the famous person, then your statement "if Person[CurrentPerson].Knows(Person) then" is saying does the famous person know Person. Already you are checking to see if the famous person knows any of the others (which you need to do), but you code is not checking to see if the other person knows the famous person? You could have a situation where the person might be famous, but some or none of the other people have heard of him/her?
(no need to quote the whole post.) your last statement/question is wrong. The rules state that the famous person is known by everyone.
Yes, I realise that, but the psudo code " if Person[CurrentPerson].Knows(Person) then" does not check that condition. A boolean function (true or false), can either tell you does A know B, or does B know A? In this example, the code reflect does the famous person know the other person? It does not tell you if the non-famous people know the famous person. P.S. I purely quoted the whole thing to save going back to the previous page.
It doesn't need to check, think about it, I can't be bothered repeating myself, read my previous posts. The beauty of the code is it only does what is necessary and doesn't waste extra time checking things that don't need checking. I'll say this once again, if you don't think it works prove it. All it takes is one example the doesn't work, you won't find one...
But it's still on this page. (when viewing 40 posts per page like) anyway, let's not get carried away
My thoughts exactly...though I have this sinking feeling that I'm gonna have to know WTF all this mumbo-jumbo is in the next few years
Easy, you have a cenario with 3 people, 2 famous and 2 non-famous. Lets assume the 2nd non-famous person is known by the famous person. If the famous person knew just one of the non-famous people this would fail. I will take you through the the loop: // This is the position of the famous person CurrentPerson = 0 if Person[CurrentPerson].Knows(Person[1]) then CurrentPerson = 1 // Current Person will remain at 0 if Person[CurrentPerson].Knows(Person[2]) then CurrentPerson = 2 // CurrentPerson would then be set to 2 Here, you have CurrentPerson = 2, even though the 2Nd person is not famous.
But what, he states that the value of CurrentPerson is the famous person after execution. Weill, if the famous person is in position 0, and you run this code, you will end up with CurrentPerson being set to 2 after execution (which is wrong).
problems with simple maths isn't going to help anyone. --- relix, have you shown this to anyone at uni?
2 + 2 != 3 You can't have 2 famous people either as that would contradict the requirements: famous people don't know anyone but must be known by everyone - if you have 2 then the famous people can't know each other, as they know no one, but must know each other as every famous person must be know. See the post made by relix. The only situation the code will not work is when no-one is famous
You can't have 2 famous people, if person 0 is famous, then person 0 will not know anyone, and so currentPerson will still be 0 at the end. edit: yay double post for me
Maybe I am missing something here, but is this psudo code meant to work in any group of famous or non-famous people, or just in a group with a single famous person? I'm starting to think that my interpretation of what was asked for is different from others. EDIT: from the statement "The characteristics of a famous person are:", I am assuming that if the correct group is provided it will be true, but if the incorrect group is provided, the function will be false.
Please follow these steps: read, think, post You CANNOT have more than one famous person, this is implied in post #1
Well, if the lecturer thinks it is wrong, and I think it is wrong, I am guessing my interpretation of what has been asked is the same as his. I have read the original post several times, and still understand it in my EDIT ammend in my previous post. That's it for me, after all, I've only been programming for 17 years, what do I know. EDIT: I would like to point out that the approach by relix is a fine example of trying to solve a problem using lateral thinking, and I give him credit for the attempt, but I still beleive it to be wrong (unless someone can explain how they are interpreting the exercise?)
Henchman:crg, I don't like to say this to anyone, but I'll make an exception for you: please go away and die, thanks. If you've been programming for 17 years then your programs must be utter crap. You can't even read a definition of a problem correctly, let alone solve it. People have stated numerous times that you should read the fricking thread, which you obviously haven't. Everything you said has been covered already. There can't be two famous persons in one group. There is one and only one famous person in a group. And, if you would've read the thread and saved us all from your stupidness, you would've know that the assistant does indeed agree with me. The algorithm is correct and has been proven. You just made a fool out of yourself. Haha. Edit: okay, maybe I've overreacted and this was uncalled for, but your failure at reading my explenation in the first and third posts makes me bitter and sad.
this was not in original post, and was this specified by the lecturer, or something you asumed? ANYWAY: Firstly, I read everyones comments and didn't just dive in. As far as I could tell, nobody really delved into the interpretation fully. And after all that, I guess your lecturer still thinks your solution is wrong. I will not make the mistake of complimenting you again (or anything else for that matter). I do not like rude people, and if you cannot appreciate when someone is trying to give a different point of view, but at the same time try to be helpful, then this is not my problem.
I was just wondering if you might be better off with the nested loops but with breaks at every chance? edit: argh! it's impossible - it's a paradox, as has been explained.