This file contains 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
class KnightTravails | |
def initialize size=8 | |
@size = size | |
@board = Array.new(@size) { Array.new(@size)} | |
end | |
def knight_path start_node, end_node, forbidden_nodes | |
mark_forbidden forbidden_nodes | |
path = breadth_first_search start_node, end_node |
This file contains 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
# -*- tab-width:4 -*- | |
def x(): | |
if 1: | |
if 0: | |
print "x 12 space" | |
print "x 1 tab plus 4 space" | |
# -*- tab-width:8 -*- | |
def y(): | |
if 1: |
This file contains 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
irb(main):001:0> class A | |
irb(main):002:1> def foo | |
irb(main):003:2> puts 'foo' | |
irb(main):004:2> end | |
irb(main):005:1> def foo= bar | |
irb(main):006:2> puts 'bar' | |
irb(main):007:2> end | |
irb(main):008:1> end | |
=> nil | |
irb(main):009:0> x = A.new |
This file contains 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
class CacheDb | |
TABLE_POOL_LIMIT = 15 | |
DB = :cache_db | |
AR_PROTOTYPE = Class.new(ActiveRecord::Base) | |
AR_PROTOTYPE.abstract_class = true # To avoid STI inheritance.. | |
AR_PROTOTYPE.establish_connection DB | |
def self.connection | |
AR_PROTOTYPE.connection |
This file contains 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
Running 156 tasks using 4 parallel threads | |
1: CXX vm/builtin/constant_table.cpp | |
2: CXX vm/builtin/data.cpp | |
3: CXX vm/builtin/block_environment.cpp | |
4: CXX vm/builtin/compiled_code.cpp | |
In file included from /usr/lib/llvm-3.0/include/llvm/BasicBlock.h:18:0, | |
from /usr/lib/llvm-3.0/include/llvm/Function.h:23, | |
from /usr/lib/llvm-3.0/include/llvm/Module.h:18, | |
from /home/linus/prog/rubinius/vm/llvm/state.hpp:15, | |
from vm/builtin/block_environment.cpp:23: |
This file contains 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
The Rubinius process is aborting with signal: SIGSEGV | |
--- begin system backtrace --- | |
bin/rbx() [0x6574b9] | |
/lib/x86_64-linux-gnu/libpthread.so.0(+0x10340) [0x7fc52c1f8340] | |
bin/rbx(_ZN8rubinius16GarbageCollector11scan_objectEPNS_6ObjectE+0x16c) [0x7071cc] | |
bin/rbx(_ZN8rubinius7BakerGC17handle_promotionsEv+0x34) [0x703264] | |
bin/rbx(_ZN8rubinius7BakerGC7collectEPNS_6GCDataEPNS_17YoungCollectStatsE+0x302) [0x703e82] | |
bin/rbx(_ZN8rubinius12ObjectMemory13collect_youngEPNS_5StateEPNS_6GCDataEPNS_17YoungCollectStatsE+0x7c) [0x644d2c] | |
bin/rbx(_ZN8rubinius12ObjectMemory13collect_maybeEPNS_5StateERNS_11GCTokenImplEPNS_9CallFrameE+0x23a) [0x6451ca] | |
bin/rbx(_ZN8rubinius2VM13collect_maybeERNS_11GCTokenImplEPNS_9CallFrameE+0x42) [0x6827d2] |
This file contains 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
"test".each_char do |char| | |
^~~~~~~~~ | |
in ./test.cr:13: no overload matches 'Hash({Char | Symbol, Int32}, Item)#[]=' with types {Char, Int32}, Item | |
Overloads are: | |
- Hash({Char | Symbol, Int32}, Item)#[]=(key : {Char | Symbol, Int32}, value : Item) | |
foo[{char, 42}] = Item.new "foo" | |
^ |
This file contains 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
class Hash | |
def dig(key : K, *args) | |
value = fetch(key, nil) | |
if args.size == 0 || value.nil? | |
return value | |
end | |
if value.responds_to?(:dig) | |
value.dig(*args) | |
else | |
raise ArgumentError.new |
This file contains 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
data = ['0', '1'] | |
while data.size.even? | |
data = data.each_slice(2).map do |(a, b)| | |
a == b ? '1' : '0' | |
end | |
end | |
data |
This file contains 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
require "benchmark" | |
require "big" | |
struct Int | |
def binary_gcd(other) | |
u = self.abs | |
v = other.abs | |
shift = self.class.zero | |
return v if u == 0 |
OlderNewer