Monday, July 11, 2022

UVa 10550- combination lock



 ```


while True:
a, b, c, d = map(int, input().split())
if a==b and b==c and c==d and c==0:
break
x1 = x2 = 0
x3 = 0
#clock wise
if a < b:
x1 = 40 - b + a
else:
x1 = a - b
#counter clockwise
if b > c:
x2 = 40 - b + c
else:
x2 = c - b
#clock wise
if c < d:
x3 = 40 - d + c
else:
x3 = c - d
print(1080+(x1+x2+x3)*9)

```

Wednesday, August 26, 2020

Codeforces problem-b-Teams forming

 Link : http://codeforces.com/contest/1092/problem/B

Python code : 

n=int(input())
x=[int(x) for x in input().split()]
x.sort()
i=1
s=0
while(i<n):
s=s+x[i]-x[i-1]
i=i+2
print(s)


C ++ Code :


#include<bits/stdc++.h>
using namespace std;
int main()
{
int t,i,n;
cin >> n;
int x[n];
for(i=0;i<n;i++)
{
cin >> x[i];
}
sort(x,x+n);
int s=0;
for(i=1;i<n;i=i+2)
{
s=s+(x[i]-x[i-1]);
}
cout << s << endl;
}


Friday, July 3, 2020

LOVE VIRUS

The LOVE VIRUS: 
Who doesn't want love. Every one want love . But  In 2000 the letter which is the love letter was not the love . IT was breakdown over 10 million Windows Operating system .Onel De Guzman's thesis brought out this love letter .For details : https://en.wikipedia.org/wiki/ILOVEYOU

UVa 10550- combination lock

 ``` while True: a , b , c , d = map ( int , input (). split ()) if a == b and b == c and c == d and c == 0 : break x1 =...