- Rook, Bishop, Queen able to move multiple squares...
- Pass en passent.
- Promotion of pawn to piece other than Queen.
- Castling.
- Check, Checkmate, Draw.
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
def smurfize(code) | |
puts code.gsub!("s", "smurfy") | |
end | |
code = "Lions and tigers and bears, oh my!" | |
smurfize code | |
#=> Lionsmurfy and tigersmurfy and bearsmurfy, oh my! |
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
def captains_log | |
time = Time.now | |
puts "Captains log,", "Stardate #{time.year}.#{time.yday}" | |
"#{time.year}.#{time.yday}".to_f | |
end |
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
∞ = 1.0 / 0 | |
(1..∞).each do |check_eet| | |
break check_eet if (1..20).all? do |against_this| | |
check_eet % against_this == 0 | |
end | |
end | |
#=> 232792560 |
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
#!/usr/bin/env ruby | |
class Time | |
WEEKDAYS = %w[ Sunday Monday Tuesday Wednesday Thursday Friday Saturday ] | |
def day_before_yesterday | |
xday -2 | |
end | |
def yesterday |
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
module Kernel | |
def push | |
Maglev.commit_transaction | |
end | |
def pull | |
Maglev.abort_transaction | |
end | |
def box |
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
def gsub!(pattern, replacement=undefined) | |
# Because of the behavior of $~, this is duplicated from gsub! because | |
# if we call gsub! from gsub, the last_match can't be updated properly. | |
if undefined.equal? replacement | |
unless block_given? | |
return to_enum(:gsub, pattern, replacement) | |
end | |
tainted = false |
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 Parser | |
def split_pattern text | |
text.split(/(?:[^|]), /) | |
end | |
def match_escape_pattern text | |
text.match(/\|([,{}])/) | |
end | |
def replace_tricky_end_pattern text |
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
def scrub character | |
results.delete("#{character}").to_i | |
end | |
case results[-3] | |
when "." | |
scrub "," | |
when "," | |
scrub "." | |
else |
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
perl6: | |
my $sentence = "an acorn fell here." | |
#=> an acorn fell here. | |
my @words = $sentence.split(" ") | |
#=> an acorn fell here. | |
say @words.capitalize | |
An Acorn Fell Here. | |
ruby: |