Thank you very much Regis, Justin, and Julian! I am grateful that you
have taken the time to not just respond, but to make this educational as
well, that is exactly what I was looking for.
Regis:
I have tested your code on codeacademy labs and it does work on 1.8.3,
but seems to have a problem with not running multiple times, I believe
that is an issue with their site though. When running, it works very
smoothly!
Recurring issue with it: It cannot accept apostrophe’s. It will lock up
the site if an apostrophe is anywhere in the text. Which I will work on
resolving.
Justin:
Up until my conversation with Regis yesterday, I had no coding down,
just the concept. Knowing that there would be multiple possible
approaches, I was wanting to see at least one possible way that someone
knew how to do it, and then assess, reconfigure, rebuild, etc…
whatever needed to be done.
My goal is to create an encrypter that mimics DNA sequencing which only
uses four letters: A, T, G, C. Wherein there is a rule they must follow,
A always pairs with T, and C always pairs with G.
So this encrypter would take text, reassign it’s values to one of the
four letters (this assigning could then be changed in a whim if anyone
ever figured it out), and then spit out the result.
{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{
The end product would then be to have a way of re-combining everything
on the receiving end. Which is the hard part. I want it to take the
code, assess the different possible letters, for instance, “You”
translated in the example above WOULD be “DCD”, which then re-translated
back COULD be any combination of [S,T,U,V,W,X,Y,Z] [M,N,O,P,Q,R]
[S,T,U,V,W,X,Y,Z]. It would need to compare the possible combinations to
a dictionary, which would be ranked on the most probable words, and then
spit out the most accurate answer.
{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{
So, there is still a lot of work to do. I just wanted a good footing to
base it on. So that’s where I’m at now.
Julian:
Thank you very much for your solution, but also for the detailed
explanation and breakdown! I have learned about a lot of the different
components you mentioned through Code Academy, but also a lot of them I
either haven’t gotten to, or they don’t teach it. So THANK YOU!
I’m going to read through everything bit by bit and see if I can get it
to run on code academy labs. Then play with it as need be.
Here are the small changes I have made to Regis’ solution so far (mostly
spacing and rewording of the request for input):
$h={
“A” => %w{A B C D E F},
“T” => %w{G H I J K L},
“G” => %w{M N O P Q R},
“C” => %w{S T U V W X Y Z}
}
$reverseh= $h.inject({}) { |h,(k,a)| a.each {|l| h[l]=k } ; h }
def conv(letter) $reverseh[letter] || letter end
print “DNAS: Sequencing Open… Input? "
puts " "
while (word=$stdin.gets).size>1
puts word.chomp.upcase.split(//).map { |l| conv(l) }.join(”")
puts " "
print "DNAS: Additional Input? "
puts " "
end
Again, thank you very much everybody! I don’t want anyone to think that
I am asking you to do the work for me. I want to learn all of this and
will do it all myself if it comes to it, it just helps to have solid
grounding to work with. Not to mention, I will give credit on everyone’s
contributions at the end of this all and in the final product, unless
they ask me not to. I’m not here to steal work. 