Commit 66560af5 authored by Narumon Mokpha 's avatar Narumon Mokpha

ส่งงานค่ะ

parent cffb2e5c
def value(v,p,n): def value(v,p,n):
v = [0,0,0,0,1,0,1,1] sign = -1 if v[0] == 1 else 1
return sign*sum([v[i]*2**(p-i)for i in range(1,(p+n+1))])
sign = -1 if v[0] == 1 else 1 def values(V,p,n):
v=list(map(int,V))
return sign*sum([v[i]*2**(p-i)for i in range(1,(p+n+1))]) sign = -1 if v[0] == 1 else 1
return sign*sum([v[i]*2**(p-i)for i in range(1,(p+n+1))])
print( value(v,4,3) ) \ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment