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 lookandsay(seq) | |
| seq.reduce{|s, v| s = [[1, s]] if s != s.to_a;if s.last.last == v then s[ s.length - 1 ] = [ s.last.first + 1 , v] else s.push [1, v] end; s}.flatten | |
| end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| (defn seq-groups [seq] | |
| (partition-by (fn [x] seq))) | |
| (defn look-and-say [seq] | |
| (interleave | |
| (map count (seq-groups seq)) | |
| (map first (seq-groups seq)))) |
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 fib_generator | |
| constructor: -> | |
| last = 0 | |
| current = 1 | |
| @first = -> | |
| last = 0 | |
| current = 1 | |
| @next = -> | |
| temp = last | |
| last = current |
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
| function Generator(f,s,i){i=0;return{first:function(){return s[i=0];},next:function(){return s.length<=++i?s[i]=f(s):s[i];},nth:function(n){while(s.length<=n)this.next();return s[n];},take:function(n){this.nth(n);return s.slice(0,n);}};} |
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
| range = (function(s,e){var i=s,r={};f=fuction(){r[i+1]=f;i++;return i;};r[i]=f;r.length=e-s;return r;}; | |
| some_range = range( 0 , 10 ); | |
| for ( i = 0 ; i <= some_range.length ; ++i ) { | |
| console.log( some_range[ i ]() ); | |
| } |
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
| localStorage=(function(){function t(){this.store={};};t.prototype={constructor:t,setItem:function(k,v){this.store[k]=v;},getItem:function(k){return this.store[k];}};return new t;})() |
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
| [][$___=(($=(({}+"")))[$__=-~-~-~-~-~[]]+$[-~[]]+(""[+[]]+"")[-~[]]+(![]+"")[-~-~-~[]]+(($_=(!""+"")))[+[]]+$_[-~[]]+$_[-~-~[]]+$[$__]+$_[+[]]+$[-~[]]+$_[-~[]])][$___](($$=($_____=(!""+"")[-~[]]+(!""+"")[-~-~-~[]]+(!""+"")[+[]]+(!""+"")[-~-~[]]+(!""+"")[-~[]]+(""[+[]]+"")[-~[]] | |
| )+"[][$___][$___]('"+$_____+"\"\\"+(""[+[]]+"")[+[]] | |
| +(+[])+(+[]))+($$$=""+(-~-~-~-~[])+(-~[]))+($$$$="\"')()"))()+[][$___][$___]($$+($$$=-~$$$)+$$$$)()+[][$___][$___]($$+($$$=-~$$$)+$$$$)()+[][$___][$___]($$+($$$=-~$$$)+$$$$)() |
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
| # Modified from http://repo.or.cz/w/anomen-overlay.git/tree/HEAD:/dev-java/maven-color | |
| color_maven() { | |
| local BOLD=`tput bold` | |
| local TEXT_RED=`tput setaf 1` | |
| local TEXT_GREEN=`tput setaf 2` | |
| local TEXT_YELLOW=`tput setaf 3` | |
| local RESET_FORMATTING=`tput sgr0` | |
| $MAVEN_HOME/bin/mvn $@ | sed -e "s/\(\[INFO\]\ \-\-\-\ .*\)/${TEXT_BLUE}\1${RESET_FORMATTING}/g" \ | |
| -e "s/\(\[INFO\]\ \[.*\)/${RESET_FORMATTING}\1${RESET_FORMATTING}/g" \ | |
| -e "s/\(\[INFO\]\ \)\(BUILD SUCCESS\)/\1${TEXT_GREEN}\2${RESET_FORMATTING}/g" \ |
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
| (ns dijkstra.core) | |
| (def initial-node {:score Integer/MAX_VALUE :route [] :dead? false}) | |
| (defn make-initial-state [edges start-node] | |
| (-> (zipmap (keys edges) (repeat initial-node)) | |
| (assoc-in [start-node :score] 0) | |
| (assoc-in [start-node :route] [start-node]))) | |
| (defn live-nodes [state] |
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
| (ns dijkstra.core) | |
| (def edges {:A {:F 14 :C 9 :B 7} | |
| :B {:A 7 :C 10 :D 15} | |
| :C {:A 9 :B 10 :D 11 :F 2} | |
| :D {:B 15 :C 11 :E 6} | |
| :E {:D 6 :F 9} | |
| :F {:A 14 :C 2 :E 9}}) | |
| (def inf Integer/MAX_VALUE) |
OlderNewer