defgrille(message,code)output=""# convert code to binarybinary_code=code.to_s(2)# prepend the appropriate number of zeros to match length of messagewhilemessage.length>binary_code.lengthbinary_code.prepend('0')end# combine messages and binary_code into a hasharrays_hash=Hash[message.split("").zip(binary_code.split(""))]# if the value is 1, add the key to the output stringarrays_hash.eachdo|k,v|ifv=="1"output<<kendendreturnoutputend
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
ruby