Posts

Showing posts from May, 2019

DJANGO - a web frame work of python (part-1)

Image
third blog of series is       here : https://codexmaze.blogspot.com/2019/06/django-web-framework-of-pythonpart-3.html Django is python framework for web development. This framework is now in use by big companies as google , instagram etc. The reason is python and other reason is a set pattern of django. This will be a three blog series to tell you what is Django , where to start and basic command lines with some snippets. Now we first start with installation of django.But first you have to check python is install in your windows or not. OPEN "WINDOW POWERSHELL" and type "python --version".If it is found then python is install. Now proceed further for installation of Django. Install PIP: PIP  is a package manager for Python that uses the  Python Package Index  to install Python packages. PIP will later be used to install Django from PyPI. If you’ve installed Python 3.4,  pip  is included so you may skip this section. O...

hacker rank python (collections.Counter())solution

31.collections.Counter() #counter just devvide list in keys and values from collections import Counter x= int ( input ()) sum = 0 l=[] shoes = Counter( map ( int , raw_input ().split())) n= int ( input ()) for j in range (n): sn ,sp = map ( int , raw_input ().split()) if (shoes[sn]> 0 ): sum = sum +sp shoes[sn] -= 1 print ( sum )

Hacker Rank all java and python problem solutions

JAVA : 1.  https://codexmaze.blogspot.com/2019/05/hacker-rank-java-problem-1-solution.html    2. https://codexmaze.blogspot.com/2019/05/hacker-rank-java-2nd-solution.html 3. https://codexmaze.blogspot.com/2019/05/hacker-rank-java-3rd-question-solution.html 4. https://codexmaze.blogspot.com/2019/05/hacker-rank-java-4th-solution.html       5. https://codexmaze.blogspot.com/2019/05/hacker-rank-java-5th-solution.html 6. https://codexmaze.blogspot.com/2019/05/hacker-rank-6th-question-solution.html 7. https://codexmaze.blogspot.com/2019/05/hacker-rank-java-7th-problem-solution.html 8. https://codexmaze.blogspot.com/2019/05/hacker-rank-java-8th-problem-silution.html 9. https://codexmaze.blogspot.com/2019/05/hacker-rank-java-9th-question-solution.html 10. https://codexmaze.blogspot.com/2019/05/hacker-rank-java-10th-problem-solution.html 11. https://codexmaze.blogspot.com/2019/05/hacker-rank-11th-java-problem-solution.html 12  https://c...

hacker rank python problem(itertools.permutations())soluiton

itertools.permutations() from itertools import permutations l,b=input().split() l1=list(permutations(l,int(b))) for i in sorted(l1):       print(*i,sep='')  Compiler Message Success Input (stdin) Download HACK 2 Expected Output Download AC AH AK CA CH CK HA HC HK KA KC KH

hacker rank python (matrix script)

MATRIX SCRIPT //HARDEST IN THE SOLUTIONS import re import sys nm = input().split() n = int(nm[0]) m = int(nm[1]) matrix = [] for _ in range(n):     matrix_item = input()     matrix.append(matrix_item) string = ""       for i in range(m):     string += "".join(matrix[j][i] for j in range(n)) res = re.sub(r"(?<=\w)[!@#$%&\s]+(?=\w)",r" ",string)     sys.stdout.write(res)

hacker rank python(validating postals)

VALIDATING POSTALS regex_integer_in_range = r"^[1-9][0-9]{5}$"    regex_alternating_repetitive_digit_pair = r"(\d)(?=(\d)\1)" Compiler Message Success Input (stdin) Download 110000 Expected Output Download False

hacker rank python(itertools.product())

ITERTOOLS.PRODUCT() # Enter your code here. Read input from STDIN. Print output to STDOUT from itertools import product a = list(map(int, input().split())) b = list(map(int, input().split())) print(*product(a, b)) Compiler Message Success Input (stdin) Download 1 2 3 4 Expected Output Download (1, 3) (1, 4) (2, 3) (2, 4)

hacker rank python(the minion game)solution

