Skip to content

Instantly share code, notes, and snippets.

@TheGistGuy
Created March 7, 2015 16:15
Show Gist options
  • Save TheGistGuy/d43a32d8f560aa7e1e7c to your computer and use it in GitHub Desktop.
Save TheGistGuy/d43a32d8f560aa7e1e7c to your computer and use it in GitHub Desktop.
Emelt informatika érettségi 2014 május (e_inf_14maj)
#!/usr/bin/python3
# 1. feladat
cimek = open('ip.txt').readlines()
# 2. feladat
print("""2. feladat:
Az állományban {} darab adatsor van.
""".format(len(cimek)))
# 3. feladat
print("""3. feladat:
A legalacsonyabb tárolt IP-cím:
{}""".format(min(cimek)))
# 4. feladat
print("""4. feladat:
Dokumentációs cím: {} darab
Globális egyedi cím: {} darab
Helyi egyedi cím: {} darab
""".format(*tuple(map(sum,zip(*((x.startswith('2001:0db8'), x.startswith('2001:0e'), x.startswith('fc') or x.startswith('fd')) for x in cimek))))))
# 5. feladat
open('sok.txt', 'w').writelines([str(i+1) + ' ' + cim for (i, cim) in enumerate(cimek) if cim.count('0') >= 18])
# 6. feladat
print('6. feladat:')
n = int(input('Kérek egy sorszámot: ')) - 1
cim = ':'.join(x.lstrip('0') or '0' for x in cimek[n].split(':'))
print('{}{}'.format(cimek[n], cim))
# 7. feladat
print('7. feladat:')
for i in range(8,0,-1):
if ':0'*i in ':'+cim:
print((':'+cim).replace(':0'*i,':',1)[1:])
break
else:
print('Nem rövidíthető tovább')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment