Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

First pull request #1

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file added .DS_Store
Binary file not shown.
41 changes: 33 additions & 8 deletions 4.rb
Original file line number Diff line number Diff line change
Expand Up @@ -278,23 +278,48 @@
}

def is_palindrome? string
# A palindrome is a word that reads the same backwards and forwards, like 'racecar'
# This function should return true if the string is a palindrome and false if not
# Note: single letter words typically do not count as palindromes
if string.length < 2
return false
end

if string == string.reverse
return true
else
return false
end
end


# Find / compute the following things from the corpus of text by filling in the blanks
# (though feel free to add more lines if it would be helpful)

words = __
unique_words = __
words = Corpus.split
unique_words = words.uniq.count
puts "There are #{words.count} words (#{unique_words} unique words) in the text"

pal = __
palindrome = []
words.each do |word|
if is_palindrome? word
palindrome.push word
end
end

pal = words.find { |word| is_palindrome? word }
puts "The corpus contains the following palindrome: #{pal}"

speak_count = __
speak_count = 0
words.each do |word|
if word == "speak"
speak_count = speak_count + 1
end
end
puts "The word 'speak' appears #{speak_count} times."

longest_word = __
longest_word = words.first
words.each do |word|
if word.length > longest_word.length
longest_word = word
end
end

puts "The longest word in the corpus is #{longest_word}"
12 changes: 12 additions & 0 deletions 5.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
require 'pry'

puts "Give me a sentence > "
sentence = gets.chomp

letters = sentence.split("")
sorted_letters = letters.sort
sorted_string = sorted_letters.join

puts "Results is: #{sorted_stringrub} "

bind.pry
18 changes: 18 additions & 0 deletions Answers.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
Pre work Assessment

What files are in your home directory? Other projects

How did you determine that? Done through a tutorial and I kept using it as my code folder

Navigate into the 3 directory. How many files are there? 43

What is in the gunner-lind.txt file? A method for random name generator

What commands did you use to determine those? (You may be interested to read thepopulate_directory.rb file to see how these were generated.) Determine what?

4.rb contains the start of a text analysis program. Complete it, following the included comments.
Write a program that asks the user to type a sentence and sorts it (so if you type thisbecomes efhiiopsttuyy).

6.rb contains the start of a very rough social network. Flesh it out, following the outline and comments.

I'm still working on the .rb files and trying to figure it out