     
     typealias AccumulatedResultType = AccumulatedChallengeResult<Self>
     
+    /**
+     Run all of this Challenge's entries using the same generated dataset.
+     
+     This function calls `generateDataset()` and then runs each input in the dataset through each entry in the `entries` multiple times, concurrently. It then processes all of the `CodeChallengeResult`s into `AcummulatedChallengeResult`s for each participant and returns them sorted by `totalTime`.
+     
+     - Returns: An array of `AcummulatedChallengeResult`s for each participant sorted by `totalTime`.
+    */
     func runAll() -> [AccumulatedResultType] {
         let dataset = generateDataset()
         


import Foundation

protocol CodeChallengeType {
    typealias InputType
    typealias OutputType
    
    var title: String { get }
    
    var entries: [CodeChallengeEntry<Self>] { get }
    
    func generateDataset() -> [InputType]
    func verifyOutput(output: OutputType, forInput input: InputType) -> Bool
}

struct CodeChallengeEntry<ChallengeType: CodeChallengeType> {
    let name: String
    let block: (input: ChallengeType.InputType) -> ChallengeType.OutputType
}

struct CodeChallengeResult<ChallengeType: CodeChallengeType> {
    let name: String
    let input: ChallengeType.InputType
    let output: ChallengeType.OutputType
    let time: NSTimeInterval
}

struct AccumulatedChallengeResult<ChallengeType: CodeChallengeType> {
    let name: String
    let successes: Int
    let failures: Int
    let results: [CodeChallengeResult<ChallengeType>]
    let totalTime: NSTimeInterval
    let averageTime: NSTimeInterval
    
    init(name: String, results: [CodeChallengeResult<ChallengeType>], successes: Int, failures: Int) {
        self.name = name
        self.results = results

        self.totalTime = results.reduce(0) { $0 + $1.time }
        self.averageTime = totalTime / Double(results.count)
    }
}

extension CodeChallengeType {
