Skip to content

Instantly share code, notes, and snippets.

View AnkDos's full-sized avatar
🎯
Focusing

Ankur AnkDos

🎯
Focusing
  • Niyo
  • Banglore,India
View GitHub Profile
@AnkDos
AnkDos / randomStr.go
Created October 16, 2021 20:34
Random String Generator in Golang
/*
Author : Ankur
Date : 17/10/21
*/
package main
import (
"fmt"
"math/rand"
@AnkDos
AnkDos / flatten_dict.py
Created October 9, 2021 18:45
Flatten a dictonary , nested dictionary into plain dictonary
def flatten(data):
flatten_dict = {}
def flat(data_, key, pkey=''):
if isinstance(data_, dict):
if data_ == dict():
flatten_dict[f"{pkey}"] = data_
for key, value in data_.items():
key_fmt = [pkey, key]
if pkey == '':
key_fmt = [key]
@AnkDos
AnkDos / console_quiz.py
Last active July 3, 2021 17:47
Simple python program to demonstrate the use of thread .
import threading
import sys
import time
import os
class ConsoleQuiz:
""""""
QUESTIONS = {
'01': {
@AnkDos
AnkDos / any_dictionary_parser.py
Last active July 3, 2021 17:37
Method to Parse any type of dictionary in python without using recursion . Input any dict , Returns list of list of all key value pair in dict
def dictionary_parser(dict_):
"""
Traversing through any type of dictionary wihout using recursion
Input any dict , Returns list of list of all key value pair in dict
SAMPLE :
:arg : {
"a": "b",
"c": "d",
"e": [
{"aa": "bb"},
def test_func(a, b):
"""asserting every argument"""
assert isinstance(a, int) , "Invalid Attribute"
assert isinstance(b, str) , "Invalid Attribute"
#Created By AnkDos(https://github.com/AnkDos)
#A decorator to validate function argument
def validate_inputs(func):
def validate(*args):
variables_value_map = dict(zip(func.__code__.co_varnames,args))
for key, value in func.__annotations__.items():
assert isinstance(variables_value_map[key],value),\
'Invalid Attribute'
return func(*args)
# CREATED BY ANKDOS
# A PROGRAM THAT TAKES Nth HIGHEST NUMBER (only n , not element) IN THE ARRAY AND RETURNS HOW MANY TIMES ITS REPEATING
def sort_dec (ar) :
swap_count = 0
i = 0
while True :
while i < len(ar)-1 :
if ar[i] < ar[i+1] :
temp = ar[i+1]
# Created By Ankdos
# Program to print random number between range without using inbuilt function
import datetime
def push (mins , maxs , ms) :
ran = gen_rand(0,maxs-mins)
ms = mins + ran
if ms > maxs :
import java.util.*;
public class Ankdos{
static int count(char letter , String word ){
int i = 0,counts = 0 ;
while(i<word.length()){
if (letter == word.charAt(i) ){
counts++;
@AnkDos
AnkDos / near_prime.rb
Created September 25, 2018 22:13
Program to find the nearest smaller or larger prime number from the given number.
def is_prime(num)
i=2
res = true
while i < num
if num % i == 0
res = false
break
end
i+=1
end