-
Notifications
You must be signed in to change notification settings - Fork 0
/
hash.rb
98 lines (58 loc) · 1.74 KB
/
hash.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
require 'pry'
Alphabet = {"A" => "Alpha", "B" => "Bravo", "C" => "Charlie",
"D"=> "Delta", "E" => "Echo", "F" => "Foxtrot", "G" => "Gold", "H" => "Hotel",
"I" => "India", "J" => "Juliet", "K" => "Kilo", "L" => "Lima",
"M" => "Mike", "N" => "November", "O" => "Oscar", "P" => "Papa", "Q" => "Quebec",
"R" => "Romeo", "S" => "Sierra", "T" => "Tango", "U" => "Uniform" , "V" => "Victor",
"W" => "Whiskey", "X" => "X-Ray" , "Y" => "Yankee", "Z" => "Zulu"}
puts Alphabet
# ENCODE
def classify(message)
translated_message = []
message = message.upcase
message.each_char do |letter|
translated_message << Alphabet[letter]
end
translated_message.join(", ")
end
def declassify(message_declassified)
declassified = []
message = message_declassified
message do |sentence|
message_declassified << Alphabet.values[sentence]
end
declassified(", ")
end
binding.pry
# def encode(phrase, alphabet)
# result = []
# phrase.each_char do |letter|
# result.push(alphabet[letter])
# end
# result.join("")
# end
# puts alphabet
# encode( "my name is juan", alphabet)
#binding.pry
# f alphabet.include?(word) then
# value = alphabet[word]
# puts "This is #{word} that equals #{value}"
# else
# puts "I dont know"
# end
#I want to prompt the user to enter a word
# print("Please enter a word: ")
# word = alphabet.key
# clasified_words = alphabet.value
# word = gets.chomp.to_s
# def clasify(alphabet, word)
# if alphabet.include?(word)
# puts "This is the return #{clasified_words}"
# return alphabet.value
# else
# puts("I don't know!")
# end
# end
# clasify(alphabet, word)
#turnering
#code Golf