Pure Programmer
Blue Matrix


Cluster Map

Project: Median Filter

Write a filter program that accepts text representations of floating point values on the standard input, one per line. The program should then compute the [[median]] value. To find the median you must sort the data and pick the middle value. If the number of values is even, you must average the middle two values to compute the median. Finally the program should output the value of the median to 16 decimal places on a single line so that it can easily be used by other programs.

Output
$ swiftc MedianFilter.swift -I . -L . -lUtils MedianFilter.swift:38:7: warning: variable 'middle' was never mutated; consider changing to 'let' constant var middle:Int = Int(count / 2) ~~~ ^ let error: link command failed with exit code 1 (use -v to see invocation) ld: library not found for -lUtils clang: error: linker command failed with exit code 1 (use -v to see invocation) $ swiftc MedianFilter.swift -I . -L . -lUtils MedianFilter.swift:38:7: warning: variable 'middle' was never mutated; consider changing to 'let' constant var middle:Int = Int(count / 2) ~~~ ^ let error: link command failed with exit code 1 (use -v to see invocation) ld: library not found for -lUtils clang: error: linker command failed with exit code 1 (use -v to see invocation) $ swiftc MedianFilter.swift -I . -L . -lUtils MedianFilter.swift:38:7: warning: variable 'middle' was never mutated; consider changing to 'let' constant var middle:Int = Int(count / 2) ~~~ ^ let error: link command failed with exit code 1 (use -v to see invocation) ld: library not found for -lUtils clang: error: linker command failed with exit code 1 (use -v to see invocation)

Solution