From b4d4a241b0f9b834181740b2fc5cadde19098725 Mon Sep 17 00:00:00 2001 From: anuraggoel Date: Thu, 31 Jan 2019 10:45:10 +0530 Subject: [PATCH] GFG --- GFG/max_ocr_chr_string.py | 15 +++++++++++++++ GFG/printSum.py | 6 ++++++ GFG/print_1_to_100.py | 7 +++++++ 3 files changed, 28 insertions(+) create mode 100644 GFG/max_ocr_chr_string.py create mode 100644 GFG/printSum.py create mode 100644 GFG/print_1_to_100.py diff --git a/GFG/max_ocr_chr_string.py b/GFG/max_ocr_chr_string.py new file mode 100644 index 0000000..558e43e --- /dev/null +++ b/GFG/max_ocr_chr_string.py @@ -0,0 +1,15 @@ +def countMax(string): + map = {} + mxChr = None + mxCount = 0 + for i in string: + if i in map: + map[i]+=1 + else: + map[i]=1 + if map[i] > mxCount: + mxCount = map[i] + mxChr = i + return mxChr +string = "mynameisanurag" +print (countMax(string)) \ No newline at end of file diff --git a/GFG/printSum.py b/GFG/printSum.py new file mode 100644 index 0000000..bef6ff5 --- /dev/null +++ b/GFG/printSum.py @@ -0,0 +1,6 @@ +def sum(no): + if no/10 == 0: + return no + return sum(no/10)+no%10 +no= 297 +print(sum(no)) \ No newline at end of file diff --git a/GFG/print_1_to_100.py b/GFG/print_1_to_100.py new file mode 100644 index 0000000..aa87d48 --- /dev/null +++ b/GFG/print_1_to_100.py @@ -0,0 +1,7 @@ +def printNos(n): + if n==101: + return + print(n) + printNos(n+1) + +printNos(1) \ No newline at end of file