This file contains hidden or 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
function part1(input, days) { | |
let gens = [0,0,0,0,0,0,0,0,0] | |
input.split(',').forEach((x) => gens[x]++) | |
let zeroes = 0; | |
for(let d=0;d<days;d++) { | |
[zeroes, ...gens] = gens; | |
gens.push(zeroes) | |
gens[6] += zeroes | |
} | |
console.log(gens.reduce((a,b) => a+b)) |
This file contains hidden or 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
L=require('fs').readFileSync(0,{encoding:'utf8'}).split("\n");B=L[0].length;a=[0,1].map(v=>{n=L.map(l=>parseInt(l,2));for(b=B-1;b>=0&&n.length>1;b--){c=[0,0];n.map(n=>c[n>>b&1]++);n=n.filter(n=>(n>>b&1)==v^(c[0]>c[1]))}return n[0];});console.log(a[0]*a[1]) |
This file contains hidden or 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=b=0;require('fs').readFileSync(0,{encoding:'utf8'}).replace(/^(.).*(\d+)$/gm,(_,v,d)=>{a+=d*(v=='f'),b+=v=='d'?+d:v=='u'?-d:0});console.log(a*b) |
This file contains hidden or 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
exports.config = { | |
// See http://brunch.io/#documentation for docs. | |
files: { | |
javascripts: { | |
joinTo: "js/app.js" | |
// To use a separate vendor.js bundle, specify two files path | |
// http://brunch.io/docs/config#-files- | |
// joinTo: { | |
// "js/app.js": /^js/, |
This file contains hidden or 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
defmodule InvertImage do | |
@magic_reduction_number 20000 | |
@mask :binary.copy(<<255>>, @magic_reduction_number) | |
def invert(binary), do: do_exor(binary, []) | |
defp do_exor("", acc), do: acc | |
defp do_exor(data, acc) when byte_size(data) < @magic_reduction_number, | |
do: [acc | :crypto.exor(data, :binary.copy(<<255>>, byte_size(data)))] |
This file contains hidden or 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
# This file is in the public domain, so clarified as of | |
# 2009-05-17 by Arthur David Olson. | |
# also includes Central America and the Caribbean | |
# This file is by no means authoritative; if you think you know better, | |
# go ahead and edit the file (and please send any changes to | |
# [email protected] for general use in the future). For more, please see | |
# the file CONTRIBUTING in the tz distribution. |
This file contains hidden or 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 add_attr(event_attr, person_attrs) do | |
new_attr_value = [%Person.AttributeValue{ | |
:timestamp => event_attr.timestamp, | |
:confidence => event_attr.confidence, | |
:value => event_attr.value | |
}] | |
curr_attr = Map.get(person_attrs, event_attr.field) | |
if (curr_attr === nil) do #the person doesn't have that attr | |
# add_new(person_attrs, ) | |
new_attr_source = %{ |
This file contains hidden or 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
str = SSHEx.stream connection, 'ping -c 5 www.google.com' | |
Enum.reduce(str, {:ok, :running}, fn | |
_, {:error, reason} -> {:error, reason | |
{:stdout,row}, {:ok, :running} -> | |
IO.puts row | |
{:ok, :running} | |
{:stderr,row}, {:ok, :running} -> | |
IO.puts row | |
{:ok, :running} |
This file contains hidden or 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
defmodule Test.Sup do | |
use Supervisor | |
def start_link(opts), do: Supervisor.start_link(__MODULE__, opts, name: __MODULE__) | |
def init([]) do | |
children = [ | |
# Supervisor.Spec.worker(Test.Server, [[]]), | |
Test.Server | |
] |
This file contains hidden or 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
{:ok, trees} = :code.lib_dir(:public_key) | |
|> Path.join("include/OTP-PUB-KEY.hrl") | |
|> :epp_dodger.parse_file() | |
constants = trees | |
|> Enum.map(&:erl_syntax_lib.strip_comments/1) | |
|> Enum.reject(&match?({:record, _},:erl_syntax_lib.analyze_attribute(&1))) | |
|> Enum.map(fn {:tree, :attribute, {:attr, _, _, :none}, {:attribute, {:atom, _, :define}, [{:atom,_,_}=a,b]}} -> | |
{:erl_syntax.concrete(a), :erl_syntax.concrete(b)}; | |
_ -> nil | |
end) |
NewerOlder