Giter Site home page Giter Site logo

csfx-py / hacktober2020 Goto Github PK

View Code? Open in Web Editor NEW
11.0 1.0 124.0 12.89 MB

C 6.32% Java 9.10% HTML 1.74% Python 19.08% C++ 21.80% JavaScript 0.72% Jupyter Notebook 39.44% CSS 0.57% Shell 0.30% PHP 0.77% Perl 0.05% C# 0.11%
hacktober hacktoberfest hacktoberfest-accepted

hacktober2020's Introduction

Make pull requests, enjoy the month!!

hacktober2020's People

Contributors

2016ipg-032 avatar abdul-pitodia avatar agasthya36 avatar akashashu1799 avatar amaan-farooq avatar chirag-goel360 avatar csfx-py avatar diyaacharya avatar fan-of-porter avatar h4wwk3ye avatar helper-uttam avatar imhkr avatar jithindk avatar koushal-op avatar krushi-21 avatar mht570 avatar najaf48 avatar nivya-21 avatar psujit775 avatar rishabhs-s avatar ritik047 avatar roshanb79 avatar s0zu avatar sakshi13-m avatar sickboy9665 avatar singh728om avatar sourav-nanda avatar vatsalnarwal avatar vikramadityasinghs avatar yg12061998 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

hacktober2020's Issues

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.

  1. 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.
  2. 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 photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.