This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 04f6b145eacc69a769a91f9f8a4f20a3eb065048e6ca944b31d5cba7c720406b289c00e2893f2ff6ff5d9cbce1159a00e1ddaa36b4b96cc43270327a5641311b1a |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #include<iostream> | |
| using namespace std; | |
| class splay | |
| { | |
| private: | |
| int val; | |
| splay *left; | |
| splay *right; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| def palindrome? (string) | |
| filtered = string.downcase.gsub(/\W/,'') | |
| filtered.reverse == filtered | |
| end | |
| def count_words (sentence) | |
| words = sentence.downcase.split(/\W/) | |
| result = {} | |
| words.uniq.select{ |w| !w.empty? }.each do |e| | |
| result.store(e, words.count(e)) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class CartesianProduct | |
| include Enumerable | |
| def initialize(a,b) | |
| @values = [] | |
| @values = a.product(b) unless b.empty? | |
| end | |
| def each(&block) | |
| @values.each {|v| yield v} |