Skip to content

Instantly share code, notes, and snippets.

Horie Issei #hashtagtest is2ei

Block or report user

Report or block is2ei

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@is2ei
is2ei / .gitconfig
Created Jul 25, 2017 — forked from pksunkara/.gitconfig
Sample of git config file (Example .gitconfig)
View .gitconfig
[user]
name = Pavan Kumar Sunkara
email = pavan.sss1991@gmail.com
[core]
editor = vim
whitespace = fix,-indent-with-non-tab,trailing-space,cr-at-eol
excludesfile = ~/.gitignore
[sendemail]
smtpencryption = tls
smtpserver = smtp.gmail.com
View swap_every_two_adjacent.rb
class Node
attr_accessor :value, :next_node
def initialize(value, next_node = nil)
@value = value
@next_node = next_node
end
def to_s
"#{value} -> #{next_node.to_s}"
View btree.rb
class BinaryTree
attr_accessor :payload, :left, :right
def initialize(payload, left, right)
@payload = payload
@left = left
@right = right
end
end
View tree_traversal.rb
class Tree
attr_accessor :payload, :children
def initialize(payload, children)
@payload = payload
@children = children
end
end
def depth_first_search(node, target)
View collatz.rb
def collatz(num)
return 1 if num == 1
len=1
while num != 1
if num % 2 == 0
num /= 2
else
num = 3 * num + 1
end
View fibonacci.rb
def recursive_fib(num, i=2, current=1, previous=1)
return 0 if num == 0
return 1 if num == 1
return 1 if num == 2
return current if num == i
_next = current + previous
recursive_fib(num, i+1, _next, current)
end
View luhn.rb
module Luhn
def self.is_valid?(number)
# WRITE YOUR SOLUTION HERE
sum = 0
number.to_s.split("").reverse.each_with_index do |digit, i|
digit = digit.to_i
if (i+1) % 2 == 0
digit *= 2
if digit >= 10
digit -= 9
View linked_list_02.rb
class LinkedListNode
attr_accessor :value, :next_node
def initialize(value, next_node=nil)
@value = value
@next_node = next_node
end
end
def print_values(list_node)
View linked_list_01.rb
class LinkedListNode
attr_accessor :value, :next_node
def initialize(value, next_node=nil)
@value = value
@next_node = next_node
end
end
class Stack
View quiz_03.rb
class Dog
attr_accessor :name, :age
def initialize(name, age)
@name = name
@age = age
end
end
dog = Dog.new("bob", "13")
You can’t perform that action at this time.