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
| m = Array.new(1000) { |a| Array.new(1000, 0) } | |
| transformations = { | |
| "toggle" => proc { |input| input+2 }, | |
| "turn on" => proc { |input| input+1 }, | |
| "turn off" => proc { |input| [0, input-1].max }, | |
| } | |
| open("advent6.txt") do |f| | |
| f.each_line do |line| |
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
| #!/usr/bin/env python3 | |
| from itertools import islice | |
| from time import time | |
| def time_generator(func, n=500000): | |
| generator = func() | |
| start = time() | |
| islice(generator, n) | |
| elapsed = time() - start |
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
| words = open("advent5.txt").each_line.map(&:strip) | |
| doubles = /([a-z]{2}).*\1/ | |
| repeat = /([a-z])[a-z]\1/ | |
| nice = words.select { |s| s =~ doubles and s =~ repeat } | |
| p nice.size |
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
| words = open("advent5.txt").each_line.map(&:strip) | |
| vowels = /[aeiou]/ | |
| doubles = /([a-z])\1/ | |
| bad = /(ab|cd|pq|xy)/ | |
| nice = words.select { |s| (s.scan(vowels).size >= 3) and (s =~ doubles) and not (s =~ bad) } | |
| p nice.size |
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 ip_to_int(ip) | |
| ip.split(".").map(&:to_i).reverse.each_with_index.map {|n,i| n << (i*8) }.reduce(:+) | |
| end | |
| def range_to_ip_and_mask(range) | |
| ip, width = range.split("/") | |
| mask = 0xffffffff >> width.to_i | |
| [ip_to_int(ip), mask] | |
| end |
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 C do | |
| def map([], _f), do: [] | |
| def map([ head | tail ], f), do: [ f.(head) | map(tail, f) ] | |
| end | |
| # works | |
| IO.inspect C.map [1,2,3,4,5], fn x -> x*x end |
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
| https://code.google.com/p/mintty/wiki/Keycodes | |
| http://rtfm.etla.org/xterm/ctlseq.html | |
| http://man7.org/linux/man-pages/man4/console_codes.4.html | |
| http://www.termsys.demon.co.uk/vtansi.htm | |
| http://invisible-island.net/xterm/ctlseqs/ctlseqs.html | |
| CSI = ESC[ | |
| K |
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
| $ nvcc --gpu-architecture=compute_20 --gpu-code=compute_20 -I/usr/local/cuda/include/ -DGPU --compiler-options "-Wall -Ofast -DGPU" -c ./src/convolutional_kernels.cu -o obj/convolutional_kernels.o | |
| /usr/local/cuda/include/cuda_fp16.h:314:83: error: conflicting declaration of C function ‘__half __ldg(const __half*)’ | |
| /usr/local/cuda/include/cuda_fp16.h:313:60: note: previous declaration ‘__half2 __ldg(const __half2*)’ | |
| /usr/local/cuda/include/cuda_fp16.h: In function ‘__half2 __ldg(const __half2*)’: | |
| /usr/local/cuda/include/cuda_fp16.h:1180:84: error: conflicting declaration of C function ‘__half2 __ldg(const __half2*)’ | |
| /usr/local/cuda/include/cuda_fp16.h:314:59: note: previous declaration ‘__half __ldg(const __half*)’ | |
| Makefile:54: recipe for target 'obj/convolutional_kernels.o' failed | |
| make: *** [obj/convolutional_kernels.o] Error 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
| MS4wLjU5|Q2hlYXRlciA6KAoKN4IglgJiBcIG4AYB0AmEAaEALApgQwCcAXAI3yIEkpZFVpdDTyMQBXAOzCKIE8AHHAGcYoMOzhhBYEgBscWPEQDGuAjxggAjCwC2zWAGZUCBAHYArADYEKBAYAsCc45uWUOANSabLGYTh4Gpb2luYI1qb2KAaatgCcRiimpgAcLEoA9pkZ7BoILEQ4BARcGWoaKEgxmimWcVGWKTF1mnHe5p6mBiw47EUA5uqwNXHIduZxKfbTpprBBnGWpiwEQgJKAKJ9BIN5LH0AHqzCsPbpaoJEeDJ7mDqsV/29tyB8q/ePz8Pec/VxziYWHhBEpelIchpvCwAGarHAAJTWOCUFRYEAIORwkKQ9hiBhQuPMpksSwQUxMcXcHlGLAAjqwcF8QJUUKNzJook5IgYUosDPjTJ00pg+pcNKYkJoObMUs44qYUFYUiZzOYUp4lix+qtFEV6YzcsMkAh7BYEhyUqZ6hNiSheZ41SwsGA4FjYCkkP9LcEposEilFSayZ57MLsC6cPqmfYkAHYjZNOzori2irBR5HD0dG8hCcQB65uYUG4DFYkqyQlECZ58Sw3hk+LgiNiFjUHCSUgHZYqulZPMWtRkIBBcxV7HEEo06klLAYTLKSeY63h2ERcBDYPlMHwV2ucDk0Jvl6v1+xukft7vT2cL68r/v2EvbxlXQQdGJqCAtyAX0V3+wIEPL8WF/N8P3PYDMFA/8IBvSCf1fGCn3g6CP0sF5BAAd0IHQZDEfoMKIfCigwvhIBI28dAyQR6VKIJ+WJXllSLNVx3qRxrF8LJjmbWBLCQEkEnqTQHGmDse1Cfs0EwDE8BUDQ4iqXkunlSw5nsRNTDMETNCkrUwF3QQyJHAgNHMSVHBQRMEASfF7GcKyrQMPTMFBVcwAEEcNCMLSLCshBvFNfEwgnKz+20TBsKMl4RzgDJWFWUzb36DIN3gzh+iwUhWAIyiMjXDRam/EhFBeD4r0UFQiiGEB+RcEwGsahqIpAcrV |
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
| BASIC_NUMERALS = { | |
| 1000 => "M", | |
| 500 => "D", | |
| 100 => "C", | |
| 50 => "L", | |
| 10 => "X", | |
| 5 => "V", | |
| 1 => "I", | |
| } |