Make pull requests, enjoy the month!!
hacktober2020's Introduction
hacktober2020's People
Forkers
harshitg088 sourav-nanda swikritcodes vick1165 sangtaniaryan h4wwk3ye susmitbhamare avinashchandan12 doniwalji sickboy9665 amaan-farooq arjunprasadsarkhel udaspriest sp2224 roshanb79 abdul-pitodia kuldipsharma adithyapaib sahilsharma100 shubhamdharak m0nx73r sgshivamgarg8 klutchit shantanub007 sukaran ankitpal3722 pridude vritikamalhotra psujit775 shivmsahu naresh-khatri sirvi3014 vijay0112 mht570 dragonpin akshayshet ritik047 kpatel2000 yashashvi65 imhkr hussein-hub officialshubhamsinha ramang0 shubham-k-sinha arunkumar-25 2016ipg-032 nishant07singh gdasv0101 nivya-21 mohitkhemchandani meghna25 dsprajput sugata98 bunny2210 anurupsdev fan-of-porter koushal-op 5hantanu ushnis25 premnathdey akashashu1799 kartiknoob sakshi13-m ryug8444 gs-vamsi smd-1 ashifa1999 git-rishabh-jha jithindk thijsvlaeyen himanshu12145 jonasberx saubhagya-gupta muskanbansal18 kgoyal000 kirito-udit vaibhavbansal93 mega-leio kuchiie neeladrikumar20 shristify ashup99 shivamshan beingpraveenverma darknez07 bwhite77 ritz2626 code-king1 iamshivamashish kosakanishkdev nikhilg07 danialmonachan11 vatsalnarwal ritwika-bhattacharjee hksingh4545 yatharthmahesh habib3865 smhari ananthuajay dotagodhacktober2020's Issues
cant do the pull request
Digit_pair.py
Digit Pairs
Problem Description
Given N three-digit numbers, your task is to find bit score of all N numbers and then print the number of pairs possible based on these calculated bit score.
- Rule for calculating bit score from three digit number:
From the 3-digit number,
· extract largest digit and multiply by 11 then
· extract smallest digit multiply by 7 then
· add both the result for getting bit pairs.
Note: - Bit score should be of 2-digits, if above results in a 3-digit bit score, simply ignore most significant digit.
Consider following examples:
Say, number is 286
Largest digit is 8 and smallest digit is 2
So, 811+27 =102 so ignore most significant bit , So bit score = 02.
Say, Number is 123
Largest digit is 3 and smallest digit is 1
So, 311+71=40, so bit score is 40. - Rules for making pairs from above calculated bit scores
Condition for making pairs are
· Both bit scores should be in either odd position or even position to be eligible to form a pair.
· Pairs can be only made if most significant digit are same and at most two pair can be made for a given significant digit.
Constraints
N<=500
Input Format
First line contains an integer N, denoting the count of numbers.
Second line contains N 3-digit integers delimited by space
Output
One integer value denoting the number of bit pairs.
Timeout
1
Explanation
Example 1
Input
8
234 567 321 345 123 110 767 111
Output
3
Explanation
After getting the most and least significant digits of the numbers and applying the formula given in Rule 1 we get the bit scores of the numbers as:
58 12 40 76 40 11 19 18
No. of pair possible are 3:
40 appears twice at odd-indices 3 and 5 respectively. Hence, this is one pair.
12, 11, 18 are at even-indices. Hence, two pairs are possible from these three-bit scores.
Hence total pairs possible is 3
Solution
def dig(n):
s,l=9,0
while(n):
r=n%10
if(s>r):
s=r
if(l<r):
l=r
n=n//10
return [s,l]
def pair(t):
if(t==2):
return 1
if(t>2):
return 2
return 0
n=int(input())
array=list(map(int,input().split()))
even=[]
odd=[]
for i in range(n):
t=dig(array[i])
s,l=t[0],t[1]
l*=11
s*=7
array[i]=(l+s)%100
even=[0]*10
odd=[0]*10
for i in range(n):
t=array[i]//10
if (i+1)%2==0:
even[t]+=1
else:
odd[t]+=1
c=[0]*10
for i in range(10):
if(even[i]<=1) and odd[i]<=1:
continue
c[i]+=pair(even[i])+pair(odd[i])
c[i]=min(2,c[i])
#print(p,odd[i])
print(sum(c))
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.