THE MINION GAME def minion_game(string):     Kevin = 0     Stuart = 0     word = list(string)     x = len(word)     vowels = ['A','E','I','O','U']     for inx, w in enumerate(word):         if w in vowels:             Kevin = Kevin + x         else:             Stuart = Stuart + x         x = x - 1     if Stuart > Kevin:         print ('Stuart', Stuart)     elif Kevin > Stuart:         print ('Kevin', Kevin)     else:         print ('Draw')

hacker rank python(Capitalize!)solution

CAPITALIZE! # Complete the solve function below. def solve(s):     str= [i.strip().capitalize() for i in s.split() ]     for i in str:          s =s.replace(i.lower(),i)     return s Compiler Message Success Input (stdin) Download hello world Expected Output Download Hello World

hacker rank python problem(Alphabet rangoli)

ALPHABET RANGOLI def print_rangoli(size):    # your code goes here     alpha = ['a']     for i in range(size-1):         alpha.append(chr(ord(alpha[i]) + 1))     poped = []     beta = list(alpha)     beta.reverse()     beta.pop() # remove the extra a => e,c,d,b         full_list = list(beta)     full_list.extend(alpha)     # to determine the width of the line with no outer dashes     max_len = len('-'.join(full_list))     for j in range(1,size+1):         m_str = ""         if (j-1) > 0:             m_str = '-'.join(beta[:j-1]) + '-'         m_str += '-'.join(alpha[j*-1:])         string = '{s:{c}^{n}}'.format(s=m_str, n=max_len, c='-')         poped.append(string)    ...

hacker rank python(string formatting)solution

STRING FORMATTING def print_formatted(number):     w = len(str(bin(number)).replace('0b',''))     for i in range(1,number+1):            d = str(i).rjust(w,' ')         b = bin(i)[2:].rjust(w,' ')   ## rjust is used for line alignment         o = oct(i)[2:].rjust(w, ' ')         h = hex(i)[2:].rjust(w, ' ').upper()         print(d, o, h, b) Compiler Message Success Input (stdin) Download 2 Expected Output Download 1 1 1 1 2 2 2 10

hacker rank python(Designer Door mat)solution

DESIGNER DOOR MAT  # Enter your code here. Read input from STDIN. Print output to STDOUT N,M=map(int,str(raw_input()).split()) for i in range(1,N,2):     print((i*".|.").center(M,'-')) print("WELCOME".center(M,'-')) for j in range(N-2,-1,-2):     print((j*".|.").center(M,'-'))

hacker rank python(text wrap)

TEXT WRAP def wrap(string, max_width):   return "\n".join([string[i:i+max_width] for i in range(0, len(string), max_width)]) Compiler Message Success Input (stdin) Download ABCDEFGHIJKLIMNOQRSTUVWXYZ 4 Expected Output Download ABCD EFGH IJKL IMNO QRST UVWX YZ

hacker rank python(text alignment )solution

TEXT ALIGNMENT def func():     #Replace all ______ with rjust, ljust or center.     thickness = int(input()) #This must be an odd number     c = 'H'     #Top Cone     for i in range(thickness):         print((c*i).rjust(thickness-1)+c+(c*i).ljust(thickness-1))     #Top Pillars     for i in range(thickness+1):         print((c*thickness).center(thickness*2)+(c*thickness).center(thickness*6))     #Middle Belt     for i in range((thickness+1)//2):         print((c*thickness*5).center(thickness*6))        #Bottom Pillars     for i in range(thickness+1):         print((c*thickness).center(thickness*2)+(c*thickness).center(thickness*6))        #Bottom Cone     for i in range(thickness):         print(((c*(thickness-i-1...

hacker rank python(String Validator)

STRING VALIDATOR if __name__ == '__main__':     s = input()     print(len([True for c in s if c.isalnum()]) != 0)     print(len([True for c in s if c.isalpha()]) != 0)     print(len([True for c in s if c.isdigit()]) != 0)     print(len([True for c in s if c.islower()]) != 0)     print(len([True for c in s if c.isupper()]) != 0) Compiler Message Success Input (stdin) Download qA2 Expected Output Download True True True True True