Skip to content

Instantly share code, notes, and snippets.

View lexun's full-sized avatar

Luke Barbuto lexun

View GitHub Profile
def pairs(participants)
pairs = participants.shuffle.each_slice(2).to_a
if pairs.last.size == 1
loner = pairs.pop
pairs.last << loner.first
end
pairs
end
@lexun
lexun / ex.clj
Last active January 4, 2016 11:19
Comparing ruby and clojure solutions - https://www.hackerrank.com/challenges/eval-ex
(dotimes [n (read-string (read-line))]
(let [x (read-string (read-line))]
(println
(format "%.4f"
(float (reduce (fn [m, i] (+ m (/ (reduce * (repeat i x))
(reduce * (range 1 (inc i))))))
(int 1)
(range 1 10)))))))
@lexun
lexun / segment.rb
Last active January 4, 2016 07:29
Basic Segment.io example with Resque
module Segment
module Tracking
@queue = :low
def self.perform(action, data)
data.symbolize_keys!
Analytics.send action, data
end
def identify(user = @user)
@lexun
lexun / tron.rb
Last active January 4, 2016 07:29
Tron Code Challenge -- codingame.com
# Work in progress
STDOUT.sync = true
def log(text, obj)
STDERR.puts "#{text}: #{obj.to_s}"
end
def time
(Time.now - $start) * 1000
@lexun
lexun / unity3d.gitignore
Created August 31, 2013 20:57
.gitignore for unity3d projects
# =============== #
# Unity generated #
# =============== #
[Ll]ibrary/
[Tt]emp/
[Oo]bj/
UnityGenerated/
# ================ #
# Editor Generated #
# This early version gets me through level 5
# It's just a start... I'll add more later
class Player
def play_turn(w)
@warrior = w
perform_next_move
update_status
end
class Lexun < RTanque::Bot::Brain
NAME = 'Lexun'
include RTanque::Bot::BrainHelper
Wall = Struct.new :name, :axis, :position, :opposite
def tick!
@tick = @tick.to_i.succ
setup if @tick == 1