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 Androsphinx | |
class Node | |
# 最基础的树节点 | |
def initialize(name) | |
@name = name | |
@childrens = [] | |
end | |
def add_child(child) | |
@childrens << child |
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 the csv done | |
#create array done | |
#extract email address done | |
#push address into array done | |
#create a hash done | |
#for each address in the array | |
#if in the hash, ++ | |
#if not, set the value to 1 | |
#sort the hash by value | |
#top 5 |
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 Fixnum | |
alias :original_plus :+ | |
def +(another) | |
original_plus(another).original_plus(another) | |
end | |
end | |
puts 1 + 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
# 1. print welcome message | |
# 2. ask for first number (or exit) | |
# 3. ask for operation (or exit) | |
# 4. ask for second number (or exit) | |
# 5. perform calculation | |
# 6. show result | |
# 7. go back to 2 |
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
# Armanni TODO required file DONE | |
# grabbed text from file DONE | |
# filter the text | |
# split it with empty space DONE | |
# downcase text DONE | |
# create empty hash DONE |
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
musicians = [ | |
'Jimmy Page', | |
'Bieber', | |
'Robert Plant', | |
'John Paul Jones', | |
'John Bonham' | |
] | |
# def print_musicians(musicians) |
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
forrest_is_handsome && forrest_is_tall # => false | |
forrest_is_handsome || forrest_is_tall # => true |
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 colorful?(number) | |
nums = number.to_s.split('').map(&:to_i) | |
results = [] | |
(1..nums.size).each do |batch_size| | |
(0..(nums.size - batch_size)).each do |start_pos| | |
product = nums[start_pos, batch_size].inject(&:*) |
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_relative 'tic_tac_toe' | |
def print_board(board) | |
puts board[0..2].join | |
puts board[3..5].join | |
puts board[6..8].join | |
end | |
def prompt_player_input(player) | |
puts "Player #{player}, now is your turn. enter position (0..8)" |
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 | |
(0...1114112).each do |i| | |
next if (0xD800..0xDFFF).include?(i) # surrogate area | |
str = [i].pack('U*') | |
if str.match(/[[:space:]]/) | |
p [i, str] | |
end | |
end |