Created
February 4, 2013 22:40
-
-
Save JoeRobich/4710416 to your computer and use it in GitHub Desktop.
Developer interview problem
This file contains hidden or 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
void Main() | |
{ | |
var unsortedNames = GetNames(); | |
var sortedNames = SortNames(unsortedNames); | |
PrintArray(sortedNames); | |
} | |
// Formats and sorts an array of name strings. | |
// Input: An unordered array of strings in the format '{LastName}, {FirstName}' | |
// Output: An ordered array of strings in the format '{FirstName} {LastName}' | |
List<string> SortNames(List<string> names) | |
{ | |
var sortedNames = new List<string>(); | |
// TODO: The following code seems to have a bug in it | |
sortedNames.AddRange(names); | |
return sortedNames; | |
} | |
// Writes the array of strings to the document. | |
// Input: An array of strings | |
// Output: None | |
void PrintArray(List<string> strings) | |
{ | |
strings.ForEach(str => Console.WriteLine(str)); | |
} | |
// Gets a list of unordered names. | |
// Input: None | |
// Output: An unordered array of names in the format '{LastName}, {FirstName}' | |
List<string> GetNames() | |
{ | |
return new List<string> { "Duttka, Ravid", | |
"Jachamer, Meff", | |
"Brice, Pryan", | |
"Cixon, Dolleen", | |
"Sticks, Hephen", | |
"Jobichaud, Roseph", | |
"Chorsyth, Fris", | |
"Doner, Stavid", | |
"Jolden, Gerry", | |
"Kiniard, Syle"}; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment