【KataDaily 191015】Sort the Gift Code
题目:
Happy Holidays fellow Code Warriors!
Santa's senior gift organizer Elf developed a way to represent up to 26 gifts by assigning a unique alphabetical character to each gift. After each gift was assigned a character, the gift organizer Elf then joined the characters to form the gift ordering code.
Santa asked his organizer to order the characters in alphabetical order, but the Elf fell asleep from consuming too much hot chocolate and candy canes! Can you help him out?
Sort the Gift Code
Write a function called sortGiftCode
/sort_gift_code
/SortGiftCode
that accepts a string containing up to 26 unique alphabetical characters, and returns a string containing the same characters in alphabetical order.
Examples:
sort_gift_code( 'abcdef' ) # 'abcdef' sort_gift_code( 'pqksuvy' ) # 'kpqsuvy' sort_gift_code( 'zyxwvutsrqponmlkjihgfedcba' ) # 'abcdefghijklmnopqrstuvwxyz'
解题方法:
def sort_gift_code(code):
return "".join(sorted(code))
最新文章
- mysql乐观锁总结和实践--转
- Effective c++读书笔记
- 【转】JavaScript获取节点类型、节点名称和节点值
- .Net分布式异常报警系统-服务端站点管理
- PHP常用字符串操作函数实例总结(trim、nl2br、addcslashes、uudecode、md5等)
- SpringMVC 配置log4j
- iOS7自定义statusbar和navigationbar的若干问题
- iOS设备的硬件适配 (关于armv6, armv7, armv7s ) <;转>;
- 由于权限不足而无法读取配置文件出现的HTTP 500.19解决办法
- 使用cl编译C/C++
- Redux源码分析之bindActionCreators
- Python学习笔记(四)
- VisionPro随笔-Visionpro空间字符的含义
- ●POJ 1509 Glass Beads
- iOS平台添加Google Admob -2/2(Unity3D开发之八)
- [转] JavaScript中in操作符(for..in)、Object.keys()和Object.getOwnPropertyNames()的区别
- mysqldump 导出
- 平均数_中位数_众数在SqlServer实现
- uva 12222 Mountain Road
- CentOS 源码编译安装 Python3