Last active
August 29, 2015 14:17
-
-
Save schleary/2a414a816d51c7c0b61c to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System.IO; | |
using System; | |
using System.Collections.Generic; | |
class Program | |
{ | |
static void Main() | |
{ | |
List<String> finalist = new List<string>(Josephina(10, 2, 3)); | |
foreach (object i in finalist) | |
{ | |
Console.WriteLine(i); | |
} | |
} | |
public static List<String> CreatePeople(int number) | |
{ | |
List<string> list = new List<string>(); | |
for(int i = 0; i < number; i++) | |
{ | |
list.Add("Person" + (i+1).ToString()); | |
} | |
return list; | |
} | |
public static List<String> Josephina(int quantity, int starter, int skips) | |
{ | |
List<string> list = CreatePeople(quantity); | |
starter = starter + skips; | |
list = Recursive(list, skips, starter); | |
return list; | |
} | |
public static List<String> Recursive(List<String> list, int skips, int starter){ | |
if (list.Count == 1){ | |
return list; | |
} else if (starter < list.Count){ | |
list.RemoveAt(starter); | |
starter = skips + starter; | |
return Recursive(list, skips, starter); | |
} else { | |
starter = starter - list.Count; | |
list.RemoveAt(starter); | |
starter = skips + starter; | |
return Recursive(list, skips, starter); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment