Thursday, October 15, 2015

Q:In the coordinate plane consider the set S of all points with integer coordinates. For a
positive integer k, two distinct points A,B belonging to  S will be called k-friends if there is a point C belonging to S such that the area of the triangle ABC is equal to k. A set T is a subset of S will be called a k-clique
if every two points in T are k-friends. Find the least positive integer k for which there exists
a k-clique with more than 200 elements.
A: Let us picture this problem. We can peg one vertex of the triangle on the origin and choose the remaining points  B(u,v) and C(x,y) such that they form a triangle with an area k. These points are said to be k-friends. If we translate this triangle by a vector, it will not change the area and we will get new k-friends. There are many such translations possible before we determine their number let us look at the properties of the triangle. One such translation would be to choose a new origin such that the old-origin and new-origin are k-friends.
We know the well known formula for a triangle with one vertex at origin is half of mod(uy-vx) which is equal to k for k-friends. This is equivalent to saying  the gcd of u,v is also a divisor of 2k. In other words, two points (u,v) and (0,0) are k -friends if and only if the gcd(u,v) is a divisor of 2k. When we translate, the new point (s,t) and (u,v) are k friends if and only if the point (u-s,v-t) is a k friend of (0,0) which implies gcd(u-s, v-t) divides 2k.
Let us choose a number n that does not divide 2k The claim here is that a k-clique cannot have more than n^2 elements. This is because all points (x,y) can be divided into n^2 classes determined by the remainders that x and y leave in the division by n. If a set T has more than this many points, some two points will have to fall into the same class. This means n divides u-s and n divides v-t  and hence n divides gcd(u-s,v-t) Since n does not divide 2k therefore d does not divide 2k. Points (s,t) and (u,v) are now k-friends and the set T is not a k-clique. Our claim holds.
We can now investigate different values of n to come up with 200 elements.


#custom authentication in django
We take a short break to list the custom authentication in django:
we can do this the following ways
1) we can change the  default authentication backend
2) we can change the user model
3) we can change the permissions
4) we can change the default user

How does a JWTHelper parse ?

token_parts = token.split('.')

if len(token_parts) >= 2:

        import base64

        header = base64.b64decode(token_parts[0])

        claims = base64.b64decode(token_parts[1])

        if len(token_parts) == 3:

           crypto = base64.b64decode(token_parts[2])
        if header and header.get("alg") and header.get("enc") and header.get("iv") and header.get("typ"):

                alg = header["alg"]

                enc = header["enc"]  

                iv = header["iv"]

                typ = header["typ"]

No comments:

Post a Comment