This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/python3 | |
import os, sys, math | |
def reflectionComponent(pcomp, qcomp): | |
if pcomp > qcomp: | |
return qcomp - abs(qcomp - pcomp) | |
elif pcomp < qcomp: | |
return qcomp + abs(qcomp - pcomp) | |
else: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def is_leap_year(year): | |
if year < 1918: | |
return year%4 == 0 | |
elif year > 1918: | |
return (year%400==0) or ((year%4==0) and (year%100 != 0)) | |
def day_of_programmer(year): | |
if year == 1918: | |
return f"26.09.{year}" | |
else: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def migratory_birds(arr): | |
index = dict() | |
max_sight_count, min_ids = 0, 6 | |
for bird_id in arr: | |
if bird_id not in index: | |
index[bird_id] = 0 | |
index[bird_id] += 1 | |
max_sight_count = max(index[bird_id], max_sight_count) | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def rotate_array(arr, k): | |
element_at_secondary_index = None | |
primary_index = 0 | |
steps = 0 | |
n = len(arr) | |
while steps < n: | |
secondary_index = (primary_index+k) % n |