faqts : Computers : Programming : Languages : Python : Snippets

+ Search
Add Entry AlertManage Folder Edit Entry Add page to http://del.icio.us/
Did You Find This Entry Useful?

7 of 12 people (58%) answered Yes
Recently 5 of 10 people (50%) answered Yes

Entry

Obfuscated Python

Jul 5th, 2000 09:59
Nathan Wallace, Hans Nowak, Snippet 13, Andrew Csillag


"""
Packages: miscellaneous.obfuscated
"""

"""
> > I've found the following essentially single-line Python script useful in
> > decoding hexadecimal IP-Numbers (as given by /sbin/hostid on most unix
> > systems, I believe).
> > (For python newbies: The two lines at the bottom of the script should be
> > combined to one line)

Or my favorite loan amortizer:
"""

import sys;(lambda (R,A,N,P,x):map(lambda (i,a),R=R,A=A,P=P,N=N:
sys.stdout.write('%2d %8.2f %8.2f %8.2f\n'%(i,a,a*R,P-(a*R))),map(lambda
n,A=A,
R=R,P=P:(n,reduce(lambda
A,y,R=R,P=P:A-(P-(A*R)),range(n),A)),range(N))))((
lambda (R,A,N,P):(R,A,N,P,sys.stdout.write(('Payment=%.2f\nTotal Cost=%.2f\nCo'
+'st of Loan=%.2f\nPy Principl Interest  Towards\n-- -------- -------- ------'+
'--\n')%(P,P*N,(P*N)-A))))((lambda(R,A,N):(R,A,N,A*((((1+R)**N)*R))/(((1+R)**N)
-1)))((float(raw_input("Interest Rate/year="))/1200.0,float(raw_input("Amount="
)),float(raw_input("# of Months="))))))