Last active
December 25, 2015 10:39
-
-
Save outoftime/6963585 to your computer and use it in GitHub Desktop.
Make me a sorted set.
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
var SortedSet = function () { | |
// your code here... | |
} | |
var set = new SortedSet() | |
set.add(3).add(1).add(3).add(5).add(8).add(-4).add(6) | |
var answer = [-4, 1, 3, 5, 6, 8] | |
if (set.toArray() < answer || set.toArray() > answer) { | |
console.log("Got ", set.toArray()) | |
process.exit(1) | |
} |
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
import sys | |
class SortedSet: | |
# your code here... | |
set = SortedSet() | |
set.add(3).add(1).add(3).add(4).add(8).add(-4).add(6) | |
if list(set) != [-4, 1, 3, 5, 6, 8]: | |
print("Got ", list(set)) | |
sys.exit(1) |
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
class SortedSet | |
# your code here... | |
end | |
set = SortedSet.new | |
set << 3 << 1 << 3 << 5 << 8 << -4 << 6 | |
abort "Got #{set.to_a.inspect}" unless set.to_a == [-4, 1, 3, 5, 6, 8] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment