我对Python还很陌生。能否有人解释一下这行代码的含义:
exec("print(' '.join(map(lambda x: s[x::{0}], range({0}))))".format(ceil(sqrt(len(s)))))
s[x::{0}]
和 range({0}))
是什么意思?请详细解释以下代码:
这段代码是下面hackerrank问题的解决方案: https://www.hackerrank.com/challenges/encryption/problem
#!/bin/python3
import sys
from math import ceil, floor, sqrt
def encryption(s):
exec("print(' '.join(map(lambda x: s[x::{0}], range({0}))))".format(ceil(sqrt(len(s)))))
if __name__ == "__main__":
s = input().strip()
result = encryption(s)