├── reverse-words ├── README.md ├── doc │ └── intro.md ├── .gitignore ├── src │ └── reverse_words │ │ └── core.clj ├── project.clj ├── test │ └── reverse_words │ │ └── core_test.clj └── CHANGELOG.md ├── cake-thief ├── README.md ├── doc │ └── intro.md ├── .gitignore ├── project.clj ├── CHANGELOG.md ├── src │ └── cake_thief │ │ └── core.clj ├── test │ └── cake_thief │ │ └── core_test.clj └── LICENSE ├── making-change ├── README.md ├── doc │ └── intro.md ├── .gitignore ├── project.clj ├── src │ └── making_change │ │ └── core.clj ├── CHANGELOG.md ├── test │ └── making_change │ │ └── core_test.clj └── LICENSE ├── top-scores ├── README.md ├── doc │ └── intro.md ├── .gitignore ├── project.clj ├── src │ └── top_scores │ │ └── core.clj ├── CHANGELOG.md ├── test │ └── top_scores │ │ └── core_test.clj └── LICENSE ├── word-cloud ├── README.md ├── doc │ └── intro.md ├── .gitignore ├── project.clj ├── src │ └── word_cloud │ │ └── core.clj ├── CHANGELOG.md ├── test │ └── word_cloud │ │ └── core_test.clj └── LICENSE ├── apple-stocks ├── README.md ├── doc │ └── intro.md ├── .gitignore ├── project.clj ├── src │ └── apple_stocks │ │ └── core.clj ├── test │ └── apple_stocks │ │ └── core_test.clj ├── CHANGELOG.md └── LICENSE ├── in-place-shuffle ├── README.md ├── doc │ └── intro.md ├── .gitignore ├── project.clj ├── src │ └── in_place_shuffle │ │ └── core.clj ├── CHANGELOG.md ├── test │ └── in_place_shuffle │ │ └── core_test.clj └── LICENSE ├── bracket-validator ├── README.md ├── doc │ └── intro.md ├── .gitignore ├── project.clj ├── src │ └── bracket_validator │ │ └── core.clj ├── CHANGELOG.md └── test │ └── bracket_validator │ └── core_test.clj ├── rectangular-love ├── README.md ├── doc │ └── intro.md ├── .gitignore ├── project.clj ├── CHANGELOG.md ├── test │ └── rectangular_love │ │ └── core_test.clj └── src │ └── rectangular_love │ └── core.clj ├── find-in-ordered-set ├── README.md ├── doc │ └── intro.md ├── .gitignore ├── project.clj ├── src │ └── find_in_ordered_set │ │ └── core.clj ├── CHANGELOG.md └── test │ └── find_in_ordered_set │ └── core_test.clj ├── find-rotation-point ├── README.md ├── doc │ └── intro.md ├── .gitignore ├── project.clj ├── src │ └── find_rotation_point │ │ └── core.clj ├── CHANGELOG.md └── test │ └── find_rotation_point │ └── core_test.clj ├── merge-sorted-arrays ├── README.md ├── doc │ └── intro.md ├── .gitignore ├── project.clj ├── src │ └── merge_sorted_arrays │ │ └── core.clj ├── CHANGELOG.md └── test │ └── merge_sorted_arrays │ └── core_test.clj ├── merging-meeting-times ├── README.md ├── doc │ └── intro.md ├── .gitignore ├── project.clj ├── src │ └── merging_meeting_times │ │ └── core.clj ├── CHANGELOG.md └── test │ └── merging_meeting_times │ └── core_test.clj ├── parenthesis-matching ├── README.md ├── doc │ └── intro.md ├── .gitignore ├── project.clj ├── src │ └── parenthesis_matching │ │ └── core.clj ├── CHANGELOG.md └── test │ └── parenthesis_matching │ └── core_test.clj ├── reverse-linked-list ├── README.md ├── doc │ └── intro.md ├── .gitignore ├── src │ └── reverse_linked_list │ │ ├── list.clj │ │ └── core.clj ├── project.clj ├── test │ └── reverse_linked_list │ │ └── core_test.clj └── CHANGELOG.md ├── which-appears-twice ├── README.md ├── doc │ └── intro.md ├── .gitignore ├── project.clj ├── src │ └── which_appears_twice │ │ └── core.clj ├── CHANGELOG.md └── test │ └── which_appears_twice │ └── core_test.clj ├── balanced-binary-tree ├── README.md ├── doc │ └── intro.md ├── .gitignore ├── src │ └── balanced_binary_tree │ │ ├── core.clj │ │ └── binary_tree.clj ├── project.clj ├── CHANGELOG.md └── test │ └── balanced_binary_tree │ └── core_test.clj ├── simulate-5-sided-die ├── README.md ├── doc │ └── intro.md ├── .gitignore ├── src │ └── simulate_5_sided_die │ │ └── core.clj ├── project.clj ├── CHANGELOG.md └── test │ └── simulate_5_sided_die │ └── core_test.clj ├── simulate-7-sided-die ├── README.md ├── doc │ └── intro.md ├── .gitignore ├── project.clj ├── src │ └── simulate_7_sided_die │ │ └── core.clj ├── CHANGELOG.md └── test │ └── simulate_7_sided_die │ └── core_test.clj ├── single-riffle-shuffle ├── README.md ├── doc │ └── intro.md ├── .gitignore ├── project.clj ├── src │ └── single_riffle_shuffle │ │ └── core.clj ├── CHANGELOG.md └── test │ └── single_riffle_shuffle │ └── core_test.clj ├── binary-search-tree-checker ├── README.md ├── doc │ └── intro.md ├── .gitignore ├── project.clj ├── src │ └── binary_search_tree_checker │ │ ├── core.clj │ │ └── binary_tree.clj ├── CHANGELOG.md └── test │ └── binary_search_tree_checker │ └── core_test.clj ├── inflight-entertainment ├── README.md ├── doc │ └── intro.md ├── .gitignore ├── project.clj ├── src │ └── inflight_entertainment │ │ └── core.clj ├── CHANGELOG.md └── test │ └── inflight_entertainment │ └── core_test.clj ├── permutation-palindrome ├── README.md ├── doc │ └── intro.md ├── .gitignore ├── project.clj ├── src │ └── permutation_palindrome │ │ └── core.clj ├── CHANGELOG.md └── test │ └── permutation_palindrome │ └── core_test.clj ├── compute-nth-fibbonacci-number ├── README.md ├── doc │ └── intro.md ├── .gitignore ├── src │ └── compute_nth_fibbonacci_number │ │ └── core.clj ├── project.clj ├── test │ └── compute_nth_fibbonacci_number │ │ └── core_test.clj └── CHANGELOG.md ├── highest-product-of-three ├── README.md ├── doc │ └── intro.md ├── .gitignore ├── project.clj ├── src │ └── highest_product_of_three │ │ └── core.clj ├── CHANGELOG.md └── test │ └── highest_product_of_three │ └── core_test.clj ├── reverse-string-in-place ├── README.md ├── doc │ └── intro.md ├── .gitignore ├── project.clj ├── src │ └── reverse_string_in_place │ │ └── core.clj ├── test │ └── reverse_string_in_place │ │ └── core_test.clj └── CHANGELOG.md ├── product-of-all-other-numbers ├── README.md ├── doc │ └── intro.md ├── .gitignore ├── project.clj ├── src │ └── product_of_all_other_numbers │ │ └── core.clj ├── CHANGELOG.md └── test │ └── product_of_all_other_numbers │ └── core_test.clj ├── find-repeat-space-edition ├── README.md ├── doc │ └── intro.md ├── .gitignore ├── project.clj ├── CHANGELOG.md ├── test │ └── find_repeat_space_edition │ │ └── core_test.clj └── src │ └── find_repeat_space_edition │ └── core.clj ├── kth-to-last-linked-list ├── README.md ├── doc │ └── intro.md ├── .gitignore ├── src │ └── kth_to_last_linked_list │ │ ├── core.clj │ │ └── list.clj ├── project.clj ├── CHANGELOG.md └── test │ └── kth_to_last_linked_list │ └── core_test.clj ├── recursive-string-permutations ├── README.md ├── doc │ └── intro.md ├── .gitignore ├── project.clj ├── src │ └── recursive_string_permutations │ │ └── core.clj ├── CHANGELOG.md └── test │ └── recursive_string_permutations │ └── core_test.clj ├── the-stolen-breakfast-drone ├── README.md ├── doc │ └── intro.md ├── .gitignore ├── project.clj ├── src │ └── the_stolen_breakfast_drone │ │ └── core.clj ├── CHANGELOG.md └── test │ └── the_stolen_breakfast_drone │ └── core_test.clj ├── second-largest-in-binary-search-tree ├── README.md ├── doc │ └── intro.md ├── .gitignore ├── project.clj ├── src │ └── second_largest_in_binary_search_tree │ │ ├── core.clj │ │ └── binary_tree.clj ├── CHANGELOG.md └── test │ └── second_largest_in_binary_search_tree │ └── core_test.clj ├── .gitignore ├── .editorconfig └── README.md /reverse-words/README.md: -------------------------------------------------------------------------------- 1 | # reverse-words 2 | 3 | FIXME: description 4 | -------------------------------------------------------------------------------- /cake-thief/README.md: -------------------------------------------------------------------------------- 1 | # cake-thief 2 | 3 | https://www.interviewcake.com/question/cake-thief 4 | -------------------------------------------------------------------------------- /making-change/README.md: -------------------------------------------------------------------------------- 1 | # making-change 2 | 3 | https://www.interviewcake.com/question/coin 4 | -------------------------------------------------------------------------------- /top-scores/README.md: -------------------------------------------------------------------------------- 1 | # top-scores 2 | 3 | https://www.interviewcake.com/question/top-scores 4 | -------------------------------------------------------------------------------- /word-cloud/README.md: -------------------------------------------------------------------------------- 1 | # word-cloud 2 | 3 | https://www.interviewcake.com/question/word-cloud 4 | -------------------------------------------------------------------------------- /apple-stocks/README.md: -------------------------------------------------------------------------------- 1 | # apple-stocks 2 | 3 | https://www.interviewcake.com/question/stock-price 4 | -------------------------------------------------------------------------------- /in-place-shuffle/README.md: -------------------------------------------------------------------------------- 1 | # in-place-shuffle 2 | 3 | https://www.interviewcake.com/question/shuffle 4 | -------------------------------------------------------------------------------- /bracket-validator/README.md: -------------------------------------------------------------------------------- 1 | # bracket-validator 2 | 3 | https://www.interviewcake.com/question/bracket-validator 4 | -------------------------------------------------------------------------------- /rectangular-love/README.md: -------------------------------------------------------------------------------- 1 | # rectangular-love 2 | 3 | https://www.interviewcake.com/question/rectangular-love 4 | -------------------------------------------------------------------------------- /find-in-ordered-set/README.md: -------------------------------------------------------------------------------- 1 | # find-in-ordered-set 2 | 3 | https://www.interviewcake.com/question/find-in-ordered-set 4 | -------------------------------------------------------------------------------- /find-rotation-point/README.md: -------------------------------------------------------------------------------- 1 | # find-rotation-point 2 | 3 | https://www.interviewcake.com/question/find-rotation-point 4 | -------------------------------------------------------------------------------- /merge-sorted-arrays/README.md: -------------------------------------------------------------------------------- 1 | # merge-sorted-arrays 2 | 3 | https://www.interviewcake.com/question/merge-sorted-arrays 4 | -------------------------------------------------------------------------------- /merging-meeting-times/README.md: -------------------------------------------------------------------------------- 1 | # merging-meeting-times 2 | 3 | https://www.interviewcake.com/question/merging-ranges 4 | -------------------------------------------------------------------------------- /parenthesis-matching/README.md: -------------------------------------------------------------------------------- 1 | # parenthesis-matching 2 | 3 | https://www.interviewcake.com/question/matching-parens 4 | -------------------------------------------------------------------------------- /reverse-linked-list/README.md: -------------------------------------------------------------------------------- 1 | # reverse-linked-list 2 | 3 | https://www.interviewcake.com/question/reverse-linked-list 4 | -------------------------------------------------------------------------------- /which-appears-twice/README.md: -------------------------------------------------------------------------------- 1 | # which-appears-twice 2 | 3 | https://www.interviewcake.com/question/which-appears-twice 4 | -------------------------------------------------------------------------------- /balanced-binary-tree/README.md: -------------------------------------------------------------------------------- 1 | # balanced-binary-tree 2 | 3 | https://www.interviewcake.com/question/balanced-binary-tree 4 | -------------------------------------------------------------------------------- /simulate-5-sided-die/README.md: -------------------------------------------------------------------------------- 1 | # simulate-5-sided-die 2 | 3 | https://www.interviewcake.com/question/simulate-5-sided-die 4 | -------------------------------------------------------------------------------- /simulate-7-sided-die/README.md: -------------------------------------------------------------------------------- 1 | # simulate-7-sided-die 2 | 3 | https://www.interviewcake.com/question/simulate-7-sided-die 4 | -------------------------------------------------------------------------------- /single-riffle-shuffle/README.md: -------------------------------------------------------------------------------- 1 | # single-riffle-shuffle 2 | 3 | https://www.interviewcake.com/question/single-rifle-check 4 | -------------------------------------------------------------------------------- /binary-search-tree-checker/README.md: -------------------------------------------------------------------------------- 1 | # binary-search-tree-checker 2 | 3 | https://www.interviewcake.com/question/bst-checker 4 | -------------------------------------------------------------------------------- /inflight-entertainment/README.md: -------------------------------------------------------------------------------- 1 | # inflight-entertainment 2 | 3 | https://www.interviewcake.com/question/inflight-entertainment 4 | -------------------------------------------------------------------------------- /permutation-palindrome/README.md: -------------------------------------------------------------------------------- 1 | # permutation-palindrome 2 | 3 | https://www.interviewcake.com/question/permutation-palindrome 4 | -------------------------------------------------------------------------------- /compute-nth-fibbonacci-number/README.md: -------------------------------------------------------------------------------- 1 | # compute-nth-fibbonacci-number 2 | 3 | https://www.interviewcake.com/question/nth-fibonacci 4 | -------------------------------------------------------------------------------- /highest-product-of-three/README.md: -------------------------------------------------------------------------------- 1 | # highest-product-of-three 2 | 3 | https://www.interviewcake.com/question/highest-product-of-3 4 | -------------------------------------------------------------------------------- /reverse-string-in-place/README.md: -------------------------------------------------------------------------------- 1 | # reverse-string-in-place 2 | 3 | https://www.interviewcake.com/question/reverse-string-in-place 4 | -------------------------------------------------------------------------------- /cake-thief/doc/intro.md: -------------------------------------------------------------------------------- 1 | # Introduction to cake-thief 2 | 3 | TODO: write [great documentation](http://jacobian.org/writing/what-to-write/) 4 | -------------------------------------------------------------------------------- /top-scores/doc/intro.md: -------------------------------------------------------------------------------- 1 | # Introduction to top-scores 2 | 3 | TODO: write [great documentation](http://jacobian.org/writing/what-to-write/) 4 | -------------------------------------------------------------------------------- /word-cloud/doc/intro.md: -------------------------------------------------------------------------------- 1 | # Introduction to word-cloud 2 | 3 | TODO: write [great documentation](http://jacobian.org/writing/what-to-write/) 4 | -------------------------------------------------------------------------------- /apple-stocks/doc/intro.md: -------------------------------------------------------------------------------- 1 | # Introduction to apple-stocks 2 | 3 | TODO: write [great documentation](http://jacobian.org/writing/what-to-write/) 4 | -------------------------------------------------------------------------------- /product-of-all-other-numbers/README.md: -------------------------------------------------------------------------------- 1 | # product-of-all-other-numbers 2 | 3 | https://www.interviewcake.com/question/product-of-other-numbers 4 | -------------------------------------------------------------------------------- /find-repeat-space-edition/README.md: -------------------------------------------------------------------------------- 1 | # find-repeat-space-edition 2 | 3 | https://www.interviewcake.com/question/find-duplicate-optimize-for-space 4 | -------------------------------------------------------------------------------- /kth-to-last-linked-list/README.md: -------------------------------------------------------------------------------- 1 | # kth-to-last-linked-list 2 | 3 | https://www.interviewcake.com/question/kth-to-last-node-in-singly-linked-list 4 | -------------------------------------------------------------------------------- /making-change/doc/intro.md: -------------------------------------------------------------------------------- 1 | # Introduction to making-change 2 | 3 | TODO: write [great documentation](http://jacobian.org/writing/what-to-write/) 4 | -------------------------------------------------------------------------------- /recursive-string-permutations/README.md: -------------------------------------------------------------------------------- 1 | # recursive-string-permutations 2 | 3 | https://www.interviewcake.com/question/recursive-string-permutations 4 | -------------------------------------------------------------------------------- /reverse-words/doc/intro.md: -------------------------------------------------------------------------------- 1 | # Introduction to reverse-words 2 | 3 | TODO: write [great documentation](http://jacobian.org/writing/what-to-write/) 4 | -------------------------------------------------------------------------------- /the-stolen-breakfast-drone/README.md: -------------------------------------------------------------------------------- 1 | # the-stolen-breakfast-drone 2 | 3 | https://www.interviewcake.com/question/find-unique-int-among-duplicates 4 | -------------------------------------------------------------------------------- /bracket-validator/doc/intro.md: -------------------------------------------------------------------------------- 1 | # Introduction to bracket-validator 2 | 3 | TODO: write [great documentation](http://jacobian.org/writing/what-to-write/) 4 | -------------------------------------------------------------------------------- /in-place-shuffle/doc/intro.md: -------------------------------------------------------------------------------- 1 | # Introduction to in-place-shuffle 2 | 3 | TODO: write [great documentation](http://jacobian.org/writing/what-to-write/) 4 | -------------------------------------------------------------------------------- /rectangular-love/doc/intro.md: -------------------------------------------------------------------------------- 1 | # Introduction to rectangular-love 2 | 3 | TODO: write [great documentation](http://jacobian.org/writing/what-to-write/) 4 | -------------------------------------------------------------------------------- /balanced-binary-tree/doc/intro.md: -------------------------------------------------------------------------------- 1 | # Introduction to balanced-binary-tree 2 | 3 | TODO: write [great documentation](http://jacobian.org/writing/what-to-write/) 4 | -------------------------------------------------------------------------------- /find-in-ordered-set/doc/intro.md: -------------------------------------------------------------------------------- 1 | # Introduction to find-in-ordered-set 2 | 3 | TODO: write [great documentation](http://jacobian.org/writing/what-to-write/) 4 | -------------------------------------------------------------------------------- /find-rotation-point/doc/intro.md: -------------------------------------------------------------------------------- 1 | # Introduction to find-rotation-point 2 | 3 | TODO: write [great documentation](http://jacobian.org/writing/what-to-write/) 4 | -------------------------------------------------------------------------------- /merge-sorted-arrays/doc/intro.md: -------------------------------------------------------------------------------- 1 | # Introduction to merge-sorted-arrays 2 | 3 | TODO: write [great documentation](http://jacobian.org/writing/what-to-write/) 4 | -------------------------------------------------------------------------------- /parenthesis-matching/doc/intro.md: -------------------------------------------------------------------------------- 1 | # Introduction to parenthesis-matching 2 | 3 | TODO: write [great documentation](http://jacobian.org/writing/what-to-write/) 4 | -------------------------------------------------------------------------------- /reverse-linked-list/doc/intro.md: -------------------------------------------------------------------------------- 1 | # Introduction to reverse-linked-list 2 | 3 | TODO: write [great documentation](http://jacobian.org/writing/what-to-write/) 4 | -------------------------------------------------------------------------------- /simulate-5-sided-die/doc/intro.md: -------------------------------------------------------------------------------- 1 | # Introduction to simulate-5-sided-die 2 | 3 | TODO: write [great documentation](http://jacobian.org/writing/what-to-write/) 4 | -------------------------------------------------------------------------------- /simulate-7-sided-die/doc/intro.md: -------------------------------------------------------------------------------- 1 | # Introduction to simulate-7-sided-die 2 | 3 | TODO: write [great documentation](http://jacobian.org/writing/what-to-write/) 4 | -------------------------------------------------------------------------------- /which-appears-twice/doc/intro.md: -------------------------------------------------------------------------------- 1 | # Introduction to which-appears-twice 2 | 3 | TODO: write [great documentation](http://jacobian.org/writing/what-to-write/) 4 | -------------------------------------------------------------------------------- /inflight-entertainment/doc/intro.md: -------------------------------------------------------------------------------- 1 | # Introduction to inflight-entertainment 2 | 3 | TODO: write [great documentation](http://jacobian.org/writing/what-to-write/) 4 | -------------------------------------------------------------------------------- /merging-meeting-times/doc/intro.md: -------------------------------------------------------------------------------- 1 | # Introduction to merging-meeting-times 2 | 3 | TODO: write [great documentation](http://jacobian.org/writing/what-to-write/) 4 | -------------------------------------------------------------------------------- /permutation-palindrome/doc/intro.md: -------------------------------------------------------------------------------- 1 | # Introduction to permutation-palindrome 2 | 3 | TODO: write [great documentation](http://jacobian.org/writing/what-to-write/) 4 | -------------------------------------------------------------------------------- /second-largest-in-binary-search-tree/README.md: -------------------------------------------------------------------------------- 1 | # second-largest-in-binary-search-tree 2 | 3 | https://www.interviewcake.com/question/second-largest-item-in-bst 4 | -------------------------------------------------------------------------------- /single-riffle-shuffle/doc/intro.md: -------------------------------------------------------------------------------- 1 | # Introduction to single-riffle-shuffle 2 | 3 | TODO: write [great documentation](http://jacobian.org/writing/what-to-write/) 4 | -------------------------------------------------------------------------------- /find-repeat-space-edition/doc/intro.md: -------------------------------------------------------------------------------- 1 | # Introduction to find-repeat-space-edition 2 | 3 | TODO: write [great documentation](http://jacobian.org/writing/what-to-write/) 4 | -------------------------------------------------------------------------------- /highest-product-of-three/doc/intro.md: -------------------------------------------------------------------------------- 1 | # Introduction to highest-product-of-three 2 | 3 | TODO: write [great documentation](http://jacobian.org/writing/what-to-write/) 4 | -------------------------------------------------------------------------------- /kth-to-last-linked-list/doc/intro.md: -------------------------------------------------------------------------------- 1 | # Introduction to kth-to-last-linked-list 2 | 3 | TODO: write [great documentation](http://jacobian.org/writing/what-to-write/) 4 | -------------------------------------------------------------------------------- /reverse-string-in-place/doc/intro.md: -------------------------------------------------------------------------------- 1 | # Introduction to reverse-string-in-place 2 | 3 | TODO: write [great documentation](http://jacobian.org/writing/what-to-write/) 4 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | /target 2 | /classes 3 | /checkouts 4 | pom.xml 5 | pom.xml.asc 6 | *.jar 7 | *.class 8 | /.lein-* 9 | /.nrepl-port 10 | .hgignore 11 | .hg/ 12 | TODO.md 13 | -------------------------------------------------------------------------------- /apple-stocks/.gitignore: -------------------------------------------------------------------------------- 1 | /target 2 | /classes 3 | /checkouts 4 | pom.xml 5 | pom.xml.asc 6 | *.jar 7 | *.class 8 | /.lein-* 9 | /.nrepl-port 10 | .hgignore 11 | .hg/ 12 | -------------------------------------------------------------------------------- /binary-search-tree-checker/doc/intro.md: -------------------------------------------------------------------------------- 1 | # Introduction to binary-search-tree-checker 2 | 3 | TODO: write [great documentation](http://jacobian.org/writing/what-to-write/) 4 | -------------------------------------------------------------------------------- /cake-thief/.gitignore: -------------------------------------------------------------------------------- 1 | /target 2 | /classes 3 | /checkouts 4 | pom.xml 5 | pom.xml.asc 6 | *.jar 7 | *.class 8 | /.lein-* 9 | /.nrepl-port 10 | .hgignore 11 | .hg/ 12 | -------------------------------------------------------------------------------- /the-stolen-breakfast-drone/doc/intro.md: -------------------------------------------------------------------------------- 1 | # Introduction to the-stolen-breakfast-drone 2 | 3 | TODO: write [great documentation](http://jacobian.org/writing/what-to-write/) 4 | -------------------------------------------------------------------------------- /top-scores/.gitignore: -------------------------------------------------------------------------------- 1 | /target 2 | /classes 3 | /checkouts 4 | pom.xml 5 | pom.xml.asc 6 | *.jar 7 | *.class 8 | /.lein-* 9 | /.nrepl-port 10 | .hgignore 11 | .hg/ 12 | -------------------------------------------------------------------------------- /word-cloud/.gitignore: -------------------------------------------------------------------------------- 1 | /target 2 | /classes 3 | /checkouts 4 | pom.xml 5 | pom.xml.asc 6 | *.jar 7 | *.class 8 | /.lein-* 9 | /.nrepl-port 10 | .hgignore 11 | .hg/ 12 | -------------------------------------------------------------------------------- /bracket-validator/.gitignore: -------------------------------------------------------------------------------- 1 | /target 2 | /classes 3 | /checkouts 4 | pom.xml 5 | pom.xml.asc 6 | *.jar 7 | *.class 8 | /.lein-* 9 | /.nrepl-port 10 | .hgignore 11 | .hg/ 12 | -------------------------------------------------------------------------------- /compute-nth-fibbonacci-number/doc/intro.md: -------------------------------------------------------------------------------- 1 | # Introduction to compute-nth-fibbonacci-number 2 | 3 | TODO: write [great documentation](http://jacobian.org/writing/what-to-write/) 4 | -------------------------------------------------------------------------------- /in-place-shuffle/.gitignore: -------------------------------------------------------------------------------- 1 | /target 2 | /classes 3 | /checkouts 4 | pom.xml 5 | pom.xml.asc 6 | *.jar 7 | *.class 8 | /.lein-* 9 | /.nrepl-port 10 | .hgignore 11 | .hg/ 12 | -------------------------------------------------------------------------------- /making-change/.gitignore: -------------------------------------------------------------------------------- 1 | /target 2 | /classes 3 | /checkouts 4 | pom.xml 5 | pom.xml.asc 6 | *.jar 7 | *.class 8 | /.lein-* 9 | /.nrepl-port 10 | .hgignore 11 | .hg/ 12 | -------------------------------------------------------------------------------- /product-of-all-other-numbers/doc/intro.md: -------------------------------------------------------------------------------- 1 | # Introduction to product-of-all-other-numbers 2 | 3 | TODO: write [great documentation](http://jacobian.org/writing/what-to-write/) 4 | -------------------------------------------------------------------------------- /rectangular-love/.gitignore: -------------------------------------------------------------------------------- 1 | /target 2 | /classes 3 | /checkouts 4 | pom.xml 5 | pom.xml.asc 6 | *.jar 7 | *.class 8 | /.lein-* 9 | /.nrepl-port 10 | .hgignore 11 | .hg/ 12 | -------------------------------------------------------------------------------- /recursive-string-permutations/doc/intro.md: -------------------------------------------------------------------------------- 1 | # Introduction to recursive-string-permutations 2 | 3 | TODO: write [great documentation](http://jacobian.org/writing/what-to-write/) 4 | -------------------------------------------------------------------------------- /reverse-words/.gitignore: -------------------------------------------------------------------------------- 1 | /target 2 | /classes 3 | /checkouts 4 | pom.xml 5 | pom.xml.asc 6 | *.jar 7 | *.class 8 | /.lein-* 9 | /.nrepl-port 10 | .hgignore 11 | .hg/ 12 | -------------------------------------------------------------------------------- /balanced-binary-tree/.gitignore: -------------------------------------------------------------------------------- 1 | /target 2 | /classes 3 | /checkouts 4 | pom.xml 5 | pom.xml.asc 6 | *.jar 7 | *.class 8 | /.lein-* 9 | /.nrepl-port 10 | .hgignore 11 | .hg/ 12 | -------------------------------------------------------------------------------- /find-in-ordered-set/.gitignore: -------------------------------------------------------------------------------- 1 | /target 2 | /classes 3 | /checkouts 4 | pom.xml 5 | pom.xml.asc 6 | *.jar 7 | *.class 8 | /.lein-* 9 | /.nrepl-port 10 | .hgignore 11 | .hg/ 12 | -------------------------------------------------------------------------------- /find-rotation-point/.gitignore: -------------------------------------------------------------------------------- 1 | /target 2 | /classes 3 | /checkouts 4 | pom.xml 5 | pom.xml.asc 6 | *.jar 7 | *.class 8 | /.lein-* 9 | /.nrepl-port 10 | .hgignore 11 | .hg/ 12 | -------------------------------------------------------------------------------- /inflight-entertainment/.gitignore: -------------------------------------------------------------------------------- 1 | /target 2 | /classes 3 | /checkouts 4 | pom.xml 5 | pom.xml.asc 6 | *.jar 7 | *.class 8 | /.lein-* 9 | /.nrepl-port 10 | .hgignore 11 | .hg/ 12 | -------------------------------------------------------------------------------- /merge-sorted-arrays/.gitignore: -------------------------------------------------------------------------------- 1 | /target 2 | /classes 3 | /checkouts 4 | pom.xml 5 | pom.xml.asc 6 | *.jar 7 | *.class 8 | /.lein-* 9 | /.nrepl-port 10 | .hgignore 11 | .hg/ 12 | -------------------------------------------------------------------------------- /merging-meeting-times/.gitignore: -------------------------------------------------------------------------------- 1 | /target 2 | /classes 3 | /checkouts 4 | pom.xml 5 | pom.xml.asc 6 | *.jar 7 | *.class 8 | /.lein-* 9 | /.nrepl-port 10 | .hgignore 11 | .hg/ 12 | -------------------------------------------------------------------------------- /parenthesis-matching/.gitignore: -------------------------------------------------------------------------------- 1 | /target 2 | /classes 3 | /checkouts 4 | pom.xml 5 | pom.xml.asc 6 | *.jar 7 | *.class 8 | /.lein-* 9 | /.nrepl-port 10 | .hgignore 11 | .hg/ 12 | -------------------------------------------------------------------------------- /permutation-palindrome/.gitignore: -------------------------------------------------------------------------------- 1 | /target 2 | /classes 3 | /checkouts 4 | pom.xml 5 | pom.xml.asc 6 | *.jar 7 | *.class 8 | /.lein-* 9 | /.nrepl-port 10 | .hgignore 11 | .hg/ 12 | -------------------------------------------------------------------------------- /reverse-linked-list/.gitignore: -------------------------------------------------------------------------------- 1 | /target 2 | /classes 3 | /checkouts 4 | pom.xml 5 | pom.xml.asc 6 | *.jar 7 | *.class 8 | /.lein-* 9 | /.nrepl-port 10 | .hgignore 11 | .hg/ 12 | -------------------------------------------------------------------------------- /simulate-5-sided-die/.gitignore: -------------------------------------------------------------------------------- 1 | /target 2 | /classes 3 | /checkouts 4 | pom.xml 5 | pom.xml.asc 6 | *.jar 7 | *.class 8 | /.lein-* 9 | /.nrepl-port 10 | .hgignore 11 | .hg/ 12 | -------------------------------------------------------------------------------- /simulate-7-sided-die/.gitignore: -------------------------------------------------------------------------------- 1 | /target 2 | /classes 3 | /checkouts 4 | pom.xml 5 | pom.xml.asc 6 | *.jar 7 | *.class 8 | /.lein-* 9 | /.nrepl-port 10 | .hgignore 11 | .hg/ 12 | -------------------------------------------------------------------------------- /single-riffle-shuffle/.gitignore: -------------------------------------------------------------------------------- 1 | /target 2 | /classes 3 | /checkouts 4 | pom.xml 5 | pom.xml.asc 6 | *.jar 7 | *.class 8 | /.lein-* 9 | /.nrepl-port 10 | .hgignore 11 | .hg/ 12 | -------------------------------------------------------------------------------- /which-appears-twice/.gitignore: -------------------------------------------------------------------------------- 1 | /target 2 | /classes 3 | /checkouts 4 | pom.xml 5 | pom.xml.asc 6 | *.jar 7 | *.class 8 | /.lein-* 9 | /.nrepl-port 10 | .hgignore 11 | .hg/ 12 | -------------------------------------------------------------------------------- /binary-search-tree-checker/.gitignore: -------------------------------------------------------------------------------- 1 | /target 2 | /classes 3 | /checkouts 4 | pom.xml 5 | pom.xml.asc 6 | *.jar 7 | *.class 8 | /.lein-* 9 | /.nrepl-port 10 | .hgignore 11 | .hg/ 12 | -------------------------------------------------------------------------------- /find-repeat-space-edition/.gitignore: -------------------------------------------------------------------------------- 1 | /target 2 | /classes 3 | /checkouts 4 | pom.xml 5 | pom.xml.asc 6 | *.jar 7 | *.class 8 | /.lein-* 9 | /.nrepl-port 10 | .hgignore 11 | .hg/ 12 | -------------------------------------------------------------------------------- /highest-product-of-three/.gitignore: -------------------------------------------------------------------------------- 1 | /target 2 | /classes 3 | /checkouts 4 | pom.xml 5 | pom.xml.asc 6 | *.jar 7 | *.class 8 | /.lein-* 9 | /.nrepl-port 10 | .hgignore 11 | .hg/ 12 | -------------------------------------------------------------------------------- /kth-to-last-linked-list/.gitignore: -------------------------------------------------------------------------------- 1 | /target 2 | /classes 3 | /checkouts 4 | pom.xml 5 | pom.xml.asc 6 | *.jar 7 | *.class 8 | /.lein-* 9 | /.nrepl-port 10 | .hgignore 11 | .hg/ 12 | -------------------------------------------------------------------------------- /reverse-string-in-place/.gitignore: -------------------------------------------------------------------------------- 1 | /target 2 | /classes 3 | /checkouts 4 | pom.xml 5 | pom.xml.asc 6 | *.jar 7 | *.class 8 | /.lein-* 9 | /.nrepl-port 10 | .hgignore 11 | .hg/ 12 | -------------------------------------------------------------------------------- /the-stolen-breakfast-drone/.gitignore: -------------------------------------------------------------------------------- 1 | /target 2 | /classes 3 | /checkouts 4 | pom.xml 5 | pom.xml.asc 6 | *.jar 7 | *.class 8 | /.lein-* 9 | /.nrepl-port 10 | .hgignore 11 | .hg/ 12 | -------------------------------------------------------------------------------- /compute-nth-fibbonacci-number/.gitignore: -------------------------------------------------------------------------------- 1 | /target 2 | /classes 3 | /checkouts 4 | pom.xml 5 | pom.xml.asc 6 | *.jar 7 | *.class 8 | /.lein-* 9 | /.nrepl-port 10 | .hgignore 11 | .hg/ 12 | -------------------------------------------------------------------------------- /product-of-all-other-numbers/.gitignore: -------------------------------------------------------------------------------- 1 | /target 2 | /classes 3 | /checkouts 4 | pom.xml 5 | pom.xml.asc 6 | *.jar 7 | *.class 8 | /.lein-* 9 | /.nrepl-port 10 | .hgignore 11 | .hg/ 12 | -------------------------------------------------------------------------------- /recursive-string-permutations/.gitignore: -------------------------------------------------------------------------------- 1 | /target 2 | /classes 3 | /checkouts 4 | pom.xml 5 | pom.xml.asc 6 | *.jar 7 | *.class 8 | /.lein-* 9 | /.nrepl-port 10 | .hgignore 11 | .hg/ 12 | -------------------------------------------------------------------------------- /second-largest-in-binary-search-tree/doc/intro.md: -------------------------------------------------------------------------------- 1 | # Introduction to second-largest-in-binary-search-tree 2 | 3 | TODO: write [great documentation](http://jacobian.org/writing/what-to-write/) 4 | -------------------------------------------------------------------------------- /second-largest-in-binary-search-tree/.gitignore: -------------------------------------------------------------------------------- 1 | /target 2 | /classes 3 | /checkouts 4 | pom.xml 5 | pom.xml.asc 6 | *.jar 7 | *.class 8 | /.lein-* 9 | /.nrepl-port 10 | .hgignore 11 | .hg/ 12 | -------------------------------------------------------------------------------- /.editorconfig: -------------------------------------------------------------------------------- 1 | # editorconfig.org 2 | root = true 3 | 4 | [*] 5 | indent_style = space 6 | indent_size = 2 7 | end_of_line = lf 8 | charset = utf-8 9 | trim_trailing_whitespace = true 10 | insert_final_newline = true 11 | 12 | [*.md] 13 | trim_trailing_whitespace = false 14 | -------------------------------------------------------------------------------- /balanced-binary-tree/src/balanced_binary_tree/core.clj: -------------------------------------------------------------------------------- 1 | (ns balanced-binary-tree.core 2 | (:require [balanced-binary-tree.binary-tree :as tree]) 3 | (:gen-class)) 4 | 5 | (defn balanced? 6 | "O(n) time solution." 7 | [root] 8 | (>= 1 (- (tree/max-height root) (tree/min-height root)))) 9 | -------------------------------------------------------------------------------- /reverse-linked-list/src/reverse_linked_list/list.clj: -------------------------------------------------------------------------------- 1 | (ns reverse-linked-list.list 2 | (:gen-class)) 3 | 4 | (defn node [value] 5 | {:value value :next nil}) 6 | 7 | (defn insert [head value] 8 | (if (empty? head) 9 | (node value) 10 | (assoc (node value) :next head))) 11 | 12 | (defn coll->list [coll] 13 | (reduce insert {} (reverse coll))) 14 | -------------------------------------------------------------------------------- /simulate-5-sided-die/src/simulate_5_sided_die/core.clj: -------------------------------------------------------------------------------- 1 | (ns simulate-5-sided-die.core 2 | (:gen-class)) 3 | 4 | (defn- random [floor ceiling] 5 | (+ floor (rand-int (inc (- ceiling floor))))) 6 | 7 | (defn- rand7 [] 8 | (random 1 7)) 9 | 10 | (defn rand5 [] 11 | (loop [rand (rand7)] 12 | (if (<= rand 5) 13 | rand 14 | (recur (rand7))))) 15 | -------------------------------------------------------------------------------- /compute-nth-fibbonacci-number/src/compute_nth_fibbonacci_number/core.clj: -------------------------------------------------------------------------------- 1 | (ns compute-nth-fibbonacci-number.core 2 | (:gen-class)) 3 | 4 | (defn fib-seq 5 | ([] 6 | (fib-seq 0 1)) 7 | ([a b] 8 | (cons a (lazy-seq (fib-seq b (+ a b)))))) 9 | 10 | (defn fib 11 | "O(n) time solution - lazy and bottom up" 12 | [n] 13 | (last (take (inc n) (fib-seq)))) 14 | -------------------------------------------------------------------------------- /reverse-words/src/reverse_words/core.clj: -------------------------------------------------------------------------------- 1 | (ns reverse-words.core 2 | (:require [clojure.string :as str]) 3 | (:gen-class)) 4 | 5 | ;; This problem gets much more challenging in-place with mutable strings 6 | ;; not going to attempt 7 | (defn reverse-words 8 | "O(n) time solution - using built in functions" 9 | [s] 10 | (str/join #" " (reverse (str/split s #" ")))) 11 | -------------------------------------------------------------------------------- /kth-to-last-linked-list/src/kth_to_last_linked_list/core.clj: -------------------------------------------------------------------------------- 1 | (ns kth-to-last-linked-list.core 2 | (:require [kth-to-last-linked-list.list :as list]) 3 | (:gen-class)) 4 | 5 | (defn kth-to-last-node 6 | "O(n) time solution." 7 | [head k] 8 | (let [k-idx (- (dec (list/length head)) k)] 9 | (when-not (neg? k-idx) 10 | (->> (range k-idx) 11 | (reduce :next head) 12 | :value)))) 13 | -------------------------------------------------------------------------------- /cake-thief/project.clj: -------------------------------------------------------------------------------- 1 | (defproject cake-thief "0.1.0-SNAPSHOT" 2 | :description "FIXME: write description" 3 | :url "http://example.com/FIXME" 4 | :license {:name "Eclipse Public License" 5 | :url "http://www.eclipse.org/legal/epl-v10.html"} 6 | :dependencies [[org.clojure/clojure "1.8.0"]] 7 | :main ^:skip-aot cake-thief.core 8 | :target-path "target/%s" 9 | :profiles {:uberjar {:aot :all}}) 10 | -------------------------------------------------------------------------------- /top-scores/project.clj: -------------------------------------------------------------------------------- 1 | (defproject top-scores "0.1.0-SNAPSHOT" 2 | :description "FIXME: write description" 3 | :url "http://example.com/FIXME" 4 | :license {:name "Eclipse Public License" 5 | :url "http://www.eclipse.org/legal/epl-v10.html"} 6 | :dependencies [[org.clojure/clojure "1.8.0"]] 7 | :main ^:skip-aot top-scores.core 8 | :target-path "target/%s" 9 | :profiles {:uberjar {:aot :all}}) 10 | -------------------------------------------------------------------------------- /word-cloud/project.clj: -------------------------------------------------------------------------------- 1 | (defproject word-cloud "0.1.0-SNAPSHOT" 2 | :description "FIXME: write description" 3 | :url "http://example.com/FIXME" 4 | :license {:name "Eclipse Public License" 5 | :url "http://www.eclipse.org/legal/epl-v10.html"} 6 | :dependencies [[org.clojure/clojure "1.8.0"]] 7 | :main ^:skip-aot word-cloud.core 8 | :target-path "target/%s" 9 | :profiles {:uberjar {:aot :all}}) 10 | -------------------------------------------------------------------------------- /apple-stocks/project.clj: -------------------------------------------------------------------------------- 1 | (defproject apple-stocks "0.1.0-SNAPSHOT" 2 | :description "FIXME: write description" 3 | :url "http://example.com/FIXME" 4 | :license {:name "Eclipse Public License" 5 | :url "http://www.eclipse.org/legal/epl-v10.html"} 6 | :dependencies [[org.clojure/clojure "1.8.0"]] 7 | :main ^:skip-aot apple-stocks.core 8 | :target-path "target/%s" 9 | :profiles {:uberjar {:aot :all}}) 10 | -------------------------------------------------------------------------------- /making-change/project.clj: -------------------------------------------------------------------------------- 1 | (defproject making-change "0.1.0-SNAPSHOT" 2 | :description "FIXME: write description" 3 | :url "http://example.com/FIXME" 4 | :license {:name "Eclipse Public License" 5 | :url "http://www.eclipse.org/legal/epl-v10.html"} 6 | :dependencies [[org.clojure/clojure "1.8.0"]] 7 | :main ^:skip-aot making-change.core 8 | :target-path "target/%s" 9 | :profiles {:uberjar {:aot :all}}) 10 | -------------------------------------------------------------------------------- /reverse-words/project.clj: -------------------------------------------------------------------------------- 1 | (defproject reverse-words "0.1.0-SNAPSHOT" 2 | :description "FIXME: write description" 3 | :url "http://example.com/FIXME" 4 | :license {:name "Eclipse Public License" 5 | :url "http://www.eclipse.org/legal/epl-v10.html"} 6 | :dependencies [[org.clojure/clojure "1.8.0"]] 7 | :main ^:skip-aot reverse-words.core 8 | :target-path "target/%s" 9 | :profiles {:uberjar {:aot :all}}) 10 | -------------------------------------------------------------------------------- /in-place-shuffle/project.clj: -------------------------------------------------------------------------------- 1 | (defproject in-place-shuffle "0.1.0-SNAPSHOT" 2 | :description "FIXME: write description" 3 | :url "http://example.com/FIXME" 4 | :license {:name "Eclipse Public License" 5 | :url "http://www.eclipse.org/legal/epl-v10.html"} 6 | :dependencies [[org.clojure/clojure "1.8.0"]] 7 | :main ^:skip-aot in-place-shuffle.core 8 | :target-path "target/%s" 9 | :profiles {:uberjar {:aot :all}}) 10 | -------------------------------------------------------------------------------- /rectangular-love/project.clj: -------------------------------------------------------------------------------- 1 | (defproject rectangular-love "0.1.0-SNAPSHOT" 2 | :description "FIXME: write description" 3 | :url "http://example.com/FIXME" 4 | :license {:name "Eclipse Public License" 5 | :url "http://www.eclipse.org/legal/epl-v10.html"} 6 | :dependencies [[org.clojure/clojure "1.8.0"]] 7 | :main ^:skip-aot rectangular-love.core 8 | :target-path "target/%s" 9 | :profiles {:uberjar {:aot :all}}) 10 | -------------------------------------------------------------------------------- /bracket-validator/project.clj: -------------------------------------------------------------------------------- 1 | (defproject bracket-validator "0.1.0-SNAPSHOT" 2 | :description "FIXME: write description" 3 | :url "http://example.com/FIXME" 4 | :license {:name "Eclipse Public License" 5 | :url "http://www.eclipse.org/legal/epl-v10.html"} 6 | :dependencies [[org.clojure/clojure "1.8.0"]] 7 | :main ^:skip-aot bracket-validator.core 8 | :target-path "target/%s" 9 | :profiles {:uberjar {:aot :all}}) 10 | -------------------------------------------------------------------------------- /reverse-linked-list/src/reverse_linked_list/core.clj: -------------------------------------------------------------------------------- 1 | (ns reverse-linked-list.core 2 | (:require [reverse-linked-list.list :as list]) 3 | (:gen-class)) 4 | 5 | (defn reverse-list 6 | "O(n) time & space - not in-place, returns new list." 7 | [head] 8 | (loop [head head 9 | reversed nil] 10 | (if (nil? head) 11 | reversed 12 | (recur (:next head) 13 | (list/insert reversed (:value head)))))) 14 | -------------------------------------------------------------------------------- /find-in-ordered-set/project.clj: -------------------------------------------------------------------------------- 1 | (defproject find-in-ordered-set "0.1.0-SNAPSHOT" 2 | :description "FIXME: write description" 3 | :url "http://example.com/FIXME" 4 | :license {:name "Eclipse Public License" 5 | :url "http://www.eclipse.org/legal/epl-v10.html"} 6 | :dependencies [[org.clojure/clojure "1.8.0"]] 7 | :main ^:skip-aot find-in-ordered-set.core 8 | :target-path "target/%s" 9 | :profiles {:uberjar {:aot :all}}) 10 | -------------------------------------------------------------------------------- /find-rotation-point/project.clj: -------------------------------------------------------------------------------- 1 | (defproject find-rotation-point "0.1.0-SNAPSHOT" 2 | :description "FIXME: write description" 3 | :url "http://example.com/FIXME" 4 | :license {:name "Eclipse Public License" 5 | :url "http://www.eclipse.org/legal/epl-v10.html"} 6 | :dependencies [[org.clojure/clojure "1.8.0"]] 7 | :main ^:skip-aot find-rotation-point.core 8 | :target-path "target/%s" 9 | :profiles {:uberjar {:aot :all}}) 10 | -------------------------------------------------------------------------------- /merge-sorted-arrays/project.clj: -------------------------------------------------------------------------------- 1 | (defproject merge-sorted-arrays "0.1.0-SNAPSHOT" 2 | :description "FIXME: write description" 3 | :url "http://example.com/FIXME" 4 | :license {:name "Eclipse Public License" 5 | :url "http://www.eclipse.org/legal/epl-v10.html"} 6 | :dependencies [[org.clojure/clojure "1.8.0"]] 7 | :main ^:skip-aot merge-sorted-arrays.core 8 | :target-path "target/%s" 9 | :profiles {:uberjar {:aot :all}}) 10 | -------------------------------------------------------------------------------- /reverse-linked-list/project.clj: -------------------------------------------------------------------------------- 1 | (defproject reverse-linked-list "0.1.0-SNAPSHOT" 2 | :description "FIXME: write description" 3 | :url "http://example.com/FIXME" 4 | :license {:name "Eclipse Public License" 5 | :url "http://www.eclipse.org/legal/epl-v10.html"} 6 | :dependencies [[org.clojure/clojure "1.8.0"]] 7 | :main ^:skip-aot reverse-linked-list.core 8 | :target-path "target/%s" 9 | :profiles {:uberjar {:aot :all}}) 10 | -------------------------------------------------------------------------------- /which-appears-twice/project.clj: -------------------------------------------------------------------------------- 1 | (defproject which-appears-twice "0.1.0-SNAPSHOT" 2 | :description "FIXME: write description" 3 | :url "http://example.com/FIXME" 4 | :license {:name "Eclipse Public License" 5 | :url "http://www.eclipse.org/legal/epl-v10.html"} 6 | :dependencies [[org.clojure/clojure "1.8.0"]] 7 | :main ^:skip-aot which-appears-twice.core 8 | :target-path "target/%s" 9 | :profiles {:uberjar {:aot :all}}) 10 | -------------------------------------------------------------------------------- /balanced-binary-tree/project.clj: -------------------------------------------------------------------------------- 1 | (defproject balanced-binary-tree "0.1.0-SNAPSHOT" 2 | :description "FIXME: write description" 3 | :url "http://example.com/FIXME" 4 | :license {:name "Eclipse Public License" 5 | :url "http://www.eclipse.org/legal/epl-v10.html"} 6 | :dependencies [[org.clojure/clojure "1.8.0"]] 7 | :main ^:skip-aot balanced-binary-tree.core 8 | :target-path "target/%s" 9 | :profiles {:uberjar {:aot :all}}) 10 | -------------------------------------------------------------------------------- /merging-meeting-times/project.clj: -------------------------------------------------------------------------------- 1 | (defproject merging-meeting-times "0.1.0-SNAPSHOT" 2 | :description "FIXME: write description" 3 | :url "http://example.com/FIXME" 4 | :license {:name "Eclipse Public License" 5 | :url "http://www.eclipse.org/legal/epl-v10.html"} 6 | :dependencies [[org.clojure/clojure "1.8.0"]] 7 | :main ^:skip-aot merging-meeting-times.core 8 | :target-path "target/%s" 9 | :profiles {:uberjar {:aot :all}}) 10 | -------------------------------------------------------------------------------- /parenthesis-matching/project.clj: -------------------------------------------------------------------------------- 1 | (defproject parenthesis-matching "0.1.0-SNAPSHOT" 2 | :description "FIXME: write description" 3 | :url "http://example.com/FIXME" 4 | :license {:name "Eclipse Public License" 5 | :url "http://www.eclipse.org/legal/epl-v10.html"} 6 | :dependencies [[org.clojure/clojure "1.8.0"]] 7 | :main ^:skip-aot parenthesis-matching.core 8 | :target-path "target/%s" 9 | :profiles {:uberjar {:aot :all}}) 10 | -------------------------------------------------------------------------------- /simulate-5-sided-die/project.clj: -------------------------------------------------------------------------------- 1 | (defproject simulate-5-sided-die "0.1.0-SNAPSHOT" 2 | :description "FIXME: write description" 3 | :url "http://example.com/FIXME" 4 | :license {:name "Eclipse Public License" 5 | :url "http://www.eclipse.org/legal/epl-v10.html"} 6 | :dependencies [[org.clojure/clojure "1.8.0"]] 7 | :main ^:skip-aot simulate-5-sided-die.core 8 | :target-path "target/%s" 9 | :profiles {:uberjar {:aot :all}}) 10 | -------------------------------------------------------------------------------- /simulate-7-sided-die/project.clj: -------------------------------------------------------------------------------- 1 | (defproject simulate-7-sided-die "0.1.0-SNAPSHOT" 2 | :description "FIXME: write description" 3 | :url "http://example.com/FIXME" 4 | :license {:name "Eclipse Public License" 5 | :url "http://www.eclipse.org/legal/epl-v10.html"} 6 | :dependencies [[org.clojure/clojure "1.8.0"]] 7 | :main ^:skip-aot simulate-7-sided-die.core 8 | :target-path "target/%s" 9 | :profiles {:uberjar {:aot :all}}) 10 | -------------------------------------------------------------------------------- /single-riffle-shuffle/project.clj: -------------------------------------------------------------------------------- 1 | (defproject single-riffle-shuffle "0.1.0-SNAPSHOT" 2 | :description "FIXME: write description" 3 | :url "http://example.com/FIXME" 4 | :license {:name "Eclipse Public License" 5 | :url "http://www.eclipse.org/legal/epl-v10.html"} 6 | :dependencies [[org.clojure/clojure "1.8.0"]] 7 | :main ^:skip-aot single-riffle-shuffle.core 8 | :target-path "target/%s" 9 | :profiles {:uberjar {:aot :all}}) 10 | -------------------------------------------------------------------------------- /inflight-entertainment/project.clj: -------------------------------------------------------------------------------- 1 | (defproject inflight-entertainment "0.1.0-SNAPSHOT" 2 | :description "FIXME: write description" 3 | :url "http://example.com/FIXME" 4 | :license {:name "Eclipse Public License" 5 | :url "http://www.eclipse.org/legal/epl-v10.html"} 6 | :dependencies [[org.clojure/clojure "1.8.0"]] 7 | :main ^:skip-aot inflight-entertainment.core 8 | :target-path "target/%s" 9 | :profiles {:uberjar {:aot :all}}) 10 | -------------------------------------------------------------------------------- /permutation-palindrome/project.clj: -------------------------------------------------------------------------------- 1 | (defproject permutation-palindrome "0.1.0-SNAPSHOT" 2 | :description "FIXME: write description" 3 | :url "http://example.com/FIXME" 4 | :license {:name "Eclipse Public License" 5 | :url "http://www.eclipse.org/legal/epl-v10.html"} 6 | :dependencies [[org.clojure/clojure "1.8.0"]] 7 | :main ^:skip-aot permutation-palindrome.core 8 | :target-path "target/%s" 9 | :profiles {:uberjar {:aot :all}}) 10 | -------------------------------------------------------------------------------- /highest-product-of-three/project.clj: -------------------------------------------------------------------------------- 1 | (defproject highest-product-of-three "0.1.0-SNAPSHOT" 2 | :description "FIXME: write description" 3 | :url "http://example.com/FIXME" 4 | :license {:name "Eclipse Public License" 5 | :url "http://www.eclipse.org/legal/epl-v10.html"} 6 | :dependencies [[org.clojure/clojure "1.8.0"]] 7 | :main ^:skip-aot highest-product-of-three.core 8 | :target-path "target/%s" 9 | :profiles {:uberjar {:aot :all}}) 10 | -------------------------------------------------------------------------------- /kth-to-last-linked-list/project.clj: -------------------------------------------------------------------------------- 1 | (defproject kth-to-last-linked-list "0.1.0-SNAPSHOT" 2 | :description "FIXME: write description" 3 | :url "http://example.com/FIXME" 4 | :license {:name "Eclipse Public License" 5 | :url "http://www.eclipse.org/legal/epl-v10.html"} 6 | :dependencies [[org.clojure/clojure "1.8.0"]] 7 | :main ^:skip-aot kth-to-last-linked-list.core 8 | :target-path "target/%s" 9 | :profiles {:uberjar {:aot :all}}) 10 | -------------------------------------------------------------------------------- /reverse-string-in-place/project.clj: -------------------------------------------------------------------------------- 1 | (defproject reverse-string-in-place "0.1.0-SNAPSHOT" 2 | :description "FIXME: write description" 3 | :url "http://example.com/FIXME" 4 | :license {:name "Eclipse Public License" 5 | :url "http://www.eclipse.org/legal/epl-v10.html"} 6 | :dependencies [[org.clojure/clojure "1.8.0"]] 7 | :main ^:skip-aot reverse-string-in-place.core 8 | :target-path "target/%s" 9 | :profiles {:uberjar {:aot :all}}) 10 | -------------------------------------------------------------------------------- /binary-search-tree-checker/project.clj: -------------------------------------------------------------------------------- 1 | (defproject binary-search-tree-checker "0.1.0-SNAPSHOT" 2 | :description "FIXME: write description" 3 | :url "http://example.com/FIXME" 4 | :license {:name "Eclipse Public License" 5 | :url "http://www.eclipse.org/legal/epl-v10.html"} 6 | :dependencies [[org.clojure/clojure "1.8.0"]] 7 | :main ^:skip-aot binary-search-tree-checker.core 8 | :target-path "target/%s" 9 | :profiles {:uberjar {:aot :all}}) 10 | -------------------------------------------------------------------------------- /find-repeat-space-edition/project.clj: -------------------------------------------------------------------------------- 1 | (defproject find-repeat-space-edition "0.1.0-SNAPSHOT" 2 | :description "FIXME: write description" 3 | :url "http://example.com/FIXME" 4 | :license {:name "Eclipse Public License" 5 | :url "http://www.eclipse.org/legal/epl-v10.html"} 6 | :dependencies [[org.clojure/clojure "1.8.0"]] 7 | :main ^:skip-aot find-repeat-space-edition.core 8 | :target-path "target/%s" 9 | :profiles {:uberjar {:aot :all}}) 10 | -------------------------------------------------------------------------------- /the-stolen-breakfast-drone/project.clj: -------------------------------------------------------------------------------- 1 | (defproject the-stolen-breakfast-drone "0.1.0-SNAPSHOT" 2 | :description "FIXME: write description" 3 | :url "http://example.com/FIXME" 4 | :license {:name "Eclipse Public License" 5 | :url "http://www.eclipse.org/legal/epl-v10.html"} 6 | :dependencies [[org.clojure/clojure "1.8.0"]] 7 | :main ^:skip-aot the-stolen-breakfast-drone.core 8 | :target-path "target/%s" 9 | :profiles {:uberjar {:aot :all}}) 10 | -------------------------------------------------------------------------------- /compute-nth-fibbonacci-number/project.clj: -------------------------------------------------------------------------------- 1 | (defproject compute-nth-fibbonacci-number "0.1.0-SNAPSHOT" 2 | :description "FIXME: write description" 3 | :url "http://example.com/FIXME" 4 | :license {:name "Eclipse Public License" 5 | :url "http://www.eclipse.org/legal/epl-v10.html"} 6 | :dependencies [[org.clojure/clojure "1.8.0"]] 7 | :main ^:skip-aot compute-nth-fibbonacci-number.core 8 | :target-path "target/%s" 9 | :profiles {:uberjar {:aot :all}}) 10 | -------------------------------------------------------------------------------- /product-of-all-other-numbers/project.clj: -------------------------------------------------------------------------------- 1 | (defproject product-of-all-other-numbers "0.1.0-SNAPSHOT" 2 | :description "FIXME: write description" 3 | :url "http://example.com/FIXME" 4 | :license {:name "Eclipse Public License" 5 | :url "http://www.eclipse.org/legal/epl-v10.html"} 6 | :dependencies [[org.clojure/clojure "1.8.0"]] 7 | :main ^:skip-aot product-of-all-other-numbers.core 8 | :target-path "target/%s" 9 | :profiles {:uberjar {:aot :all}}) 10 | -------------------------------------------------------------------------------- /recursive-string-permutations/project.clj: -------------------------------------------------------------------------------- 1 | (defproject recursive-string-permutations "0.1.0-SNAPSHOT" 2 | :description "FIXME: write description" 3 | :url "http://example.com/FIXME" 4 | :license {:name "Eclipse Public License" 5 | :url "http://www.eclipse.org/legal/epl-v10.html"} 6 | :dependencies [[org.clojure/clojure "1.8.0"]] 7 | :main ^:skip-aot recursive-string-permutations.core 8 | :target-path "target/%s" 9 | :profiles {:uberjar {:aot :all}}) 10 | -------------------------------------------------------------------------------- /parenthesis-matching/src/parenthesis_matching/core.clj: -------------------------------------------------------------------------------- 1 | (ns parenthesis-matching.core 2 | (:gen-class)) 3 | 4 | (defn find-closing-parenthesis 5 | "O(n) time & O(1) space solution - doesn't handle no closing parenthesis." 6 | [s open-idx] 7 | (reduce 8 | (fn [open-count idx] 9 | (case (get s idx) 10 | \( (inc open-count) 11 | \) (if (zero? open-count) (reduced idx) (dec open-count)) 12 | open-count)) 13 | 0 14 | (range (inc open-idx) (count s)))) 15 | -------------------------------------------------------------------------------- /second-largest-in-binary-search-tree/project.clj: -------------------------------------------------------------------------------- 1 | (defproject second-largest-in-binary-search-tree "0.1.0-SNAPSHOT" 2 | :description "FIXME: write description" 3 | :url "http://example.com/FIXME" 4 | :license {:name "Eclipse Public License" 5 | :url "http://www.eclipse.org/legal/epl-v10.html"} 6 | :dependencies [[org.clojure/clojure "1.8.0"]] 7 | :main ^:skip-aot second-largest-in-binary-search-tree.core 8 | :target-path "target/%s" 9 | :profiles {:uberjar {:aot :all}}) 10 | -------------------------------------------------------------------------------- /kth-to-last-linked-list/src/kth_to_last_linked_list/list.clj: -------------------------------------------------------------------------------- 1 | (ns kth-to-last-linked-list.list 2 | (:gen-class)) 3 | 4 | (defn node [value] 5 | {:value value :next nil :count 1}) 6 | 7 | (defn insert [head value] 8 | (if (empty? head) 9 | (node value) 10 | (-> (node value) 11 | (assoc :next head) 12 | (assoc :count (inc (:count head)))))) 13 | 14 | (defn coll->list [coll] 15 | (reduce insert {} (reverse coll))) 16 | 17 | (defn length [head] 18 | (:count head 0)) 19 | -------------------------------------------------------------------------------- /inflight-entertainment/src/inflight_entertainment/core.clj: -------------------------------------------------------------------------------- 1 | (ns inflight-entertainment.core 2 | (:gen-class)) 3 | 4 | (defn can-two-movies-fill-flight? 5 | "O(n) time solution - using a set." 6 | [movie-lengths flight-length] 7 | (true? (reduce 8 | (fn [seen-lengths movie-length] 9 | (if (contains? seen-lengths (- flight-length movie-length)) 10 | (reduced true) 11 | (conj seen-lengths movie-length))) 12 | #{} 13 | movie-lengths))) 14 | -------------------------------------------------------------------------------- /binary-search-tree-checker/src/binary_search_tree_checker/core.clj: -------------------------------------------------------------------------------- 1 | (ns binary-search-tree-checker.core 2 | (:gen-class)) 3 | 4 | (defn bst? 5 | "O(n) time solution - recursively checking every node agaist range." 6 | ([root] 7 | (bst? root Integer/MIN_VALUE Integer/MAX_VALUE)) 8 | ([{:keys [value left right] :as root} min max] 9 | (cond 10 | (empty? root) true 11 | (not (< min value max)) false 12 | :else (and (bst? left min value) 13 | (bst? right value max))))) 14 | -------------------------------------------------------------------------------- /second-largest-in-binary-search-tree/src/second_largest_in_binary_search_tree/core.clj: -------------------------------------------------------------------------------- 1 | (ns second-largest-in-binary-search-tree.core 2 | (:require [second-largest-in-binary-search-tree.binary-tree :as tree]) 3 | (:gen-class)) 4 | 5 | (defn second-largest 6 | "O(lgn) time solution." 7 | [root] 8 | (loop [parent nil 9 | {:keys [value left right] :as current} root] 10 | (if (nil? right) 11 | (if (nil? left) 12 | (:value parent) 13 | (tree/largest left)) 14 | (recur current right)))) 15 | -------------------------------------------------------------------------------- /top-scores/src/top_scores/core.clj: -------------------------------------------------------------------------------- 1 | (ns top-scores.core 2 | (:gen-class)) 3 | 4 | (defn- sorted-frequencies [coll max-value] 5 | (reduce 6 | (fn [counts value] 7 | (update counts value inc)) 8 | (vec (replicate (inc max-value) 0)) 9 | coll)) 10 | 11 | (defn counting-sort 12 | "O(n) time & O(n + k) space solution, where k = max-value." 13 | [coll max-value] 14 | (reduce-kv 15 | (fn [sorted value count] 16 | (into sorted (replicate count value))) 17 | [] 18 | (sorted-frequencies coll max-value))) 19 | -------------------------------------------------------------------------------- /merge-sorted-arrays/src/merge_sorted_arrays/core.clj: -------------------------------------------------------------------------------- 1 | (ns merge-sorted-arrays.core 2 | (:gen-class)) 3 | 4 | (defn merge-colls 5 | "O(n) time & space solution." 6 | [coll-a coll-b] 7 | (loop [[a & as :as coll-a] coll-a 8 | [b & bs :as coll-b] coll-b 9 | merged []] 10 | (cond 11 | (and (empty? coll-a) (empty? coll-b)) 12 | merged 13 | (or (nil? b) (and (not (nil? a)) (< a b))) 14 | (recur as coll-b (conj merged a)) 15 | :else 16 | (recur coll-a bs (conj merged b))))) 17 | -------------------------------------------------------------------------------- /apple-stocks/src/apple_stocks/core.clj: -------------------------------------------------------------------------------- 1 | (ns apple-stocks.core 2 | (:gen-class)) 3 | 4 | (defn- update-min-max [{:keys [min-price max-profit]} price] 5 | {:min-price (min price min-price) 6 | :max-profit (max (- price min-price) max-profit)}) 7 | 8 | (defn get-max-profit 9 | "O(n) time solution - returns max potential profit from set of stock prices." 10 | [stock-prices] 11 | (:max-profit (reduce update-min-max 12 | {:max-profit 0 :min-price (first stock-prices)} 13 | (rest stock-prices)))) 14 | -------------------------------------------------------------------------------- /the-stolen-breakfast-drone/src/the_stolen_breakfast_drone/core.clj: -------------------------------------------------------------------------------- 1 | (ns the-stolen-breakfast-drone.core 2 | (:gen-class)) 3 | 4 | (defn find-unique 5 | "O(n) time & space solution - using a set." 6 | [ids] 7 | (first (reduce 8 | (fn [uniques id] 9 | (if (contains? uniques id) 10 | (disj uniques id) 11 | (conj uniques id))) 12 | #{} 13 | ids))) 14 | 15 | (defn find-unique-bitwise 16 | "O(n) time solution - using bitwise xor." 17 | [ids] 18 | (reduce bit-xor ids)) 19 | -------------------------------------------------------------------------------- /compute-nth-fibbonacci-number/test/compute_nth_fibbonacci_number/core_test.clj: -------------------------------------------------------------------------------- 1 | (ns compute-nth-fibbonacci-number.core-test 2 | (:require [clojure.test :refer :all] 3 | [compute-nth-fibbonacci-number.core :refer :all])) 4 | 5 | (deftest fib-test 6 | (testing "fibonacci seq - very basic testing" 7 | (is (= (fib 0) 0)) 8 | (is (= (fib 1) 1)) 9 | (is (= (fib 2) 1)) 10 | (is (= (fib 3) 2)) 11 | (is (= (fib 4) 3)) 12 | (is (= (fib 5) 5)) 13 | (is (= (fib 6) 8)) 14 | (is (= (fib 7) 13)) 15 | (is (= (fib 8) 21)))) 16 | -------------------------------------------------------------------------------- /which-appears-twice/src/which_appears_twice/core.clj: -------------------------------------------------------------------------------- 1 | (ns which-appears-twice.core 2 | (:gen-class)) 3 | 4 | (defn find-dup-in-range 5 | "O(n) time & space solution - partitioning by id." 6 | [range n] 7 | (->> (partition-by identity range) 8 | (filter #(>= (count %) 2)) 9 | ffirst)) 10 | 11 | (defn- sum-of-range [n] 12 | (/ (* n (inc n)) 2)) 13 | 14 | (defn find-dup-in-range-with-sum 15 | "O(n) time solution - taking difference of actual and expected sums from 1 to n." 16 | [range n] 17 | (- (apply + range) (sum-of-range n))) 18 | -------------------------------------------------------------------------------- /in-place-shuffle/src/in_place_shuffle/core.clj: -------------------------------------------------------------------------------- 1 | (ns in-place-shuffle.core 2 | (:gen-class)) 3 | 4 | (defn- random [floor ceiling] 5 | (+ floor (rand-int (inc (- ceiling floor))))) 6 | 7 | (defn- swap [arr idx-a idx-b] 8 | (-> arr 9 | (assoc idx-a (get arr idx-b)) 10 | (assoc idx-b (get arr idx-a)))) 11 | 12 | (defn fisher-yates-shuffle 13 | "O(n) time solution - can't do this in-place ~ but can use similar algorithm." 14 | [arr] 15 | (reduce 16 | (fn [shuffled idx] 17 | (->> (random idx (dec (count arr))) 18 | (swap shuffled idx))) 19 | arr 20 | (range (count arr)))) 21 | -------------------------------------------------------------------------------- /recursive-string-permutations/src/recursive_string_permutations/core.clj: -------------------------------------------------------------------------------- 1 | (ns recursive-string-permutations.core 2 | (:gen-class)) 3 | 4 | (defn- remaining-subs [s idx] 5 | (str (subs s 0 idx) 6 | (subs s (inc idx) (count s)))) 7 | 8 | (defn permutations 9 | "O(n!) time solution - recursively computing permutations." 10 | [s] 11 | (if (<= (count s) 1) 12 | #{s} 13 | (reduce-kv 14 | (fn [permutations-so-far idx char] 15 | (->> (permutations (remaining-subs s idx)) 16 | (map (partial str char)) 17 | (into permutations-so-far))) 18 | #{} 19 | (vec s)))) 20 | -------------------------------------------------------------------------------- /word-cloud/src/word_cloud/core.clj: -------------------------------------------------------------------------------- 1 | (ns word-cloud.core 2 | (:require [clojure.string :as str]) 3 | (:gen-class)) 4 | 5 | (defn- normalize [s] 6 | (map #(str/lower-case (str/replace % #"(?i)[^\w']+" "")) 7 | (str/split s #" "))) 8 | 9 | (defn word-cloud 10 | "O(n) time & space solution - manually counting frequencies w/reduce." 11 | [s] 12 | (reduce 13 | (fn [counts word] 14 | (update counts word (fnil inc 0))) 15 | {} 16 | (normalize s))) 17 | 18 | (defn word-cloud-with-freq 19 | "O(n) time & space solution - using built-in frequencies function." 20 | [s] 21 | (frequencies (normalize s))) 22 | -------------------------------------------------------------------------------- /reverse-string-in-place/src/reverse_string_in_place/core.clj: -------------------------------------------------------------------------------- 1 | (ns reverse-string-in-place.core 2 | (:gen-class)) 3 | 4 | (defn- swap [arr idx-a idx-b] 5 | (-> arr 6 | (assoc idx-a (get arr idx-b)) 7 | (assoc idx-b (get arr idx-a)))) 8 | 9 | (defn reverse-string 10 | "O(n) time - not in place (converting to vector) ~ but similar algorithm." 11 | [s] 12 | (loop [lower-idx 0 13 | upper-idx (dec (count s)) 14 | reversed (vec s)] 15 | (if (>= lower-idx upper-idx) 16 | (apply str reversed) 17 | (recur (inc lower-idx) 18 | (dec upper-idx) 19 | (swap reversed lower-idx upper-idx))))) 20 | -------------------------------------------------------------------------------- /reverse-string-in-place/test/reverse_string_in_place/core_test.clj: -------------------------------------------------------------------------------- 1 | (ns reverse-string-in-place.core-test 2 | (:require [clojure.test :refer :all] 3 | [reverse-string-in-place.core :refer :all])) 4 | 5 | (deftest reverse-string-test 6 | (testing "edge cases" 7 | (is (= (reverse-string "") "")) 8 | (is (= (reverse-string "a") "a")) 9 | (is (= (reverse-string "ab") "ba"))) 10 | (testing "returns string reversed" 11 | (is (= (reverse-string "abc") "cba")) 12 | (is (= (reverse-string "hello") "olleh")) 13 | (is (= (reverse-string "Hello World!") "!dlroW olleH")) 14 | (is (= (reverse-string "eeeffffggg") "gggffffeee")))) 15 | -------------------------------------------------------------------------------- /permutation-palindrome/src/permutation_palindrome/core.clj: -------------------------------------------------------------------------------- 1 | (ns permutation-palindrome.core 2 | (:gen-class)) 3 | 4 | (defn- odd-frequencies [s] 5 | (reduce 6 | (fn [counts char] 7 | (if (contains? counts char) 8 | (disj counts char) 9 | (conj counts char))) 10 | #{} 11 | s)) 12 | 13 | (defn permutation-palindrome? 14 | "O(n) time & space solution - counting odd frequencies with a set." 15 | [s] 16 | (<= (count (odd-frequencies s)) 1)) 17 | 18 | (defn permutation-palindrome-better? 19 | "O(n) time & space solution - counting odd frequencies w/frequencies fn." 20 | [s] 21 | (<= (count (filter odd? (vals (frequencies s)))) 1)) 22 | -------------------------------------------------------------------------------- /find-rotation-point/src/find_rotation_point/core.clj: -------------------------------------------------------------------------------- 1 | (ns find-rotation-point.core 2 | (:gen-class)) 3 | 4 | (def ^:private gt? (comp pos? compare)) 5 | (def ^:private lt? (comp neg? compare)) 6 | 7 | (defn- midpoint [start end] 8 | (-> (- end start) 9 | (/ 2) 10 | int 11 | (+ start))) 12 | 13 | (defn find-rotation-point 14 | "O(lgn) time solution - binary search like." 15 | [[first-word :as words]] 16 | (loop [start 0 17 | end (count words)] 18 | (let [mid (midpoint start end)] 19 | (cond 20 | (<= (- end start) 1) end 21 | (gt? (get words mid) first-word) (recur mid end) 22 | :else (recur start mid))))) 23 | -------------------------------------------------------------------------------- /highest-product-of-three/src/highest_product_of_three/core.clj: -------------------------------------------------------------------------------- 1 | (ns highest-product-of-three.core 2 | (:gen-class)) 3 | 4 | (defn- rotation 5 | "Rotates bucket of k length around the bottom and top of arr by idx." 6 | [arr k idx] 7 | (let [top (- (count arr) (- k idx))] 8 | (vec (concat (subvec arr 0 idx) 9 | (subvec arr top))))) 10 | 11 | (defn highest-product-of-k 12 | "O(nlgn) time + O(n + (k + k^2)) space solution." 13 | [k arr] 14 | (if (>= k (count arr)) 15 | (reduce * arr) 16 | (->> (range (inc k)) 17 | (map (partial rotation (vec (sort arr)) k)) 18 | (map (partial reduce *)) 19 | (apply max)))) 20 | -------------------------------------------------------------------------------- /single-riffle-shuffle/src/single_riffle_shuffle/core.clj: -------------------------------------------------------------------------------- 1 | (ns single-riffle-shuffle.core 2 | (:gen-class)) 3 | 4 | (defn single-riffle-shuffle? 5 | "O(n) time solution - assuming counts of half-a + half-b = count of shuffled." 6 | [shuffled half-a half-b] 7 | (loop [idx-a 0 8 | idx-b 0 9 | idx-shuffled 0] 10 | (cond 11 | (= idx-shuffled (count shuffled)) 12 | true 13 | (= (get half-a idx-a) (get shuffled idx-shuffled)) 14 | (recur (inc idx-a) idx-b (inc idx-shuffled)) 15 | (= (get half-b idx-b) (get shuffled idx-shuffled)) 16 | (recur idx-a (inc idx-b) (inc idx-shuffled)) 17 | :else 18 | false))) 19 | -------------------------------------------------------------------------------- /making-change/src/making_change/core.clj: -------------------------------------------------------------------------------- 1 | (ns making-change.core 2 | (:gen-class)) 3 | 4 | (defn ways-to-make-amount 5 | "O(n * m) time and O(n) space solution, where m = # of denominations." 6 | [amount denominations] 7 | (get (reduce 8 | (fn [ways-of-doing-n-cents coin] 9 | (reduce 10 | (fn [ways-of-doing-n-cents higher-amount] 11 | (->> (- higher-amount coin) 12 | (get ways-of-doing-n-cents) 13 | (update ways-of-doing-n-cents higher-amount +))) 14 | ways-of-doing-n-cents 15 | (range coin (inc amount)))) 16 | (vec (conj (replicate amount 0) 1)) 17 | denominations) 18 | amount)) 19 | -------------------------------------------------------------------------------- /product-of-all-other-numbers/src/product_of_all_other_numbers/core.clj: -------------------------------------------------------------------------------- 1 | (ns product-of-all-other-numbers.core 2 | (:gen-class)) 3 | 4 | (defn product-of-others 5 | "O(n^2) solutions - using division (not checking for zeros)" 6 | [nums] 7 | (map #(/ (apply * nums) %) nums)) 8 | 9 | (defn- products-before [nums] 10 | (reduce 11 | (fn [acc n] 12 | (conj acc (* n (last acc)))) 13 | [1] 14 | (butlast nums))) 15 | 16 | (defn- products-after [nums] 17 | (rseq (products-before (rseq (vec nums))))) 18 | 19 | (defn product-of-others-fast 20 | "O(n) solution - without using division" 21 | [nums] 22 | (if (empty? nums) 23 | '() 24 | (map * (products-before nums) (products-after nums)))) 25 | -------------------------------------------------------------------------------- /find-in-ordered-set/src/find_in_ordered_set/core.clj: -------------------------------------------------------------------------------- 1 | (ns find-in-ordered-set.core 2 | (:gen-class)) 3 | 4 | (def ^:private gt? (comp pos? compare)) 5 | (def ^:private eq? (comp zero? compare)) 6 | 7 | (defn- midpoint [start end] 8 | (-> (- end start) 9 | (/ 2) 10 | int 11 | (+ start))) 12 | 13 | (defn binary-search 14 | "O(lgn) - returns index of item in sorted vector, -1 if not found." 15 | [arr item] 16 | (loop [start 0 17 | end (count arr)] 18 | (let [mid (midpoint start end) 19 | mid-item (get arr mid)] 20 | (cond 21 | (eq? mid-item item) mid 22 | (<= (- end start) 1) -1 23 | (gt? mid-item item) (recur start mid) 24 | :else (recur mid end))))) 25 | -------------------------------------------------------------------------------- /bracket-validator/src/bracket_validator/core.clj: -------------------------------------------------------------------------------- 1 | (ns bracket-validator.core 2 | (:gen-class)) 3 | 4 | (def ^:private openers #{\( \{ \[}) 5 | (def ^:private closers #{\) \} \]}) 6 | (def ^:private closer->opener {\) \( \} \{ \] \[}) 7 | 8 | (defn- update-stack [stack char] 9 | (cond 10 | (contains? openers char) 11 | (conj stack char) 12 | (contains? closers char) 13 | (if (= (peek stack) (closer->opener char)) 14 | (pop stack) 15 | (reduced nil)) 16 | :else 17 | stack)) 18 | 19 | (defn valid-brackets? 20 | "O(n) time & O(k) space solution, where k = number of brackets - using a stack." 21 | [s] 22 | (let [remaining-stack (reduce update-stack [] s)] 23 | (and (some? remaining-stack) 24 | (empty? remaining-stack)))) 25 | -------------------------------------------------------------------------------- /reverse-words/test/reverse_words/core_test.clj: -------------------------------------------------------------------------------- 1 | (ns reverse-words.core-test 2 | (:require [clojure.test :refer :all] 3 | [reverse-words.core :refer :all])) 4 | 5 | (def message-a "world hello") 6 | (def message-b "you meet to nice") 7 | (def message-c "find you will pain only go you recordings security the into if") 8 | 9 | (def edge-a "") 10 | (def edge-b "hello") 11 | 12 | (deftest reverse-words-test 13 | (testing "edge cases" 14 | (is (= (reverse-words edge-a) "")) 15 | (is (= (reverse-words edge-b) "hello"))) 16 | (testing "should reverse the words in string" 17 | (is (= (reverse-words message-a) "hello world")) 18 | (is (= (reverse-words message-b) "nice to meet you")) 19 | (is (= (reverse-words message-c) "if into the security recordings you go only pain will you find")))) 20 | -------------------------------------------------------------------------------- /merging-meeting-times/src/merging_meeting_times/core.clj: -------------------------------------------------------------------------------- 1 | (ns merging-meeting-times.core 2 | (:gen-class)) 3 | 4 | (defn- merge-if-overlap [meeting-a meeting-b] 5 | (let [[earlier later] (sort-by :start [meeting-a meeting-b])] 6 | (when (>= (:end earlier) (:start later)) 7 | {:start (:start earlier) 8 | :end (max (:end earlier) (:end later))}))) 9 | 10 | (defn merge-meeting-times 11 | "O(nlgn) soluting - sorting input meeting times." 12 | [meeting-times] 13 | (let [[first-meeting & rest-meetings] (sort-by :start meeting-times)] 14 | (reduce 15 | (fn [merged-so-far meeting] 16 | (if-let [merged (merge-if-overlap (last merged-so-far) meeting)] 17 | (conj (pop merged-so-far) merged) 18 | (conj merged-so-far meeting))) 19 | [first-meeting] 20 | rest-meetings))) 21 | -------------------------------------------------------------------------------- /apple-stocks/test/apple_stocks/core_test.clj: -------------------------------------------------------------------------------- 1 | (ns apple-stocks.core-test 2 | (:require [clojure.test :refer :all] 3 | [apple-stocks.core :refer :all])) 4 | 5 | (deftest get-max-profit-test 6 | (testing "edge cases" 7 | (is (= (get-max-profit []) 0)) 8 | (is (= (get-max-profit '()) 0)) 9 | (is (= (get-max-profit [0]) 0)) 10 | (is (= (get-max-profit '(0)) 0)) 11 | (is (= (get-max-profit '(2 7)) (- 7 2)))) 12 | (testing "given set of stock prices, returns maximum profit" 13 | (is (= (get-max-profit [10 7 5 8 11 9]) 6)) 14 | (is (= (get-max-profit [57 34 67 90 77]) 56)) 15 | (is (= (get-max-profit [23 4 56 88 100 150]) 146)) 16 | (is (= (get-max-profit (range 10)) 9)) 17 | (is (= (get-max-profit (reverse (range 10))) 0)) 18 | (is (= (get-max-profit (range 10 100 5)) 85)))) 19 | -------------------------------------------------------------------------------- /reverse-linked-list/test/reverse_linked_list/core_test.clj: -------------------------------------------------------------------------------- 1 | (ns reverse-linked-list.core-test 2 | (:require [clojure.test :refer :all] 3 | [reverse-linked-list.core :refer :all] 4 | [reverse-linked-list.list :as list])) 5 | 6 | (def list-a (list/coll->list [4 2])) 7 | (def list-b (list/coll->list [6 7 8])) 8 | (def list-c (list/coll->list [5 8 3 4])) 9 | 10 | (def reversed-a (list/coll->list [2 4])) 11 | (def reversed-b (list/coll->list [8 7 6])) 12 | (def reversed-c (list/coll->list [4 3 8 5])) 13 | 14 | (deftest reverse-list-test 15 | (testing "edge cases" 16 | (is (= (reverse-list (list/coll->list [7])) (list/coll->list [7])))) 17 | (testing "returns reversed list, not in-place" 18 | (is (= (reverse-list list-a) reversed-a)) 19 | (is (= (reverse-list list-b) reversed-b)) 20 | (is (= (reverse-list list-c) reversed-c)))) 21 | -------------------------------------------------------------------------------- /simulate-7-sided-die/src/simulate_7_sided_die/core.clj: -------------------------------------------------------------------------------- 1 | (ns simulate-7-sided-die.core 2 | (:gen-class)) 3 | 4 | (defn- random [floor ceiling] 5 | (+ floor (rand-int (inc (- ceiling floor))))) 6 | 7 | (defn- rand5 [] 8 | (random 1 5)) 9 | 10 | (def ^:private rand7-matrix 11 | (->> (range 1 8) 12 | (cycle) 13 | (take 21) 14 | (partition 5 5 (repeat 0)) 15 | (mapv vec))) 16 | 17 | (defn rand7-with-matrix [] 18 | (loop [row (dec (rand5)) 19 | column (dec (rand5))] 20 | (if (and (= row 4) (> column 0)) 21 | (recur (dec (rand5)) (dec (rand5))) 22 | (get-in rand7-matrix [row column])))) 23 | 24 | (defn rand7 [] 25 | (loop [rand-a (rand5) 26 | rand-b (rand5)] 27 | (let [out (inc (+ (* (dec rand-a) 5) (dec rand-b)))] 28 | (if (<= out 21) 29 | (inc (mod out 7)) 30 | (recur (rand5) (rand5)))))) 31 | -------------------------------------------------------------------------------- /cake-thief/CHANGELOG.md: -------------------------------------------------------------------------------- 1 | # Change Log 2 | All notable changes to this project will be documented in this file. This change log follows the conventions of [keepachangelog.com](http://keepachangelog.com/). 3 | 4 | ## [Unreleased] 5 | ### Changed 6 | - Add a new arity to `make-widget-async` to provide a different widget shape. 7 | 8 | ## [0.1.1] - 2016-05-29 9 | ### Changed 10 | - Documentation on how to make the widgets. 11 | 12 | ### Removed 13 | - `make-widget-sync` - we're all async, all the time. 14 | 15 | ### Fixed 16 | - Fixed widget maker to keep working when daylight savings switches over. 17 | 18 | ## 0.1.0 - 2016-05-29 19 | ### Added 20 | - Files from the new template. 21 | - Widget maker public API - `make-widget-sync`. 22 | 23 | [Unreleased]: https://github.com/your-name/cake-thief/compare/0.1.1...HEAD 24 | [0.1.1]: https://github.com/your-name/cake-thief/compare/0.1.0...0.1.1 25 | -------------------------------------------------------------------------------- /top-scores/CHANGELOG.md: -------------------------------------------------------------------------------- 1 | # Change Log 2 | All notable changes to this project will be documented in this file. This change log follows the conventions of [keepachangelog.com](http://keepachangelog.com/). 3 | 4 | ## [Unreleased] 5 | ### Changed 6 | - Add a new arity to `make-widget-async` to provide a different widget shape. 7 | 8 | ## [0.1.1] - 2016-06-05 9 | ### Changed 10 | - Documentation on how to make the widgets. 11 | 12 | ### Removed 13 | - `make-widget-sync` - we're all async, all the time. 14 | 15 | ### Fixed 16 | - Fixed widget maker to keep working when daylight savings switches over. 17 | 18 | ## 0.1.0 - 2016-06-05 19 | ### Added 20 | - Files from the new template. 21 | - Widget maker public API - `make-widget-sync`. 22 | 23 | [Unreleased]: https://github.com/your-name/top-scores/compare/0.1.1...HEAD 24 | [0.1.1]: https://github.com/your-name/top-scores/compare/0.1.0...0.1.1 25 | -------------------------------------------------------------------------------- /word-cloud/CHANGELOG.md: -------------------------------------------------------------------------------- 1 | # Change Log 2 | All notable changes to this project will be documented in this file. This change log follows the conventions of [keepachangelog.com](http://keepachangelog.com/). 3 | 4 | ## [Unreleased] 5 | ### Changed 6 | - Add a new arity to `make-widget-async` to provide a different widget shape. 7 | 8 | ## [0.1.1] - 2016-06-07 9 | ### Changed 10 | - Documentation on how to make the widgets. 11 | 12 | ### Removed 13 | - `make-widget-sync` - we're all async, all the time. 14 | 15 | ### Fixed 16 | - Fixed widget maker to keep working when daylight savings switches over. 17 | 18 | ## 0.1.0 - 2016-06-07 19 | ### Added 20 | - Files from the new template. 21 | - Widget maker public API - `make-widget-sync`. 22 | 23 | [Unreleased]: https://github.com/your-name/word-cloud/compare/0.1.1...HEAD 24 | [0.1.1]: https://github.com/your-name/word-cloud/compare/0.1.0...0.1.1 25 | -------------------------------------------------------------------------------- /apple-stocks/CHANGELOG.md: -------------------------------------------------------------------------------- 1 | # Change Log 2 | All notable changes to this project will be documented in this file. This change log follows the conventions of [keepachangelog.com](http://keepachangelog.com/). 3 | 4 | ## [Unreleased] 5 | ### Changed 6 | - Add a new arity to `make-widget-async` to provide a different widget shape. 7 | 8 | ## [0.1.1] - 2016-05-15 9 | ### Changed 10 | - Documentation on how to make the widgets. 11 | 12 | ### Removed 13 | - `make-widget-sync` - we're all async, all the time. 14 | 15 | ### Fixed 16 | - Fixed widget maker to keep working when daylight savings switches over. 17 | 18 | ## 0.1.0 - 2016-05-15 19 | ### Added 20 | - Files from the new template. 21 | - Widget maker public API - `make-widget-sync`. 22 | 23 | [Unreleased]: https://github.com/your-name/apple-stocks/compare/0.1.1...HEAD 24 | [0.1.1]: https://github.com/your-name/apple-stocks/compare/0.1.0...0.1.1 25 | -------------------------------------------------------------------------------- /making-change/CHANGELOG.md: -------------------------------------------------------------------------------- 1 | # Change Log 2 | All notable changes to this project will be documented in this file. This change log follows the conventions of [keepachangelog.com](http://keepachangelog.com/). 3 | 4 | ## [Unreleased] 5 | ### Changed 6 | - Add a new arity to `make-widget-async` to provide a different widget shape. 7 | 8 | ## [0.1.1] - 2016-06-18 9 | ### Changed 10 | - Documentation on how to make the widgets. 11 | 12 | ### Removed 13 | - `make-widget-sync` - we're all async, all the time. 14 | 15 | ### Fixed 16 | - Fixed widget maker to keep working when daylight savings switches over. 17 | 18 | ## 0.1.0 - 2016-06-18 19 | ### Added 20 | - Files from the new template. 21 | - Widget maker public API - `make-widget-sync`. 22 | 23 | [Unreleased]: https://github.com/your-name/making-change/compare/0.1.1...HEAD 24 | [0.1.1]: https://github.com/your-name/making-change/compare/0.1.0...0.1.1 25 | -------------------------------------------------------------------------------- /reverse-words/CHANGELOG.md: -------------------------------------------------------------------------------- 1 | # Change Log 2 | All notable changes to this project will be documented in this file. This change log follows the conventions of [keepachangelog.com](http://keepachangelog.com/). 3 | 4 | ## [Unreleased] 5 | ### Changed 6 | - Add a new arity to `make-widget-async` to provide a different widget shape. 7 | 8 | ## [0.1.1] - 2016-06-02 9 | ### Changed 10 | - Documentation on how to make the widgets. 11 | 12 | ### Removed 13 | - `make-widget-sync` - we're all async, all the time. 14 | 15 | ### Fixed 16 | - Fixed widget maker to keep working when daylight savings switches over. 17 | 18 | ## 0.1.0 - 2016-06-02 19 | ### Added 20 | - Files from the new template. 21 | - Widget maker public API - `make-widget-sync`. 22 | 23 | [Unreleased]: https://github.com/your-name/reverse-words/compare/0.1.1...HEAD 24 | [0.1.1]: https://github.com/your-name/reverse-words/compare/0.1.0...0.1.1 25 | -------------------------------------------------------------------------------- /cake-thief/src/cake_thief/core.clj: -------------------------------------------------------------------------------- 1 | (ns cake-thief.core 2 | (:gen-class)) 3 | 4 | (defn- max-value-for [current-capacity max-value-at-capacity cakes] 5 | (reduce 6 | (fn [max-value {:keys [weight value]}] 7 | (if (< current-capacity weight) 8 | max-value 9 | (->> (- current-capacity weight) 10 | (get max-value-at-capacity) 11 | (+ value) 12 | (max max-value)))) 13 | 0 14 | cakes)) 15 | 16 | (defn max-duffel-bag-value 17 | "O(n * k) time solution, where k = capacity - dynamic and bottom up." 18 | [cakes capacity] 19 | (get (reduce 20 | (fn [max-value-at-capacity current-capacity] 21 | (->> (max-value-for current-capacity max-value-at-capacity cakes) 22 | (assoc max-value-at-capacity current-capacity))) 23 | (vec (repeat (inc capacity) 0)) 24 | (range (inc capacity))) 25 | capacity)) 26 | -------------------------------------------------------------------------------- /in-place-shuffle/CHANGELOG.md: -------------------------------------------------------------------------------- 1 | # Change Log 2 | All notable changes to this project will be documented in this file. This change log follows the conventions of [keepachangelog.com](http://keepachangelog.com/). 3 | 4 | ## [Unreleased] 5 | ### Changed 6 | - Add a new arity to `make-widget-async` to provide a different widget shape. 7 | 8 | ## [0.1.1] - 2016-06-08 9 | ### Changed 10 | - Documentation on how to make the widgets. 11 | 12 | ### Removed 13 | - `make-widget-sync` - we're all async, all the time. 14 | 15 | ### Fixed 16 | - Fixed widget maker to keep working when daylight savings switches over. 17 | 18 | ## 0.1.0 - 2016-06-08 19 | ### Added 20 | - Files from the new template. 21 | - Widget maker public API - `make-widget-sync`. 22 | 23 | [Unreleased]: https://github.com/your-name/in-place-shuffle/compare/0.1.1...HEAD 24 | [0.1.1]: https://github.com/your-name/in-place-shuffle/compare/0.1.0...0.1.1 25 | -------------------------------------------------------------------------------- /rectangular-love/CHANGELOG.md: -------------------------------------------------------------------------------- 1 | # Change Log 2 | All notable changes to this project will be documented in this file. This change log follows the conventions of [keepachangelog.com](http://keepachangelog.com/). 3 | 4 | ## [Unreleased] 5 | ### Changed 6 | - Add a new arity to `make-widget-async` to provide a different widget shape. 7 | 8 | ## [0.1.1] - 2016-05-24 9 | ### Changed 10 | - Documentation on how to make the widgets. 11 | 12 | ### Removed 13 | - `make-widget-sync` - we're all async, all the time. 14 | 15 | ### Fixed 16 | - Fixed widget maker to keep working when daylight savings switches over. 17 | 18 | ## 0.1.0 - 2016-05-24 19 | ### Added 20 | - Files from the new template. 21 | - Widget maker public API - `make-widget-sync`. 22 | 23 | [Unreleased]: https://github.com/your-name/rectangular-love/compare/0.1.1...HEAD 24 | [0.1.1]: https://github.com/your-name/rectangular-love/compare/0.1.0...0.1.1 25 | -------------------------------------------------------------------------------- /bracket-validator/CHANGELOG.md: -------------------------------------------------------------------------------- 1 | # Change Log 2 | All notable changes to this project will be documented in this file. This change log follows the conventions of [keepachangelog.com](http://keepachangelog.com/). 3 | 4 | ## [Unreleased] 5 | ### Changed 6 | - Add a new arity to `make-widget-async` to provide a different widget shape. 7 | 8 | ## [0.1.1] - 2016-06-03 9 | ### Changed 10 | - Documentation on how to make the widgets. 11 | 12 | ### Removed 13 | - `make-widget-sync` - we're all async, all the time. 14 | 15 | ### Fixed 16 | - Fixed widget maker to keep working when daylight savings switches over. 17 | 18 | ## 0.1.0 - 2016-06-03 19 | ### Added 20 | - Files from the new template. 21 | - Widget maker public API - `make-widget-sync`. 22 | 23 | [Unreleased]: https://github.com/your-name/bracket-validator/compare/0.1.1...HEAD 24 | [0.1.1]: https://github.com/your-name/bracket-validator/compare/0.1.0...0.1.1 25 | -------------------------------------------------------------------------------- /balanced-binary-tree/CHANGELOG.md: -------------------------------------------------------------------------------- 1 | # Change Log 2 | All notable changes to this project will be documented in this file. This change log follows the conventions of [keepachangelog.com](http://keepachangelog.com/). 3 | 4 | ## [Unreleased] 5 | ### Changed 6 | - Add a new arity to `make-widget-async` to provide a different widget shape. 7 | 8 | ## [0.1.1] - 2016-05-25 9 | ### Changed 10 | - Documentation on how to make the widgets. 11 | 12 | ### Removed 13 | - `make-widget-sync` - we're all async, all the time. 14 | 15 | ### Fixed 16 | - Fixed widget maker to keep working when daylight savings switches over. 17 | 18 | ## 0.1.0 - 2016-05-25 19 | ### Added 20 | - Files from the new template. 21 | - Widget maker public API - `make-widget-sync`. 22 | 23 | [Unreleased]: https://github.com/your-name/balanced-binary-tree/compare/0.1.1...HEAD 24 | [0.1.1]: https://github.com/your-name/balanced-binary-tree/compare/0.1.0...0.1.1 25 | -------------------------------------------------------------------------------- /find-in-ordered-set/CHANGELOG.md: -------------------------------------------------------------------------------- 1 | # Change Log 2 | All notable changes to this project will be documented in this file. This change log follows the conventions of [keepachangelog.com](http://keepachangelog.com/). 3 | 4 | ## [Unreleased] 5 | ### Changed 6 | - Add a new arity to `make-widget-async` to provide a different widget shape. 7 | 8 | ## [0.1.1] - 2016-05-28 9 | ### Changed 10 | - Documentation on how to make the widgets. 11 | 12 | ### Removed 13 | - `make-widget-sync` - we're all async, all the time. 14 | 15 | ### Fixed 16 | - Fixed widget maker to keep working when daylight savings switches over. 17 | 18 | ## 0.1.0 - 2016-05-28 19 | ### Added 20 | - Files from the new template. 21 | - Widget maker public API - `make-widget-sync`. 22 | 23 | [Unreleased]: https://github.com/your-name/find-in-ordered-set/compare/0.1.1...HEAD 24 | [0.1.1]: https://github.com/your-name/find-in-ordered-set/compare/0.1.0...0.1.1 25 | -------------------------------------------------------------------------------- /find-rotation-point/CHANGELOG.md: -------------------------------------------------------------------------------- 1 | # Change Log 2 | All notable changes to this project will be documented in this file. This change log follows the conventions of [keepachangelog.com](http://keepachangelog.com/). 3 | 4 | ## [Unreleased] 5 | ### Changed 6 | - Add a new arity to `make-widget-async` to provide a different widget shape. 7 | 8 | ## [0.1.1] - 2016-05-28 9 | ### Changed 10 | - Documentation on how to make the widgets. 11 | 12 | ### Removed 13 | - `make-widget-sync` - we're all async, all the time. 14 | 15 | ### Fixed 16 | - Fixed widget maker to keep working when daylight savings switches over. 17 | 18 | ## 0.1.0 - 2016-05-28 19 | ### Added 20 | - Files from the new template. 21 | - Widget maker public API - `make-widget-sync`. 22 | 23 | [Unreleased]: https://github.com/your-name/find-rotation-point/compare/0.1.1...HEAD 24 | [0.1.1]: https://github.com/your-name/find-rotation-point/compare/0.1.0...0.1.1 25 | -------------------------------------------------------------------------------- /in-place-shuffle/test/in_place_shuffle/core_test.clj: -------------------------------------------------------------------------------- 1 | (ns in-place-shuffle.core-test 2 | (:require [clojure.test :refer :all] 3 | [in-place-shuffle.core :refer :all])) 4 | 5 | (def vector-a [1 2]) 6 | (def vector-b [1 2 3]) 7 | (def vector-c [6 7 2 9 8 1 3]) 8 | (def vector-d [23 88 6 54 23 40 91 66 78 20 12 102]) 9 | 10 | (def edge-a []) 11 | (def edge-b [3]) 12 | 13 | (deftest fisher-yates-shuffle-test 14 | (testing "edge cases" 15 | (is (= (fisher-yates-shuffle edge-a) [])) 16 | (is (= (fisher-yates-shuffle edge-b) [3]))) 17 | (testing "shuffles items in vector, preserves items and count of vector" 18 | (is (= (sort (fisher-yates-shuffle vector-a)) (sort vector-a))) 19 | (is (= (sort (fisher-yates-shuffle vector-b)) (sort vector-b))) 20 | (is (= (sort (fisher-yates-shuffle vector-c)) (sort vector-c))) 21 | (is (= (sort (fisher-yates-shuffle vector-d)) (sort vector-d))))) 22 | -------------------------------------------------------------------------------- /merge-sorted-arrays/CHANGELOG.md: -------------------------------------------------------------------------------- 1 | # Change Log 2 | All notable changes to this project will be documented in this file. This change log follows the conventions of [keepachangelog.com](http://keepachangelog.com/). 3 | 4 | ## [Unreleased] 5 | ### Changed 6 | - Add a new arity to `make-widget-async` to provide a different widget shape. 7 | 8 | ## [0.1.1] - 2016-06-12 9 | ### Changed 10 | - Documentation on how to make the widgets. 11 | 12 | ### Removed 13 | - `make-widget-sync` - we're all async, all the time. 14 | 15 | ### Fixed 16 | - Fixed widget maker to keep working when daylight savings switches over. 17 | 18 | ## 0.1.0 - 2016-06-12 19 | ### Added 20 | - Files from the new template. 21 | - Widget maker public API - `make-widget-sync`. 22 | 23 | [Unreleased]: https://github.com/your-name/merge-sorted-arrays/compare/0.1.1...HEAD 24 | [0.1.1]: https://github.com/your-name/merge-sorted-arrays/compare/0.1.0...0.1.1 25 | -------------------------------------------------------------------------------- /parenthesis-matching/CHANGELOG.md: -------------------------------------------------------------------------------- 1 | # Change Log 2 | All notable changes to this project will be documented in this file. This change log follows the conventions of [keepachangelog.com](http://keepachangelog.com/). 3 | 4 | ## [Unreleased] 5 | ### Changed 6 | - Add a new arity to `make-widget-async` to provide a different widget shape. 7 | 8 | ## [0.1.1] - 2016-06-03 9 | ### Changed 10 | - Documentation on how to make the widgets. 11 | 12 | ### Removed 13 | - `make-widget-sync` - we're all async, all the time. 14 | 15 | ### Fixed 16 | - Fixed widget maker to keep working when daylight savings switches over. 17 | 18 | ## 0.1.0 - 2016-06-03 19 | ### Added 20 | - Files from the new template. 21 | - Widget maker public API - `make-widget-sync`. 22 | 23 | [Unreleased]: https://github.com/your-name/parenthesis-matching/compare/0.1.1...HEAD 24 | [0.1.1]: https://github.com/your-name/parenthesis-matching/compare/0.1.0...0.1.1 25 | -------------------------------------------------------------------------------- /reverse-linked-list/CHANGELOG.md: -------------------------------------------------------------------------------- 1 | # Change Log 2 | All notable changes to this project will be documented in this file. This change log follows the conventions of [keepachangelog.com](http://keepachangelog.com/). 3 | 4 | ## [Unreleased] 5 | ### Changed 6 | - Add a new arity to `make-widget-async` to provide a different widget shape. 7 | 8 | ## [0.1.1] - 2016-06-01 9 | ### Changed 10 | - Documentation on how to make the widgets. 11 | 12 | ### Removed 13 | - `make-widget-sync` - we're all async, all the time. 14 | 15 | ### Fixed 16 | - Fixed widget maker to keep working when daylight savings switches over. 17 | 18 | ## 0.1.0 - 2016-06-01 19 | ### Added 20 | - Files from the new template. 21 | - Widget maker public API - `make-widget-sync`. 22 | 23 | [Unreleased]: https://github.com/your-name/reverse-linked-list/compare/0.1.1...HEAD 24 | [0.1.1]: https://github.com/your-name/reverse-linked-list/compare/0.1.0...0.1.1 25 | -------------------------------------------------------------------------------- /simulate-5-sided-die/CHANGELOG.md: -------------------------------------------------------------------------------- 1 | # Change Log 2 | All notable changes to this project will be documented in this file. This change log follows the conventions of [keepachangelog.com](http://keepachangelog.com/). 3 | 4 | ## [Unreleased] 5 | ### Changed 6 | - Add a new arity to `make-widget-async` to provide a different widget shape. 7 | 8 | ## [0.1.1] - 2016-06-09 9 | ### Changed 10 | - Documentation on how to make the widgets. 11 | 12 | ### Removed 13 | - `make-widget-sync` - we're all async, all the time. 14 | 15 | ### Fixed 16 | - Fixed widget maker to keep working when daylight savings switches over. 17 | 18 | ## 0.1.0 - 2016-06-09 19 | ### Added 20 | - Files from the new template. 21 | - Widget maker public API - `make-widget-sync`. 22 | 23 | [Unreleased]: https://github.com/your-name/simulate-5-sided-die/compare/0.1.1...HEAD 24 | [0.1.1]: https://github.com/your-name/simulate-5-sided-die/compare/0.1.0...0.1.1 25 | -------------------------------------------------------------------------------- /simulate-7-sided-die/CHANGELOG.md: -------------------------------------------------------------------------------- 1 | # Change Log 2 | All notable changes to this project will be documented in this file. This change log follows the conventions of [keepachangelog.com](http://keepachangelog.com/). 3 | 4 | ## [Unreleased] 5 | ### Changed 6 | - Add a new arity to `make-widget-async` to provide a different widget shape. 7 | 8 | ## [0.1.1] - 2016-06-10 9 | ### Changed 10 | - Documentation on how to make the widgets. 11 | 12 | ### Removed 13 | - `make-widget-sync` - we're all async, all the time. 14 | 15 | ### Fixed 16 | - Fixed widget maker to keep working when daylight savings switches over. 17 | 18 | ## 0.1.0 - 2016-06-10 19 | ### Added 20 | - Files from the new template. 21 | - Widget maker public API - `make-widget-sync`. 22 | 23 | [Unreleased]: https://github.com/your-name/simulate-7-sided-die/compare/0.1.1...HEAD 24 | [0.1.1]: https://github.com/your-name/simulate-7-sided-die/compare/0.1.0...0.1.1 25 | -------------------------------------------------------------------------------- /which-appears-twice/CHANGELOG.md: -------------------------------------------------------------------------------- 1 | # Change Log 2 | All notable changes to this project will be documented in this file. This change log follows the conventions of [keepachangelog.com](http://keepachangelog.com/). 3 | 4 | ## [Unreleased] 5 | ### Changed 6 | - Add a new arity to `make-widget-async` to provide a different widget shape. 7 | 8 | ## [0.1.1] - 2016-06-06 9 | ### Changed 10 | - Documentation on how to make the widgets. 11 | 12 | ### Removed 13 | - `make-widget-sync` - we're all async, all the time. 14 | 15 | ### Fixed 16 | - Fixed widget maker to keep working when daylight savings switches over. 17 | 18 | ## 0.1.0 - 2016-06-06 19 | ### Added 20 | - Files from the new template. 21 | - Widget maker public API - `make-widget-sync`. 22 | 23 | [Unreleased]: https://github.com/your-name/which-appears-twice/compare/0.1.1...HEAD 24 | [0.1.1]: https://github.com/your-name/which-appears-twice/compare/0.1.0...0.1.1 25 | -------------------------------------------------------------------------------- /merging-meeting-times/CHANGELOG.md: -------------------------------------------------------------------------------- 1 | # Change Log 2 | All notable changes to this project will be documented in this file. This change log follows the conventions of [keepachangelog.com](http://keepachangelog.com/). 3 | 4 | ## [Unreleased] 5 | ### Changed 6 | - Add a new arity to `make-widget-async` to provide a different widget shape. 7 | 8 | ## [0.1.1] - 2016-05-24 9 | ### Changed 10 | - Documentation on how to make the widgets. 11 | 12 | ### Removed 13 | - `make-widget-sync` - we're all async, all the time. 14 | 15 | ### Fixed 16 | - Fixed widget maker to keep working when daylight savings switches over. 17 | 18 | ## 0.1.0 - 2016-05-24 19 | ### Added 20 | - Files from the new template. 21 | - Widget maker public API - `make-widget-sync`. 22 | 23 | [Unreleased]: https://github.com/your-name/merging-meeting-times/compare/0.1.1...HEAD 24 | [0.1.1]: https://github.com/your-name/merging-meeting-times/compare/0.1.0...0.1.1 25 | -------------------------------------------------------------------------------- /single-riffle-shuffle/CHANGELOG.md: -------------------------------------------------------------------------------- 1 | # Change Log 2 | All notable changes to this project will be documented in this file. This change log follows the conventions of [keepachangelog.com](http://keepachangelog.com/). 3 | 4 | ## [Unreleased] 5 | ### Changed 6 | - Add a new arity to `make-widget-async` to provide a different widget shape. 7 | 8 | ## [0.1.1] - 2016-06-08 9 | ### Changed 10 | - Documentation on how to make the widgets. 11 | 12 | ### Removed 13 | - `make-widget-sync` - we're all async, all the time. 14 | 15 | ### Fixed 16 | - Fixed widget maker to keep working when daylight savings switches over. 17 | 18 | ## 0.1.0 - 2016-06-08 19 | ### Added 20 | - Files from the new template. 21 | - Widget maker public API - `make-widget-sync`. 22 | 23 | [Unreleased]: https://github.com/your-name/single-riffle-shuffle/compare/0.1.1...HEAD 24 | [0.1.1]: https://github.com/your-name/single-riffle-shuffle/compare/0.1.0...0.1.1 25 | -------------------------------------------------------------------------------- /inflight-entertainment/CHANGELOG.md: -------------------------------------------------------------------------------- 1 | # Change Log 2 | All notable changes to this project will be documented in this file. This change log follows the conventions of [keepachangelog.com](http://keepachangelog.com/). 3 | 4 | ## [Unreleased] 5 | ### Changed 6 | - Add a new arity to `make-widget-async` to provide a different widget shape. 7 | 8 | ## [0.1.1] - 2016-05-28 9 | ### Changed 10 | - Documentation on how to make the widgets. 11 | 12 | ### Removed 13 | - `make-widget-sync` - we're all async, all the time. 14 | 15 | ### Fixed 16 | - Fixed widget maker to keep working when daylight savings switches over. 17 | 18 | ## 0.1.0 - 2016-05-28 19 | ### Added 20 | - Files from the new template. 21 | - Widget maker public API - `make-widget-sync`. 22 | 23 | [Unreleased]: https://github.com/your-name/inflight-entertainment/compare/0.1.1...HEAD 24 | [0.1.1]: https://github.com/your-name/inflight-entertainment/compare/0.1.0...0.1.1 25 | -------------------------------------------------------------------------------- /kth-to-last-linked-list/CHANGELOG.md: -------------------------------------------------------------------------------- 1 | # Change Log 2 | All notable changes to this project will be documented in this file. This change log follows the conventions of [keepachangelog.com](http://keepachangelog.com/). 3 | 4 | ## [Unreleased] 5 | ### Changed 6 | - Add a new arity to `make-widget-async` to provide a different widget shape. 7 | 8 | ## [0.1.1] - 2016-06-01 9 | ### Changed 10 | - Documentation on how to make the widgets. 11 | 12 | ### Removed 13 | - `make-widget-sync` - we're all async, all the time. 14 | 15 | ### Fixed 16 | - Fixed widget maker to keep working when daylight savings switches over. 17 | 18 | ## 0.1.0 - 2016-06-01 19 | ### Added 20 | - Files from the new template. 21 | - Widget maker public API - `make-widget-sync`. 22 | 23 | [Unreleased]: https://github.com/your-name/kth-to-last-linked-list/compare/0.1.1...HEAD 24 | [0.1.1]: https://github.com/your-name/kth-to-last-linked-list/compare/0.1.0...0.1.1 25 | -------------------------------------------------------------------------------- /permutation-palindrome/CHANGELOG.md: -------------------------------------------------------------------------------- 1 | # Change Log 2 | All notable changes to this project will be documented in this file. This change log follows the conventions of [keepachangelog.com](http://keepachangelog.com/). 3 | 4 | ## [Unreleased] 5 | ### Changed 6 | - Add a new arity to `make-widget-async` to provide a different widget shape. 7 | 8 | ## [0.1.1] - 2016-06-04 9 | ### Changed 10 | - Documentation on how to make the widgets. 11 | 12 | ### Removed 13 | - `make-widget-sync` - we're all async, all the time. 14 | 15 | ### Fixed 16 | - Fixed widget maker to keep working when daylight savings switches over. 17 | 18 | ## 0.1.0 - 2016-06-04 19 | ### Added 20 | - Files from the new template. 21 | - Widget maker public API - `make-widget-sync`. 22 | 23 | [Unreleased]: https://github.com/your-name/permutation-palindrome/compare/0.1.1...HEAD 24 | [0.1.1]: https://github.com/your-name/permutation-palindrome/compare/0.1.0...0.1.1 25 | -------------------------------------------------------------------------------- /reverse-string-in-place/CHANGELOG.md: -------------------------------------------------------------------------------- 1 | # Change Log 2 | All notable changes to this project will be documented in this file. This change log follows the conventions of [keepachangelog.com](http://keepachangelog.com/). 3 | 4 | ## [Unreleased] 5 | ### Changed 6 | - Add a new arity to `make-widget-async` to provide a different widget shape. 7 | 8 | ## [0.1.1] - 2016-06-16 9 | ### Changed 10 | - Documentation on how to make the widgets. 11 | 12 | ### Removed 13 | - `make-widget-sync` - we're all async, all the time. 14 | 15 | ### Fixed 16 | - Fixed widget maker to keep working when daylight savings switches over. 17 | 18 | ## 0.1.0 - 2016-06-16 19 | ### Added 20 | - Files from the new template. 21 | - Widget maker public API - `make-widget-sync`. 22 | 23 | [Unreleased]: https://github.com/your-name/reverse-string-in-place/compare/0.1.1...HEAD 24 | [0.1.1]: https://github.com/your-name/reverse-string-in-place/compare/0.1.0...0.1.1 25 | -------------------------------------------------------------------------------- /find-repeat-space-edition/CHANGELOG.md: -------------------------------------------------------------------------------- 1 | # Change Log 2 | All notable changes to this project will be documented in this file. This change log follows the conventions of [keepachangelog.com](http://keepachangelog.com/). 3 | 4 | ## [Unreleased] 5 | ### Changed 6 | - Add a new arity to `make-widget-async` to provide a different widget shape. 7 | 8 | ## [0.1.1] - 2016-06-16 9 | ### Changed 10 | - Documentation on how to make the widgets. 11 | 12 | ### Removed 13 | - `make-widget-sync` - we're all async, all the time. 14 | 15 | ### Fixed 16 | - Fixed widget maker to keep working when daylight savings switches over. 17 | 18 | ## 0.1.0 - 2016-06-16 19 | ### Added 20 | - Files from the new template. 21 | - Widget maker public API - `make-widget-sync`. 22 | 23 | [Unreleased]: https://github.com/your-name/find-repeat-space-edition/compare/0.1.1...HEAD 24 | [0.1.1]: https://github.com/your-name/find-repeat-space-edition/compare/0.1.0...0.1.1 25 | -------------------------------------------------------------------------------- /highest-product-of-three/CHANGELOG.md: -------------------------------------------------------------------------------- 1 | # Change Log 2 | All notable changes to this project will be documented in this file. This change log follows the conventions of [keepachangelog.com](http://keepachangelog.com/). 3 | 4 | ## [Unreleased] 5 | ### Changed 6 | - Add a new arity to `make-widget-async` to provide a different widget shape. 7 | 8 | ## [0.1.1] - 2016-05-17 9 | ### Changed 10 | - Documentation on how to make the widgets. 11 | 12 | ### Removed 13 | - `make-widget-sync` - we're all async, all the time. 14 | 15 | ### Fixed 16 | - Fixed widget maker to keep working when daylight savings switches over. 17 | 18 | ## 0.1.0 - 2016-05-17 19 | ### Added 20 | - Files from the new template. 21 | - Widget maker public API - `make-widget-sync`. 22 | 23 | [Unreleased]: https://github.com/your-name/highest-product-of-three/compare/0.1.1...HEAD 24 | [0.1.1]: https://github.com/your-name/highest-product-of-three/compare/0.1.0...0.1.1 25 | -------------------------------------------------------------------------------- /binary-search-tree-checker/CHANGELOG.md: -------------------------------------------------------------------------------- 1 | # Change Log 2 | All notable changes to this project will be documented in this file. This change log follows the conventions of [keepachangelog.com](http://keepachangelog.com/). 3 | 4 | ## [Unreleased] 5 | ### Changed 6 | - Add a new arity to `make-widget-async` to provide a different widget shape. 7 | 8 | ## [0.1.1] - 2016-05-26 9 | ### Changed 10 | - Documentation on how to make the widgets. 11 | 12 | ### Removed 13 | - `make-widget-sync` - we're all async, all the time. 14 | 15 | ### Fixed 16 | - Fixed widget maker to keep working when daylight savings switches over. 17 | 18 | ## 0.1.0 - 2016-05-26 19 | ### Added 20 | - Files from the new template. 21 | - Widget maker public API - `make-widget-sync`. 22 | 23 | [Unreleased]: https://github.com/your-name/binary-search-tree-checker/compare/0.1.1...HEAD 24 | [0.1.1]: https://github.com/your-name/binary-search-tree-checker/compare/0.1.0...0.1.1 25 | -------------------------------------------------------------------------------- /the-stolen-breakfast-drone/CHANGELOG.md: -------------------------------------------------------------------------------- 1 | # Change Log 2 | All notable changes to this project will be documented in this file. This change log follows the conventions of [keepachangelog.com](http://keepachangelog.com/). 3 | 4 | ## [Unreleased] 5 | ### Changed 6 | - Add a new arity to `make-widget-async` to provide a different widget shape. 7 | 8 | ## [0.1.1] - 2016-06-01 9 | ### Changed 10 | - Documentation on how to make the widgets. 11 | 12 | ### Removed 13 | - `make-widget-sync` - we're all async, all the time. 14 | 15 | ### Fixed 16 | - Fixed widget maker to keep working when daylight savings switches over. 17 | 18 | ## 0.1.0 - 2016-06-01 19 | ### Added 20 | - Files from the new template. 21 | - Widget maker public API - `make-widget-sync`. 22 | 23 | [Unreleased]: https://github.com/your-name/the-stolen-breakfast-drone/compare/0.1.1...HEAD 24 | [0.1.1]: https://github.com/your-name/the-stolen-breakfast-drone/compare/0.1.0...0.1.1 25 | -------------------------------------------------------------------------------- /product-of-all-other-numbers/CHANGELOG.md: -------------------------------------------------------------------------------- 1 | # Change Log 2 | All notable changes to this project will be documented in this file. This change log follows the conventions of [keepachangelog.com](http://keepachangelog.com/). 3 | 4 | ## [Unreleased] 5 | ### Changed 6 | - Add a new arity to `make-widget-async` to provide a different widget shape. 7 | 8 | ## [0.1.1] - 2016-05-15 9 | ### Changed 10 | - Documentation on how to make the widgets. 11 | 12 | ### Removed 13 | - `make-widget-sync` - we're all async, all the time. 14 | 15 | ### Fixed 16 | - Fixed widget maker to keep working when daylight savings switches over. 17 | 18 | ## 0.1.0 - 2016-05-15 19 | ### Added 20 | - Files from the new template. 21 | - Widget maker public API - `make-widget-sync`. 22 | 23 | [Unreleased]: https://github.com/your-name/product-of-all-other-numbers/compare/0.1.1...HEAD 24 | [0.1.1]: https://github.com/your-name/product-of-all-other-numbers/compare/0.1.0...0.1.1 25 | -------------------------------------------------------------------------------- /compute-nth-fibbonacci-number/CHANGELOG.md: -------------------------------------------------------------------------------- 1 | # Change Log 2 | All notable changes to this project will be documented in this file. This change log follows the conventions of [keepachangelog.com](http://keepachangelog.com/). 3 | 4 | ## [Unreleased] 5 | ### Changed 6 | - Add a new arity to `make-widget-async` to provide a different widget shape. 7 | 8 | ## [0.1.1] - 2016-05-28 9 | ### Changed 10 | - Documentation on how to make the widgets. 11 | 12 | ### Removed 13 | - `make-widget-sync` - we're all async, all the time. 14 | 15 | ### Fixed 16 | - Fixed widget maker to keep working when daylight savings switches over. 17 | 18 | ## 0.1.0 - 2016-05-28 19 | ### Added 20 | - Files from the new template. 21 | - Widget maker public API - `make-widget-sync`. 22 | 23 | [Unreleased]: https://github.com/your-name/compute-nth-fibbonacci-number/compare/0.1.1...HEAD 24 | [0.1.1]: https://github.com/your-name/compute-nth-fibbonacci-number/compare/0.1.0...0.1.1 25 | -------------------------------------------------------------------------------- /recursive-string-permutations/CHANGELOG.md: -------------------------------------------------------------------------------- 1 | # Change Log 2 | All notable changes to this project will be documented in this file. This change log follows the conventions of [keepachangelog.com](http://keepachangelog.com/). 3 | 4 | ## [Unreleased] 5 | ### Changed 6 | - Add a new arity to `make-widget-async` to provide a different widget shape. 7 | 8 | ## [0.1.1] - 2016-06-05 9 | ### Changed 10 | - Documentation on how to make the widgets. 11 | 12 | ### Removed 13 | - `make-widget-sync` - we're all async, all the time. 14 | 15 | ### Fixed 16 | - Fixed widget maker to keep working when daylight savings switches over. 17 | 18 | ## 0.1.0 - 2016-06-05 19 | ### Added 20 | - Files from the new template. 21 | - Widget maker public API - `make-widget-sync`. 22 | 23 | [Unreleased]: https://github.com/your-name/recursive-string-permutations/compare/0.1.1...HEAD 24 | [0.1.1]: https://github.com/your-name/recursive-string-permutations/compare/0.1.0...0.1.1 25 | -------------------------------------------------------------------------------- /second-largest-in-binary-search-tree/CHANGELOG.md: -------------------------------------------------------------------------------- 1 | # Change Log 2 | All notable changes to this project will be documented in this file. This change log follows the conventions of [keepachangelog.com](http://keepachangelog.com/). 3 | 4 | ## [Unreleased] 5 | ### Changed 6 | - Add a new arity to `make-widget-async` to provide a different widget shape. 7 | 8 | ## [0.1.1] - 2016-05-27 9 | ### Changed 10 | - Documentation on how to make the widgets. 11 | 12 | ### Removed 13 | - `make-widget-sync` - we're all async, all the time. 14 | 15 | ### Fixed 16 | - Fixed widget maker to keep working when daylight savings switches over. 17 | 18 | ## 0.1.0 - 2016-05-27 19 | ### Added 20 | - Files from the new template. 21 | - Widget maker public API - `make-widget-sync`. 22 | 23 | [Unreleased]: https://github.com/your-name/second-largest-in-binary-search-tree/compare/0.1.1...HEAD 24 | [0.1.1]: https://github.com/your-name/second-largest-in-binary-search-tree/compare/0.1.0...0.1.1 25 | -------------------------------------------------------------------------------- /bracket-validator/test/bracket_validator/core_test.clj: -------------------------------------------------------------------------------- 1 | (ns bracket-validator.core-test 2 | (:require [clojure.test :refer :all] 3 | [bracket-validator.core :refer :all])) 4 | 5 | (def str-a "{[]()}") 6 | (def str-b "{[(])}") 7 | (def str-c "{[}") 8 | (def str-d "{[()()[[()]{{}}]]}") 9 | (def str-e "{[()([[(){{}]]}") 10 | 11 | (def edge-a "[]") 12 | (def edge-b ")") 13 | (def edge-c "{") 14 | (def edge-d "{[(({{[[") 15 | 16 | (deftest valid-brackets?-test 17 | (testing "edge cases" 18 | (is (= (valid-brackets? edge-a) true)) 19 | (is (= (valid-brackets? edge-b) false)) 20 | (is (= (valid-brackets? edge-c) false)) 21 | (is (= (valid-brackets? edge-d) false))) 22 | (testing "checks validity of brackets" 23 | (is (= (valid-brackets? str-a) true)) 24 | (is (= (valid-brackets? str-b) false)) 25 | (is (= (valid-brackets? str-c) false)) 26 | (is (= (valid-brackets? str-d) true)) 27 | (is (= (valid-brackets? str-e) false)))) 28 | -------------------------------------------------------------------------------- /find-in-ordered-set/test/find_in_ordered_set/core_test.clj: -------------------------------------------------------------------------------- 1 | (ns find-in-ordered-set.core-test 2 | (:require [clojure.test :refer :all] 3 | [find-in-ordered-set.core :refer :all])) 4 | 5 | (deftest binary-search-test 6 | (testing "edge cases" 7 | (is (= (binary-search [] 1) -1)) 8 | (is (= (binary-search (vec (range 5)) 10) -1)) 9 | (is (= (binary-search [1 2] 3) -1)) 10 | (is (= (binary-search [1 2] 2) 1))) 11 | (testing "should return index of item in vector, -1 if not found" 12 | (is (= (binary-search (vec (range 10)) 2) 2)) 13 | (is (= (binary-search (vec (range 2 20 2)) 2) 0)) 14 | (is (= (binary-search (vec (range 2 20 2)) 12) 5)) 15 | (is (= (binary-search (vec (range 0 10 3)) 9) 3)) 16 | (is (= (binary-search (vec (range 0 10 3)) 3) 1)) 17 | (is (= (binary-search (vec (range 0 10 3)) 0) 0)) 18 | (is (= (binary-search (vec (range 0 100 3)) 45) 15)) 19 | (is (= (binary-search (vec (range 0 100 3)) 500) -1)))) 20 | -------------------------------------------------------------------------------- /top-scores/test/top_scores/core_test.clj: -------------------------------------------------------------------------------- 1 | (ns top-scores.core-test 2 | (:require [clojure.test :refer :all] 3 | [top-scores.core :refer :all])) 4 | 5 | (defn ordered? [coll] 6 | (if (<= (count coll) 1) 7 | true 8 | (apply <= coll))) 9 | 10 | (def coll-a (shuffle [5 3 4 8])) 11 | (def coll-b (shuffle [45 78 2 4 9 99 100 23 17])) 12 | (def coll-c (shuffle [4 49 15 2 2 3 15 17 9 13 23 45 4 13])) 13 | (def coll-d (shuffle [678 812 13 100 245 346 45 98 99 956 100 13 812 812])) 14 | (def coll-e (shuffle [1 1 1 3 3 3 3 4 4 5 6 6 6 6 6])) 15 | 16 | (deftest counting-sort-test 17 | (testing "edge cases" 18 | (is (ordered? (counting-sort [] 0))) 19 | (is (ordered? (counting-sort [1] 1))) 20 | (is (ordered? (counting-sort [1 2] 2)))) 21 | (testing "returns sorted collection" 22 | (is (ordered? (counting-sort coll-a 10))) 23 | (is (ordered? (counting-sort coll-b 100))) 24 | (is (ordered? (counting-sort coll-c 50))) 25 | (is (ordered? (counting-sort coll-d 1000))) 26 | (is (ordered? (counting-sort coll-e 6))))) 27 | -------------------------------------------------------------------------------- /find-repeat-space-edition/test/find_repeat_space_edition/core_test.clj: -------------------------------------------------------------------------------- 1 | (ns find-repeat-space-edition.core-test 2 | (:require [clojure.test :refer :all] 3 | [find-repeat-space-edition.core :refer :all])) 4 | 5 | (deftest find-repeat-test 6 | (testing "edge cases" 7 | (is (= (find-repeat []) 1)) 8 | (is (= (find-repeat [1 1]) 1)) 9 | (is (= (find-repeat '()) 1)) 10 | (is (= (find-repeat '(1 2 2 3)) 2))) 11 | (testing "returns duplicate item in range" 12 | (is (= (find-repeat [1 2 2]) 2)) 13 | (is (= (find-repeat [2 2 1]) 2)) 14 | (is (= (find-repeat [3 4 4 5 1 2]) 4)) 15 | (is (= (find-repeat '(3 4 4 5 1 2)) 4)) 16 | (is (= (find-repeat [5 4 3 7 1 2 6 6 8 9 10]) 6)) 17 | (is (= (find-repeat [1 1 2 3 4 5 6 7 8 9 10 11 12 13]) 1)) 18 | (is (= (find-repeat [1 2 3 4 5 6 7 8 9 10 11 12 13 13]) 13)) 19 | (is (= (find-repeat (concat (range 1 100) (range 99 200))) 99)) 20 | (is (= (find-repeat (reverse (concat (range 1 50) (range 49 60)))) 49)) 21 | (is (= (find-repeat (shuffle (concat (range 1 50) (range 49 200)))) 49)))) 22 | -------------------------------------------------------------------------------- /merge-sorted-arrays/test/merge_sorted_arrays/core_test.clj: -------------------------------------------------------------------------------- 1 | (ns merge-sorted-arrays.core-test 2 | (:require [clojure.test :refer :all] 3 | [merge-sorted-arrays.core :refer :all])) 4 | 5 | (def vec-a [1 2 3]) 6 | (def vec-b [3 4 7 9 13]) 7 | (def vec-c [1 2 5 23 54 67 89 123 456 789]) 8 | (def vec-d (vec (filter even? (range 1000)))) 9 | (def vec-e (vec (filter odd? (range 1000)))) 10 | (def vec-f (vec (range 1000))) 11 | 12 | (def edge-a []) 13 | (def edge-b [5]) 14 | (def edge-c '(4)) 15 | 16 | (deftest merge-colls-test 17 | (testing "edge cases" 18 | (is (= (merge-colls edge-a edge-a) edge-a)) 19 | (is (= (merge-colls edge-a edge-b) edge-b)) 20 | (is (= (merge-colls edge-b edge-c) (concat edge-c edge-b)))) 21 | (testing "returns merged sorted collections" 22 | (is (= (merge-colls vec-a edge-a) vec-a)) 23 | (is (= (merge-colls vec-a vec-b) (concat vec-a vec-b))) 24 | (is (= (merge-colls (seq vec-a) (seq vec-b)) (concat vec-a vec-b))) 25 | (is (= (merge-colls vec-b vec-c) [1 2 3 4 5 7 9 13 23 54 67 89 123 456 789])) 26 | (is (= (merge-colls vec-d vec-e) vec-f)))) 27 | -------------------------------------------------------------------------------- /balanced-binary-tree/test/balanced_binary_tree/core_test.clj: -------------------------------------------------------------------------------- 1 | (ns balanced-binary-tree.core-test 2 | (:require [clojure.test :refer :all] 3 | [balanced-binary-tree.core :refer :all] 4 | [balanced-binary-tree.binary-tree :as tree])) 5 | 6 | (def balanced-a (tree/coll->binary-search-tree [10 5 15 0 20])) 7 | (def balanced-b (tree/coll->binary-search-tree [10 5 15 20])) 8 | (def unbalanced-a (tree/coll->binary-search-tree (range 10))) 9 | (def unbalanced-b (tree/coll->binary-search-tree [10 5 15 20 25])) 10 | 11 | (def edge-a (tree/coll->binary-search-tree [])) 12 | (def edge-b (tree/coll->binary-search-tree [10])) 13 | (def edge-c (tree/coll->binary-search-tree [10 5])) 14 | 15 | (deftest balanced?-test 16 | (testing "edge cases" 17 | (is (= (balanced? edge-a) true)) 18 | (is (= (balanced? edge-b) true)) 19 | (is (= (balanced? edge-c) true))) 20 | (testing "should check if a binary tree is balanced" 21 | (is (= (balanced? balanced-a) true)) 22 | (is (= (balanced? balanced-b) true)) 23 | (is (= (balanced? unbalanced-a) false)) 24 | (is (= (balanced? unbalanced-b) false)))) 25 | -------------------------------------------------------------------------------- /find-repeat-space-edition/src/find_repeat_space_edition/core.clj: -------------------------------------------------------------------------------- 1 | (ns find-repeat-space-edition.core 2 | (:gen-class)) 3 | 4 | (defn- bound [floor ceiling] 5 | {:floor floor :ceiling ceiling}) 6 | 7 | (defn- bound->midpoint [{:keys [floor ceiling]}] 8 | (-> (- ceiling floor) 9 | (/ 2) 10 | int 11 | (+ floor))) 12 | 13 | (defn- bound->length [{:keys [floor ceiling]}] 14 | (inc (- ceiling floor))) 15 | 16 | (defn- lower-bound [{:keys [floor] :as bounds}] 17 | (bound floor (bound->midpoint bounds))) 18 | 19 | (defn- upper-bound [{:keys [ceiling] :as bounds}] 20 | (bound (inc (bound->midpoint bounds)) ceiling)) 21 | 22 | (defn- items-in-bound [arr {:keys [floor ceiling]}] 23 | (count (filter #(<= floor % ceiling) arr))) 24 | 25 | (defn find-repeat 26 | "O(nlgn) time + O(1) space solution." 27 | [arr] 28 | (loop [{:keys [floor ceiling] :as bounds} (bound 1 (dec (count arr)))] 29 | (let [lower (lower-bound bounds) 30 | upper (upper-bound bounds)] 31 | (cond 32 | (>= floor ceiling) floor 33 | (> (items-in-bound arr lower) (bound->length lower)) (recur lower) 34 | :else (recur upper))))) 35 | -------------------------------------------------------------------------------- /simulate-5-sided-die/test/simulate_5_sided_die/core_test.clj: -------------------------------------------------------------------------------- 1 | (ns simulate-5-sided-die.core-test 2 | (:require [clojure.test :refer :all] 3 | [simulate-5-sided-die.core :refer :all])) 4 | 5 | (def ^:const min-value 1) 6 | (def ^:const max-value 5) 7 | (def ^:const sample-size 10000) 8 | 9 | (def ^:const expected-frequency (* sample-size (/ min-value max-value))) 10 | (def ^:const limit-frequency (* sample-size (/ (inc min-value) max-value))) 11 | (def ^:const margin-of-error (/ (- limit-frequency expected-frequency) 16)) 12 | 13 | (defn within-margin-of-error? [freq] 14 | (<= (- expected-frequency margin-of-error) 15 | freq 16 | (+ expected-frequency margin-of-error))) 17 | 18 | (defn within-range? [value] 19 | (<= min-value value max-value)) 20 | 21 | (deftest rand5-test 22 | (let [sample (take sample-size (repeatedly rand5)) 23 | sample-frequencies (frequencies sample)] 24 | (testing "probablity distribution" 25 | (is (= max-value (count (keys sample-frequencies)))) 26 | (is (every? within-margin-of-error? (vals sample-frequencies)))) 27 | (testing "range check" 28 | (is (every? within-range? (keys sample-frequencies)))))) 29 | -------------------------------------------------------------------------------- /simulate-7-sided-die/test/simulate_7_sided_die/core_test.clj: -------------------------------------------------------------------------------- 1 | (ns simulate-7-sided-die.core-test 2 | (:require [clojure.test :refer :all] 3 | [simulate-7-sided-die.core :refer :all])) 4 | 5 | (def ^:const min-value 1) 6 | (def ^:const max-value 7) 7 | (def ^:const sample-size 10000) 8 | 9 | (def ^:const expected-frequency (* sample-size (/ min-value max-value))) 10 | (def ^:const limit-frequency (* sample-size (/ (inc min-value) max-value))) 11 | (def ^:const margin-of-error (/ (- limit-frequency expected-frequency) 8)) 12 | 13 | (defn within-margin-of-error? [freq] 14 | (<= (- expected-frequency margin-of-error) 15 | freq 16 | (+ expected-frequency margin-of-error))) 17 | 18 | (defn within-range? [value] 19 | (<= min-value value max-value)) 20 | 21 | (deftest rand7-test 22 | (let [sample (take sample-size (repeatedly rand7)) 23 | sample-frequencies (frequencies sample)] 24 | (testing "probablity distribution" 25 | (is (= max-value (count (keys sample-frequencies)))) 26 | (is (every? within-margin-of-error? (vals sample-frequencies)))) 27 | (testing "range check" 28 | (is (every? within-range? (keys sample-frequencies)))))) 29 | -------------------------------------------------------------------------------- /kth-to-last-linked-list/test/kth_to_last_linked_list/core_test.clj: -------------------------------------------------------------------------------- 1 | (ns kth-to-last-linked-list.core-test 2 | (:require [clojure.test :refer :all] 3 | [kth-to-last-linked-list.core :refer :all] 4 | [kth-to-last-linked-list.list :as list])) 5 | 6 | (def list-a (list/coll->list [4 2 5])) 7 | (def list-b (list/coll->list [6 7 8])) 8 | (def list-c (list/coll->list [5 8 3 4 5 8])) 9 | (def list-d (list/coll->list [3 56 99 72 45 76 1 29])) 10 | (def list-e (list/coll->list (range 0 50 3))) 11 | 12 | (def edge-a (list/coll->list [])) 13 | (def edge-b (list/coll->list [7])) 14 | 15 | (deftest kth-to-last-node-test 16 | (testing "edge cases" 17 | (is (= (kth-to-last-node edge-a 0) nil)) 18 | (is (= (kth-to-last-node edge-b 0) 7)) 19 | (is (= (kth-to-last-node edge-b 5) nil)) 20 | (is (= (kth-to-last-node list-b 2) 6))) 21 | (testing "returns kth from last node in list" 22 | (is (= (kth-to-last-node list-a 0) 5)) 23 | (is (= (kth-to-last-node list-a 1) 2)) 24 | (is (= (kth-to-last-node list-b 2) 6)) 25 | (is (= (kth-to-last-node list-c 3) 3)) 26 | (is (= (kth-to-last-node list-d 4) 72)) 27 | (is (= (kth-to-last-node list-d (dec (list/length list-d))) 3)) 28 | (is (= (kth-to-last-node list-e 5) 33)))) 29 | -------------------------------------------------------------------------------- /parenthesis-matching/test/parenthesis_matching/core_test.clj: -------------------------------------------------------------------------------- 1 | (ns parenthesis-matching.core-test 2 | (:require [clojure.test :refer :all] 3 | [parenthesis-matching.core :refer :all])) 4 | 5 | (def str-a "Sometimes (when I nest them (my parentheticals) too much (like this (and this))) they get confusing.") 6 | (def str-b "(lispy (lisp))") 7 | (def str-c "(lispy (lisp) (lisp))") 8 | (def str-d "(filter even? (map inc '(1 2 3 4)))") 9 | 10 | (def edge-a "()") 11 | (def edge-b "()()") 12 | (def edge-c "(())") 13 | 14 | (deftest find-closing-parenthesis-test 15 | (testing "edge cases" 16 | (is (= (find-closing-parenthesis edge-a 0) 1)) 17 | (is (= (find-closing-parenthesis edge-b 2) 3)) 18 | (is (= (find-closing-parenthesis edge-c 1) 2))) 19 | (testing "should return index of closing parenthesis" 20 | (is (= (find-closing-parenthesis str-a 10) 79)) 21 | (is (= (find-closing-parenthesis str-a 28) 46)) 22 | (is (= (find-closing-parenthesis str-b 0) (dec (count str-b)))) 23 | (is (= (find-closing-parenthesis str-c 0) (dec (count str-c)))) 24 | (is (= (find-closing-parenthesis str-d 0) (dec (count str-d)))) 25 | (is (= (find-closing-parenthesis str-b 7) 12)) 26 | (is (= (find-closing-parenthesis str-d 14) 33)) 27 | (is (= (find-closing-parenthesis str-d 24) 32)))) 28 | -------------------------------------------------------------------------------- /second-largest-in-binary-search-tree/test/second_largest_in_binary_search_tree/core_test.clj: -------------------------------------------------------------------------------- 1 | (ns second-largest-in-binary-search-tree.core-test 2 | (:require [clojure.test :refer :all] 3 | [second-largest-in-binary-search-tree.core :refer :all] 4 | [second-largest-in-binary-search-tree.binary-tree :as tree])) 5 | 6 | (def bst-a (tree/coll->binary-search-tree [10 9])) 7 | (def bst-b (tree/coll->binary-search-tree [10 5 15 20])) 8 | (def bst-c (tree/coll->binary-search-tree (range 100))) 9 | (def bst-d (tree/coll->binary-search-tree [10 5 15 20 45 32 2 90 100 22])) 10 | (def bst-e (tree/coll->binary-search-tree [10 5 15 20 17 2])) 11 | (def bst-f (tree/coll->binary-search-tree [10 5 8 15 20 18 17 19])) 12 | 13 | (def edge-a (tree/coll->binary-search-tree [])) 14 | (def edge-b (tree/coll->binary-search-tree [10])) 15 | 16 | (deftest second-largest-test 17 | (testing "edge cases" 18 | (is (= (second-largest edge-a) nil)) 19 | (is (= (second-largest edge-b) nil))) 20 | (testing "should return second largest item in bst" 21 | (is (= (second-largest bst-a) 9)) 22 | (is (= (second-largest bst-b) 15)) 23 | (is (= (second-largest bst-c) 98)) 24 | (is (= (second-largest bst-d) 90)) 25 | (is (= (second-largest bst-e) 17)) 26 | (is (= (second-largest bst-f) 19)))) 27 | -------------------------------------------------------------------------------- /word-cloud/test/word_cloud/core_test.clj: -------------------------------------------------------------------------------- 1 | (ns word-cloud.core-test 2 | (:require [clojure.test :refer :all] 3 | [word-cloud.core :refer :all])) 4 | 5 | (def sentence-a "After beating the eggs, Dana read the next step:") 6 | (def sentence-b "Add milk and eggs, then add flour and sugar.") 7 | (def sentence-c "Hi how are you?") 8 | (def sentence-d "What when where why when why what? Where when. I don't know.") 9 | (def sentence-e "Hello bye hi hi hello hi bye hi bye.") 10 | 11 | (def map-a {"after" 1 "beating" 1 "the" 2 "eggs" 1 "dana" 1 "read" 1 "next" 1 "step" 1}) 12 | (def map-b {"add" 2 "milk" 1 "and" 2 "eggs" 1 "then" 1 "flour" 1 "sugar" 1}) 13 | (def map-c {"hi" 1 "how" 1 "are" 1 "you" 1}) 14 | (def map-d {"what" 2 "when" 3 "where" 2 "why" 2 "i" 1 "don't" 1 "know" 1}) 15 | (def map-e {"hello" 2 "bye" 3 "hi" 4}) 16 | 17 | (deftest word-cloud-test 18 | (testing "edge cases" 19 | (is (= (word-cloud "hi") {"hi" 1})) 20 | (is (= (word-cloud "hi HI Hi hI hi. hi? hi!") {"hi" 7}))) 21 | (testing "returns frequencies of words in sentence, ignores case and punctuation." 22 | (is (= (word-cloud sentence-a) map-a)) 23 | (is (= (word-cloud sentence-b) map-b)) 24 | (is (= (word-cloud sentence-c) map-c)) 25 | (is (= (word-cloud sentence-d) map-d)) 26 | (is (= (word-cloud sentence-e) map-e)))) 27 | -------------------------------------------------------------------------------- /inflight-entertainment/test/inflight_entertainment/core_test.clj: -------------------------------------------------------------------------------- 1 | (ns inflight-entertainment.core-test 2 | (:require [clojure.test :refer :all] 3 | [inflight-entertainment.core :refer :all])) 4 | 5 | (def movies-lengths-a [109 130 80 65 150 75 120]) 6 | (def movies-lengths-b [100 105 80 60 120 50 160]) 7 | (def movies-lengths-c [34 88]) 8 | 9 | (def edge-a []) 10 | (def edge-b [1]) 11 | (def edge-c [1 2]) 12 | 13 | (deftest can-two-movies-fill-flight?-test 14 | (testing "edge cases" 15 | (is (= (can-two-movies-fill-flight? edge-a 100) false)) 16 | (is (= (can-two-movies-fill-flight? edge-b 1) false)) 17 | (is (= (can-two-movies-fill-flight? edge-c 3) true))) 18 | (testing "returns true if the sum of two movies can fit in flight length" 19 | (is (= (can-two-movies-fill-flight? movies-lengths-a 100) false)) 20 | (is (= (can-two-movies-fill-flight? movies-lengths-a 155) true)) 21 | (is (= (can-two-movies-fill-flight? movies-lengths-a 259) true)) 22 | (is (= (can-two-movies-fill-flight? movies-lengths-b 56) false)) 23 | (is (= (can-two-movies-fill-flight? movies-lengths-b 110) true)) 24 | (is (= (can-two-movies-fill-flight? movies-lengths-b 265) true)) 25 | (is (= (can-two-movies-fill-flight? movies-lengths-c 45) false)) 26 | (is (= (can-two-movies-fill-flight? movies-lengths-c 122) true)))) 27 | -------------------------------------------------------------------------------- /rectangular-love/test/rectangular_love/core_test.clj: -------------------------------------------------------------------------------- 1 | (ns rectangular-love.core-test 2 | (:require [clojure.test :refer :all] 3 | [rectangular-love.core :refer :all])) 4 | 5 | (def rect-a {:x 1 :y 5 :width 10 :height 4}) 6 | (def rect-b {:x 3 :y 7 :width 5 :height 8}) 7 | (def rect-c {:x -5 :y 3 :width 7 :height 10}) 8 | (def rect-d {:x 0 :y 0 :width 8 :height 12}) 9 | (def rect-e {:x 1 :y -5 :width 10 :height 4}) 10 | 11 | (def overlapping-ab {:x 3 :y 7 :width 5 :height 2}) 12 | (def overlapping-ac {:x 1, :y 5, :width 1, :height 4}) 13 | (def overlapping-ad {:x 1 :y 5 :width 7 :height 4}) 14 | (def overlapping-bc nil) 15 | (def overlapping-bd {:x 3, :y 7, :width 5, :height 5}) 16 | (def overlapping-cd {:x 0 :y 3 :width 2 :height 9}) 17 | 18 | (deftest a-test 19 | (testing "edge cases" 20 | (is (= (rectangular-overlap rect-e rect-a) nil)) 21 | (is (= (rectangular-overlap rect-a rect-a) rect-a))) 22 | (testing "returns overlapping rectangle, nil if no overlap" 23 | (is (= (rectangular-overlap rect-a rect-b) overlapping-ab)) 24 | (is (= (rectangular-overlap rect-a rect-c) overlapping-ac)) 25 | (is (= (rectangular-overlap rect-a rect-d) overlapping-ad)) 26 | (is (= (rectangular-overlap rect-b rect-c) overlapping-bc)) 27 | (is (= (rectangular-overlap rect-b rect-d) overlapping-bd)) 28 | (is (= (rectangular-overlap rect-c rect-d) overlapping-cd)))) 29 | -------------------------------------------------------------------------------- /the-stolen-breakfast-drone/test/the_stolen_breakfast_drone/core_test.clj: -------------------------------------------------------------------------------- 1 | (ns the-stolen-breakfast-drone.core-test 2 | (:require [clojure.test :refer :all] 3 | [the-stolen-breakfast-drone.core :refer :all])) 4 | 5 | (def delivery-ids-a '(2 4 5 7 8 4 5 2 8)) 6 | (def delivery-ids-b '(23 77 12 34 9 76 23 13 67 12 77 76 9 13 67)) 7 | (def delivery-ids-c (shuffle (concat (range 100) (range 99)))) 8 | (def delivery-ids-d (shuffle (concat (range 1 50 3) (range 1 49 3)))) 9 | 10 | (def edge-a '(1 2 2)) 11 | (def edge-b '(1 2 1)) 12 | 13 | (deftest find-unique-test 14 | (testing "edge cases" 15 | (is (= (find-unique edge-a) 1)) 16 | (is (= (find-unique edge-b) 2))) 17 | (testing "returns unique integer in collection of ids" 18 | (is (= (find-unique delivery-ids-a) 7)) 19 | (is (= (find-unique delivery-ids-b) 34)) 20 | (is (= (find-unique delivery-ids-c) 99)) 21 | (is (= (find-unique delivery-ids-d) 49)))) 22 | 23 | (deftest find-unique-bitwise-test 24 | (testing "edge cases" 25 | (is (= (find-unique-bitwise edge-a) 1)) 26 | (is (= (find-unique-bitwise edge-b) 2))) 27 | (testing "returns unique integer in collection of ids" 28 | (is (= (find-unique-bitwise delivery-ids-a) 7)) 29 | (is (= (find-unique-bitwise delivery-ids-b) 34)) 30 | (is (= (find-unique-bitwise delivery-ids-c) 99)) 31 | (is (= (find-unique-bitwise delivery-ids-d) 49)))) 32 | -------------------------------------------------------------------------------- /making-change/test/making_change/core_test.clj: -------------------------------------------------------------------------------- 1 | (ns making-change.core-test 2 | (:require [clojure.test :refer :all] 3 | [making-change.core :refer :all])) 4 | 5 | (def denominations-a #{1 2 3}) 6 | (def denominations-b #{1 2 3 4 5}) 7 | (def denominations-c #{2 5 8 9}) 8 | 9 | (def edge-denominations-a #{1}) 10 | (def edge-denominations-b #{1 2}) 11 | (def edge-denominations-c #{100 200}) 12 | 13 | (deftest ways-to-make-amount-test 14 | (testing "edge cases" 15 | (is (= (ways-to-make-amount 1 edge-denominations-a) 1)) 16 | (is (= (ways-to-make-amount 5 edge-denominations-a) 1)) 17 | (is (= (ways-to-make-amount 4 edge-denominations-b) 3)) 18 | (is (= (ways-to-make-amount 5 edge-denominations-c) 0)) 19 | (is (= (ways-to-make-amount 50 edge-denominations-c) 0))) 20 | (testing "returns number of distinct ways to make amount using denominations" 21 | (is (= (ways-to-make-amount 1 denominations-a) 1)) 22 | (is (= (ways-to-make-amount 2 denominations-a) 2)) 23 | (is (= (ways-to-make-amount 3 denominations-a) 3)) 24 | (is (= (ways-to-make-amount 4 denominations-a) 4)) 25 | (is (= (ways-to-make-amount 3 denominations-b) 3)) 26 | (is (= (ways-to-make-amount 5 denominations-b) 7)) 27 | (is (= (ways-to-make-amount 1 denominations-c) 0)) 28 | (is (= (ways-to-make-amount 2 denominations-c) 1)) 29 | (is (= (ways-to-make-amount 18 denominations-c) 7)))) 30 | -------------------------------------------------------------------------------- /permutation-palindrome/test/permutation_palindrome/core_test.clj: -------------------------------------------------------------------------------- 1 | (ns permutation-palindrome.core-test 2 | (:require [clojure.test :refer :all] 3 | [clojure.string :as str] 4 | [permutation-palindrome.core :refer :all])) 5 | 6 | (def str-a "civic") 7 | (def str-b "ivicc") 8 | (def str-c "civil") 9 | (def str-d "livci") 10 | 11 | (def str-e (str/join (shuffle (vec "racecar")))) 12 | (def str-f (str/join (shuffle (vec "civic")))) 13 | (def str-g (str/join (shuffle (vec "abcba")))) 14 | (def str-h (str/join (shuffle (vec "palindrome")))) 15 | 16 | (deftest permutation-palindrome?-test 17 | (testing "edge cases" 18 | (is (= (permutation-palindrome? "") true)) 19 | (is (= (permutation-palindrome? "a") true)) 20 | (is (= (permutation-palindrome? "ab") false)) 21 | (is (= (permutation-palindrome? "aba") true)) 22 | (is (= (permutation-palindrome? "abc") false))) 23 | (testing "returns true if any permutaion of a string is a palindrome" 24 | (is (= (permutation-palindrome? str-a) true)) 25 | (is (= (permutation-palindrome? str-b) true)) 26 | (is (= (permutation-palindrome? str-c) false)) 27 | (is (= (permutation-palindrome? str-d) false)) 28 | (is (= (permutation-palindrome? str-e) true)) 29 | (is (= (permutation-palindrome? str-f) true)) 30 | (is (= (permutation-palindrome? str-g) true)) 31 | (is (= (permutation-palindrome? str-h) false)))) 32 | -------------------------------------------------------------------------------- /binary-search-tree-checker/test/binary_search_tree_checker/core_test.clj: -------------------------------------------------------------------------------- 1 | (ns binary-search-tree-checker.core-test 2 | (:require [clojure.test :refer :all] 3 | [binary-search-tree-checker.core :refer :all] 4 | [binary-search-tree-checker.binary-tree :as tree])) 5 | 6 | (def valid-a (tree/coll->binary-search-tree [10])) 7 | (def valid-b (tree/coll->binary-search-tree [10 5 15 20])) 8 | (def valid-c (tree/coll->binary-search-tree (range 100))) 9 | (def valid-d (tree/coll->binary-search-tree [10 5 15 20 45 32 2 90 100 22])) 10 | (def valid-e (tree/coll->binary-search-tree [10 5 15 20])) 11 | 12 | (def invalid-a (assoc (tree/node 10) :left (tree/node 20))) 13 | (def invalid-b (assoc (tree/node 10) :right (tree/node 5))) 14 | (def invalid-c (assoc-in valid-b [:left :right] (tree/node 25))) 15 | (def invalid-d (assoc-in valid-d [:left :left :left] (tree/node 125))) 16 | 17 | (deftest bst?-test 18 | (testing "egde cases" 19 | (is (= (bst? {}) true)) 20 | (is (= (bst? (tree/node 4)) true))) 21 | (testing "should test weather a binary tree is a valid binary search tree" 22 | (is (= (bst? valid-a) true)) 23 | (is (= (bst? valid-b) true)) 24 | (is (= (bst? valid-c) true)) 25 | (is (= (bst? valid-d) true)) 26 | (is (= (bst? valid-e) true)) 27 | (is (= (bst? invalid-a) false)) 28 | (is (= (bst? invalid-b) false)) 29 | (is (= (bst? invalid-c) false)) 30 | (is (= (bst? invalid-d) false)))) 31 | -------------------------------------------------------------------------------- /recursive-string-permutations/test/recursive_string_permutations/core_test.clj: -------------------------------------------------------------------------------- 1 | (ns recursive-string-permutations.core-test 2 | (:require [clojure.test :refer :all] 3 | [recursive-string-permutations.core :refer :all])) 4 | 5 | (def permutations-a 6 | #{"a"}) 7 | 8 | (def permutations-b 9 | #{"ab" "ba"}) 10 | 11 | (def permutations-c 12 | #{"abc" "acb" 13 | "bac" "bca" 14 | "cab" "cba"}) 15 | 16 | (def permutations-d 17 | #{"abcd" "abdc" "acbd" "acdb" "adbc" "adcb" 18 | "badc" "bacd" "bcda" "bcad" "bdca" "bdac" 19 | "cabd" "cadb" "cbad" "cbda" "cdab" "cdba" 20 | "dacb" "dabc" "dbca" "dbac" "dcba" "dcab"}) 21 | 22 | (def long-permutations-a (permutations "abcdef")) 23 | (def long-permutations-b (permutations "abcdefgh")) 24 | 25 | (defn factorial [n] 26 | (reduce * (range 1 (inc n)))) 27 | 28 | (deftest permutations-test 29 | (testing "edge cases" 30 | (is (= (permutations "") #{""})) 31 | (is (= (permutations "a") permutations-a))) 32 | (testing "returns set of all permutations of an input string" 33 | (is (= (permutations "ab") permutations-b)) 34 | (is (= (permutations "abc") permutations-c)) 35 | (is (= (permutations "abcd") permutations-d))) 36 | (testing "longer permutations" 37 | (is (set? long-permutations-a)) 38 | (is (set? long-permutations-b)) 39 | (is (= (count long-permutations-a) (factorial 6))) 40 | (is (= (count long-permutations-b) (factorial 8))))) 41 | -------------------------------------------------------------------------------- /cake-thief/test/cake_thief/core_test.clj: -------------------------------------------------------------------------------- 1 | (ns cake-thief.core-test 2 | (:require [clojure.test :refer :all] 3 | [cake-thief.core :refer :all])) 4 | 5 | (def cakes-a 6 | [{:weight 7 :value 160} 7 | {:weight 3 :value 90} 8 | {:weight 2 :value 15}]) 9 | 10 | (def cakes-b 11 | [{:weight 1 :value 30} 12 | {:weight 50 :value 200}]) 13 | 14 | (def cakes-c 15 | [{:weight 3 :value 40} 16 | {:weight 5 :value 70}]) 17 | 18 | (def cakes-d 19 | [{:weight 8 :value 90} 20 | {:weight 23 :value 150} 21 | {:weight 17 :value 160} 22 | {:weight 32 :value 290} 23 | {:weight 4 :value 5} 24 | {:weight 55 :value 140} 25 | {:weight 7 :value 55}]) 26 | 27 | (def edge-a 28 | [{:weight 5 :value 30}]) 29 | 30 | (deftest max-duffel-bag-value-test 31 | (testing "edge cases" 32 | (is (= (max-duffel-bag-value [] 10) 0)) 33 | (is (= (max-duffel-bag-value edge-a 4) 0)) 34 | (is (= (max-duffel-bag-value edge-a 5) 30)) 35 | (is (= (max-duffel-bag-value edge-a 20) 120))) 36 | (testing "returns max monetary value duffel bag can hold" 37 | (is (= (max-duffel-bag-value cakes-a 20) 555)) 38 | (is (= (max-duffel-bag-value cakes-b 100) 3000)) 39 | (is (= (max-duffel-bag-value cakes-c 8) 110)) 40 | (is (= (max-duffel-bag-value cakes-c 9) 120)) 41 | (is (= (max-duffel-bag-value cakes-d 17) 180)) 42 | (is (= (max-duffel-bag-value cakes-d 34) 360)) 43 | (is (= (max-duffel-bag-value cakes-d 500) 5585)))) 44 | -------------------------------------------------------------------------------- /which-appears-twice/test/which_appears_twice/core_test.clj: -------------------------------------------------------------------------------- 1 | (ns which-appears-twice.core-test 2 | (:require [clojure.test :refer :all] 3 | [which-appears-twice.core :refer :all])) 4 | 5 | (def range-a '(1 2 3 3)) 6 | (def range-b '(1 2 2 3 4)) 7 | (def range-c '(1 2 3 4 4 5 6 7 8 9)) 8 | (def range-d '(1 2 3 4 5 6 7 8 9 10 11 12 12 13)) 9 | (def range-e (concat (range 10) (range 9 20 1))) 10 | 11 | (def edge-a '(1 1)) 12 | (def edge-b '(1 2 2)) 13 | 14 | (deftest find-dup-in-range-test 15 | (testing "edge cases" 16 | (is (= (find-dup-in-range edge-a 1) 1)) 17 | (is (= (find-dup-in-range edge-b 2) 2))) 18 | (testing "returns duplicate value in range of 1...n" 19 | (is (= (find-dup-in-range range-a 3) 3)) 20 | (is (= (find-dup-in-range range-b 4) 2)) 21 | (is (= (find-dup-in-range range-c 9) 4)) 22 | (is (= (find-dup-in-range range-d 13) 12)) 23 | (is (= (find-dup-in-range range-e 19) 9)))) 24 | 25 | (deftest find-dup-in-range-with-sum-test 26 | (testing "edge cases" 27 | (is (= (find-dup-in-range-with-sum edge-a 1) 1)) 28 | (is (= (find-dup-in-range-with-sum edge-b 2) 2))) 29 | (testing "returns duplicate value in range of 1...n" 30 | (is (= (find-dup-in-range-with-sum range-a 3) 3)) 31 | (is (= (find-dup-in-range-with-sum range-b 4) 2)) 32 | (is (= (find-dup-in-range-with-sum range-c 9) 4)) 33 | (is (= (find-dup-in-range-with-sum range-d 13) 12)) 34 | (is (= (find-dup-in-range-with-sum range-e 19) 9)))) 35 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Interview Cake Clojure Solutions 2 | This repository contains most solutions (32/44), with corresponding unit tests, for the problems defined on [interview cake](https://www.interviewcake.com). The solutions are implemented in Clojure as idiomatically as possible and attempt to follow the guidelines outlined in the [clojure-style-guide](https://github.com/bbatsov/clojure-style-guide). 3 | 4 | Some problems are left unsolved either because they are mostly theoretical, discussion based, or do not fit nicely with Clojure (eg. problems dealing purely with mutation). 5 | 6 | ## Running The Problems 7 | Each problem is defined as its own self contained Clojure leiningen project. To run, first make sure to have [leiningen](https://github.com/technomancy/leiningen) installed. Then, after cloning the main repository, `cd` into the directory of a problem and either run the unit tests with `lein test` or launch the Clojure REPL with `lein repl`. 8 | 9 | ## A Few Favorites 10 | - [recursive-string-permutations](recursive-string-permutations/) 11 | - [highest-product-of-three](highest-product-of-three/) 12 | - [find-rotation-point](find-rotation-point/) 13 | - [in-place-shuffle](in-place-shuffle/) 14 | - [rectangular-love](rectangular-love/) 15 | - [simulate-7-sided-die](simulate-7-sided-die/) 16 | 17 | ## Contributing 18 | Contributions are very welcome! Please feel free to open an issue or pull request if you find a bug or think there is a better way to solve one of the problems solved above. 19 | -------------------------------------------------------------------------------- /rectangular-love/src/rectangular_love/core.clj: -------------------------------------------------------------------------------- 1 | (ns rectangular-love.core 2 | (:gen-class)) 3 | 4 | (defn- range->length [{:keys [start end]}] 5 | (- end start)) 6 | 7 | (defn- intersection [range-a range-b] 8 | (let [[first-range second-range] (sort-by :start [range-a range-b])] 9 | (when (>= (:end first-range) (:start second-range)) 10 | {:start (:start second-range) 11 | :end (min (:end first-range) (:end second-range))}))) 12 | 13 | (defn- rect->vertical-range [{:keys [y height]}] 14 | {:start y :end (+ y height)}) 15 | 16 | (defn- rect->horizontal-range [{:keys [x width]}] 17 | {:start x :end (+ x width)}) 18 | 19 | (defn- find-vertical-intersection [rect-a rect-b] 20 | (intersection (rect->vertical-range rect-a) 21 | (rect->vertical-range rect-b))) 22 | 23 | (defn- find-horizontal-intersection [rect-a rect-b] 24 | (intersection (rect->horizontal-range rect-a) 25 | (rect->horizontal-range rect-b))) 26 | 27 | (defn rectangular-overlap 28 | "O(1) time solution - will return overlapping rectangle, nil if no overlap." 29 | [rect-a rect-b] 30 | (let [vertical-intersection (find-vertical-intersection rect-a rect-b) 31 | horizontal-intersection (find-horizontal-intersection rect-a rect-b)] 32 | (when (and vertical-intersection horizontal-intersection) 33 | {:x (:start horizontal-intersection) 34 | :y (:start vertical-intersection) 35 | :width (range->length horizontal-intersection) 36 | :height (range->length vertical-intersection)}))) 37 | -------------------------------------------------------------------------------- /find-rotation-point/test/find_rotation_point/core_test.clj: -------------------------------------------------------------------------------- 1 | (ns find-rotation-point.core-test 2 | (:require [clojure.test :refer :all] 3 | [find-rotation-point.core :refer :all])) 4 | 5 | (def words-a 6 | ["ptolemaic" 7 | "retrograde" 8 | "supplant" 9 | "undulate" 10 | "xenoepist" 11 | "asymptote" 12 | "babka" 13 | "banoffee" 14 | "engender" 15 | "karpatka" 16 | "othellolagkage"]) 17 | 18 | (def words-b 19 | ["ptolemaic" 20 | "retrograde" 21 | "asymptote" 22 | "babka" 23 | "banoffee" 24 | "engender" 25 | "karpatka" 26 | "othellolagkage"]) 27 | 28 | (def words-c 29 | ["ptolemaic" 30 | "supplant" 31 | "undulate" 32 | "xenoepist" 33 | "banoffee" 34 | "engender" 35 | "othellolagkage"]) 36 | 37 | (def words-d 38 | ["ptolemaic" 39 | "asymptote" 40 | "babka" 41 | "banoffee" 42 | "engender" 43 | "karpatka" 44 | "othellolagkage"]) 45 | 46 | (def words-e 47 | ["ptolemaic" 48 | "retrograde" 49 | "supplant" 50 | "undulate" 51 | "xenoepist" 52 | "asymptote"]) 53 | 54 | (def words-f 55 | ["undulate" 56 | "xenoepist" 57 | "asymptote" 58 | "banoffee"]) 59 | 60 | (deftest find-rotation-point-test 61 | (testing "should return index of rotation, assuming rotation exists" 62 | (is (= (find-rotation-point words-a) 5)) 63 | (is (= (find-rotation-point words-b) 2)) 64 | (is (= (find-rotation-point words-c) 4)) 65 | (is (= (find-rotation-point words-d) 1)) 66 | (is (= (find-rotation-point words-e) 5)) 67 | (is (= (find-rotation-point words-f) 2)))) 68 | -------------------------------------------------------------------------------- /merging-meeting-times/test/merging_meeting_times/core_test.clj: -------------------------------------------------------------------------------- 1 | (ns merging-meeting-times.core-test 2 | (:require [clojure.test :refer :all] 3 | [merging-meeting-times.core :refer :all])) 4 | 5 | (def meeting-times-a 6 | [{:start 0 :end 1} 7 | {:start 3 :end 5} 8 | {:start 4 :end 8} 9 | {:start 10 :end 12} 10 | {:start 9 :end 10}]) 11 | 12 | (def merged-meetings-a 13 | [{:start 0 :end 1} 14 | {:start 3 :end 8} 15 | {:start 9 :end 12}]) 16 | 17 | (def meeting-times-b 18 | [{:start 0 :end 10} 19 | {:start 3 :end 5} 20 | {:start 4 :end 8} 21 | {:start 10 :end 12} 22 | {:start 9 :end 10}]) 23 | 24 | (def merged-meetings-b 25 | [{:start 0 :end 12}]) 26 | 27 | (def meeting-times-c 28 | [{:start 8 :end 9} 29 | {:start 3 :end 5} 30 | {:start 0 :end 2} 31 | {:start 4 :end 8} 32 | {:start 6 :end 10}]) 33 | 34 | (def merged-meetings-c 35 | [{:start 0 :end 2} 36 | {:start 3 :end 10}]) 37 | 38 | (def meeting-times-d 39 | [{:start 4 :end 9} 40 | {:start 3 :end 5}]) 41 | 42 | (def merged-meetings-d 43 | [{:start 3 :end 9}]) 44 | 45 | (deftest merge-meeting-times-test 46 | (testing "edge cases" 47 | (is (= (merge-meeting-times [{}]) [{}])) 48 | (is (= (merge-meeting-times [{:start 4 :end 9}]) [{:start 4 :end 9}]))) 49 | (testing "should merge overlapping meetings" 50 | (is (= (merge-meeting-times meeting-times-a) merged-meetings-a)) 51 | (is (= (merge-meeting-times meeting-times-b) merged-meetings-b)) 52 | (is (= (merge-meeting-times meeting-times-c) merged-meetings-c)) 53 | (is (= (merge-meeting-times meeting-times-d) merged-meetings-d)))) 54 | -------------------------------------------------------------------------------- /product-of-all-other-numbers/test/product_of_all_other_numbers/core_test.clj: -------------------------------------------------------------------------------- 1 | (ns product-of-all-other-numbers.core-test 2 | (:require [clojure.test :refer :all] 3 | [product-of-all-other-numbers.core :refer :all])) 4 | 5 | (deftest product-of-others-test 6 | (testing "edge cases" 7 | (is (= (product-of-others []) '())) 8 | (is (= (product-of-others '()) '())) 9 | (is (= (product-of-others [1]) '(1))) 10 | (is (= (product-of-others '(1)) '(1))) 11 | (is (= (product-of-others '(5)) '(1))) 12 | (is (= (product-of-others '(1 1 1)) '(1 1 1)))) 13 | (testing "should map coll to the product of every integer except the integer at that index" 14 | (is (= (product-of-others [1 2 3 4 5]) '(120 60 40 30 24))) 15 | (is (= (product-of-others [1 7 3 4]) '(84 12 28 21))) 16 | (is (= (product-of-others [7 2 3 5]) '(30 105 70 42))) 17 | (is (= (product-of-others [3 2]) '(2 3))))) 18 | 19 | (deftest product-of-others-fast-test 20 | (testing "edge cases" 21 | (is (= (product-of-others-fast []) '())) 22 | (is (= (product-of-others-fast '()) '())) 23 | (is (= (product-of-others-fast [1]) '(1))) 24 | (is (= (product-of-others-fast '(1)) '(1))) 25 | (is (= (product-of-others-fast '(5)) '(1))) 26 | (is (= (product-of-others-fast '(1 1 1)) '(1 1 1)))) 27 | (testing "should map coll to the product of every integer except the integer at that index" 28 | (is (= (product-of-others-fast [1 2 3 4 5]) '(120 60 40 30 24))) 29 | (is (= (product-of-others-fast [1 7 3 4]) '(84 12 28 21))) 30 | (is (= (product-of-others-fast [1 0 7 3 4]) '(0 84 0 0 0))) 31 | (is (= (product-of-others-fast [7 2 3 5]) '(30 105 70 42))) 32 | (is (= (product-of-others-fast [3 2]) '(2 3))))) 33 | -------------------------------------------------------------------------------- /single-riffle-shuffle/test/single_riffle_shuffle/core_test.clj: -------------------------------------------------------------------------------- 1 | (ns single-riffle-shuffle.core-test 2 | (:require [clojure.test :refer :all] 3 | [single-riffle-shuffle.core :refer :all])) 4 | 5 | (def half-a-a [6 3 2]) 6 | (def half-a-b [4 1 7]) 7 | (def shuffled-a [6 3 4 2 1 7]) 8 | 9 | (def half-b-a [6 3 2]) 10 | (def half-b-b [4 1 7]) 11 | (def shuffled-b [7 2 3 1 4 6]) 12 | 13 | (def half-c-a [12 5 3 8 7 11]) 14 | (def half-c-b [9 2 1 0 5 6]) 15 | (def shuffled-c [12 5 9 2 1 0 5 3 8 7 6 11]) 16 | 17 | (def half-d-a [12 5 3 8 7]) 18 | (def half-d-b [9 2 1 0 5 6]) 19 | (def shuffled-d [12 5 9 2 5 6 0 1 3 8 7]) 20 | 21 | (def edge-a-half-a []) 22 | (def edge-a-half-b []) 23 | (def edge-a-shuffled-a []) 24 | 25 | (def edge-b-half-a [1]) 26 | (def edge-b-half-b [4]) 27 | (def edge-b-shuffled-a [4 1]) 28 | 29 | (def edge-c-half-a [1]) 30 | (def edge-c-half-b [4]) 31 | (def edge-c-shuffled-a [4 7]) 32 | 33 | (def edge-d-half-a [1 7 0 9]) 34 | (def edge-d-half-b [4 8]) 35 | (def edge-d-shuffled-a [1 7 0 4 8 9]) 36 | 37 | (deftest single-riffle-shuffle?-test 38 | (testing "edge cases" 39 | (is (= (single-riffle-shuffle? edge-a-shuffled-a edge-a-half-a edge-a-half-b) true)) 40 | (is (= (single-riffle-shuffle? edge-b-shuffled-a edge-b-half-a edge-b-half-b) true)) 41 | (is (= (single-riffle-shuffle? edge-c-shuffled-a edge-c-half-a edge-c-half-b) false)) 42 | (is (= (single-riffle-shuffle? edge-d-shuffled-a edge-d-half-a edge-d-half-b) true))) 43 | (testing "returns true if shuffled deck was a single riffle shuffle of both halfs" 44 | (is (= (single-riffle-shuffle? shuffled-a half-a-a half-a-b) true)) 45 | (is (= (single-riffle-shuffle? shuffled-b half-b-a half-b-b) false)) 46 | (is (= (single-riffle-shuffle? shuffled-c half-c-a half-c-b) true)) 47 | (is (= (single-riffle-shuffle? shuffled-d half-d-a half-d-b) false)))) 48 | -------------------------------------------------------------------------------- /highest-product-of-three/test/highest_product_of_three/core_test.clj: -------------------------------------------------------------------------------- 1 | (ns highest-product-of-three.core-test 2 | (:require [clojure.test :refer :all] 3 | [highest-product-of-three.core :refer :all])) 4 | 5 | (def highest-product-of-1 (partial highest-product-of-k 1)) 6 | (def highest-product-of-2 (partial highest-product-of-k 2)) 7 | (def highest-product-of-3 (partial highest-product-of-k 3)) 8 | (def highest-product-of-4 (partial highest-product-of-k 4)) 9 | (def highest-product-of-5 (partial highest-product-of-k 5)) 10 | (def highest-product-of-8 (partial highest-product-of-k 8)) 11 | 12 | (deftest highest-product-of-k-test 13 | (testing "edge cases" 14 | (is (= (highest-product-of-1 [5]) 5)) 15 | (is (= (highest-product-of-1 [-7]) -7)) 16 | (is (= (highest-product-of-1 [-3 -5]) -3)) 17 | (is (= (highest-product-of-2 [5]) 5)) 18 | (is (= (highest-product-of-2 [1 -3 -5]) 15)) 19 | (is (= (highest-product-of-2 [2 3 2 3 2 3 3 3 2 2]) 9)) 20 | (is (= (highest-product-of-3 [0 2 3]) 0)) 21 | (is (= (highest-product-of-3 [1 2 3]) 6)) 22 | (is (= (highest-product-of-3 [2 3 2 3 2 3 3 3 2 2]) 27)) 23 | (is (= (highest-product-of-4 [3 2 1]) 6))) 24 | (testing "returns highest product of k ints - handles negative numbers" 25 | (is (= (highest-product-of-3 [6 4 5 2]) 120)) 26 | (is (= (highest-product-of-3 [5 8 7 2 3]) 280)) 27 | (is (= (highest-product-of-3 [3 5 7 1 2 4]) 140)) 28 | (is (= (highest-product-of-3 [5 8 -9]) -360)) 29 | (is (= (highest-product-of-3 [5 8 -9 -3]) 216)) 30 | (is (= (highest-product-of-3 [5 8 -9 -3 -5]) 360)) 31 | (is (= (highest-product-of-4 [1 2 3 4 5]) 120)) 32 | (is (= (highest-product-of-4 [1 2 -3 -4 -5]) 40)) 33 | (is (= (highest-product-of-4 [1 -2 -3 -4 -5]) 120)) 34 | (is (= (highest-product-of-5 (range 7)) 720)) 35 | (is (= (highest-product-of-8 (range 10)) 362880)))) 36 | -------------------------------------------------------------------------------- /balanced-binary-tree/src/balanced_binary_tree/binary_tree.clj: -------------------------------------------------------------------------------- 1 | (ns balanced-binary-tree.binary-tree 2 | (:gen-class)) 3 | 4 | (defn node [value] 5 | {:value value :left nil :right nil}) 6 | 7 | (defn max-height [root] 8 | (if (nil? root) 9 | 0 10 | (inc (max (max-height (:left root)) 11 | (max-height (:right root)))))) 12 | 13 | (defn min-height [root] 14 | (if (nil? root) 15 | 0 16 | (inc (min (min-height (:left root)) 17 | (min-height (:right root)))))) 18 | 19 | (defn insert [root value] 20 | (loop [current root 21 | path []] 22 | (cond 23 | (nil? current) 24 | (assoc-in root path (node value)) 25 | (neg? (compare value (:value current))) 26 | (recur (:left current) (conj path :left)) 27 | (pos? (compare value (:value current))) 28 | (recur (:right current) (conj path :right))))) 29 | 30 | (defn coll->binary-search-tree [coll] 31 | (reduce insert 32 | (node (first coll)) 33 | (rest coll))) 34 | 35 | (defn tree->preorder-lazy-seq [root] 36 | (if (empty? root) 37 | '() 38 | (lazy-cat (list (:value root)) 39 | (tree->preorder-lazy-seq (:left root)) 40 | (tree->preorder-lazy-seq (:right root))))) 41 | 42 | (defn tree->inorder-lazy-seq [root] 43 | (if (empty? root) 44 | '() 45 | (lazy-cat (tree->inorder-lazy-seq (:left root)) 46 | (list (:value root)) 47 | (tree->inorder-lazy-seq (:right root))))) 48 | 49 | (defn tree->postorder-lazy-seq [root] 50 | (if (empty? root) 51 | '() 52 | (lazy-cat (tree->postorder-lazy-seq (:left root)) 53 | (tree->postorder-lazy-seq (:right root)) 54 | (list (:value root))))) 55 | 56 | (defn largest [{:keys [value right]}] 57 | (if (nil? right) 58 | value 59 | (recur right))) 60 | 61 | (defn smallest [{:keys [value left]}] 62 | (if (nil? left) 63 | value 64 | (recur left))) 65 | -------------------------------------------------------------------------------- /binary-search-tree-checker/src/binary_search_tree_checker/binary_tree.clj: -------------------------------------------------------------------------------- 1 | (ns binary-search-tree-checker.binary-tree 2 | (:gen-class)) 3 | 4 | (defn node [value] 5 | {:value value :left nil :right nil}) 6 | 7 | (defn max-height [root] 8 | (if (nil? root) 9 | 0 10 | (inc (max (max-height (:left root)) 11 | (max-height (:right root)))))) 12 | 13 | (defn min-height [root] 14 | (if (nil? root) 15 | 0 16 | (inc (min (min-height (:left root)) 17 | (min-height (:right root)))))) 18 | 19 | (defn insert [root value] 20 | (loop [current root 21 | path []] 22 | (cond 23 | (nil? current) 24 | (assoc-in root path (node value)) 25 | (neg? (compare value (:value current))) 26 | (recur (:left current) (conj path :left)) 27 | (pos? (compare value (:value current))) 28 | (recur (:right current) (conj path :right))))) 29 | 30 | (defn coll->binary-search-tree [coll] 31 | (reduce insert 32 | (node (first coll)) 33 | (rest coll))) 34 | 35 | (defn tree->preorder-lazy-seq [root] 36 | (if (empty? root) 37 | '() 38 | (lazy-cat (list (:value root)) 39 | (tree->preorder-lazy-seq (:left root)) 40 | (tree->preorder-lazy-seq (:right root))))) 41 | 42 | (defn tree->inorder-lazy-seq [root] 43 | (if (empty? root) 44 | '() 45 | (lazy-cat (tree->inorder-lazy-seq (:left root)) 46 | (list (:value root)) 47 | (tree->inorder-lazy-seq (:right root))))) 48 | 49 | (defn tree->postorder-lazy-seq [root] 50 | (if (empty? root) 51 | '() 52 | (lazy-cat (tree->postorder-lazy-seq (:left root)) 53 | (tree->postorder-lazy-seq (:right root)) 54 | (list (:value root))))) 55 | 56 | (defn largest [{:keys [value right]}] 57 | (if (nil? right) 58 | value 59 | (recur right))) 60 | 61 | (defn smallest [{:keys [value left]}] 62 | (if (nil? left) 63 | value 64 | (recur left))) 65 | -------------------------------------------------------------------------------- /second-largest-in-binary-search-tree/src/second_largest_in_binary_search_tree/binary_tree.clj: -------------------------------------------------------------------------------- 1 | (ns second-largest-in-binary-search-tree.binary-tree 2 | (:gen-class)) 3 | 4 | (defn node [value] 5 | {:value value :left nil :right nil}) 6 | 7 | (defn max-height [root] 8 | (if (nil? root) 9 | 0 10 | (inc (max (max-height (:left root)) 11 | (max-height (:right root)))))) 12 | 13 | (defn min-height [root] 14 | (if (nil? root) 15 | 0 16 | (inc (min (min-height (:left root)) 17 | (min-height (:right root)))))) 18 | 19 | (defn insert [root value] 20 | (loop [current root 21 | path []] 22 | (cond 23 | (nil? current) 24 | (assoc-in root path (node value)) 25 | (neg? (compare value (:value current))) 26 | (recur (:left current) (conj path :left)) 27 | (pos? (compare value (:value current))) 28 | (recur (:right current) (conj path :right))))) 29 | 30 | (defn coll->binary-search-tree [coll] 31 | (reduce insert 32 | (node (first coll)) 33 | (rest coll))) 34 | 35 | (defn tree->preorder-lazy-seq [root] 36 | (if (empty? root) 37 | '() 38 | (lazy-cat (list (:value root)) 39 | (tree->preorder-lazy-seq (:left root)) 40 | (tree->preorder-lazy-seq (:right root))))) 41 | 42 | (defn tree->inorder-lazy-seq [root] 43 | (if (empty? root) 44 | '() 45 | (lazy-cat (tree->inorder-lazy-seq (:left root)) 46 | (list (:value root)) 47 | (tree->inorder-lazy-seq (:right root))))) 48 | 49 | (defn tree->postorder-lazy-seq [root] 50 | (if (empty? root) 51 | '() 52 | (lazy-cat (tree->postorder-lazy-seq (:left root)) 53 | (tree->postorder-lazy-seq (:right root)) 54 | (list (:value root))))) 55 | 56 | (defn largest [{:keys [value right]}] 57 | (if (nil? right) 58 | value 59 | (recur right))) 60 | 61 | (defn smallest [{:keys [value left]}] 62 | (if (nil? left) 63 | value 64 | (recur left))) 65 | -------------------------------------------------------------------------------- /cake-thief/LICENSE: -------------------------------------------------------------------------------- 1 | THE ACCOMPANYING PROGRAM IS PROVIDED UNDER THE TERMS OF THIS ECLIPSE PUBLIC 2 | LICENSE ("AGREEMENT"). ANY USE, REPRODUCTION OR DISTRIBUTION OF THE PROGRAM 3 | CONSTITUTES RECIPIENT'S ACCEPTANCE OF THIS AGREEMENT. 4 | 5 | 1. DEFINITIONS 6 | 7 | "Contribution" means: 8 | 9 | a) in the case of the initial Contributor, the initial code and 10 | documentation distributed under this Agreement, and 11 | 12 | b) in the case of each subsequent Contributor: 13 | 14 | i) changes to the Program, and 15 | 16 | ii) additions to the Program; 17 | 18 | where such changes and/or additions to the Program originate from and are 19 | distributed by that particular Contributor. A Contribution 'originates' from 20 | a Contributor if it was added to the Program by such Contributor itself or 21 | anyone acting on such Contributor's behalf. Contributions do not include 22 | additions to the Program which: (i) are separate modules of software 23 | distributed in conjunction with the Program under their own license 24 | agreement, and (ii) are not derivative works of the Program. 25 | 26 | "Contributor" means any person or entity that distributes the Program. 27 | 28 | "Licensed Patents" mean patent claims licensable by a Contributor which are 29 | necessarily infringed by the use or sale of its Contribution alone or when 30 | combined with the Program. 31 | 32 | "Program" means the Contributions distributed in accordance with this 33 | Agreement. 34 | 35 | "Recipient" means anyone who receives the Program under this Agreement, 36 | including all Contributors. 37 | 38 | 2. GRANT OF RIGHTS 39 | 40 | a) Subject to the terms of this Agreement, each Contributor hereby grants 41 | Recipient a non-exclusive, worldwide, royalty-free copyright license to 42 | reproduce, prepare derivative works of, publicly display, publicly perform, 43 | distribute and sublicense the Contribution of such Contributor, if any, and 44 | such derivative works, in source code and object code form. 45 | 46 | b) Subject to the terms of this Agreement, each Contributor hereby grants 47 | Recipient a non-exclusive, worldwide, royalty-free patent license under 48 | Licensed Patents to make, use, sell, offer to sell, import and otherwise 49 | transfer the Contribution of such Contributor, if any, in source code and 50 | object code form. This patent license shall apply to the combination of the 51 | Contribution and the Program if, at the time the Contribution is added by the 52 | Contributor, such addition of the Contribution causes such combination to be 53 | covered by the Licensed Patents. The patent license shall not apply to any 54 | other combinations which include the Contribution. No hardware per se is 55 | licensed hereunder. 56 | 57 | c) Recipient understands that although each Contributor grants the licenses 58 | to its Contributions set forth herein, no assurances are provided by any 59 | Contributor that the Program does not infringe the patent or other 60 | intellectual property rights of any other entity. Each Contributor disclaims 61 | any liability to Recipient for claims brought by any other entity based on 62 | infringement of intellectual property rights or otherwise. As a condition to 63 | exercising the rights and licenses granted hereunder, each Recipient hereby 64 | assumes sole responsibility to secure any other intellectual property rights 65 | needed, if any. For example, if a third party patent license is required to 66 | allow Recipient to distribute the Program, it is Recipient's responsibility 67 | to acquire that license before distributing the Program. 68 | 69 | d) Each Contributor represents that to its knowledge it has sufficient 70 | copyright rights in its Contribution, if any, to grant the copyright license 71 | set forth in this Agreement. 72 | 73 | 3. REQUIREMENTS 74 | 75 | A Contributor may choose to distribute the Program in object code form under 76 | its own license agreement, provided that: 77 | 78 | a) it complies with the terms and conditions of this Agreement; and 79 | 80 | b) its license agreement: 81 | 82 | i) effectively disclaims on behalf of all Contributors all warranties and 83 | conditions, express and implied, including warranties or conditions of title 84 | and non-infringement, and implied warranties or conditions of merchantability 85 | and fitness for a particular purpose; 86 | 87 | ii) effectively excludes on behalf of all Contributors all liability for 88 | damages, including direct, indirect, special, incidental and consequential 89 | damages, such as lost profits; 90 | 91 | iii) states that any provisions which differ from this Agreement are offered 92 | by that Contributor alone and not by any other party; and 93 | 94 | iv) states that source code for the Program is available from such 95 | Contributor, and informs licensees how to obtain it in a reasonable manner on 96 | or through a medium customarily used for software exchange. 97 | 98 | When the Program is made available in source code form: 99 | 100 | a) it must be made available under this Agreement; and 101 | 102 | b) a copy of this Agreement must be included with each copy of the Program. 103 | 104 | Contributors may not remove or alter any copyright notices contained within 105 | the Program. 106 | 107 | Each Contributor must identify itself as the originator of its Contribution, 108 | if any, in a manner that reasonably allows subsequent Recipients to identify 109 | the originator of the Contribution. 110 | 111 | 4. COMMERCIAL DISTRIBUTION 112 | 113 | Commercial distributors of software may accept certain responsibilities with 114 | respect to end users, business partners and the like. While this license is 115 | intended to facilitate the commercial use of the Program, the Contributor who 116 | includes the Program in a commercial product offering should do so in a 117 | manner which does not create potential liability for other Contributors. 118 | Therefore, if a Contributor includes the Program in a commercial product 119 | offering, such Contributor ("Commercial Contributor") hereby agrees to defend 120 | and indemnify every other Contributor ("Indemnified Contributor") against any 121 | losses, damages and costs (collectively "Losses") arising from claims, 122 | lawsuits and other legal actions brought by a third party against the 123 | Indemnified Contributor to the extent caused by the acts or omissions of such 124 | Commercial Contributor in connection with its distribution of the Program in 125 | a commercial product offering. The obligations in this section do not apply 126 | to any claims or Losses relating to any actual or alleged intellectual 127 | property infringement. In order to qualify, an Indemnified Contributor must: 128 | a) promptly notify the Commercial Contributor in writing of such claim, and 129 | b) allow the Commercial Contributor tocontrol, and cooperate with the 130 | Commercial Contributor in, the defense and any related settlement 131 | negotiations. The Indemnified Contributor may participate in any such claim 132 | at its own expense. 133 | 134 | For example, a Contributor might include the Program in a commercial product 135 | offering, Product X. That Contributor is then a Commercial Contributor. If 136 | that Commercial Contributor then makes performance claims, or offers 137 | warranties related to Product X, those performance claims and warranties are 138 | such Commercial Contributor's responsibility alone. Under this section, the 139 | Commercial Contributor would have to defend claims against the other 140 | Contributors related to those performance claims and warranties, and if a 141 | court requires any other Contributor to pay any damages as a result, the 142 | Commercial Contributor must pay those damages. 143 | 144 | 5. NO WARRANTY 145 | 146 | EXCEPT AS EXPRESSLY SET FORTH IN THIS AGREEMENT, THE PROGRAM IS PROVIDED ON 147 | AN "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, EITHER 148 | EXPRESS OR IMPLIED INCLUDING, WITHOUT LIMITATION, ANY WARRANTIES OR 149 | CONDITIONS OF TITLE, NON-INFRINGEMENT, MERCHANTABILITY OR FITNESS FOR A 150 | PARTICULAR PURPOSE. Each Recipient is solely responsible for determining the 151 | appropriateness of using and distributing the Program and assumes all risks 152 | associated with its exercise of rights under this Agreement , including but 153 | not limited to the risks and costs of program errors, compliance with 154 | applicable laws, damage to or loss of data, programs or equipment, and 155 | unavailability or interruption of operations. 156 | 157 | 6. DISCLAIMER OF LIABILITY 158 | 159 | EXCEPT AS EXPRESSLY SET FORTH IN THIS AGREEMENT, NEITHER RECIPIENT NOR ANY 160 | CONTRIBUTORS SHALL HAVE ANY LIABILITY FOR ANY DIRECT, INDIRECT, INCIDENTAL, 161 | SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING WITHOUT LIMITATION 162 | LOST PROFITS), HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 163 | CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 164 | ARISING IN ANY WAY OUT OF THE USE OR DISTRIBUTION OF THE PROGRAM OR THE 165 | EXERCISE OF ANY RIGHTS GRANTED HEREUNDER, EVEN IF ADVISED OF THE POSSIBILITY 166 | OF SUCH DAMAGES. 167 | 168 | 7. GENERAL 169 | 170 | If any provision of this Agreement is invalid or unenforceable under 171 | applicable law, it shall not affect the validity or enforceability of the 172 | remainder of the terms of this Agreement, and without further action by the 173 | parties hereto, such provision shall be reformed to the minimum extent 174 | necessary to make such provision valid and enforceable. 175 | 176 | If Recipient institutes patent litigation against any entity (including a 177 | cross-claim or counterclaim in a lawsuit) alleging that the Program itself 178 | (excluding combinations of the Program with other software or hardware) 179 | infringes such Recipient's patent(s), then such Recipient's rights granted 180 | under Section 2(b) shall terminate as of the date such litigation is filed. 181 | 182 | All Recipient's rights under this Agreement shall terminate if it fails to 183 | comply with any of the material terms or conditions of this Agreement and 184 | does not cure such failure in a reasonable period of time after becoming 185 | aware of such noncompliance. If all Recipient's rights under this Agreement 186 | terminate, Recipient agrees to cease use and distribution of the Program as 187 | soon as reasonably practicable. However, Recipient's obligations under this 188 | Agreement and any licenses granted by Recipient relating to the Program shall 189 | continue and survive. 190 | 191 | Everyone is permitted to copy and distribute copies of this Agreement, but in 192 | order to avoid inconsistency the Agreement is copyrighted and may only be 193 | modified in the following manner. The Agreement Steward reserves the right to 194 | publish new versions (including revisions) of this Agreement from time to 195 | time. No one other than the Agreement Steward has the right to modify this 196 | Agreement. The Eclipse Foundation is the initial Agreement Steward. The 197 | Eclipse Foundation may assign the responsibility to serve as the Agreement 198 | Steward to a suitable separate entity. Each new version of the Agreement will 199 | be given a distinguishing version number. The Program (including 200 | Contributions) may always be distributed subject to the version of the 201 | Agreement under which it was received. In addition, after a new version of 202 | the Agreement is published, Contributor may elect to distribute the Program 203 | (including its Contributions) under the new version. Except as expressly 204 | stated in Sections 2(a) and 2(b) above, Recipient receives no rights or 205 | licenses to the intellectual property of any Contributor under this 206 | Agreement, whether expressly, by implication, estoppel or otherwise. All 207 | rights in the Program not expressly granted under this Agreement are 208 | reserved. 209 | 210 | This Agreement is governed by the laws of the State of New York and the 211 | intellectual property laws of the United States of America. No party to this 212 | Agreement will bring a legal action under this Agreement more than one year 213 | after the cause of action arose. Each party waives its rights to a jury trial 214 | in any resulting litigation. 215 | -------------------------------------------------------------------------------- /top-scores/LICENSE: -------------------------------------------------------------------------------- 1 | THE ACCOMPANYING PROGRAM IS PROVIDED UNDER THE TERMS OF THIS ECLIPSE PUBLIC 2 | LICENSE ("AGREEMENT"). ANY USE, REPRODUCTION OR DISTRIBUTION OF THE PROGRAM 3 | CONSTITUTES RECIPIENT'S ACCEPTANCE OF THIS AGREEMENT. 4 | 5 | 1. DEFINITIONS 6 | 7 | "Contribution" means: 8 | 9 | a) in the case of the initial Contributor, the initial code and 10 | documentation distributed under this Agreement, and 11 | 12 | b) in the case of each subsequent Contributor: 13 | 14 | i) changes to the Program, and 15 | 16 | ii) additions to the Program; 17 | 18 | where such changes and/or additions to the Program originate from and are 19 | distributed by that particular Contributor. A Contribution 'originates' from 20 | a Contributor if it was added to the Program by such Contributor itself or 21 | anyone acting on such Contributor's behalf. Contributions do not include 22 | additions to the Program which: (i) are separate modules of software 23 | distributed in conjunction with the Program under their own license 24 | agreement, and (ii) are not derivative works of the Program. 25 | 26 | "Contributor" means any person or entity that distributes the Program. 27 | 28 | "Licensed Patents" mean patent claims licensable by a Contributor which are 29 | necessarily infringed by the use or sale of its Contribution alone or when 30 | combined with the Program. 31 | 32 | "Program" means the Contributions distributed in accordance with this 33 | Agreement. 34 | 35 | "Recipient" means anyone who receives the Program under this Agreement, 36 | including all Contributors. 37 | 38 | 2. GRANT OF RIGHTS 39 | 40 | a) Subject to the terms of this Agreement, each Contributor hereby grants 41 | Recipient a non-exclusive, worldwide, royalty-free copyright license to 42 | reproduce, prepare derivative works of, publicly display, publicly perform, 43 | distribute and sublicense the Contribution of such Contributor, if any, and 44 | such derivative works, in source code and object code form. 45 | 46 | b) Subject to the terms of this Agreement, each Contributor hereby grants 47 | Recipient a non-exclusive, worldwide, royalty-free patent license under 48 | Licensed Patents to make, use, sell, offer to sell, import and otherwise 49 | transfer the Contribution of such Contributor, if any, in source code and 50 | object code form. This patent license shall apply to the combination of the 51 | Contribution and the Program if, at the time the Contribution is added by the 52 | Contributor, such addition of the Contribution causes such combination to be 53 | covered by the Licensed Patents. The patent license shall not apply to any 54 | other combinations which include the Contribution. No hardware per se is 55 | licensed hereunder. 56 | 57 | c) Recipient understands that although each Contributor grants the licenses 58 | to its Contributions set forth herein, no assurances are provided by any 59 | Contributor that the Program does not infringe the patent or other 60 | intellectual property rights of any other entity. Each Contributor disclaims 61 | any liability to Recipient for claims brought by any other entity based on 62 | infringement of intellectual property rights or otherwise. As a condition to 63 | exercising the rights and licenses granted hereunder, each Recipient hereby 64 | assumes sole responsibility to secure any other intellectual property rights 65 | needed, if any. For example, if a third party patent license is required to 66 | allow Recipient to distribute the Program, it is Recipient's responsibility 67 | to acquire that license before distributing the Program. 68 | 69 | d) Each Contributor represents that to its knowledge it has sufficient 70 | copyright rights in its Contribution, if any, to grant the copyright license 71 | set forth in this Agreement. 72 | 73 | 3. REQUIREMENTS 74 | 75 | A Contributor may choose to distribute the Program in object code form under 76 | its own license agreement, provided that: 77 | 78 | a) it complies with the terms and conditions of this Agreement; and 79 | 80 | b) its license agreement: 81 | 82 | i) effectively disclaims on behalf of all Contributors all warranties and 83 | conditions, express and implied, including warranties or conditions of title 84 | and non-infringement, and implied warranties or conditions of merchantability 85 | and fitness for a particular purpose; 86 | 87 | ii) effectively excludes on behalf of all Contributors all liability for 88 | damages, including direct, indirect, special, incidental and consequential 89 | damages, such as lost profits; 90 | 91 | iii) states that any provisions which differ from this Agreement are offered 92 | by that Contributor alone and not by any other party; and 93 | 94 | iv) states that source code for the Program is available from such 95 | Contributor, and informs licensees how to obtain it in a reasonable manner on 96 | or through a medium customarily used for software exchange. 97 | 98 | When the Program is made available in source code form: 99 | 100 | a) it must be made available under this Agreement; and 101 | 102 | b) a copy of this Agreement must be included with each copy of the Program. 103 | 104 | Contributors may not remove or alter any copyright notices contained within 105 | the Program. 106 | 107 | Each Contributor must identify itself as the originator of its Contribution, 108 | if any, in a manner that reasonably allows subsequent Recipients to identify 109 | the originator of the Contribution. 110 | 111 | 4. COMMERCIAL DISTRIBUTION 112 | 113 | Commercial distributors of software may accept certain responsibilities with 114 | respect to end users, business partners and the like. While this license is 115 | intended to facilitate the commercial use of the Program, the Contributor who 116 | includes the Program in a commercial product offering should do so in a 117 | manner which does not create potential liability for other Contributors. 118 | Therefore, if a Contributor includes the Program in a commercial product 119 | offering, such Contributor ("Commercial Contributor") hereby agrees to defend 120 | and indemnify every other Contributor ("Indemnified Contributor") against any 121 | losses, damages and costs (collectively "Losses") arising from claims, 122 | lawsuits and other legal actions brought by a third party against the 123 | Indemnified Contributor to the extent caused by the acts or omissions of such 124 | Commercial Contributor in connection with its distribution of the Program in 125 | a commercial product offering. The obligations in this section do not apply 126 | to any claims or Losses relating to any actual or alleged intellectual 127 | property infringement. In order to qualify, an Indemnified Contributor must: 128 | a) promptly notify the Commercial Contributor in writing of such claim, and 129 | b) allow the Commercial Contributor tocontrol, and cooperate with the 130 | Commercial Contributor in, the defense and any related settlement 131 | negotiations. The Indemnified Contributor may participate in any such claim 132 | at its own expense. 133 | 134 | For example, a Contributor might include the Program in a commercial product 135 | offering, Product X. That Contributor is then a Commercial Contributor. If 136 | that Commercial Contributor then makes performance claims, or offers 137 | warranties related to Product X, those performance claims and warranties are 138 | such Commercial Contributor's responsibility alone. Under this section, the 139 | Commercial Contributor would have to defend claims against the other 140 | Contributors related to those performance claims and warranties, and if a 141 | court requires any other Contributor to pay any damages as a result, the 142 | Commercial Contributor must pay those damages. 143 | 144 | 5. NO WARRANTY 145 | 146 | EXCEPT AS EXPRESSLY SET FORTH IN THIS AGREEMENT, THE PROGRAM IS PROVIDED ON 147 | AN "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, EITHER 148 | EXPRESS OR IMPLIED INCLUDING, WITHOUT LIMITATION, ANY WARRANTIES OR 149 | CONDITIONS OF TITLE, NON-INFRINGEMENT, MERCHANTABILITY OR FITNESS FOR A 150 | PARTICULAR PURPOSE. Each Recipient is solely responsible for determining the 151 | appropriateness of using and distributing the Program and assumes all risks 152 | associated with its exercise of rights under this Agreement , including but 153 | not limited to the risks and costs of program errors, compliance with 154 | applicable laws, damage to or loss of data, programs or equipment, and 155 | unavailability or interruption of operations. 156 | 157 | 6. DISCLAIMER OF LIABILITY 158 | 159 | EXCEPT AS EXPRESSLY SET FORTH IN THIS AGREEMENT, NEITHER RECIPIENT NOR ANY 160 | CONTRIBUTORS SHALL HAVE ANY LIABILITY FOR ANY DIRECT, INDIRECT, INCIDENTAL, 161 | SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING WITHOUT LIMITATION 162 | LOST PROFITS), HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 163 | CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 164 | ARISING IN ANY WAY OUT OF THE USE OR DISTRIBUTION OF THE PROGRAM OR THE 165 | EXERCISE OF ANY RIGHTS GRANTED HEREUNDER, EVEN IF ADVISED OF THE POSSIBILITY 166 | OF SUCH DAMAGES. 167 | 168 | 7. GENERAL 169 | 170 | If any provision of this Agreement is invalid or unenforceable under 171 | applicable law, it shall not affect the validity or enforceability of the 172 | remainder of the terms of this Agreement, and without further action by the 173 | parties hereto, such provision shall be reformed to the minimum extent 174 | necessary to make such provision valid and enforceable. 175 | 176 | If Recipient institutes patent litigation against any entity (including a 177 | cross-claim or counterclaim in a lawsuit) alleging that the Program itself 178 | (excluding combinations of the Program with other software or hardware) 179 | infringes such Recipient's patent(s), then such Recipient's rights granted 180 | under Section 2(b) shall terminate as of the date such litigation is filed. 181 | 182 | All Recipient's rights under this Agreement shall terminate if it fails to 183 | comply with any of the material terms or conditions of this Agreement and 184 | does not cure such failure in a reasonable period of time after becoming 185 | aware of such noncompliance. If all Recipient's rights under this Agreement 186 | terminate, Recipient agrees to cease use and distribution of the Program as 187 | soon as reasonably practicable. However, Recipient's obligations under this 188 | Agreement and any licenses granted by Recipient relating to the Program shall 189 | continue and survive. 190 | 191 | Everyone is permitted to copy and distribute copies of this Agreement, but in 192 | order to avoid inconsistency the Agreement is copyrighted and may only be 193 | modified in the following manner. The Agreement Steward reserves the right to 194 | publish new versions (including revisions) of this Agreement from time to 195 | time. No one other than the Agreement Steward has the right to modify this 196 | Agreement. The Eclipse Foundation is the initial Agreement Steward. The 197 | Eclipse Foundation may assign the responsibility to serve as the Agreement 198 | Steward to a suitable separate entity. Each new version of the Agreement will 199 | be given a distinguishing version number. The Program (including 200 | Contributions) may always be distributed subject to the version of the 201 | Agreement under which it was received. In addition, after a new version of 202 | the Agreement is published, Contributor may elect to distribute the Program 203 | (including its Contributions) under the new version. Except as expressly 204 | stated in Sections 2(a) and 2(b) above, Recipient receives no rights or 205 | licenses to the intellectual property of any Contributor under this 206 | Agreement, whether expressly, by implication, estoppel or otherwise. All 207 | rights in the Program not expressly granted under this Agreement are 208 | reserved. 209 | 210 | This Agreement is governed by the laws of the State of New York and the 211 | intellectual property laws of the United States of America. No party to this 212 | Agreement will bring a legal action under this Agreement more than one year 213 | after the cause of action arose. Each party waives its rights to a jury trial 214 | in any resulting litigation. 215 | -------------------------------------------------------------------------------- /word-cloud/LICENSE: -------------------------------------------------------------------------------- 1 | THE ACCOMPANYING PROGRAM IS PROVIDED UNDER THE TERMS OF THIS ECLIPSE PUBLIC 2 | LICENSE ("AGREEMENT"). ANY USE, REPRODUCTION OR DISTRIBUTION OF THE PROGRAM 3 | CONSTITUTES RECIPIENT'S ACCEPTANCE OF THIS AGREEMENT. 4 | 5 | 1. DEFINITIONS 6 | 7 | "Contribution" means: 8 | 9 | a) in the case of the initial Contributor, the initial code and 10 | documentation distributed under this Agreement, and 11 | 12 | b) in the case of each subsequent Contributor: 13 | 14 | i) changes to the Program, and 15 | 16 | ii) additions to the Program; 17 | 18 | where such changes and/or additions to the Program originate from and are 19 | distributed by that particular Contributor. A Contribution 'originates' from 20 | a Contributor if it was added to the Program by such Contributor itself or 21 | anyone acting on such Contributor's behalf. Contributions do not include 22 | additions to the Program which: (i) are separate modules of software 23 | distributed in conjunction with the Program under their own license 24 | agreement, and (ii) are not derivative works of the Program. 25 | 26 | "Contributor" means any person or entity that distributes the Program. 27 | 28 | "Licensed Patents" mean patent claims licensable by a Contributor which are 29 | necessarily infringed by the use or sale of its Contribution alone or when 30 | combined with the Program. 31 | 32 | "Program" means the Contributions distributed in accordance with this 33 | Agreement. 34 | 35 | "Recipient" means anyone who receives the Program under this Agreement, 36 | including all Contributors. 37 | 38 | 2. GRANT OF RIGHTS 39 | 40 | a) Subject to the terms of this Agreement, each Contributor hereby grants 41 | Recipient a non-exclusive, worldwide, royalty-free copyright license to 42 | reproduce, prepare derivative works of, publicly display, publicly perform, 43 | distribute and sublicense the Contribution of such Contributor, if any, and 44 | such derivative works, in source code and object code form. 45 | 46 | b) Subject to the terms of this Agreement, each Contributor hereby grants 47 | Recipient a non-exclusive, worldwide, royalty-free patent license under 48 | Licensed Patents to make, use, sell, offer to sell, import and otherwise 49 | transfer the Contribution of such Contributor, if any, in source code and 50 | object code form. This patent license shall apply to the combination of the 51 | Contribution and the Program if, at the time the Contribution is added by the 52 | Contributor, such addition of the Contribution causes such combination to be 53 | covered by the Licensed Patents. The patent license shall not apply to any 54 | other combinations which include the Contribution. No hardware per se is 55 | licensed hereunder. 56 | 57 | c) Recipient understands that although each Contributor grants the licenses 58 | to its Contributions set forth herein, no assurances are provided by any 59 | Contributor that the Program does not infringe the patent or other 60 | intellectual property rights of any other entity. Each Contributor disclaims 61 | any liability to Recipient for claims brought by any other entity based on 62 | infringement of intellectual property rights or otherwise. As a condition to 63 | exercising the rights and licenses granted hereunder, each Recipient hereby 64 | assumes sole responsibility to secure any other intellectual property rights 65 | needed, if any. For example, if a third party patent license is required to 66 | allow Recipient to distribute the Program, it is Recipient's responsibility 67 | to acquire that license before distributing the Program. 68 | 69 | d) Each Contributor represents that to its knowledge it has sufficient 70 | copyright rights in its Contribution, if any, to grant the copyright license 71 | set forth in this Agreement. 72 | 73 | 3. REQUIREMENTS 74 | 75 | A Contributor may choose to distribute the Program in object code form under 76 | its own license agreement, provided that: 77 | 78 | a) it complies with the terms and conditions of this Agreement; and 79 | 80 | b) its license agreement: 81 | 82 | i) effectively disclaims on behalf of all Contributors all warranties and 83 | conditions, express and implied, including warranties or conditions of title 84 | and non-infringement, and implied warranties or conditions of merchantability 85 | and fitness for a particular purpose; 86 | 87 | ii) effectively excludes on behalf of all Contributors all liability for 88 | damages, including direct, indirect, special, incidental and consequential 89 | damages, such as lost profits; 90 | 91 | iii) states that any provisions which differ from this Agreement are offered 92 | by that Contributor alone and not by any other party; and 93 | 94 | iv) states that source code for the Program is available from such 95 | Contributor, and informs licensees how to obtain it in a reasonable manner on 96 | or through a medium customarily used for software exchange. 97 | 98 | When the Program is made available in source code form: 99 | 100 | a) it must be made available under this Agreement; and 101 | 102 | b) a copy of this Agreement must be included with each copy of the Program. 103 | 104 | Contributors may not remove or alter any copyright notices contained within 105 | the Program. 106 | 107 | Each Contributor must identify itself as the originator of its Contribution, 108 | if any, in a manner that reasonably allows subsequent Recipients to identify 109 | the originator of the Contribution. 110 | 111 | 4. COMMERCIAL DISTRIBUTION 112 | 113 | Commercial distributors of software may accept certain responsibilities with 114 | respect to end users, business partners and the like. While this license is 115 | intended to facilitate the commercial use of the Program, the Contributor who 116 | includes the Program in a commercial product offering should do so in a 117 | manner which does not create potential liability for other Contributors. 118 | Therefore, if a Contributor includes the Program in a commercial product 119 | offering, such Contributor ("Commercial Contributor") hereby agrees to defend 120 | and indemnify every other Contributor ("Indemnified Contributor") against any 121 | losses, damages and costs (collectively "Losses") arising from claims, 122 | lawsuits and other legal actions brought by a third party against the 123 | Indemnified Contributor to the extent caused by the acts or omissions of such 124 | Commercial Contributor in connection with its distribution of the Program in 125 | a commercial product offering. The obligations in this section do not apply 126 | to any claims or Losses relating to any actual or alleged intellectual 127 | property infringement. In order to qualify, an Indemnified Contributor must: 128 | a) promptly notify the Commercial Contributor in writing of such claim, and 129 | b) allow the Commercial Contributor tocontrol, and cooperate with the 130 | Commercial Contributor in, the defense and any related settlement 131 | negotiations. The Indemnified Contributor may participate in any such claim 132 | at its own expense. 133 | 134 | For example, a Contributor might include the Program in a commercial product 135 | offering, Product X. That Contributor is then a Commercial Contributor. If 136 | that Commercial Contributor then makes performance claims, or offers 137 | warranties related to Product X, those performance claims and warranties are 138 | such Commercial Contributor's responsibility alone. Under this section, the 139 | Commercial Contributor would have to defend claims against the other 140 | Contributors related to those performance claims and warranties, and if a 141 | court requires any other Contributor to pay any damages as a result, the 142 | Commercial Contributor must pay those damages. 143 | 144 | 5. NO WARRANTY 145 | 146 | EXCEPT AS EXPRESSLY SET FORTH IN THIS AGREEMENT, THE PROGRAM IS PROVIDED ON 147 | AN "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, EITHER 148 | EXPRESS OR IMPLIED INCLUDING, WITHOUT LIMITATION, ANY WARRANTIES OR 149 | CONDITIONS OF TITLE, NON-INFRINGEMENT, MERCHANTABILITY OR FITNESS FOR A 150 | PARTICULAR PURPOSE. Each Recipient is solely responsible for determining the 151 | appropriateness of using and distributing the Program and assumes all risks 152 | associated with its exercise of rights under this Agreement , including but 153 | not limited to the risks and costs of program errors, compliance with 154 | applicable laws, damage to or loss of data, programs or equipment, and 155 | unavailability or interruption of operations. 156 | 157 | 6. DISCLAIMER OF LIABILITY 158 | 159 | EXCEPT AS EXPRESSLY SET FORTH IN THIS AGREEMENT, NEITHER RECIPIENT NOR ANY 160 | CONTRIBUTORS SHALL HAVE ANY LIABILITY FOR ANY DIRECT, INDIRECT, INCIDENTAL, 161 | SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING WITHOUT LIMITATION 162 | LOST PROFITS), HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 163 | CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 164 | ARISING IN ANY WAY OUT OF THE USE OR DISTRIBUTION OF THE PROGRAM OR THE 165 | EXERCISE OF ANY RIGHTS GRANTED HEREUNDER, EVEN IF ADVISED OF THE POSSIBILITY 166 | OF SUCH DAMAGES. 167 | 168 | 7. GENERAL 169 | 170 | If any provision of this Agreement is invalid or unenforceable under 171 | applicable law, it shall not affect the validity or enforceability of the 172 | remainder of the terms of this Agreement, and without further action by the 173 | parties hereto, such provision shall be reformed to the minimum extent 174 | necessary to make such provision valid and enforceable. 175 | 176 | If Recipient institutes patent litigation against any entity (including a 177 | cross-claim or counterclaim in a lawsuit) alleging that the Program itself 178 | (excluding combinations of the Program with other software or hardware) 179 | infringes such Recipient's patent(s), then such Recipient's rights granted 180 | under Section 2(b) shall terminate as of the date such litigation is filed. 181 | 182 | All Recipient's rights under this Agreement shall terminate if it fails to 183 | comply with any of the material terms or conditions of this Agreement and 184 | does not cure such failure in a reasonable period of time after becoming 185 | aware of such noncompliance. If all Recipient's rights under this Agreement 186 | terminate, Recipient agrees to cease use and distribution of the Program as 187 | soon as reasonably practicable. However, Recipient's obligations under this 188 | Agreement and any licenses granted by Recipient relating to the Program shall 189 | continue and survive. 190 | 191 | Everyone is permitted to copy and distribute copies of this Agreement, but in 192 | order to avoid inconsistency the Agreement is copyrighted and may only be 193 | modified in the following manner. The Agreement Steward reserves the right to 194 | publish new versions (including revisions) of this Agreement from time to 195 | time. No one other than the Agreement Steward has the right to modify this 196 | Agreement. The Eclipse Foundation is the initial Agreement Steward. The 197 | Eclipse Foundation may assign the responsibility to serve as the Agreement 198 | Steward to a suitable separate entity. Each new version of the Agreement will 199 | be given a distinguishing version number. The Program (including 200 | Contributions) may always be distributed subject to the version of the 201 | Agreement under which it was received. In addition, after a new version of 202 | the Agreement is published, Contributor may elect to distribute the Program 203 | (including its Contributions) under the new version. Except as expressly 204 | stated in Sections 2(a) and 2(b) above, Recipient receives no rights or 205 | licenses to the intellectual property of any Contributor under this 206 | Agreement, whether expressly, by implication, estoppel or otherwise. All 207 | rights in the Program not expressly granted under this Agreement are 208 | reserved. 209 | 210 | This Agreement is governed by the laws of the State of New York and the 211 | intellectual property laws of the United States of America. No party to this 212 | Agreement will bring a legal action under this Agreement more than one year 213 | after the cause of action arose. Each party waives its rights to a jury trial 214 | in any resulting litigation. 215 | -------------------------------------------------------------------------------- /apple-stocks/LICENSE: -------------------------------------------------------------------------------- 1 | THE ACCOMPANYING PROGRAM IS PROVIDED UNDER THE TERMS OF THIS ECLIPSE PUBLIC 2 | LICENSE ("AGREEMENT"). ANY USE, REPRODUCTION OR DISTRIBUTION OF THE PROGRAM 3 | CONSTITUTES RECIPIENT'S ACCEPTANCE OF THIS AGREEMENT. 4 | 5 | 1. DEFINITIONS 6 | 7 | "Contribution" means: 8 | 9 | a) in the case of the initial Contributor, the initial code and 10 | documentation distributed under this Agreement, and 11 | 12 | b) in the case of each subsequent Contributor: 13 | 14 | i) changes to the Program, and 15 | 16 | ii) additions to the Program; 17 | 18 | where such changes and/or additions to the Program originate from and are 19 | distributed by that particular Contributor. A Contribution 'originates' from 20 | a Contributor if it was added to the Program by such Contributor itself or 21 | anyone acting on such Contributor's behalf. Contributions do not include 22 | additions to the Program which: (i) are separate modules of software 23 | distributed in conjunction with the Program under their own license 24 | agreement, and (ii) are not derivative works of the Program. 25 | 26 | "Contributor" means any person or entity that distributes the Program. 27 | 28 | "Licensed Patents" mean patent claims licensable by a Contributor which are 29 | necessarily infringed by the use or sale of its Contribution alone or when 30 | combined with the Program. 31 | 32 | "Program" means the Contributions distributed in accordance with this 33 | Agreement. 34 | 35 | "Recipient" means anyone who receives the Program under this Agreement, 36 | including all Contributors. 37 | 38 | 2. GRANT OF RIGHTS 39 | 40 | a) Subject to the terms of this Agreement, each Contributor hereby grants 41 | Recipient a non-exclusive, worldwide, royalty-free copyright license to 42 | reproduce, prepare derivative works of, publicly display, publicly perform, 43 | distribute and sublicense the Contribution of such Contributor, if any, and 44 | such derivative works, in source code and object code form. 45 | 46 | b) Subject to the terms of this Agreement, each Contributor hereby grants 47 | Recipient a non-exclusive, worldwide, royalty-free patent license under 48 | Licensed Patents to make, use, sell, offer to sell, import and otherwise 49 | transfer the Contribution of such Contributor, if any, in source code and 50 | object code form. This patent license shall apply to the combination of the 51 | Contribution and the Program if, at the time the Contribution is added by the 52 | Contributor, such addition of the Contribution causes such combination to be 53 | covered by the Licensed Patents. The patent license shall not apply to any 54 | other combinations which include the Contribution. No hardware per se is 55 | licensed hereunder. 56 | 57 | c) Recipient understands that although each Contributor grants the licenses 58 | to its Contributions set forth herein, no assurances are provided by any 59 | Contributor that the Program does not infringe the patent or other 60 | intellectual property rights of any other entity. Each Contributor disclaims 61 | any liability to Recipient for claims brought by any other entity based on 62 | infringement of intellectual property rights or otherwise. As a condition to 63 | exercising the rights and licenses granted hereunder, each Recipient hereby 64 | assumes sole responsibility to secure any other intellectual property rights 65 | needed, if any. For example, if a third party patent license is required to 66 | allow Recipient to distribute the Program, it is Recipient's responsibility 67 | to acquire that license before distributing the Program. 68 | 69 | d) Each Contributor represents that to its knowledge it has sufficient 70 | copyright rights in its Contribution, if any, to grant the copyright license 71 | set forth in this Agreement. 72 | 73 | 3. REQUIREMENTS 74 | 75 | A Contributor may choose to distribute the Program in object code form under 76 | its own license agreement, provided that: 77 | 78 | a) it complies with the terms and conditions of this Agreement; and 79 | 80 | b) its license agreement: 81 | 82 | i) effectively disclaims on behalf of all Contributors all warranties and 83 | conditions, express and implied, including warranties or conditions of title 84 | and non-infringement, and implied warranties or conditions of merchantability 85 | and fitness for a particular purpose; 86 | 87 | ii) effectively excludes on behalf of all Contributors all liability for 88 | damages, including direct, indirect, special, incidental and consequential 89 | damages, such as lost profits; 90 | 91 | iii) states that any provisions which differ from this Agreement are offered 92 | by that Contributor alone and not by any other party; and 93 | 94 | iv) states that source code for the Program is available from such 95 | Contributor, and informs licensees how to obtain it in a reasonable manner on 96 | or through a medium customarily used for software exchange. 97 | 98 | When the Program is made available in source code form: 99 | 100 | a) it must be made available under this Agreement; and 101 | 102 | b) a copy of this Agreement must be included with each copy of the Program. 103 | 104 | Contributors may not remove or alter any copyright notices contained within 105 | the Program. 106 | 107 | Each Contributor must identify itself as the originator of its Contribution, 108 | if any, in a manner that reasonably allows subsequent Recipients to identify 109 | the originator of the Contribution. 110 | 111 | 4. COMMERCIAL DISTRIBUTION 112 | 113 | Commercial distributors of software may accept certain responsibilities with 114 | respect to end users, business partners and the like. While this license is 115 | intended to facilitate the commercial use of the Program, the Contributor who 116 | includes the Program in a commercial product offering should do so in a 117 | manner which does not create potential liability for other Contributors. 118 | Therefore, if a Contributor includes the Program in a commercial product 119 | offering, such Contributor ("Commercial Contributor") hereby agrees to defend 120 | and indemnify every other Contributor ("Indemnified Contributor") against any 121 | losses, damages and costs (collectively "Losses") arising from claims, 122 | lawsuits and other legal actions brought by a third party against the 123 | Indemnified Contributor to the extent caused by the acts or omissions of such 124 | Commercial Contributor in connection with its distribution of the Program in 125 | a commercial product offering. The obligations in this section do not apply 126 | to any claims or Losses relating to any actual or alleged intellectual 127 | property infringement. In order to qualify, an Indemnified Contributor must: 128 | a) promptly notify the Commercial Contributor in writing of such claim, and 129 | b) allow the Commercial Contributor tocontrol, and cooperate with the 130 | Commercial Contributor in, the defense and any related settlement 131 | negotiations. The Indemnified Contributor may participate in any such claim 132 | at its own expense. 133 | 134 | For example, a Contributor might include the Program in a commercial product 135 | offering, Product X. That Contributor is then a Commercial Contributor. If 136 | that Commercial Contributor then makes performance claims, or offers 137 | warranties related to Product X, those performance claims and warranties are 138 | such Commercial Contributor's responsibility alone. Under this section, the 139 | Commercial Contributor would have to defend claims against the other 140 | Contributors related to those performance claims and warranties, and if a 141 | court requires any other Contributor to pay any damages as a result, the 142 | Commercial Contributor must pay those damages. 143 | 144 | 5. NO WARRANTY 145 | 146 | EXCEPT AS EXPRESSLY SET FORTH IN THIS AGREEMENT, THE PROGRAM IS PROVIDED ON 147 | AN "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, EITHER 148 | EXPRESS OR IMPLIED INCLUDING, WITHOUT LIMITATION, ANY WARRANTIES OR 149 | CONDITIONS OF TITLE, NON-INFRINGEMENT, MERCHANTABILITY OR FITNESS FOR A 150 | PARTICULAR PURPOSE. Each Recipient is solely responsible for determining the 151 | appropriateness of using and distributing the Program and assumes all risks 152 | associated with its exercise of rights under this Agreement , including but 153 | not limited to the risks and costs of program errors, compliance with 154 | applicable laws, damage to or loss of data, programs or equipment, and 155 | unavailability or interruption of operations. 156 | 157 | 6. DISCLAIMER OF LIABILITY 158 | 159 | EXCEPT AS EXPRESSLY SET FORTH IN THIS AGREEMENT, NEITHER RECIPIENT NOR ANY 160 | CONTRIBUTORS SHALL HAVE ANY LIABILITY FOR ANY DIRECT, INDIRECT, INCIDENTAL, 161 | SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING WITHOUT LIMITATION 162 | LOST PROFITS), HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 163 | CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 164 | ARISING IN ANY WAY OUT OF THE USE OR DISTRIBUTION OF THE PROGRAM OR THE 165 | EXERCISE OF ANY RIGHTS GRANTED HEREUNDER, EVEN IF ADVISED OF THE POSSIBILITY 166 | OF SUCH DAMAGES. 167 | 168 | 7. GENERAL 169 | 170 | If any provision of this Agreement is invalid or unenforceable under 171 | applicable law, it shall not affect the validity or enforceability of the 172 | remainder of the terms of this Agreement, and without further action by the 173 | parties hereto, such provision shall be reformed to the minimum extent 174 | necessary to make such provision valid and enforceable. 175 | 176 | If Recipient institutes patent litigation against any entity (including a 177 | cross-claim or counterclaim in a lawsuit) alleging that the Program itself 178 | (excluding combinations of the Program with other software or hardware) 179 | infringes such Recipient's patent(s), then such Recipient's rights granted 180 | under Section 2(b) shall terminate as of the date such litigation is filed. 181 | 182 | All Recipient's rights under this Agreement shall terminate if it fails to 183 | comply with any of the material terms or conditions of this Agreement and 184 | does not cure such failure in a reasonable period of time after becoming 185 | aware of such noncompliance. If all Recipient's rights under this Agreement 186 | terminate, Recipient agrees to cease use and distribution of the Program as 187 | soon as reasonably practicable. However, Recipient's obligations under this 188 | Agreement and any licenses granted by Recipient relating to the Program shall 189 | continue and survive. 190 | 191 | Everyone is permitted to copy and distribute copies of this Agreement, but in 192 | order to avoid inconsistency the Agreement is copyrighted and may only be 193 | modified in the following manner. The Agreement Steward reserves the right to 194 | publish new versions (including revisions) of this Agreement from time to 195 | time. No one other than the Agreement Steward has the right to modify this 196 | Agreement. The Eclipse Foundation is the initial Agreement Steward. The 197 | Eclipse Foundation may assign the responsibility to serve as the Agreement 198 | Steward to a suitable separate entity. Each new version of the Agreement will 199 | be given a distinguishing version number. The Program (including 200 | Contributions) may always be distributed subject to the version of the 201 | Agreement under which it was received. In addition, after a new version of 202 | the Agreement is published, Contributor may elect to distribute the Program 203 | (including its Contributions) under the new version. Except as expressly 204 | stated in Sections 2(a) and 2(b) above, Recipient receives no rights or 205 | licenses to the intellectual property of any Contributor under this 206 | Agreement, whether expressly, by implication, estoppel or otherwise. All 207 | rights in the Program not expressly granted under this Agreement are 208 | reserved. 209 | 210 | This Agreement is governed by the laws of the State of New York and the 211 | intellectual property laws of the United States of America. No party to this 212 | Agreement will bring a legal action under this Agreement more than one year 213 | after the cause of action arose. Each party waives its rights to a jury trial 214 | in any resulting litigation. 215 | -------------------------------------------------------------------------------- /in-place-shuffle/LICENSE: -------------------------------------------------------------------------------- 1 | THE ACCOMPANYING PROGRAM IS PROVIDED UNDER THE TERMS OF THIS ECLIPSE PUBLIC 2 | LICENSE ("AGREEMENT"). ANY USE, REPRODUCTION OR DISTRIBUTION OF THE PROGRAM 3 | CONSTITUTES RECIPIENT'S ACCEPTANCE OF THIS AGREEMENT. 4 | 5 | 1. DEFINITIONS 6 | 7 | "Contribution" means: 8 | 9 | a) in the case of the initial Contributor, the initial code and 10 | documentation distributed under this Agreement, and 11 | 12 | b) in the case of each subsequent Contributor: 13 | 14 | i) changes to the Program, and 15 | 16 | ii) additions to the Program; 17 | 18 | where such changes and/or additions to the Program originate from and are 19 | distributed by that particular Contributor. A Contribution 'originates' from 20 | a Contributor if it was added to the Program by such Contributor itself or 21 | anyone acting on such Contributor's behalf. Contributions do not include 22 | additions to the Program which: (i) are separate modules of software 23 | distributed in conjunction with the Program under their own license 24 | agreement, and (ii) are not derivative works of the Program. 25 | 26 | "Contributor" means any person or entity that distributes the Program. 27 | 28 | "Licensed Patents" mean patent claims licensable by a Contributor which are 29 | necessarily infringed by the use or sale of its Contribution alone or when 30 | combined with the Program. 31 | 32 | "Program" means the Contributions distributed in accordance with this 33 | Agreement. 34 | 35 | "Recipient" means anyone who receives the Program under this Agreement, 36 | including all Contributors. 37 | 38 | 2. GRANT OF RIGHTS 39 | 40 | a) Subject to the terms of this Agreement, each Contributor hereby grants 41 | Recipient a non-exclusive, worldwide, royalty-free copyright license to 42 | reproduce, prepare derivative works of, publicly display, publicly perform, 43 | distribute and sublicense the Contribution of such Contributor, if any, and 44 | such derivative works, in source code and object code form. 45 | 46 | b) Subject to the terms of this Agreement, each Contributor hereby grants 47 | Recipient a non-exclusive, worldwide, royalty-free patent license under 48 | Licensed Patents to make, use, sell, offer to sell, import and otherwise 49 | transfer the Contribution of such Contributor, if any, in source code and 50 | object code form. This patent license shall apply to the combination of the 51 | Contribution and the Program if, at the time the Contribution is added by the 52 | Contributor, such addition of the Contribution causes such combination to be 53 | covered by the Licensed Patents. The patent license shall not apply to any 54 | other combinations which include the Contribution. No hardware per se is 55 | licensed hereunder. 56 | 57 | c) Recipient understands that although each Contributor grants the licenses 58 | to its Contributions set forth herein, no assurances are provided by any 59 | Contributor that the Program does not infringe the patent or other 60 | intellectual property rights of any other entity. Each Contributor disclaims 61 | any liability to Recipient for claims brought by any other entity based on 62 | infringement of intellectual property rights or otherwise. As a condition to 63 | exercising the rights and licenses granted hereunder, each Recipient hereby 64 | assumes sole responsibility to secure any other intellectual property rights 65 | needed, if any. For example, if a third party patent license is required to 66 | allow Recipient to distribute the Program, it is Recipient's responsibility 67 | to acquire that license before distributing the Program. 68 | 69 | d) Each Contributor represents that to its knowledge it has sufficient 70 | copyright rights in its Contribution, if any, to grant the copyright license 71 | set forth in this Agreement. 72 | 73 | 3. REQUIREMENTS 74 | 75 | A Contributor may choose to distribute the Program in object code form under 76 | its own license agreement, provided that: 77 | 78 | a) it complies with the terms and conditions of this Agreement; and 79 | 80 | b) its license agreement: 81 | 82 | i) effectively disclaims on behalf of all Contributors all warranties and 83 | conditions, express and implied, including warranties or conditions of title 84 | and non-infringement, and implied warranties or conditions of merchantability 85 | and fitness for a particular purpose; 86 | 87 | ii) effectively excludes on behalf of all Contributors all liability for 88 | damages, including direct, indirect, special, incidental and consequential 89 | damages, such as lost profits; 90 | 91 | iii) states that any provisions which differ from this Agreement are offered 92 | by that Contributor alone and not by any other party; and 93 | 94 | iv) states that source code for the Program is available from such 95 | Contributor, and informs licensees how to obtain it in a reasonable manner on 96 | or through a medium customarily used for software exchange. 97 | 98 | When the Program is made available in source code form: 99 | 100 | a) it must be made available under this Agreement; and 101 | 102 | b) a copy of this Agreement must be included with each copy of the Program. 103 | 104 | Contributors may not remove or alter any copyright notices contained within 105 | the Program. 106 | 107 | Each Contributor must identify itself as the originator of its Contribution, 108 | if any, in a manner that reasonably allows subsequent Recipients to identify 109 | the originator of the Contribution. 110 | 111 | 4. COMMERCIAL DISTRIBUTION 112 | 113 | Commercial distributors of software may accept certain responsibilities with 114 | respect to end users, business partners and the like. While this license is 115 | intended to facilitate the commercial use of the Program, the Contributor who 116 | includes the Program in a commercial product offering should do so in a 117 | manner which does not create potential liability for other Contributors. 118 | Therefore, if a Contributor includes the Program in a commercial product 119 | offering, such Contributor ("Commercial Contributor") hereby agrees to defend 120 | and indemnify every other Contributor ("Indemnified Contributor") against any 121 | losses, damages and costs (collectively "Losses") arising from claims, 122 | lawsuits and other legal actions brought by a third party against the 123 | Indemnified Contributor to the extent caused by the acts or omissions of such 124 | Commercial Contributor in connection with its distribution of the Program in 125 | a commercial product offering. The obligations in this section do not apply 126 | to any claims or Losses relating to any actual or alleged intellectual 127 | property infringement. In order to qualify, an Indemnified Contributor must: 128 | a) promptly notify the Commercial Contributor in writing of such claim, and 129 | b) allow the Commercial Contributor tocontrol, and cooperate with the 130 | Commercial Contributor in, the defense and any related settlement 131 | negotiations. The Indemnified Contributor may participate in any such claim 132 | at its own expense. 133 | 134 | For example, a Contributor might include the Program in a commercial product 135 | offering, Product X. That Contributor is then a Commercial Contributor. If 136 | that Commercial Contributor then makes performance claims, or offers 137 | warranties related to Product X, those performance claims and warranties are 138 | such Commercial Contributor's responsibility alone. Under this section, the 139 | Commercial Contributor would have to defend claims against the other 140 | Contributors related to those performance claims and warranties, and if a 141 | court requires any other Contributor to pay any damages as a result, the 142 | Commercial Contributor must pay those damages. 143 | 144 | 5. NO WARRANTY 145 | 146 | EXCEPT AS EXPRESSLY SET FORTH IN THIS AGREEMENT, THE PROGRAM IS PROVIDED ON 147 | AN "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, EITHER 148 | EXPRESS OR IMPLIED INCLUDING, WITHOUT LIMITATION, ANY WARRANTIES OR 149 | CONDITIONS OF TITLE, NON-INFRINGEMENT, MERCHANTABILITY OR FITNESS FOR A 150 | PARTICULAR PURPOSE. Each Recipient is solely responsible for determining the 151 | appropriateness of using and distributing the Program and assumes all risks 152 | associated with its exercise of rights under this Agreement , including but 153 | not limited to the risks and costs of program errors, compliance with 154 | applicable laws, damage to or loss of data, programs or equipment, and 155 | unavailability or interruption of operations. 156 | 157 | 6. DISCLAIMER OF LIABILITY 158 | 159 | EXCEPT AS EXPRESSLY SET FORTH IN THIS AGREEMENT, NEITHER RECIPIENT NOR ANY 160 | CONTRIBUTORS SHALL HAVE ANY LIABILITY FOR ANY DIRECT, INDIRECT, INCIDENTAL, 161 | SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING WITHOUT LIMITATION 162 | LOST PROFITS), HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 163 | CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 164 | ARISING IN ANY WAY OUT OF THE USE OR DISTRIBUTION OF THE PROGRAM OR THE 165 | EXERCISE OF ANY RIGHTS GRANTED HEREUNDER, EVEN IF ADVISED OF THE POSSIBILITY 166 | OF SUCH DAMAGES. 167 | 168 | 7. GENERAL 169 | 170 | If any provision of this Agreement is invalid or unenforceable under 171 | applicable law, it shall not affect the validity or enforceability of the 172 | remainder of the terms of this Agreement, and without further action by the 173 | parties hereto, such provision shall be reformed to the minimum extent 174 | necessary to make such provision valid and enforceable. 175 | 176 | If Recipient institutes patent litigation against any entity (including a 177 | cross-claim or counterclaim in a lawsuit) alleging that the Program itself 178 | (excluding combinations of the Program with other software or hardware) 179 | infringes such Recipient's patent(s), then such Recipient's rights granted 180 | under Section 2(b) shall terminate as of the date such litigation is filed. 181 | 182 | All Recipient's rights under this Agreement shall terminate if it fails to 183 | comply with any of the material terms or conditions of this Agreement and 184 | does not cure such failure in a reasonable period of time after becoming 185 | aware of such noncompliance. If all Recipient's rights under this Agreement 186 | terminate, Recipient agrees to cease use and distribution of the Program as 187 | soon as reasonably practicable. However, Recipient's obligations under this 188 | Agreement and any licenses granted by Recipient relating to the Program shall 189 | continue and survive. 190 | 191 | Everyone is permitted to copy and distribute copies of this Agreement, but in 192 | order to avoid inconsistency the Agreement is copyrighted and may only be 193 | modified in the following manner. The Agreement Steward reserves the right to 194 | publish new versions (including revisions) of this Agreement from time to 195 | time. No one other than the Agreement Steward has the right to modify this 196 | Agreement. The Eclipse Foundation is the initial Agreement Steward. The 197 | Eclipse Foundation may assign the responsibility to serve as the Agreement 198 | Steward to a suitable separate entity. Each new version of the Agreement will 199 | be given a distinguishing version number. The Program (including 200 | Contributions) may always be distributed subject to the version of the 201 | Agreement under which it was received. In addition, after a new version of 202 | the Agreement is published, Contributor may elect to distribute the Program 203 | (including its Contributions) under the new version. Except as expressly 204 | stated in Sections 2(a) and 2(b) above, Recipient receives no rights or 205 | licenses to the intellectual property of any Contributor under this 206 | Agreement, whether expressly, by implication, estoppel or otherwise. All 207 | rights in the Program not expressly granted under this Agreement are 208 | reserved. 209 | 210 | This Agreement is governed by the laws of the State of New York and the 211 | intellectual property laws of the United States of America. No party to this 212 | Agreement will bring a legal action under this Agreement more than one year 213 | after the cause of action arose. Each party waives its rights to a jury trial 214 | in any resulting litigation. 215 | -------------------------------------------------------------------------------- /making-change/LICENSE: -------------------------------------------------------------------------------- 1 | THE ACCOMPANYING PROGRAM IS PROVIDED UNDER THE TERMS OF THIS ECLIPSE PUBLIC 2 | LICENSE ("AGREEMENT"). ANY USE, REPRODUCTION OR DISTRIBUTION OF THE PROGRAM 3 | CONSTITUTES RECIPIENT'S ACCEPTANCE OF THIS AGREEMENT. 4 | 5 | 1. DEFINITIONS 6 | 7 | "Contribution" means: 8 | 9 | a) in the case of the initial Contributor, the initial code and 10 | documentation distributed under this Agreement, and 11 | 12 | b) in the case of each subsequent Contributor: 13 | 14 | i) changes to the Program, and 15 | 16 | ii) additions to the Program; 17 | 18 | where such changes and/or additions to the Program originate from and are 19 | distributed by that particular Contributor. A Contribution 'originates' from 20 | a Contributor if it was added to the Program by such Contributor itself or 21 | anyone acting on such Contributor's behalf. Contributions do not include 22 | additions to the Program which: (i) are separate modules of software 23 | distributed in conjunction with the Program under their own license 24 | agreement, and (ii) are not derivative works of the Program. 25 | 26 | "Contributor" means any person or entity that distributes the Program. 27 | 28 | "Licensed Patents" mean patent claims licensable by a Contributor which are 29 | necessarily infringed by the use or sale of its Contribution alone or when 30 | combined with the Program. 31 | 32 | "Program" means the Contributions distributed in accordance with this 33 | Agreement. 34 | 35 | "Recipient" means anyone who receives the Program under this Agreement, 36 | including all Contributors. 37 | 38 | 2. GRANT OF RIGHTS 39 | 40 | a) Subject to the terms of this Agreement, each Contributor hereby grants 41 | Recipient a non-exclusive, worldwide, royalty-free copyright license to 42 | reproduce, prepare derivative works of, publicly display, publicly perform, 43 | distribute and sublicense the Contribution of such Contributor, if any, and 44 | such derivative works, in source code and object code form. 45 | 46 | b) Subject to the terms of this Agreement, each Contributor hereby grants 47 | Recipient a non-exclusive, worldwide, royalty-free patent license under 48 | Licensed Patents to make, use, sell, offer to sell, import and otherwise 49 | transfer the Contribution of such Contributor, if any, in source code and 50 | object code form. This patent license shall apply to the combination of the 51 | Contribution and the Program if, at the time the Contribution is added by the 52 | Contributor, such addition of the Contribution causes such combination to be 53 | covered by the Licensed Patents. The patent license shall not apply to any 54 | other combinations which include the Contribution. No hardware per se is 55 | licensed hereunder. 56 | 57 | c) Recipient understands that although each Contributor grants the licenses 58 | to its Contributions set forth herein, no assurances are provided by any 59 | Contributor that the Program does not infringe the patent or other 60 | intellectual property rights of any other entity. Each Contributor disclaims 61 | any liability to Recipient for claims brought by any other entity based on 62 | infringement of intellectual property rights or otherwise. As a condition to 63 | exercising the rights and licenses granted hereunder, each Recipient hereby 64 | assumes sole responsibility to secure any other intellectual property rights 65 | needed, if any. For example, if a third party patent license is required to 66 | allow Recipient to distribute the Program, it is Recipient's responsibility 67 | to acquire that license before distributing the Program. 68 | 69 | d) Each Contributor represents that to its knowledge it has sufficient 70 | copyright rights in its Contribution, if any, to grant the copyright license 71 | set forth in this Agreement. 72 | 73 | 3. REQUIREMENTS 74 | 75 | A Contributor may choose to distribute the Program in object code form under 76 | its own license agreement, provided that: 77 | 78 | a) it complies with the terms and conditions of this Agreement; and 79 | 80 | b) its license agreement: 81 | 82 | i) effectively disclaims on behalf of all Contributors all warranties and 83 | conditions, express and implied, including warranties or conditions of title 84 | and non-infringement, and implied warranties or conditions of merchantability 85 | and fitness for a particular purpose; 86 | 87 | ii) effectively excludes on behalf of all Contributors all liability for 88 | damages, including direct, indirect, special, incidental and consequential 89 | damages, such as lost profits; 90 | 91 | iii) states that any provisions which differ from this Agreement are offered 92 | by that Contributor alone and not by any other party; and 93 | 94 | iv) states that source code for the Program is available from such 95 | Contributor, and informs licensees how to obtain it in a reasonable manner on 96 | or through a medium customarily used for software exchange. 97 | 98 | When the Program is made available in source code form: 99 | 100 | a) it must be made available under this Agreement; and 101 | 102 | b) a copy of this Agreement must be included with each copy of the Program. 103 | 104 | Contributors may not remove or alter any copyright notices contained within 105 | the Program. 106 | 107 | Each Contributor must identify itself as the originator of its Contribution, 108 | if any, in a manner that reasonably allows subsequent Recipients to identify 109 | the originator of the Contribution. 110 | 111 | 4. COMMERCIAL DISTRIBUTION 112 | 113 | Commercial distributors of software may accept certain responsibilities with 114 | respect to end users, business partners and the like. While this license is 115 | intended to facilitate the commercial use of the Program, the Contributor who 116 | includes the Program in a commercial product offering should do so in a 117 | manner which does not create potential liability for other Contributors. 118 | Therefore, if a Contributor includes the Program in a commercial product 119 | offering, such Contributor ("Commercial Contributor") hereby agrees to defend 120 | and indemnify every other Contributor ("Indemnified Contributor") against any 121 | losses, damages and costs (collectively "Losses") arising from claims, 122 | lawsuits and other legal actions brought by a third party against the 123 | Indemnified Contributor to the extent caused by the acts or omissions of such 124 | Commercial Contributor in connection with its distribution of the Program in 125 | a commercial product offering. The obligations in this section do not apply 126 | to any claims or Losses relating to any actual or alleged intellectual 127 | property infringement. In order to qualify, an Indemnified Contributor must: 128 | a) promptly notify the Commercial Contributor in writing of such claim, and 129 | b) allow the Commercial Contributor tocontrol, and cooperate with the 130 | Commercial Contributor in, the defense and any related settlement 131 | negotiations. The Indemnified Contributor may participate in any such claim 132 | at its own expense. 133 | 134 | For example, a Contributor might include the Program in a commercial product 135 | offering, Product X. That Contributor is then a Commercial Contributor. If 136 | that Commercial Contributor then makes performance claims, or offers 137 | warranties related to Product X, those performance claims and warranties are 138 | such Commercial Contributor's responsibility alone. Under this section, the 139 | Commercial Contributor would have to defend claims against the other 140 | Contributors related to those performance claims and warranties, and if a 141 | court requires any other Contributor to pay any damages as a result, the 142 | Commercial Contributor must pay those damages. 143 | 144 | 5. NO WARRANTY 145 | 146 | EXCEPT AS EXPRESSLY SET FORTH IN THIS AGREEMENT, THE PROGRAM IS PROVIDED ON 147 | AN "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, EITHER 148 | EXPRESS OR IMPLIED INCLUDING, WITHOUT LIMITATION, ANY WARRANTIES OR 149 | CONDITIONS OF TITLE, NON-INFRINGEMENT, MERCHANTABILITY OR FITNESS FOR A 150 | PARTICULAR PURPOSE. Each Recipient is solely responsible for determining the 151 | appropriateness of using and distributing the Program and assumes all risks 152 | associated with its exercise of rights under this Agreement , including but 153 | not limited to the risks and costs of program errors, compliance with 154 | applicable laws, damage to or loss of data, programs or equipment, and 155 | unavailability or interruption of operations. 156 | 157 | 6. DISCLAIMER OF LIABILITY 158 | 159 | EXCEPT AS EXPRESSLY SET FORTH IN THIS AGREEMENT, NEITHER RECIPIENT NOR ANY 160 | CONTRIBUTORS SHALL HAVE ANY LIABILITY FOR ANY DIRECT, INDIRECT, INCIDENTAL, 161 | SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING WITHOUT LIMITATION 162 | LOST PROFITS), HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 163 | CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 164 | ARISING IN ANY WAY OUT OF THE USE OR DISTRIBUTION OF THE PROGRAM OR THE 165 | EXERCISE OF ANY RIGHTS GRANTED HEREUNDER, EVEN IF ADVISED OF THE POSSIBILITY 166 | OF SUCH DAMAGES. 167 | 168 | 7. GENERAL 169 | 170 | If any provision of this Agreement is invalid or unenforceable under 171 | applicable law, it shall not affect the validity or enforceability of the 172 | remainder of the terms of this Agreement, and without further action by the 173 | parties hereto, such provision shall be reformed to the minimum extent 174 | necessary to make such provision valid and enforceable. 175 | 176 | If Recipient institutes patent litigation against any entity (including a 177 | cross-claim or counterclaim in a lawsuit) alleging that the Program itself 178 | (excluding combinations of the Program with other software or hardware) 179 | infringes such Recipient's patent(s), then such Recipient's rights granted 180 | under Section 2(b) shall terminate as of the date such litigation is filed. 181 | 182 | All Recipient's rights under this Agreement shall terminate if it fails to 183 | comply with any of the material terms or conditions of this Agreement and 184 | does not cure such failure in a reasonable period of time after becoming 185 | aware of such noncompliance. If all Recipient's rights under this Agreement 186 | terminate, Recipient agrees to cease use and distribution of the Program as 187 | soon as reasonably practicable. However, Recipient's obligations under this 188 | Agreement and any licenses granted by Recipient relating to the Program shall 189 | continue and survive. 190 | 191 | Everyone is permitted to copy and distribute copies of this Agreement, but in 192 | order to avoid inconsistency the Agreement is copyrighted and may only be 193 | modified in the following manner. The Agreement Steward reserves the right to 194 | publish new versions (including revisions) of this Agreement from time to 195 | time. No one other than the Agreement Steward has the right to modify this 196 | Agreement. The Eclipse Foundation is the initial Agreement Steward. The 197 | Eclipse Foundation may assign the responsibility to serve as the Agreement 198 | Steward to a suitable separate entity. Each new version of the Agreement will 199 | be given a distinguishing version number. The Program (including 200 | Contributions) may always be distributed subject to the version of the 201 | Agreement under which it was received. In addition, after a new version of 202 | the Agreement is published, Contributor may elect to distribute the Program 203 | (including its Contributions) under the new version. Except as expressly 204 | stated in Sections 2(a) and 2(b) above, Recipient receives no rights or 205 | licenses to the intellectual property of any Contributor under this 206 | Agreement, whether expressly, by implication, estoppel or otherwise. All 207 | rights in the Program not expressly granted under this Agreement are 208 | reserved. 209 | 210 | This Agreement is governed by the laws of the State of New York and the 211 | intellectual property laws of the United States of America. No party to this 212 | Agreement will bring a legal action under this Agreement more than one year 213 | after the cause of action arose. Each party waives its rights to a jury trial 214 | in any resulting litigation. 215 | --------------------------------------------------------------------------------