今天看了下等级标示,原来kyu上面还有dan的等级,升级路漫漫,今天是5kyu题目
题目:
Write a module Converter that can take ASCII text and convert it tohexadecimal. The class should also be able to take hexadecimal andconvert it to ASCII text.
Example
Converter.to_hex("Look mom, no hands")
=> "4c6f6f6b206d6f6d2c206e6f2068616e6473"
Converter.to_ascii("4c6f6f6b206d6f6d2c206e6f2068616e6473")
=> "Look mom, no hands"
中文简介:
就是写个ASCII码和16进制的转换器,可以互相转换。
想法:
1、字符串转16进制,直接使用ord()函数然后逐个转换为16进制,再将16进制数转化成字符串形式加入到列表,再把列表合成字符串返回
2、16进制转换字符串,间隔为2历遍字符串,然后将16进制字符串转换成10进制数字,用char()函数转换为ASCII码加入列表,然后把列表合成字符串返回。<