Skip to content

Instantly share code, notes, and snippets.

View dbushong's full-sized avatar

David Bushong dbushong

View GitHub Profile

Getting seconds or milliseconds since January 1, 1970, 00:00:00 GMT in various languages

Second-Native

C (1972)

// ms
struct timespec spec;
clock_gettime(CLOCK_REALTIME, &spec);
#f '123456789',100
def f(d,t)(0...3**(d.size-1)).map{|c|d.chars.reduce{|s,g|o='+-'[c%3]||'';c=(c/3).floor;s+o+g}}.select{|e|e.scan(/\D?\d+/).map(&:to_i).reduce(:+)==t}end
if __FILE__ == $0
p f('123456789', 100)
end