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
#First iteration moving towards Harspool algorithm simply jumps forward by | |
# pattern_length if char not in pattern is found | |
# function accepts a string and a pattern and returns the index in the string where | |
# the pattern first occurs, or "not found" | |
def brute_search_2 string, pattern | |
pattern_length = pattern.length | |
bad_match_table = Hash.new | |
# Generates hash table with keys as all chars in pattern, and values as 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
#Brute Force Right to Left | |
# Function accepts a string and a pattern to find in that string | |
def brute_search_2 string, pattern | |
pattern_length = pattern.length | |
# Iterate through the string starting at string[pattern_length-1] | |
# We are starting there because we are looking for matches in the pattern starting | |
# at the last char. | |
for string_index in (pattern_length - 1 ... string.length) | |
match_count = 0 |
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
# Brute Force | |
# Takes a string and a pattern and returns the index of the pattern in the string, | |
# or returns "not found" | |
def brute_search string, pattern | |
pattern_length = pattern.length | |
for string_index in (0... string.length) | |
match_count = 0 | |
loop do | |
# if a non-match is found, then break. |
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 Rail_Fence_Cipher | |
def initialize instruction, number, text | |
@letter_array = text.split("") | |
@text_length = text.length | |
@number = number | |
case instruction | |
when "encrypt" | |
encrypt |
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 Volume_To_Shapes | |
def initialize volume_input | |
@volume_input = volume_input | |
@height = cube_root @volume_input | |
get_cube_dimensions | |
get_sphere_dimensions | |
get_cylinder_dimensions | |
get_cone_dimensions | |
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
# big text for timed tests | |
big_text = "The RSVP Hello message exchange was introduced in [RFC3209]. The | |
usage of RSVP Hello has been extended in [RFC3473] to support RSVP | |
Graceful Restart (GR) procedures. | |
More specifically, [RFC3473] specifies the use of the RSVP Hello | |
messages for GR procedures for Generalized MPLS (GMPLS). GMPLS | |
introduces the notion of control plane and data plane separation. In | |
other words, in GMPLS networks, the control plane information is | |
carried over a control network whose end-points are IP capable and | |
that may be physically or logically disjoint from the data bearer |
NewerOlder