Hi… I urgent require to convert the following ruby-code to c/c++ code.
If some-one have both the knowledge …plz help me… At least give me
some algorithm to it… IT’s ABOUT THE MORSE-CODE CONVERSION TO STRINGS
IN ALPHABETICAL ORDER
ENCODINGS.select { |p,l| p == word[0,p.size] }.map do |
prefix,letter|
# gather decoded suffixes for the current prefix
suffixes = morse_decodings( word[prefix.size,word.size] )
# append decoded suffixes to decoded letter
suffixes.empty? ? letter : suffixes.map { |s| letter + s }
end.flatten
end
decodings = morse_decodings(readline.chomp).sort
puts “All Possible Decodings:”
decodings.each { |e| puts e }
If you know neither Ruby or C++ then no one can help you. The job you
are
trying to get will have much harder problems than this interview
question.
i know C++ but don’t know the algorithm of morse-code
conversion…
finally i found the program in RUBY language… but i don’t understand
it… explaining this code steps-by-steps will be grateful …