Skip to content

Instantly share code, notes, and snippets.

View kulicuu's full-sized avatar

J Wylie Кулик kulicuu

View GitHub Profile
@kulicuu
kulicuu / flame.lua
Last active August 26, 2015 16:39 — forked from joshski/flame.lua
Generates a little flame. Works in Codea.
-- 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
}
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) ->
@kulicuu
kulicuu / shunting.coffee
Last active November 2, 2015 08:21
researching the shunting algorithm , trying it out
c = -> console.log.apply console, arguments
c 'shunting '
random_expression_string_builder = (nn) ->
rayy_builder = (n) ->
operators = ['+', '-', '*', '/']
operands_rayy = []
operators_rayy = []
@kulicuu
kulicuu / 1.1.coffee
Last active November 2, 2015 14:03
problems from "Cracking the Coding Interview"
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)
@kulicuu
kulicuu / 2.0_.coffee
Last active November 3, 2015 15:47
exercises with chapter 2 of cracking the coding interview
c = -> console.log.apply console, arguments
class Node
constructor: (d) ->
@next = null
@data = d
append_to_tail: (d)->
end = new Node(d)
n = @
@kulicuu
kulicuu / make_random_array_.coffee
Last active November 9, 2015 10:09
better quicksort
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)
def get_random_rayy(n)
rayy = []
0.upto(n - 1) {
num = (rand * 1000).floor
rayy.insert(-1, num)
}
return rayy
end
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
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 = []
@kulicuu
kulicuu / ants.clj
Created November 20, 2015 09:50 — forked from michiakig/ants.clj
Clojure ant sim from Rich Hickey
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; 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