-
Fundamentals
Code def numberprint(x): return int(''.join(map(lambda x: str(x), list(range(1, x + 1)) + list(range(x - 1, 0, -1))))) # harder to read but 1 line ¯\_(ツ)_/¯
Preloaded Code def numberprint(x): return
Test Cases import codewars_test as test from solution import numberprint .describe("Fixed Tests") def basic_tests(): .it("Fixed tests") def fixed_tests(): test.assert_equals(numberprint(1), 1) test.assert_equals(numberprint(2), 121) test.assert_equals(numberprint(10), 12345678910987654321)
Output:
-
Code - def numberprint(x):
l1 = list(map(str, range(1, x + 1)))l1.extend(l1[-2::-1])return int(''.join(l1))- return int(''.join(map(lambda x: str(x), list(range(1, x + 1)) + list(range(x - 1, 0, -1)))))
- # harder to read but 1 line ¯\_(ツ)_/¯
- All
- {{group.name}} ({{group.count}})
This comment has been reported as {{ abuseKindText }}.
Show
This comment has been hidden. You can view it now .
This comment can not be viewed.
- |
- Reply
- Edit
- View Solution
- Expand 1 Reply Expand {{ comments?.length }} replies
- Collapse
- Remove
- Remove comment & replies
- Report
{{ fetchSolutionsError }}