Created
March 20, 2015 23:22
-
-
Save schleary/3529f5c548187da84cc1 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() | |
{ | |
Console.WriteLine("Hello World"); | |
List<String> finalist = new List<string>(Josephina(10, 2, 3)); | |
Console.WriteLine("**********"); | |
foreach (object i in finalist) | |
{ | |
Console.WriteLine(i); | |
} | |
} | |
public static List<String> Josephina(int quantity, int starter, int skips) | |
{ | |
List<string> list = new List<string>(); | |
for(int i = 0; i < quantity; i++) | |
{ | |
list.Add("Person" + (i+1).ToString()); | |
} | |
int counter = starter - 1; | |
string initial = "false"; | |
while(list.Count > 1) | |
{ | |
for(int j=counter; j < list.Count; j+=(skips+1)) | |
{ | |
if (initial == "false"){ | |
Console.WriteLine(j); | |
Console.WriteLine("just skipping:"); | |
initial = "true"; | |
} else if (((list.Count - 1) - j) < skips){ | |
Console.WriteLine(j); | |
Console.WriteLine("skipping and removing:"); | |
Console.WriteLine(list[j]); | |
//Console.WriteLine(list.getItem(j)); | |
list.RemoveAt(j); | |
counter = ((j + skips) - list.Count); | |
j = j-1; | |
} else { | |
Console.WriteLine(j); | |
Console.WriteLine("just removing:"); | |
Console.WriteLine(list[j]); | |
list.RemoveAt(j); | |
// counter = ((j + skips) - list.Count); | |
j = j-1; | |
} | |
Console.WriteLine("END OF LOOP"); | |
} | |
} | |
Console.WriteLine("*******"); | |
Console.WriteLine(list); | |
return list; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment