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

Kevin Nguyen #437

Open
wants to merge 10 commits into
base: master
Choose a base branch
from

Conversation

denverdevelopments
Copy link

@denverdevelopments denverdevelopments commented Jan 6, 2021

Here is my pre-work! Thank you.

https://github.com/kevn7n/backend_mod_1_prework.git

Copy link

@ap2322 ap2322 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Kevin, Great work on this and really excellent job pushing yourself with both extensions!

Comment on lines +20 to +31
while number >= 2
p "#{number} speckled frogs sat on a log"
p "eating some most delicious bugs."
p "One jumped in the pool where its nice and cool,"
number -= 1
p "then there were #{number} speckled frogs."
puts
end
p "#{number} speckled frogs sat on a log"
p "eating some most delicious bugs."
p "One jumped in the pool where its nice and cool,"
p "then there were no more speckled frogs."
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice use of iteration. There are lots of repeated lines of code, that's a sign this could be refactored to remove those repetitions.

Comment on lines +1 to +5
def cipher(input, shift)
input_to_ascii_array = input.chars.map {|char| char.ord}
shifted = input_to_ascii_array.map {|char| char+shift}
shifted.map { |char| char.chr }.join
end
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

WARNING: When you find code on google, call it out and re-write to match your style of programming.


p cipher("Pat is Mafia!", 6)

#Or an alternate, less direct, version that includes 'class'
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good work thinking through an OOP way of doing this... keep going.

Comment on lines +7 to +8
To keep track of how many spaces to shift, a way to track the current position of each letter in needed, then the number to shift over can be applied. First, we break up the "input" string into individual characters. I found the precise coding from google [primary reference link](https://medium.com/@alexander.virga/ruby-simple-string-encryption-shift-caesar-cipher-encoder-rot-9dedf06374d1):

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Appreciate the transparency of showing your source of the solution you found. This is great.

Note: This exercise to get a step-by-step of how to solve the problem is to get you thinking algorithmically - like what is the recipe for making a caesar cipher?

Explaining the code you found in plain language is great - excellent work. I'd challenge you in the future to try to think first about the steps as you'd explain them in plain language, and then add in code snippets.

print number
end

FizzBuzz(1,100)
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice work on FizzBuzz!

Comment on lines +5 to +30
def print_rows(size,y) #define method, uses size & xx
if size % 2 == 0 #for even 'size' do this block
while size >=1 #loop counter rows
if size % 2 == 1 #print this line for odd rows
puts " X" * y #prints pair ' X' y #of-times
size -= 1
else #print this line for even rows
puts "X " * y #prints pair 'X ' y #of-times
size -= 1
end
end
else #for odd 'size' do this block
while size >=1 #loop counter rows
if size % 2 == 1 #print this line for odd rows
print "X " * y #prints pair 'X ' y #of-times
puts "X" #print last odd 'X'
size -= 1
else #print this line for even rows
print " X" * y #prints pair ' X' y #of-times
puts " " #print last odd ' '
size -= 1
end
end
end
end
print_rows(size.to_i,y.to_i) #run the method for inputed 'size'
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great work on this extension. Cool to see your process of working through it in the comments too!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants