New course! Every coder should learn Generative AI!
Try a free lesson+ 69
73 is the answer.
https://code.sololearn.com/Wu9VdBoMZsoX/?ref=app
+ 31
Funny, I got 81
https://code.sololearn.com/cY4WoMH3Y0ic/#cpp
Well.. wouldn't be the first time I was wrong :D
edit fixed...
+ 21
I got my code here by Python.
And I think this is a simple one.
https://code.sololearn.com/cCLqW7Y6N8az/?ref=app
I also found the winner will be 977 for 1000 people game, 3617 for 10000, 68929 for 100000.
For other result(person - winner): 2 - 1, 3 - 3, 4 - 1, 5 - 3, 6 - 5, 7 - 7, 8 - 1, 9 - 3, 10 - 5, 11 - 7, 12 - 9, 13 - 11, 14 - 13, 15 - 15, 16 - 1, 17 - 3, 18 - 5, 19 - 7, 20 - 9, 21 - 11, 22 - 13, 23 - 15, 24 - 17, 25 - 19, 26 - 21, 27 - 23, 28 - 25, 29 - 27, 30 - 29, 31 - 31, 32 - 1, 33 - 3, 34 - 5, 35 - 7, 36 - 9, 37 - 11, 38 - 13, 39 - 15, 40 - 17, 41 - 19, 42 - 21, 43 - 23, 44 - 25, 45 - 27, 46 - 29, 47 - 31, 48 - 33, 49 - 35, 50 - 37, 51 - 39, 52 - 41, 53 - 43, 54 - 45, 55 - 47, 56 - 49, 57 - 51, 58 - 53, 59 - 55, 60 - 57, 61 - 59, 62 - 61, 63 - 63, 64 - 1, 65 - 3, 66 - 5, 67 - 7, 68 - 9, 69 - 11, 70 - 13, 71 - 15, 72 - 17, 73 - 19, 74 - 21, 75 - 23, 76 - 25, 77 - 27, 78 - 29, 79 - 31, 80 - 33, 81 - 35, 82 - 37, 83 - 39, 84 - 41, 85 - 43, 86 - 45, 87 - 47, 88 - 49, 89 - 51, 90 - 53, 91 - 55, 92 - 57, 93 - 59, 94 - 61, 95 - 63, 96 - 65, 97 - 67, 98 - 69, 99 - 71, 100 - 73
+ 19
// 73 is answer
import java.util.ArrayList ;
public class Program
{
public static void main(String[] args) {
ArrayList<Integer> a =new ArrayList(100) ;
for(int i=1;i<=100;i++)
a.add(i);
for(int i=0;a.size()!=1;i++) {
if(a.size()<i+1)
i=0;
if(a.size()==i+1)
i=-1;
a.remove(i+1);
}
System.out.print("Answer is "+a.get(0));
}
}
+ 16
oh, I got here to late... I got 73 as well. https://code.sololearn.com/ctJ27khB3fX8/#java
+ 15
https://code.sololearn.com/cOYFDi0l9T7S/?ref=app
added simple python code
answer: 73 as well
+ 13
https://en.wikipedia.org/wiki/Josephus_problem
This challenge is just the Josephus Problem.
EDIT: I would still like to see some codes solving this problem though. I just thought I would add some clarity. I think the original problem question was "which position (position 1 being the man who starts with the sword) in the circle can you sit where you will survive in the end?".
+ 13
This link helped me solving this... Watch the proof that the survivor is 2*(number of people - 2**x)+1, where 2**x is the biggest number that is smaller than the number of people
https://m.youtube.com/watch?v=uCsD3ZGzMgE
https://code.sololearn.com/cuZjxOyE6dMC/#py
+ 12
Fun fact: If there are 2**n soldiers, n being whatever positive number, 1 will always be the survivor
+ 10
In first round survive peoples are
1,3,5,7,9,11,13,15,17,19,21,23,25,27,29,31,33,35,37,39,41,43,45,47,49,51,53,55,57,59,61,63,65,67,69,71,73,75,77,79,81,83,85,87,89,91,93,95,97,99
In second round survive peoples are
1,5,9,13,17,21,25,29,33,37,41,45,49,53,57,61,65,69,73,77,81,85,89,93,97
In third round survive peoples are
1,9,17,25,33,41,49,57,65,73,81,89,97
In fourth round survived peoples are
9,25,41,57,73,89
In fourth round survived people's are
9,41,73
In fifth round survived people's are
9,73
In sixth round survived people's are
73
Hence in the last the man with the no. 73 will remains
+ 9
Krishna always wins. One day sir Krishna Ooone Daaay!
+ 9
Ah Numberphile.
1+2+3+4+...=-1/12
+ 9
On My PC I used this method to view the real answer clearly but I wasn't able to make up to 100 players on Mobile
for 100 players, the survivor is #73, but for 33 players the survivor is #3 as seen here 👇
https://code.sololearn.com/WPs84GQozGc0/?ref=app
+ 8
I at least worked on pen and paper. Good for my Math olympiad.
It can be generalized for any n number of people
+ 8
Now that the winner has been declared in an hour..
Let me save my head the math and go back to Ruby 😂😂😂😂
Congs @Teja KTY!👑 👏👏👏👏
+ 7
I used Math for that.
73.
+ 7
Math hates me, so I had to use the computer.
+ 7
A Numberphile vid covered this problem.
link:
https://m.youtube.com/watch?v=uCsD3ZGzMgE
+ 7
No need to kill anyone, find before hand who is going to be alive :)
#include<iostream>
using std::cout;
/*
kill pattern (kp), starting with 1, person 1 kills person 2, person 3 kills person 4 and so on, so kp=2
*/
int const kp=2;
template<int const np>
struct ManAlive {
static int const npa=(ManAlive<np-1> :: npa + (kp-1)) %np +1;
};
template<>
struct ManAlive<1> {
static int const npa = 1;
};
int main() {
cout << ManAlive<100>::npa << "\n";
return 0;
}
(Compile time solution)
https://code.sololearn.com/cDsxnF09ygBx/?ref=app
+ 6
All people numbered even are killed in the first round (x gives the sword to x+2). Second round (+4), Third round (+8).......
Working on the Algorithm now.