[Bug] Swift standard code unable to handle the inputs in Stock Exchange Loss puzzle

Hi,

Problem:
The test 5 of the “Stock Exchange” puzzle can not be handled by the standard code provided: the timeout is reached before the input is parsed.

Steps to reproduce:

  • Open the “Stock Exchange Loss” puzzle
  • Chose Swift as programming language
  • Reset to the standard code
  • Run any test but the 5th, observe that the test fail due to an invalid output (expected behavior)
  • Run the test 5, observe that the test fails due to a timeout

Action items:

  • Increase the timeout of the validation for Swift
    OR
  • Optimie the standard parsing code to execute as efficiently as in other languages

Browser informations

  • Reproduced on Firefox 43.0.4 and Firefox 44.0
  • Timestamp: 04.02.2016
  • Windows 7 Enterprise Up-To-Date

More infos:
The code in question is:

import Foundation

public struct StderrOutputStream: OutputStreamType {
    public mutating func write(string: String) { fputs(string, stderr) }
}
public var errStream = StderrOutputStream()

/**
 * Auto-generated code below aims at helping you parse
 * the standard input according to the problem statement.
 **/

let n = Int(readLine()!)!
for i in ((readLine()!).characters.split{$0 == " "}.map(String.init)) {
    let v = Int(i)!
}

// Write an action using print("message...")
// To debug: debugPrint("Debug messages...", toStream: &errStream)

print(difference)

I found more issues with the standard code of other languages for the Stock Exchange Puzle. They are listed in another thread:

1 Like