cifre = ['0', '1', '6', '8', '9'] rasturnata = {'0': '0', '1': '1', '6': '9', '8': '8', '9': '6'} variante = [] for prima in cifre: if prima is '0': continue for adoua in cifre: for atreia in cifre: for apatra in cifre: numar = prima + adoua + atreia + apatra # "+" înseamnă concatenare de stringuri rasturnat = rasturnata[apatra] + rasturnata[atreia] + rasturnata[adoua] + rasturnata[prima] if numar == rasturnat: variante.append(int(numar)) # puteam să nu le convertesc la int, tot aia ieșea print sorted(variante)
Run
Reset
Share
Import
Link
Embed
Language▼
English
中文
Python Fiddle
Python Cloud IDE
Follow @python_fiddle
Browser Version Not Supported
Due to Python Fiddle's reliance on advanced JavaScript techniques, older browsers might have problems running it correctly. Please download the latest version of your favourite browser.
Chrome 10+
Firefox 4+
Safari 5+
IE 10+
Let me try anyway!
url:
Go
Python Snippet
Stackoverflow Question