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
| defmodule MSort do | |
| def msort([]), do: [] | |
| def msort([e]), do: [e] | |
| def msort(list) do | |
| {left, right} = Enum.split(list, div(Enum.count(list), 2)) | |
| merge(msort(left), msort(right)) | |
| end | |
| def merge(left, []), do: left | |
| def merge([], right), do: right |
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
| defmodule MSort do | |
| def msort(list) do | |
| case list do | |
| [] -> [] | |
| [e] -> [e] | |
| _ -> | |
| {left, right} = Enum.split(list, div(Enum.count(list), 2)) | |
| merge(msort(left), msort(right)) | |
| end | |
| end |
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
| diff --git a/Makefile b/Makefile | |
| index 873fb1b..20dcc64 100644 | |
| --- a/Makefile | |
| +++ b/Makefile | |
| @@ -1,4 +1,5 @@ | |
| -CC = gcc | |
| +CROSSCOMPILE ?= | |
| +CC = $(CROSSCOMPILE)gcc | |
| CWARN = -W -Wall | |
| COPT = -g -O2 |
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
| #!/usr/bin/env ruby | |
| CASES = { | |
| "" => ["", "", "", "", ""], | |
| "Some random data." => ["Some random data.", "", "", "", ""], | |
| "This information should be ignored RECORD_NUM 02 This is the information for record 2 RECORD_NUM 01 This is the information for record 1 RECORD_NUM 04 This is the information for record 4" => | |
| [" This is the information for record 1 ", " This is the information for record 2 ", "", " This is the information for record 4", ""], | |
| } | |
| def process(input, expected_record_count=5) |
OlderNewer