CrazyEngineers
  • The Josephus problem - Jack the Ripper strikes again !!

    suyash

    suyash

    @suyash-2N6gPP
    Updated: Oct 26, 2024
    Views: 1.1K
    Recently when I appeared for one of the management entrance exams, I found two very interesting questions in the logical reasoning section. I could only answer one of them, and that too took a long time, so couldn't dare to attempt the second one as well, for the fear of losing valuable time.

    Later on I found out that it was a variant of the popular "Josephus Problem" and boy, had I read the wiki page earlier, I would have solved the two questions in less than a minute !!

    Here's a variant of the question :-

    Assume that there is a circle of 997 people. And Jack the Ripper is free and on a killing spree. But he has strange rules. He says that he will kill every alternate person in the circle and leave the next one alive till he traverses the circle once. After that, he would again get the alive persons to form a smaller circle and the hacking (of necks 😀 would begin again and so on till he has been left with only one person.

    The question is, for 997 people, what would be the position to stand in, if you want to be the lone survivor.

    Another variant is for "n" people, and for a separation distance of "x" (in our case, n=997 , x=1) what can be the generalized position in terms of n and x ?
    0
    Replies
Howdy guest!
Dear guest, you must be logged-in to participate on CrazyEngineers. We would love to have you as a member of our community. Consider creating an account or login.
Replies
  • suyash

    MemberJan 4, 2011

    To clarify,
    After Jack traverses the circle once, the people left will be 1, 3, 5, 7, .... till 997
    After Jack traverses the circle second time, the people left will be 3, 7, 11, 15, .... till 995
    and so on...
    (this is for n=997 and x=1)
    Are you sure? This action cannot be undone.
    Cancel
  • cooltwins

    MemberJan 5, 2011

    i think the answer is 971st position from the start.
    Are you sure? This action cannot be undone.
    Cancel
  • Ankita Katdare

    AdministratorJan 5, 2011

    @suyash: Are you sure that the clarification you wrote is correct?

    In first circle it is: 1, 3, 5, 7, .... till 997

    But in 2nd circle it will be: 1, 5, 9, 13 till 997


    Correct me if I am wrong.
    Are you sure? This action cannot be undone.
    Cancel
  • Saandeep Sreerambatla

    MemberJan 5, 2011

    I guess in this case AKD the person in position 1 will never die?
    Are you sure? This action cannot be undone.
    Cancel
  • Ankita Katdare

    AdministratorJan 5, 2011

    cooltwins
    i think the answer is 971st position from the start.
    @CT: Could you put a mathematical solution?
    Are you sure? This action cannot be undone.
    Cancel
  • cooltwins

    MemberJan 5, 2011

    calculation:
    for Josephus Kind of problems the solution is: if n(no. of people)=2^x+y so that 0<y<2^x
    then the safest position is 2y+1

    so for n=997 => y=485 => safest place is 2*485+1=971
    Are you sure? This action cannot be undone.
    Cancel
  • Ankita Katdare

    AdministratorJan 5, 2011

    English-Scared
    I guess in this case AKD the person in position 1 will never die?
    @ES: Yeah. That's why I asked.


    @CT: I had got that 2^9 = 512.

    997-512 = 485.
    I was confused about how to proceed.
    Is that a standard formula you used?
    And Well, what are the other 'Josephus Kind of problems'?
    Are you sure? This action cannot be undone.
    Cancel
  • cooltwins

    MemberJan 5, 2011

    yeah you were right till that step.
    that is not standard for any Josephus problem it is the solution only for alternate counting kind.
    there are other kinds in the sense it is not necessary that alternate people only must be killed. if the problem goes as every 10th person is killed or every 5th person is attacked that solution will vary.

    but since suyash had given problem of the first kind the solution can be used.
    Are you sure? This action cannot be undone.
    Cancel
  • Ankita Katdare

    AdministratorJan 5, 2011

    @cooltwins: You should write a program in C/C++ to solve the Josephus problem for 'n' people.

    @all newbies: This could be your mini project. 😉
    Are you sure? This action cannot be undone.
    Cancel
  • suyash

    MemberJan 5, 2011

    AbraKaDabra
    @suyash: Are you sure that the clarification you wrote is correct?

    In first circle it is: 1, 3, 5, 7, .... till 997

    But in 2nd circle it will be: 1, 5, 9, 13 till 997


    Correct me if I am wrong.
    Hi AbraKaDabra,

    When I gave the clarification, I forgot to mention why during the 2nd traversal 3 will get killed and not 1.
    The reason for this is that, the circle gets "progressively" smaller as you continue to kill people one by one. So in the end when 997 survives, we don't start over from 1 again and kill 3, but kill 1 directly because 997 (the person before him survived)
    that's why in the 2nd traversal, the people alive are :-
    3, 7, 11, 15, ....

    I hope I solved your doubt...
    Are you sure? This action cannot be undone.
    Cancel
  • ISHAN TOPRE

    MemberFeb 1, 2011

    @CT:cool twins you said n=2raise to x+y
    i.e;n=2^x+y
    now if n=997 and x=1
    so we will have 997=2^1+y
    hence y=997;
    so from where did you get safest position=2Y+1?
    @AKD:How you got 2^9=512?
    can you please explain the steps you followed???
    Are you sure? This action cannot be undone.
    Cancel
Home Channels Search Login Register