These notes references 睿国丨肥头’s Walkthrough. 这些笔记参考睿国丨肥头的攻略。 🙏
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
# frozen_string_literal: true | |
# Goldberg–Tarjan Push–Relabel Algorithm | |
# with FIFO active set and BFS pre-labeling | |
# * https://www.adrian-haarbach.de/idp-graph-algorithms/implementation/maxflow-push-relabel/index_en.html | |
# * https://en.wikipedia.org/wiki/Push%E2%80%93relabel_maximum_flow_algorithm?oldid=1230043247 | |
# variable names are in dummies’ terminologies | |
class PushRelabel | |
class Node |
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 int2bytestr(int, bytesize = int.size) | |
[ | |
# Format to hex, left-pad with `0` (big-endian) for `bytesize * 2` nibbles | |
sprintf('%0*X', bytesize * 2, int) | |
].pack 'H*' # Pack string of hex chars to string of raw bytes | |
end | |
# Demo | |
print "actual\t" | |
p int2bytestr(0x4_20_69_de_ad_be_ef_13_37, 10) |
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
# Marker module for “my library” | |
module MyError end | |
# Built-in exception class example | |
ZeroDivisionError.include MyError | |
puts begin | |
1 / 0 | |
rescue MyError => e | |
e | |
end #=> divided by 0 |
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
# frozen_string_literal: true | |
class CellularAutomaton | |
def initialize(grid) | |
@grid = grid | |
# Back Buffer | |
@grid2 = grid.map(&:dup) | |
@rules = yield self | |
end | |
def self.load(file, ...) = new(file.each_line(chomp: true).map(&:chars), ...) |
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 answer1(n) = n.succ | |
def answer2(str) = str.upcase | |
def answer3(n) = (0..n).to_a | |
def answer4 = yield + 42 | |
def answer5(a, b = 1) = a + b | |
def answer6(n) = n.positive? ? (n - 1) % 9 + 1 : n | |
def answer7(x) = x.succ | |
def answer8(n) = n.digits(2).sum | |
def answer9(s) = s.gsub 'u-g0t-me', 'yikes' | |
def answer10(x = false) = @data10 = x ? 0 : @data10 ? @data10 + 1 : 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
$* << [//=~'', /$/=~'$'] << () << ->() { | |
$*[~(/$$/=~'$$')][ | |
( $*[~(/$/=~'$')] += (/$/=~'$') ) - (/$/=~'$') | |
] ||= ( | |
$*[~(/$/=~'$')] -= (/$$/=~'$$') | |
$*[~(//=~'')][] + $*[ ~(/$$/=~'$$') ][ $*[~(/$/=~'$')] - (/$$/=~'$$') ] | |
) | |
} | |
# Test |
The Legend of Zelda games presented gorgeous fantasies of the Hyrulean universe. Regrettably, Nintendo has officially declared that the events of Ocarina of Time fork the timeline into three distinct branches, only one of which develops into the Switch hits. Severing the continuity of the series’s rich lore is poor news for me and other supporters of self-consistent causality.
Fortunately, as the developers abandon the parallel universes and focus on an age over a millennia after the world’s creation, there is enough consistency and timing between the stories to realign the different sequences to a single continuous chronology. The following is my take on the Hyrule history as a singular timeline.
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
BOARD = { | |
nil => %q[SCARY?!], | |
'🎃' => %q[BDEFGH ], | |
'👻' => %q[IJKLMN'], | |
'🍬' => %q[OPQTUV,], | |
'💀' => %q[WXZ.#$:] | |
} | |
row = BOARD[nil] | |
File.foreach 'input.txt', chomp: true do|line| |