-
Fundamentals
Code def numberprint(x): n = ''.join(map(str, range(1,x))) return int(f'{n}{x}{n[::-1]}')
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):
nor = 0final = ''while nor < x:nor += 1final += str(nor)while nor > 1:nor -= 1final += str(nor)return int(final)- n = ''.join(map(str, range(1,x)))
- return int(f'{n}{x}{n[::-1]}')
- 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 }}