Skip to content

Instantly share code, notes, and snippets.

@i64
Created July 8, 2018 08:56
Show Gist options
  • Save i64/31332b7ac5c24c858c6b8a572725098d to your computer and use it in GitHub Desktop.
Save i64/31332b7ac5c24c858c6b8a572725098d to your computer and use it in GitHub Desktop.
def pad(pad, string1=None, padLeft=None):
if string1 == None:
return pad
if padLeft:
return (pad + str(string1))[-len(pad) :]
else:
return (pad + str(string1))[: len(pad)]
def sonIkiHane(tc):
tc_rakam = []
for i in range(0, 11):
tc_rakam.append(int(tc) % 10)
tc = (int(tc) - tc_rakam[i]) / 10
tc_rakam = tc_rakam[::-1]
cift = tc_rakam[0] + tc_rakam[2] + tc_rakam[4] + tc_rakam[6] + tc_rakam[8]
tek = tc_rakam[1] + tc_rakam[3] + tc_rakam[5] + tc_rakam[7]
tc_rakam[9] = (7 * cift - tek) % 10
tc_rakam[10] = (
tc_rakam[9]
+ tc_rakam[8]
+ tc_rakam[7]
+ tc_rakam[6]
+ tc_rakam[5]
+ tc_rakam[4]
+ tc_rakam[3]
+ tc_rakam[2]
+ tc_rakam[1]
+ tc_rakam[0]
) % 10
return tc_rakam[9] * 10 + tc_rakam[10]
def tc_new(tc, tc_sayisi, yasli):
tc_sayisi = int(tc_sayisi)
string = []
tc5digit = int(str(tc[0:5]))
tc4digit = int(str(tc[5:9]))
while tc_sayisi:
if yasli > 0:
tc4digit = tc4digit - 1
tc5digit = tc5digit + 3
if tc5digit > 99999:
tc5digit = tc5digit - 100000
if tc4digit < 0:
tc4digit = tc4digit + 10000
else:
tc5digit = tc5digit - 3
tc4digit = tc4digit + 1
if tc4digit > 9999:
tc4digit = tc4digit - 10000
if tc5digit < 0:
tc5digit = tc5digit + 100000
raw_tc = (
pad("00000", str(tc5digit), True) + pad("0000", str(tc4digit), True) + "00"
)
string.append(
pad("00000", str(tc5digit), True)
+ pad("0000", str(tc4digit), True)
+ pad("00", sonIkiHane(raw_tc), True)
)
tc_sayisi = tc_sayisi - 1
print(string)
tc_new("29644202458", "6", 1)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment