<commit_before># Reverse Words


# I worked on this challenge [by myself, with: ].
# This challenge took me [#] hours.

# Pseudocode



# Initial Solution
def reverser(string)
  sentence = string.split(' ')
  reverse_string = []

  sentence.length.times do |i|
    reverse_string[i] = sentence[i].reverse
  end
    

  return reverse_string.join(" ")
end
string = "ich in berliner"
reverser(string)




# Refactored Solution
def reverser(string)
  sentence = string.reverse.split(' ').reverse.join(" ")
  
  end





# Reflection
=begin
What concepts did you review or learn in this challenge?
I reviewed the concepts of iteration and how much i miss ruby. 
What is still confusing to you about Ruby?
some of the manually writing things out is still hard.
What are you going to study to get more prepared for Phase 1?
I'm going to continue to study methods and try to have a good idea about enumerators.<commit_msg>add solution for dr evil cipher and words to numbers<commit_after># Reverse Words


# I worked on this challenge [by myself, with: ].
# This challenge took me [#] hours.

# Pseudocode



# Initial Solution
def reverser(string)
  sentence = string.split(' ')
  reverse_string = []

  sentence.length.times do |i|
    reverse_string[i] = sentence[i].reverse
  end
    

  return reverse_string.join(" ")
end
string = "ich in berliner"
reverser(string)




# Refactored Solution
def reverser(string)
  sentence = string.reverse.split(' ').reverse.join(" ")
  
  end





# Reflection
=begin
What concepts did you review or learn in this challenge?
I reviewed the concepts of iteration and how much i miss ruby. 
What is still confusing to you about Ruby?
some of the manually writing things out is still hard.
What are you going to study to get more prepared for Phase 1?
I'm going to continue to study methods and try to have a good idea about enumerators.
=end
# Cipher Challenge

# I worked on this challenge [by myself, with:]
# I spent [#] hours on this challenge.

# 1. Solution
# Write your comments on what each thing is doing.
# If you have difficulty, go into IRB and play with the methods.
=begin
def dr_evils_cipher(coded_message)
  input = coded_message.downcase.split("") # Check out this method in IRB to see how it works! Also refer to the Ruby docs.
  decoded_sentence = []
  cipher = {"e" => "a",   # This is technically a shift of four letters...Can you think of a way to automate this? Is a hash
            "f" => "b",   # the best data structure for this problem? What are the pros and cons of hashes?
            "g" => "c",
            "h" => "d",
            "i" => "e",
            "j" => "f",
            "k" => "g",
            "l" => "h",
            "m" => "i",
            "n" => "j",
            "o" => "k",
            "p" => "l",
            "q" => "m",
            "r" => "n",
            "s" => "o",
            "t" => "p",
            "u" => "q",
            "v" => "r",
            "w" => "s",
            "x" => "t",
            "y" => "u",
            "z" => "v",
            "a" => "w",
            "b" => "x",
            "c" => "y",
            "d" => "z"}

  input.each do |x| # What is #each doing here?
    found_match = false  # Why would this be assigned to false from the outset? What happens when it's true?
    cipher.each_key do |y| # What is #each_key doing here?
      if x == y  # What is this comparing? Where is it getting x? Where is it getting y? What are those variables really?
        decoded_sentence << cipher[y]
        found_match = true
        break  # Why is it breaking here?
      elsif x == "@" || x == "#" || x == "$" || x == "%"|| x == "^" || x == "&"|| x =="*" #What the heck is this doing?
        decoded_sentence << " "
        found_match = true
        break
      elsif (0..9).to_a.include?(x) # Try this out in IRB. What does   " (0..9).to_a "    do?
        decoded_sentence << x
        found_match = true
        break
      end
    end
    if not found_match  # What is this looking for?
      decoded_sentence << x
    end
  end
  decoded_sentence = decoded_sentence.join("")
  #What is this method returning?
end
=end
# Your Refactored Solution

