This file contains 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
-- a little flame in a functional style | |
function particle(step, style, t) | |
local newStyle = step(style, t) | |
return { | |
style = newStyle, | |
next = function() | |
return particle(step, newStyle, t + 1) | |
end | |
} |
This file contains 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
c = -> | |
message = _.reduce arguments, (acc, item) -> | |
item = util.inspect item | |
cursor = JSON.stringify item | |
message += cursor + "\n" | |
return acc + message | |
, "" | |
fs.appendFile 'log.txt', message, (err) -> |
This file contains 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
c = -> console.log.apply console, arguments | |
c 'shunting ' | |
random_expression_string_builder = (nn) -> | |
rayy_builder = (n) -> | |
operators = ['+', '-', '*', '/'] | |
operands_rayy = [] | |
operators_rayy = [] |
This file contains 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
c = -> console.log.apply console, arguments | |
c 'cracking the coding interview questions chapter 1' | |
c "Implement an algoritm to determine if a string has all unique characters. What if you can not use additional data structures?\n \n" | |
allowed_chars= ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z'] | |
get_random_in_range = (range) -> | |
# get random integer between 0 and (range - 1) |
This file contains 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
c = -> console.log.apply console, arguments | |
class Node | |
constructor: (d) -> | |
@next = null | |
@data = d | |
append_to_tail: (d)-> | |
end = new Node(d) | |
n = @ |
This file contains 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
c = -> console.log.apply console, arguments | |
# return array of size n, of random unsigned integers between 0 and a thousand | |
get_random_rayy = (n) -> | |
rayy = [] | |
for i in [0 .. (n - 1)] | |
rayy.push Math.floor(Math.random() * 1000) |
This file contains 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 get_random_rayy(n) | |
rayy = [] | |
0.upto(n - 1) { | |
num = (rand * 1000).floor | |
rayy.insert(-1, num) | |
} | |
return rayy | |
end |
This file contains 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
c = -> console.log.apply console, arguments | |
get_random_rayy = require('./make_random_array_.coffee') | |
test_order = require('./test_ordered_000_.coffee') | |
rayy = get_random_rayy 11 | |
c 'rayy', rayy.toString() | |
bubble_sort_002 = (rayy)-> # with recursion | |
idx = 0 |
This file contains 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
c = -> console.log.apply console, arguments | |
test_order = (rayy)-> | |
for idx in [0 .. (rayy.length - 2)] | |
if rayy[idx] > rayy[idx + 1] | |
return false | |
return true | |
get_random_rayy = (n) -> | |
rayy = [] |
This file contains 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
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; Ant sim ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | |
; Copyright (c) Rich Hickey. All rights reserved. | |
; The use and distribution terms for this software are covered by the | |
; Common Public License 1.0 (http://opensource.org/licenses/cpl.php) | |
; which can be found in the file CPL.TXT at the root of this distribution. | |
; By using this software in any fashion, you are agreeing to be bound by | |
; the terms of this license. | |
; You must not remove this notice, or any other, from this software. | |
;dimensions of square world |