GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — algorithms/string/license_number.py at master · RajaRamu/algorithms

Expand file tree

/

license_number.py

Copy path
More file actions
More file actions

Latest commit

 

History

History
History
19 lines (15 loc) · 526 Bytes
/

license_number.py

Copy path

File metadata and controls

19 lines (15 loc) · 526 Bytes
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
def license_number(key, K):
res, alnum = [], []
for char in key:
if char != "-":
alnum.append(char)
for i, char in enumerate(reversed(alnum)):
res.append(char)
if (i+1) % K == 0 and i != len(alnum)-1:
res.append("-")
return "".join(res[::-1])
print(license_number("a-bc-dfd-df", 1), 1)
print(license_number("a-bc-dfd-df", 2), 2)
print(license_number("a-bc-dfd-df", 3), 3)
print(license_number("a-bc-dfd-df", 4), 4)
print(license_number("a-bc-dfd-df", 5), 5)
You are visitor 01402792 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.