def dr_evils_cipher(coded_message)
  input = coded_message
  cipher = "abcdefghijklmnopqrstuvwxyz"
  cipher2 = "efghijklmnopqrstuvwxyzabcd"
  output = []
  
  coded_message.each_char do |x| 
  if cipher2.include?(x) 
  index = cipher2.index(x)
  output.push(cipher.split("")[index])
    
  elsif "@#$%^&*".include?(x)
   
   output.push(" ")
  elsif "0123456789".include?(x)
  output.push(x)
  else
  output.push(x)
  end
  end
  return output.join("")
  end






# Driver Test Code:
p dr_evils_cipher("m^aerx%e&gsoi!") == "i want a coke!" #This is driver test code and should print true
# Find out what Dr. Evil is saying below and turn it into driver test code as well. Driver test code statements should always return "true."
p dr_evils_cipher("syv%ievpc#exxiqtxw&ex^e$xvegxsv#fieq#airx%xlvsykl$wizivep#tvitevexmsrw.#tvitevexmsrw#e*xlvsykl#k&aivi%e@gsqtpixi&jempyvi.
&fyx%rsa,$pehmiw@erh#kirxpiqir,%ai%jmreppc@lezi&e&asvomrk%xvegxsv#fieq,^almgl^ai^wlepp%gepp@tvitevexmsr^l")
p dr_evils_cipher("csy&wii,@m'zi@xyvrih$xli*qssr$mrxs&alex@m#pmoi%xs#gepp%e^hiexl#wxev.")
p dr_evils_cipher("qmrm#qi,*mj^m#iziv^pswx#csy#m^hsr'x%orsa^alex@m%asyph^hs.
@m'h%tvsfefpc%qszi$sr%erh*kix#ersxliv$gpsri@fyx*xlivi@asyph^fi@e^15&qmryxi@tivmsh%xlivi$alivi*m*asyph&nywx^fi$mrgsrwspefpi.")
p dr_evils_cipher("alc@qeoi*e$xvmppmsr^alir#ai*gsyph%qeoi...#fmppmsrw?")

# Reflection
# Keep your reflection limited to 10-15 minutes!


# Numbers to English Words


# I worked on this challenge [by myself, with: ].
# This challenge took me [#] hours.


# Pseudocode



# Initial Solution
def numbers_to_words(number)
array = []
giant_hash = {
1=>"one", 2=>"two",3=>"three",4=>"four",5=>"five",6=>"six",7=>"seven",8=>"eight",9=>"nine",10=>"ten",
11=>"eleven",12=>"twelve",13=>"thirteen",14=>"fourteen",15=>"fifteen",16=>"sixteen",17=>"seventeen",
18=>"eighteen", 19=>"nineteen", 20=>"twenty",30=>"thirty",40=>"forty",50=>"fifty",60=>"sixty",70=>"seventy",
80=>"eighty", 90=>"ninety"}

if number >= 100
    digit_1 = number/100 
    array<<(giant_hash[digit_1])<<"hundred"
    if number % 100 > 20
    digit_2 = (number % 100) / 10
    array<<(giant_hash[digit_2*10])
    digit_3 = (number % 100) % 10
    array<<(giant_hash[digit_3]) 
    else digit_4 = number % 100
    array<<(giant_hash[digit_4])
    end
elsif number == 0
    array<<"zero"
    elsif number < 20 
    array<<(giant_hash[number])
    else
    digit_5 = number / 10
    array<<(giant_hash[digit_5*10])
    digit_6 = number % 10
    array<<(giant_hash[digit_6])
    end
    return array.join(" ")
    end
    
    numbers_to_words(999)



# Refactored Solution






{'fraction_non_alphanumeric': 0.1415876777251185, 'fraction_numerical': 0.017920616113744077, 'mean_word_length': 3.1227106227106227, 'pattern_counts': {'":': 0, '<': 30, '<?xml version=': 0, '>': 58, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6314585', 'n_tokens_mistral': 2584, 'n_tokens_neox': 2391, 'n_words': 690}