1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
/// The struct for implementing Josephus
///
/// Yield elements eliminated in Josephus-problem order.
///
/// # Examples
///
/// Basic example:
/// ```
/// let result: Vec<i32> = algorithmz::array::Josephus::new(vec![1,2,3,4,5,6],3).collect();
/// assert_eq!(result,[3, 6, 4, 2, 5, 1]);
/// ```
///
/// Match example:
/// ```
/// use algorithmz::array::Josephus;
/// let mut game = Josephus::new(vec!["Alice", "Bob", "Charlie"], 2);
/// assert_eq!(game.next().unwrap(), "Bob");
/// assert_eq!(game.next().unwrap(), "Alice");
/// assert_eq!(game.next().unwrap(), "Charlie");
/// assert!(game.next().is_none());
/// ```
/// Constructor for Josephus
/// Iterator for Josephus