Getting seconds or milliseconds since January 1, 1970, 00:00:00 GMT in various languages
// 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 |