From a4d478676706b6c92b32604e06a78ebe2f99791a Mon Sep 17 00:00:00 2001 From: Mrigank Pawagi Date: Fri, 15 Dec 2023 23:26:02 +0530 Subject: [PATCH 1/6] Generate draft translations --- translation/main.py | 22 +++++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) diff --git a/translation/main.py b/translation/main.py index a38774c9..19cce222 100644 --- a/translation/main.py +++ b/translation/main.py @@ -1,5 +1,7 @@ from openai import OpenAI import os +import json +import re from dotenv import load_dotenv load_dotenv() @@ -18,11 +20,11 @@ def docstring_translator(docstr): }, { "role": "user", - "content": "Given a positive integer n, return the product of the odd digits.\\n Return 0 if all digits are even.\\n For example:\\n digits(1) == 1\\n digits(4) == 0\\n digits(235) == 15\\n" + "content": "Given a positive integer n, return the product of the odd digits.\n Return 0 if all digits are even.\n For example:\n digits(1) == 1\n digits(4) == 0\n digits(235) == 15\n" }, { "role": "assistant", - "content": "Diye gaye positive integer n ke odd digits ka product return karo.\\n Agar saare digits even ho to 0 return karo.\\n Jaise ki:\\n digits(1) == 1\\n digits(4) == 0\\n digits(235) == 15\\n" + "content": "Diye gaye positive integer n ke odd digits ka product return karo.\n Agar saare digits even ho to 0 return karo.\n Jaise ki:\n digits(1) == 1\n digits(4) == 0\n digits(235) == 15\n" }, { "role": "user", @@ -39,4 +41,18 @@ def docstring_translator(docstr): if __name__ == "__main__": - pass + with open("../HumanEval.json") as f: + data = json.load(f) + + for problem in data: + task_id = problem["task_id"].split("/")[-1] + prompt = problem["prompt"] + docstring = re.findall(r'"""(.*?)"""', prompt, re.DOTALL)[0] + + try: + res = docstring_translator(docstring) + except Exception: + continue + + with open(f"drafts/{task_id}", "w") as f: + f.write(f'"""{docstring}"""\n\n"""\n{res}\n"""') From cd9b7a8b645e8c677df95752dcf4754a52034da2 Mon Sep 17 00:00:00 2001 From: Mrigank Pawagi Date: Fri, 15 Dec 2023 23:48:42 +0530 Subject: [PATCH 2/6] =?UTF-8?q?Update=20translation=20model=20to=20gpt-4?= =?UTF-8?q?=20=F0=9F=92=AA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- translation/main.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/translation/main.py b/translation/main.py index 19cce222..44ba9fe8 100644 --- a/translation/main.py +++ b/translation/main.py @@ -12,7 +12,7 @@ def docstring_translator(docstr): response = client.chat.completions.create( - model="gpt-3.5-turbo-16k", + model="gpt-4", messages=[ { "role": "system", @@ -56,3 +56,5 @@ def docstring_translator(docstr): with open(f"drafts/{task_id}", "w") as f: f.write(f'"""{docstring}"""\n\n"""\n{res}\n"""') + + break \ No newline at end of file From 41b0dd7375f2d3fd32c6f1f12e1ee0ab15655567 Mon Sep 17 00:00:00 2001 From: Mrigank Pawagi Date: Fri, 15 Dec 2023 23:49:14 +0530 Subject: [PATCH 3/6] fix --- translation/main.py | 2 -- 1 file changed, 2 deletions(-) diff --git a/translation/main.py b/translation/main.py index 44ba9fe8..56f56626 100644 --- a/translation/main.py +++ b/translation/main.py @@ -56,5 +56,3 @@ def docstring_translator(docstr): with open(f"drafts/{task_id}", "w") as f: f.write(f'"""{docstring}"""\n\n"""\n{res}\n"""') - - break \ No newline at end of file From 4088991024b48e3fbb71ce8383de9ece9a67b174 Mon Sep 17 00:00:00 2001 From: Mrigank Pawagi Date: Fri, 15 Dec 2023 23:54:49 +0530 Subject: [PATCH 4/6] Update max_tokens value in docstring_translator function to 2048 --- translation/main.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/translation/main.py b/translation/main.py index 56f56626..9ff9966b 100644 --- a/translation/main.py +++ b/translation/main.py @@ -32,7 +32,7 @@ def docstring_translator(docstr): } ], temperature=0, - max_tokens=256, + max_tokens=2048, top_p=1, frequency_penalty=0, presence_penalty=0 From 3fedae75fb39425d38748fdc5d23e3fd206a6256 Mon Sep 17 00:00:00 2001 From: Mrigank Pawagi Date: Sat, 16 Dec 2023 00:08:59 +0530 Subject: [PATCH 5/6] fixes --- translation/main.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/translation/main.py b/translation/main.py index 9ff9966b..1e9c4129 100644 --- a/translation/main.py +++ b/translation/main.py @@ -47,12 +47,12 @@ def docstring_translator(docstr): for problem in data: task_id = problem["task_id"].split("/")[-1] prompt = problem["prompt"] - docstring = re.findall(r'"""(.*?)"""', prompt, re.DOTALL)[0] + docstring = (re.findall(r'"""(.*?)"""', prompt, re.DOTALL) + re.findall(r"'''(.*?)'''", prompt, re.DOTALL))[0] try: res = docstring_translator(docstring) except Exception: continue - with open(f"drafts/{task_id}", "w") as f: + with open(f"drafts/{task_id}", "w", encoding="utf-8") as f: f.write(f'"""{docstring}"""\n\n"""\n{res}\n"""') From beac152fbe9e976a9293e1ad298c38f2eafa82af Mon Sep 17 00:00:00 2001 From: Mrigank Pawagi Date: Sat, 16 Dec 2023 00:17:52 +0530 Subject: [PATCH 6/6] Draft Translations --- translation/drafts/0 | 15 ++++++++++ translation/drafts/1 | 16 ++++++++++ translation/drafts/10 | 5 ++++ translation/drafts/100 | 27 +++++++++++++++++ translation/drafts/101 | 17 +++++++++++ translation/drafts/102 | 18 +++++++++++ translation/drafts/103 | 22 ++++++++++++++ translation/drafts/104 | 23 ++++++++++++++ translation/drafts/105 | 43 ++++++++++++++++++++++++++ translation/drafts/106 | 18 +++++++++++ translation/drafts/107 | 45 ++++++++++++++++++++++++++++ translation/drafts/108 | 19 ++++++++++++ translation/drafts/109 | 46 ++++++++++++++++++++++++++++ translation/drafts/11 | 12 ++++++++ translation/drafts/110 | 26 ++++++++++++++++ translation/drafts/111 | 25 ++++++++++++++++ translation/drafts/112 | 23 ++++++++++++++ translation/drafts/113 | 23 ++++++++++++++ translation/drafts/114 | 14 +++++++++ translation/drafts/115 | 67 +++++++++++++++++++++++++++++++++++++++++ translation/drafts/116 | 21 +++++++++++++ translation/drafts/117 | 26 ++++++++++++++++ translation/drafts/118 | 30 +++++++++++++++++++ translation/drafts/119 | 28 +++++++++++++++++ translation/drafts/12 | 19 ++++++++++++ translation/drafts/120 | 49 ++++++++++++++++++++++++++++++ translation/drafts/121 | 18 +++++++++++ translation/drafts/122 | 26 ++++++++++++++++ translation/drafts/123 | 33 ++++++++++++++++++++ translation/drafts/124 | 41 +++++++++++++++++++++++++ translation/drafts/125 | 17 +++++++++++ translation/drafts/126 | 30 +++++++++++++++++++ translation/drafts/127 | 40 +++++++++++++++++++++++++ translation/drafts/128 | 24 +++++++++++++++ translation/drafts/129 | 57 +++++++++++++++++++++++++++++++++++ translation/drafts/13 | 14 +++++++++ translation/drafts/130 | 32 ++++++++++++++++++++ translation/drafts/131 | 16 ++++++++++ translation/drafts/132 | 26 ++++++++++++++++ translation/drafts/133 | 25 ++++++++++++++++ translation/drafts/134 | 23 ++++++++++++++ translation/drafts/135 | 21 +++++++++++++ translation/drafts/136 | 21 +++++++++++++ translation/drafts/137 | 22 ++++++++++++++ translation/drafts/138 | 15 ++++++++++ translation/drafts/139 | 24 +++++++++++++++ translation/drafts/14 | 10 +++++++ translation/drafts/140 | 21 +++++++++++++ translation/drafts/141 | 26 ++++++++++++++++ translation/drafts/142 | 23 ++++++++++++++ translation/drafts/143 | 40 +++++++++++++++++++++++++ translation/drafts/144 | 24 +++++++++++++++ translation/drafts/145 | 20 +++++++++++++ translation/drafts/146 | 16 ++++++++++ translation/drafts/147 | 27 +++++++++++++++++ translation/drafts/148 | 26 ++++++++++++++++ translation/drafts/149 | 30 +++++++++++++++++++ translation/drafts/15 | 14 +++++++++ translation/drafts/150 | 17 +++++++++++ translation/drafts/151 | 23 ++++++++++++++ translation/drafts/152 | 28 +++++++++++++++++ translation/drafts/153 | 35 ++++++++++++++++++++++ translation/drafts/154 | 20 +++++++++++++ translation/drafts/155 | 14 +++++++++ translation/drafts/156 | 21 +++++++++++++ translation/drafts/157 | 17 +++++++++++ translation/drafts/158 | 18 +++++++++++ translation/drafts/159 | 57 +++++++++++++++++++++++++++++++++++ translation/drafts/16 | 14 +++++++++ translation/drafts/160 | 49 ++++++++++++++++++++++++++++++ translation/drafts/161 | 22 ++++++++++++++ translation/drafts/162 | 13 ++++++++ translation/drafts/163 | 18 +++++++++++ translation/drafts/17 | 26 ++++++++++++++++ translation/drafts/18 | 18 +++++++++++ translation/drafts/19 | 14 +++++++++ translation/drafts/2 | 17 +++++++++++ translation/drafts/20 | 15 ++++++++++ translation/drafts/21 | 12 ++++++++ translation/drafts/22 | 14 +++++++++ translation/drafts/23 | 14 +++++++++ translation/drafts/24 | 10 +++++++ translation/drafts/25 | 22 ++++++++++++++ translation/drafts/26 | 12 ++++++++ translation/drafts/27 | 10 +++++++ translation/drafts/28 | 14 +++++++++ translation/drafts/29 | 14 +++++++++ translation/drafts/3 | 16 ++++++++++ translation/drafts/30 | 14 +++++++++ translation/drafts/31 | 34 +++++++++++++++++++++ translation/drafts/32 | 9 ++++++ translation/drafts/33 | 18 +++++++++++ translation/drafts/34 | 10 +++++++ translation/drafts/35 | 15 ++++++++++ translation/drafts/36 | 18 +++++++++++ translation/drafts/37 | 18 +++++++++++ translation/drafts/38 | 7 +++++ translation/drafts/39 | 27 +++++++++++++++++ translation/drafts/4 | 16 ++++++++++ translation/drafts/40 | 34 +++++++++++++++++++++ translation/drafts/41 | 23 ++++++++++++++ translation/drafts/42 | 14 +++++++++ translation/drafts/43 | 32 ++++++++++++++++++++ translation/drafts/44 | 22 ++++++++++++++ translation/drafts/45 | 10 +++++++ translation/drafts/46 | 31 +++++++++++++++++++ translation/drafts/47 | 14 +++++++++ translation/drafts/48 | 23 ++++++++++++++ translation/drafts/49 | 26 ++++++++++++++++ translation/drafts/5 | 14 +++++++++ translation/drafts/50 | 7 +++++ translation/drafts/51 | 31 +++++++++++++++++++ translation/drafts/52 | 14 +++++++++ translation/drafts/53 | 14 +++++++++ translation/drafts/54 | 31 +++++++++++++++++++ translation/drafts/55 | 18 +++++++++++ translation/drafts/56 | 26 ++++++++++++++++ translation/drafts/57 | 18 +++++++++++ translation/drafts/58 | 16 ++++++++++ translation/drafts/59 | 14 +++++++++ translation/drafts/6 | 17 +++++++++++ translation/drafts/60 | 27 +++++++++++++++++ translation/drafts/61 | 26 ++++++++++++++++ translation/drafts/62 | 18 +++++++++++ translation/drafts/63 | 29 ++++++++++++++++++ translation/drafts/64 | 7 +++++ translation/drafts/65 | 18 +++++++++++ translation/drafts/66 | 27 +++++++++++++++++ translation/drafts/67 | 21 +++++++++++++ translation/drafts/68 | 68 ++++++++++++++++++++++++++++++++++++++++++ translation/drafts/69 | 22 ++++++++++++++ translation/drafts/7 | 14 +++++++++ translation/drafts/70 | 22 ++++++++++++++ translation/drafts/71 | 19 ++++++++++++ translation/drafts/72 | 35 ++++++++++++++++++++++ translation/drafts/73 | 22 ++++++++++++++ translation/drafts/74 | 27 +++++++++++++++++ translation/drafts/75 | 16 ++++++++++ translation/drafts/76 | 25 ++++++++++++++++ translation/drafts/77 | 25 ++++++++++++++++ translation/drafts/78 | 31 +++++++++++++++++++ translation/drafts/79 | 24 +++++++++++++++ translation/drafts/8 | 16 ++++++++++ translation/drafts/80 | 24 +++++++++++++++ translation/drafts/81 | 51 +++++++++++++++++++++++++++++++ translation/drafts/82 | 18 +++++++++++ translation/drafts/83 | 8 +++++ translation/drafts/84 | 29 ++++++++++++++++++ translation/drafts/85 | 13 ++++++++ translation/drafts/86 | 25 ++++++++++++++++ translation/drafts/87 | 39 ++++++++++++++++++++++++ translation/drafts/88 | 29 ++++++++++++++++++ translation/drafts/89 | 22 ++++++++++++++ translation/drafts/9 | 11 +++++++ translation/drafts/90 | 22 ++++++++++++++ translation/drafts/91 | 22 ++++++++++++++ translation/drafts/92 | 33 ++++++++++++++++++++ translation/drafts/93 | 26 ++++++++++++++++ translation/drafts/94 | 25 ++++++++++++++++ translation/drafts/95 | 22 ++++++++++++++ translation/drafts/96 | 23 ++++++++++++++ translation/drafts/97 | 19 ++++++++++++ translation/drafts/98 | 17 +++++++++++ translation/drafts/99 | 35 ++++++++++++++++++++++ 164 files changed, 3760 insertions(+) create mode 100644 translation/drafts/0 create mode 100644 translation/drafts/1 create mode 100644 translation/drafts/10 create mode 100644 translation/drafts/100 create mode 100644 translation/drafts/101 create mode 100644 translation/drafts/102 create mode 100644 translation/drafts/103 create mode 100644 translation/drafts/104 create mode 100644 translation/drafts/105 create mode 100644 translation/drafts/106 create mode 100644 translation/drafts/107 create mode 100644 translation/drafts/108 create mode 100644 translation/drafts/109 create mode 100644 translation/drafts/11 create mode 100644 translation/drafts/110 create mode 100644 translation/drafts/111 create mode 100644 translation/drafts/112 create mode 100644 translation/drafts/113 create mode 100644 translation/drafts/114 create mode 100644 translation/drafts/115 create mode 100644 translation/drafts/116 create mode 100644 translation/drafts/117 create mode 100644 translation/drafts/118 create mode 100644 translation/drafts/119 create mode 100644 translation/drafts/12 create mode 100644 translation/drafts/120 create mode 100644 translation/drafts/121 create mode 100644 translation/drafts/122 create mode 100644 translation/drafts/123 create mode 100644 translation/drafts/124 create mode 100644 translation/drafts/125 create mode 100644 translation/drafts/126 create mode 100644 translation/drafts/127 create mode 100644 translation/drafts/128 create mode 100644 translation/drafts/129 create mode 100644 translation/drafts/13 create mode 100644 translation/drafts/130 create mode 100644 translation/drafts/131 create mode 100644 translation/drafts/132 create mode 100644 translation/drafts/133 create mode 100644 translation/drafts/134 create mode 100644 translation/drafts/135 create mode 100644 translation/drafts/136 create mode 100644 translation/drafts/137 create mode 100644 translation/drafts/138 create mode 100644 translation/drafts/139 create mode 100644 translation/drafts/14 create mode 100644 translation/drafts/140 create mode 100644 translation/drafts/141 create mode 100644 translation/drafts/142 create mode 100644 translation/drafts/143 create mode 100644 translation/drafts/144 create mode 100644 translation/drafts/145 create mode 100644 translation/drafts/146 create mode 100644 translation/drafts/147 create mode 100644 translation/drafts/148 create mode 100644 translation/drafts/149 create mode 100644 translation/drafts/15 create mode 100644 translation/drafts/150 create mode 100644 translation/drafts/151 create mode 100644 translation/drafts/152 create mode 100644 translation/drafts/153 create mode 100644 translation/drafts/154 create mode 100644 translation/drafts/155 create mode 100644 translation/drafts/156 create mode 100644 translation/drafts/157 create mode 100644 translation/drafts/158 create mode 100644 translation/drafts/159 create mode 100644 translation/drafts/16 create mode 100644 translation/drafts/160 create mode 100644 translation/drafts/161 create mode 100644 translation/drafts/162 create mode 100644 translation/drafts/163 create mode 100644 translation/drafts/17 create mode 100644 translation/drafts/18 create mode 100644 translation/drafts/19 create mode 100644 translation/drafts/2 create mode 100644 translation/drafts/20 create mode 100644 translation/drafts/21 create mode 100644 translation/drafts/22 create mode 100644 translation/drafts/23 create mode 100644 translation/drafts/24 create mode 100644 translation/drafts/25 create mode 100644 translation/drafts/26 create mode 100644 translation/drafts/27 create mode 100644 translation/drafts/28 create mode 100644 translation/drafts/29 create mode 100644 translation/drafts/3 create mode 100644 translation/drafts/30 create mode 100644 translation/drafts/31 create mode 100644 translation/drafts/32 create mode 100644 translation/drafts/33 create mode 100644 translation/drafts/34 create mode 100644 translation/drafts/35 create mode 100644 translation/drafts/36 create mode 100644 translation/drafts/37 create mode 100644 translation/drafts/38 create mode 100644 translation/drafts/39 create mode 100644 translation/drafts/4 create mode 100644 translation/drafts/40 create mode 100644 translation/drafts/41 create mode 100644 translation/drafts/42 create mode 100644 translation/drafts/43 create mode 100644 translation/drafts/44 create mode 100644 translation/drafts/45 create mode 100644 translation/drafts/46 create mode 100644 translation/drafts/47 create mode 100644 translation/drafts/48 create mode 100644 translation/drafts/49 create mode 100644 translation/drafts/5 create mode 100644 translation/drafts/50 create mode 100644 translation/drafts/51 create mode 100644 translation/drafts/52 create mode 100644 translation/drafts/53 create mode 100644 translation/drafts/54 create mode 100644 translation/drafts/55 create mode 100644 translation/drafts/56 create mode 100644 translation/drafts/57 create mode 100644 translation/drafts/58 create mode 100644 translation/drafts/59 create mode 100644 translation/drafts/6 create mode 100644 translation/drafts/60 create mode 100644 translation/drafts/61 create mode 100644 translation/drafts/62 create mode 100644 translation/drafts/63 create mode 100644 translation/drafts/64 create mode 100644 translation/drafts/65 create mode 100644 translation/drafts/66 create mode 100644 translation/drafts/67 create mode 100644 translation/drafts/68 create mode 100644 translation/drafts/69 create mode 100644 translation/drafts/7 create mode 100644 translation/drafts/70 create mode 100644 translation/drafts/71 create mode 100644 translation/drafts/72 create mode 100644 translation/drafts/73 create mode 100644 translation/drafts/74 create mode 100644 translation/drafts/75 create mode 100644 translation/drafts/76 create mode 100644 translation/drafts/77 create mode 100644 translation/drafts/78 create mode 100644 translation/drafts/79 create mode 100644 translation/drafts/8 create mode 100644 translation/drafts/80 create mode 100644 translation/drafts/81 create mode 100644 translation/drafts/82 create mode 100644 translation/drafts/83 create mode 100644 translation/drafts/84 create mode 100644 translation/drafts/85 create mode 100644 translation/drafts/86 create mode 100644 translation/drafts/87 create mode 100644 translation/drafts/88 create mode 100644 translation/drafts/89 create mode 100644 translation/drafts/9 create mode 100644 translation/drafts/90 create mode 100644 translation/drafts/91 create mode 100644 translation/drafts/92 create mode 100644 translation/drafts/93 create mode 100644 translation/drafts/94 create mode 100644 translation/drafts/95 create mode 100644 translation/drafts/96 create mode 100644 translation/drafts/97 create mode 100644 translation/drafts/98 create mode 100644 translation/drafts/99 diff --git a/translation/drafts/0 b/translation/drafts/0 new file mode 100644 index 00000000..9e241ce6 --- /dev/null +++ b/translation/drafts/0 @@ -0,0 +1,15 @@ +""" Check if in given list of numbers, are any two numbers closer to each other than + given threshold. + >>> has_close_elements([1.0, 2.0, 3.0], 0.5) + False + >>> has_close_elements([1.0, 2.8, 3.0, 4.0, 5.0, 2.0], 0.3) + True + """ + +""" +Diye gaye numbers ki list mein, kya koi do numbers ek dusre se diye gaye threshold se zyada close hain. + >>> has_close_elements([1.0, 2.0, 3.0], 0.5) + False + >>> has_close_elements([1.0, 2.8, 3.0, 4.0, 5.0, 2.0], 0.3) + True +""" \ No newline at end of file diff --git a/translation/drafts/1 b/translation/drafts/1 new file mode 100644 index 00000000..68a6eb1f --- /dev/null +++ b/translation/drafts/1 @@ -0,0 +1,16 @@ +""" Input to this function is a string containing multiple groups of nested parentheses. Your goal is to + separate those group into separate strings and return the list of those. + Separate groups are balanced (each open brace is properly closed) and not nested within each other + Ignore any spaces in the input string. + >>> separate_paren_groups('( ) (( )) (( )( ))') + ['()', '(())', '(()())'] + """ + +""" +Is function ka input ek string hota hai jisme multiple groups hote hain nested parentheses ke. Aapka goal hai + un groups ko alag alag strings me separate karna aur unki list return karni hai. + Separate groups balanced hote hain (har open brace sahi se close hota hai) aur ek dusre ke andar nested nahi hote + Input string me koi bhi spaces ko ignore karo. + >>> separate_paren_groups('( ) (( )) (( )( ))') + ['()', '(())', '(()())'] +""" \ No newline at end of file diff --git a/translation/drafts/10 b/translation/drafts/10 new file mode 100644 index 00000000..0e6ca1b0 --- /dev/null +++ b/translation/drafts/10 @@ -0,0 +1,5 @@ +""" Test if given string is a palindrome """ + +""" +Diye gaye string ko check karo ki woh palindrome hai ya nahi. +""" \ No newline at end of file diff --git a/translation/drafts/100 b/translation/drafts/100 new file mode 100644 index 00000000..45359095 --- /dev/null +++ b/translation/drafts/100 @@ -0,0 +1,27 @@ +""" + Given a positive integer n, you have to make a pile of n levels of stones. + The first level has n stones. + The number of stones in the next level is: + - the next odd number if n is odd. + - the next even number if n is even. + Return the number of stones in each level in a list, where element at index + i represents the number of stones in the level (i+1). + + Examples: + >>> make_a_pile(3) + [3, 5, 7] + """ + +""" +Ek positive integer n diya gaya hai, aapko n levels ki ek pile of stones banani hai. + Pehle level me n stones honge. + Agla level stones ka number hoga: + - agla odd number agar n odd hai. + - agla even number agar n even hai. + Har level me stones ki sankhya ko ek list me return karo, jaha index + i ki element level (i+1) me stones ki sankhya ko darshata hai. + + Udaharan: + >>> make_a_pile(3) + [3, 5, 7] +""" \ No newline at end of file diff --git a/translation/drafts/101 b/translation/drafts/101 new file mode 100644 index 00000000..154cd1ae --- /dev/null +++ b/translation/drafts/101 @@ -0,0 +1,17 @@ +""" + You will be given a string of words separated by commas or spaces. Your task is + to split the string into words and return an array of the words. + + For example: + words_string("Hi, my name is John") == ["Hi", "my", "name", "is", "John"] + words_string("One, two, three, four, five, six") == ["One", "two", "three", "four", "five", "six"] + """ + +""" +Aapko ek string di jayegi jisme words commas ya spaces se separated honge. Aapka task hai + string ko words mein split karna aur words ki array return karna. + + Jaise ki: + words_string("Hi, my name is John") == ["Hi", "my", "name", "is", "John"] + words_string("One, two, three, four, five, six") == ["One", "two", "three", "four", "five", "six"] +""" \ No newline at end of file diff --git a/translation/drafts/102 b/translation/drafts/102 new file mode 100644 index 00000000..0c6476b5 --- /dev/null +++ b/translation/drafts/102 @@ -0,0 +1,18 @@ +"""This function takes two positive numbers x and y and returns the + biggest even integer number that is in the range [x, y] inclusive. If + there's no such number, then the function should return -1. + + For example: + choose_num(12, 15) = 14 + choose_num(13, 12) = -1 + """ + +""" +Yeh function do positive numbers x aur y leta hai aur return karta hai + sabse bada even integer jo range [x, y] mein inclusive hai. Agar + aisa koi number nahi hai, toh function ko -1 return karna chahiye. + + Jaise ki: + choose_num(12, 15) = 14 + choose_num(13, 12) = -1 +""" \ No newline at end of file diff --git a/translation/drafts/103 b/translation/drafts/103 new file mode 100644 index 00000000..28b0a026 --- /dev/null +++ b/translation/drafts/103 @@ -0,0 +1,22 @@ +"""You are given two positive integers n and m, and your task is to compute the + average of the integers from n through m (including n and m). + Round the answer to the nearest integer and convert that to binary. + If n is greater than m, return -1. + Example: + rounded_avg(1, 5) => "0b11" + rounded_avg(7, 5) => -1 + rounded_avg(10, 20) => "0b1111" + rounded_avg(20, 33) => "0b11010" + """ + +""" +Aapko do positive integers n aur m diye gaye hain, aur aapka task hai n se lekar m tak ke integers ka + average compute karna (n aur m ko bhi include karte hue). + Answer ko nearest integer tak round karo aur usko binary mein convert karo. + Agar n m se bada hai, to -1 return karo. + Udaharan: + rounded_avg(1, 5) => "0b11" + rounded_avg(7, 5) => -1 + rounded_avg(10, 20) => "0b1111" + rounded_avg(20, 33) => "0b11010" +""" \ No newline at end of file diff --git a/translation/drafts/104 b/translation/drafts/104 new file mode 100644 index 00000000..9f3ed1bc --- /dev/null +++ b/translation/drafts/104 @@ -0,0 +1,23 @@ +"""Given a list of positive integers x. return a sorted list of all + elements that hasn't any even digit. + + Note: Returned list should be sorted in increasing order. + + For example: + >>> unique_digits([15, 33, 1422, 1]) + [1, 15, 33] + >>> unique_digits([152, 323, 1422, 10]) + [] + """ + +""" +Diye gaye positive integers ki list x. Woh saare elements return karo jo sorted list me hai aur jisme koi bhi even digit nahi hai. + + Dhyan de: Return ki gayi list ko increasing order me sort kiya jana chahiye. + + Jaise ki: + >>> unique_digits([15, 33, 1422, 1]) + [1, 15, 33] + >>> unique_digits([152, 323, 1422, 10]) + [] +""" \ No newline at end of file diff --git a/translation/drafts/105 b/translation/drafts/105 new file mode 100644 index 00000000..7b1b0a2e --- /dev/null +++ b/translation/drafts/105 @@ -0,0 +1,43 @@ +""" + Given an array of integers, sort the integers that are between 1 and 9 inclusive, + reverse the resulting array, and then replace each digit by its corresponding name from + "One", "Two", "Three", "Four", "Five", "Six", "Seven", "Eight", "Nine". + + For example: + arr = [2, 1, 1, 4, 5, 8, 2, 3] + -> sort arr -> [1, 1, 2, 2, 3, 4, 5, 8] + -> reverse arr -> [8, 5, 4, 3, 2, 2, 1, 1] + return ["Eight", "Five", "Four", "Three", "Two", "Two", "One", "One"] + + If the array is empty, return an empty array: + arr = [] + return [] + + If the array has any strange number ignore it: + arr = [1, -1 , 55] + -> sort arr -> [-1, 1, 55] + -> reverse arr -> [55, 1, -1] + return = ['One'] + """ + +""" +Ek array diya gaya hai integers ka, integers ko sort karo jo 1 se 9 ke beech mein hai, + resulting array ko reverse karo, aur phir har digit ko uske corresponding name se replace karo + "One", "Two", "Three", "Four", "Five", "Six", "Seven", "Eight", "Nine". + + Jaise ki: + arr = [2, 1, 1, 4, 5, 8, 2, 3] + -> arr ko sort karo -> [1, 1, 2, 2, 3, 4, 5, 8] + -> arr ko reverse karo -> [8, 5, 4, 3, 2, 2, 1, 1] + return ["Eight", "Five", "Four", "Three", "Two", "Two", "One", "One"] + + Agar array khali hai, toh ek khali array return karo: + arr = [] + return [] + + Agar array mein koi ajeeb number hai toh use ignore karo: + arr = [1, -1 , 55] + -> arr ko sort karo -> [-1, 1, 55] + -> arr ko reverse karo -> [55, 1, -1] + return = ['One'] +""" \ No newline at end of file diff --git a/translation/drafts/106 b/translation/drafts/106 new file mode 100644 index 00000000..ab23c240 --- /dev/null +++ b/translation/drafts/106 @@ -0,0 +1,18 @@ +""" Implement the function f that takes n as a parameter, + and returns a list of size n, such that the value of the element at index i is the factorial of i if i is even + or the sum of numbers from 1 to i otherwise. + i starts from 1. + the factorial of i is the multiplication of the numbers from 1 to i (1 * 2 * ... * i). + Example: + f(5) == [1, 2, 6, 24, 15] + """ + +""" +Function f ko implement karo jo n ko parameter ke roop mein leta hai, + aur ek list return karta hai jiska size n hota hai, aisa ki index i par element ka value i ka factorial hota hai agar i even hai + ya fir 1 se lekar i tak ke numbers ka sum hota hai otherwise. + i ka start 1 se hota hai. + i ka factorial 1 se lekar i tak ke numbers ka multiplication hota hai (1 * 2 * ... * i). + Udaharan: + f(5) == [1, 2, 6, 24, 15] +""" \ No newline at end of file diff --git a/translation/drafts/107 b/translation/drafts/107 new file mode 100644 index 00000000..c1cb2f31 --- /dev/null +++ b/translation/drafts/107 @@ -0,0 +1,45 @@ +""" + Given a positive integer n, return a tuple that has the number of even and odd + integer palindromes that fall within the range(1, n), inclusive. + + Example 1: + + Input: 3 + Output: (1, 2) + Explanation: + Integer palindrome are 1, 2, 3. one of them is even, and two of them are odd. + + Example 2: + + Input: 12 + Output: (4, 6) + Explanation: + Integer palindrome are 1, 2, 3, 4, 5, 6, 7, 8, 9, 11. four of them are even, and 6 of them are odd. + + Note: + 1. 1 <= n <= 10^3 + 2. returned tuple has the number of even and odd integer palindromes respectively. + """ + +""" +Ek positive integer n diya gaya hai, return karo ek tuple jisme even aur odd integer palindromes ki sankhya ho jo range(1, n) ke andar aate hain, inclusive. + + Udaharan 1: + + Input: 3 + Output: (1, 2) + Explanation: + Integer palindrome hain 1, 2, 3. Inme se ek even hai, aur do odd hain. + + Udaharan 2: + + Input: 12 + Output: (4, 6) + Explanation: + Integer palindrome hain 1, 2, 3, 4, 5, 6, 7, 8, 9, 11. Inme se chaar even hain, aur 6 odd hain. + + Dhyan de: + 1. 1 <= n <= 10^3 + 2. returned tuple me even aur odd integer palindromes ki sankhya kramashah hoti hai. + +""" \ No newline at end of file diff --git a/translation/drafts/108 b/translation/drafts/108 new file mode 100644 index 00000000..42a3e032 --- /dev/null +++ b/translation/drafts/108 @@ -0,0 +1,19 @@ +""" + Write a function count_nums which takes an array of integers and returns + the number of elements which has a sum of digits > 0. + If a number is negative, then its first signed digit will be negative: + e.g. -123 has signed digits -1, 2, and 3. + >>> count_nums([]) == 0 + >>> count_nums([-1, 11, -11]) == 1 + >>> count_nums([1, 1, 2]) == 3 + """ + +""" +Ek function likho count_nums jo ek array of integers leta hai aur return karta hai + un elements ki sankhya jinka digits ka sum > 0 hota hai. + Agar koi number negative hai, to uska pehla signed digit negative hoga: + jaise ki -123 ke signed digits hote hai -1, 2, aur 3. + >>> count_nums([]) == 0 + >>> count_nums([-1, 11, -11]) == 1 + >>> count_nums([1, 1, 2]) == 3 +""" \ No newline at end of file diff --git a/translation/drafts/109 b/translation/drafts/109 new file mode 100644 index 00000000..90c5bb17 --- /dev/null +++ b/translation/drafts/109 @@ -0,0 +1,46 @@ +"""We have an array 'arr' of N integers arr[1], arr[2], ..., arr[N].The + numbers in the array will be randomly ordered. Your task is to determine if + it is possible to get an array sorted in non-decreasing order by performing + the following operation on the given array: + You are allowed to perform right shift operation any number of times. + + One right shift operation means shifting all elements of the array by one + position in the right direction. The last element of the array will be moved to + the starting position in the array i.e. 0th index. + + If it is possible to obtain the sorted array by performing the above operation + then return True else return False. + If the given array is empty then return True. + + Note: The given list is guaranteed to have unique elements. + + For Example: + + move_one_ball([3, 4, 5, 1, 2])==>True + Explanation: By performin 2 right shift operations, non-decreasing order can + be achieved for the given array. + move_one_ball([3, 5, 4, 1, 2])==>False + Explanation:It is not possible to get non-decreasing order for the given + array by performing any number of right shift operations. + + """ + +""" +Humare paas ek array 'arr' hai N integers arr[1], arr[2], ..., arr[N] ka. Array mein numbers randomly order mein honge. Aapka task hai yeh determine karna ki kya hume non-decreasing order mein sorted array mil sakta hai, diye gaye array par niche diye gaye operation ko perform karke: + Aapko right shift operation ko kitni bhi baar perform karne ki anumati hai. + + Ek right shift operation ka matlab hai array ke saare elements ko ek position right direction mein shift karna. Array ka last element array ke starting position yaani 0th index par move ho jayega. + + Agar upar diye gaye operation ko perform karke sorted array mil sakta hai to True return karo, nahi to False return karo. + Agar diya gaya array khali hai to True return karo. + + Note: Diye gaye list mein unique elements honge. + + Udaharan ke liye: + + move_one_ball([3, 4, 5, 1, 2])==>True + Explanation: 2 right shift operations perform karke, diye gaye array ke liye non-decreasing order prapt kiya ja sakta hai. + move_one_ball([3, 5, 4, 1, 2])==>False + Explanation: Kisi bhi number of right shift operations perform karke diye gaye array ke liye non-decreasing order prapt karna sambhav nahi hai. + +""" \ No newline at end of file diff --git a/translation/drafts/11 b/translation/drafts/11 new file mode 100644 index 00000000..fdd33188 --- /dev/null +++ b/translation/drafts/11 @@ -0,0 +1,12 @@ +""" Input are two strings a and b consisting only of 1s and 0s. + Perform binary XOR on these inputs and return result also as a string. + >>> string_xor('010', '110') + '100' + """ + +""" +Input do strings a aur b honge jo sirf 1s aur 0s se bane honge. + In inputs par binary XOR perform karo aur result ko bhi ek string ke roop mein return karo. + >>> string_xor('010', '110') + '100' +""" \ No newline at end of file diff --git a/translation/drafts/110 b/translation/drafts/110 new file mode 100644 index 00000000..461779f9 --- /dev/null +++ b/translation/drafts/110 @@ -0,0 +1,26 @@ +"""In this problem, you will implement a function that takes two lists of numbers, + and determines whether it is possible to perform an exchange of elements + between them to make lst1 a list of only even numbers. + There is no limit on the number of exchanged elements between lst1 and lst2. + If it is possible to exchange elements between the lst1 and lst2 to make + all the elements of lst1 to be even, return "YES". + Otherwise, return "NO". + For example: + exchange([1, 2, 3, 4], [1, 2, 3, 4]) => "YES" + exchange([1, 2, 3, 4], [1, 5, 3, 4]) => "NO" + It is assumed that the input lists will be non-empty. + """ + +""" +Is problem mein, aapko ek function implement karna hai jo do list of numbers leta hai, + aur yeh determine karta hai ki kya inke beech elements ka exchange karke + lst1 ko sirf even numbers ki list banaya ja sakta hai. + lst1 aur lst2 ke beech exchanged elements ki sankhya par koi limit nahi hai. + Agar lst1 aur lst2 ke beech elements exchange karke + lst1 ke saare elements ko even banaya ja sakta hai, to "YES" return karo. + Varna, "NO" return karo. + Jaise ki: + exchange([1, 2, 3, 4], [1, 2, 3, 4]) => "YES" + exchange([1, 2, 3, 4], [1, 5, 3, 4]) => "NO" + Maan liya jata hai ki input lists khali nahi hogi. +""" \ No newline at end of file diff --git a/translation/drafts/111 b/translation/drafts/111 new file mode 100644 index 00000000..40fc8470 --- /dev/null +++ b/translation/drafts/111 @@ -0,0 +1,25 @@ +"""Given a string representing a space separated lowercase letters, return a dictionary + of the letter with the most repetition and containing the corresponding count. + If several letters have the same occurrence, return all of them. + + Example: + histogram('a b c') == {'a': 1, 'b': 1, 'c': 1} + histogram('a b b a') == {'a': 2, 'b': 2} + histogram('a b c a b') == {'a': 2, 'b': 2} + histogram('b b b b a') == {'b': 4} + histogram('') == {} + + """ + +""" +Ek string di gayi hai jo space separated lowercase letters ko represent karti hai, return karo ek dictionary + jisme sabse zyada repeat hone wale letter aur unke corresponding count ho. + Agar kai letters ka occurrence same hai, to un sabhi ko return karo. + + Udaharan: + histogram('a b c') == {'a': 1, 'b': 1, 'c': 1} + histogram('a b b a') == {'a': 2, 'b': 2} + histogram('a b c a b') == {'a': 2, 'b': 2} + histogram('b b b b a') == {'b': 4} + histogram('') == {} +""" \ No newline at end of file diff --git a/translation/drafts/112 b/translation/drafts/112 new file mode 100644 index 00000000..6f45b34b --- /dev/null +++ b/translation/drafts/112 @@ -0,0 +1,23 @@ +"""Task + We are given two strings s and c, you have to deleted all the characters in s that are equal to any character in c + then check if the result string is palindrome. + A string is called palindrome if it reads the same backward as forward. + You should return a tuple containing the result string and True/False for the check. + Example + For s = "abcde", c = "ae", the result should be ('bcd',False) + For s = "abcdef", c = "b" the result should be ('acdef',False) + For s = "abcdedcba", c = "ab", the result should be ('cdedc',True) + """ + +""" +Task + Humare paas do strings s aur c di gayi hain, aapko s mein se un sabhi characters ko delete karna hai jo c ke kisi bhi character ke barabar hain + phir check karo ki resultant string palindrome hai ya nahi. + Ek string ko palindrome tabhi kaha jata hai jab woh backward aur forward dono taraf se same padhti ho. + Aapko ek tuple return karna hai jisme resultant string aur True/False check ke liye hoga. + Udaharan + Agar s = "abcde", c = "ae", toh result ('bcd',False) hona chahiye + Agar s = "abcdef", c = "b" toh result ('acdef',False) hona chahiye + Agar s = "abcdedcba", c = "ab", toh result ('cdedc',True) hona chahiye + +""" \ No newline at end of file diff --git a/translation/drafts/113 b/translation/drafts/113 new file mode 100644 index 00000000..ac94041d --- /dev/null +++ b/translation/drafts/113 @@ -0,0 +1,23 @@ +"""Given a list of strings, where each string consists of only digits, return a list. + Each element i of the output should be "the number of odd elements in the + string i of the input." where all the i's should be replaced by the number + of odd digits in the i'th string of the input. + + >>> odd_count(['1234567']) + ["the number of odd elements 4n the str4ng 4 of the 4nput."] + >>> odd_count(['3',"11111111"]) + ["the number of odd elements 1n the str1ng 1 of the 1nput.", + "the number of odd elements 8n the str8ng 8 of the 8nput."] + """ + +""" +Ek strings ki list di gayi hai, jahan har string sirf digits se bani hoti hai, ek list return karo. + Output ki har element i ko "input ki string i mein odd elements ki sankhya." ke roop mein hona chahiye, jahan saari i's ko input ki i'th string mein odd digits ki sankhya se replace kar dena chahiye. + + >>> odd_count(['1234567']) + ["input ki string 4 mein odd elements ki sankhya 4."] + >>> odd_count(['3',"11111111"]) + ["input ki string 1 mein odd elements ki sankhya 1.", + "input ki string 8 mein odd elements ki sankhya 8."] + +""" \ No newline at end of file diff --git a/translation/drafts/114 b/translation/drafts/114 new file mode 100644 index 00000000..23022a46 --- /dev/null +++ b/translation/drafts/114 @@ -0,0 +1,14 @@ +""" + Given an array of integers nums, find the minimum sum of any non-empty sub-array + of nums. + Example + minSubArraySum([2, 3, 4, 1, 2, 4]) == 1 + minSubArraySum([-1, -2, -3]) == -6 + """ + +""" +Ek integer array nums diya gaya hai, usme se kisi bhi non-empty sub-array ka minimum sum dhundho. + Udaharan + minSubArraySum([2, 3, 4, 1, 2, 4]) == 1 + minSubArraySum([-1, -2, -3]) == -6 +""" \ No newline at end of file diff --git a/translation/drafts/115 b/translation/drafts/115 new file mode 100644 index 00000000..054fb002 --- /dev/null +++ b/translation/drafts/115 @@ -0,0 +1,67 @@ +""" + You are given a rectangular grid of wells. Each row represents a single well, + and each 1 in a row represents a single unit of water. + Each well has a corresponding bucket that can be used to extract water from it, + and all buckets have the same capacity. + Your task is to use the buckets to empty the wells. + Output the number of times you need to lower the buckets. + + Example 1: + Input: + grid : [[0,0,1,0], [0,1,0,0], [1,1,1,1]] + bucket_capacity : 1 + Output: 6 + + Example 2: + Input: + grid : [[0,0,1,1], [0,0,0,0], [1,1,1,1], [0,1,1,1]] + bucket_capacity : 2 + Output: 5 + + Example 3: + Input: + grid : [[0,0,0], [0,0,0]] + bucket_capacity : 5 + Output: 0 + + Constraints: + * all wells have the same length + * 1 <= grid.length <= 10^2 + * 1 <= grid[:,1].length <= 10^2 + * grid[i][j] -> 0 | 1 + * 1 <= capacity <= 10 + """ + +""" +Aapko ek rectangular grid di gayi hai jisme wells hain. Har row ek well ko represent karti hai, + aur row me har 1 ek unit water ko represent karta hai. + Har well ke paas ek corresponding bucket hoti hai jiska use usme se water extract karne ke liye kiya ja sakta hai, + aur saare buckets ka capacity same hota hai. + Aapka task hai buckets ka use karke wells ko empty karna. + Output me aapko ye batana hai ki kitni baar aapko buckets ko lower karna padega. + + Example 1: + Input: + grid : [[0,0,1,0], [0,1,0,0], [1,1,1,1]] + bucket_capacity : 1 + Output: 6 + + Example 2: + Input: + grid : [[0,0,1,1], [0,0,0,0], [1,1,1,1], [0,1,1,1]] + bucket_capacity : 2 + Output: 5 + + Example 3: + Input: + grid : [[0,0,0], [0,0,0]] + bucket_capacity : 5 + Output: 0 + + Constraints: + * saare wells ka length same hota hai + * 1 <= grid.length <= 10^2 + * 1 <= grid[:,1].length <= 10^2 + * grid[i][j] -> 0 | 1 + * 1 <= capacity <= 10 +""" \ No newline at end of file diff --git a/translation/drafts/116 b/translation/drafts/116 new file mode 100644 index 00000000..2a6365b7 --- /dev/null +++ b/translation/drafts/116 @@ -0,0 +1,21 @@ +""" + In this Kata, you have to sort an array of non-negative integers according to + number of ones in their binary representation in ascending order. + For similar number of ones, sort based on decimal value. + + It must be implemented like this: + >>> sort_array([1, 5, 2, 3, 4]) == [1, 2, 3, 4, 5] + >>> sort_array([-2, -3, -4, -5, -6]) == [-6, -5, -4, -3, -2] + >>> sort_array([1, 0, 2, 3, 4]) [0, 1, 2, 3, 4] + """ + +""" +Is Kata mein, aapko ek array ko sort karna hai jo non-negative integers ka hoga, + binary representation mein ones ki sankhya ke hisaab se ascending order mein. + Agar ones ki sankhya same ho, toh decimal value ke basis par sort karo. + + Isko aise implement karna hai: + >>> sort_array([1, 5, 2, 3, 4]) == [1, 2, 3, 4, 5] + >>> sort_array([-2, -3, -4, -5, -6]) == [-6, -5, -4, -3, -2] + >>> sort_array([1, 0, 2, 3, 4]) [0, 1, 2, 3, 4] +""" \ No newline at end of file diff --git a/translation/drafts/117 b/translation/drafts/117 new file mode 100644 index 00000000..e96e9c37 --- /dev/null +++ b/translation/drafts/117 @@ -0,0 +1,26 @@ +"""Given a string s and a natural number n, you have been tasked to implement + a function that returns a list of all words from string s that contain exactly + n consonants, in order these words appear in the string s. + If the string s is empty then the function should return an empty list. + Note: you may assume the input string contains only letters and spaces. + Examples: + select_words("Mary had a little lamb", 4) ==> ["little"] + select_words("Mary had a little lamb", 3) ==> ["Mary", "lamb"] + select_words("simple white space", 2) ==> [] + select_words("Hello world", 4) ==> ["world"] + select_words("Uncle sam", 3) ==> ["Uncle"] + """ + +""" +Ek string s aur ek natural number n diya gaya hai, aapko ek function implement karna hai jo + string s se exactly n consonants wale saare words ko ek list mein return kare, jis order mein ye words string s mein appear hote hain. + Agar string s khali hai to function ko ek khali list return karni chahiye. + Note: Aap maan sakte ho ki input string mein sirf letters aur spaces honge. + Examples: + select_words("Mary had a little lamb", 4) ==> ["little"] + select_words("Mary had a little lamb", 3) ==> ["Mary", "lamb"] + select_words("simple white space", 2) ==> [] + select_words("Hello world", 4) ==> ["world"] + select_words("Uncle sam", 3) ==> ["Uncle"] + +""" \ No newline at end of file diff --git a/translation/drafts/118 b/translation/drafts/118 new file mode 100644 index 00000000..40a08902 --- /dev/null +++ b/translation/drafts/118 @@ -0,0 +1,30 @@ +"""You are given a word. Your task is to find the closest vowel that stands between + two consonants from the right side of the word (case sensitive). + + Vowels in the beginning and ending doesn't count. Return empty string if you didn't + find any vowel met the above condition. + + You may assume that the given string contains English letter only. + + Example: + get_closest_vowel("yogurt") ==> "u" + get_closest_vowel("FULL") ==> "U" + get_closest_vowel("quick") ==> "" + get_closest_vowel("ab") ==> "" + """ + +""" +Aapko ek word diya gaya hai. Aapka task hai right side se dekhte hue us vowel ko dhundna hai jo + do consonants ke beech mein hai (case sensitive). + + Shuruat aur ending mein jo vowels hain unka count nahi hoga. Agar aapko koi bhi vowel upar diye gaye + condition ke hisaab se nahi mila toh khali string return karo. + + Aap maan sakte ho ki diya gaya string sirf English letters se bana hua hai. + + Udaharan: + get_closest_vowel("yogurt") ==> "u" + get_closest_vowel("FULL") ==> "U" + get_closest_vowel("quick") ==> "" + get_closest_vowel("ab") ==> "" +""" \ No newline at end of file diff --git a/translation/drafts/119 b/translation/drafts/119 new file mode 100644 index 00000000..4a88c9a1 --- /dev/null +++ b/translation/drafts/119 @@ -0,0 +1,28 @@ +""" + You are given a list of two strings, both strings consist of open + parentheses '(' or close parentheses ')' only. + Your job is to check if it is possible to concatenate the two strings in + some order, that the resulting string will be good. + A string S is considered to be good if and only if all parentheses in S + are balanced. For example: the string '(())()' is good, while the string + '())' is not. + Return 'Yes' if there's a way to make a good string, and return 'No' otherwise. + + Examples: + match_parens(['()(', ')']) == 'Yes' + match_parens([')', ')']) == 'No' + """ + +""" +Aapko do strings ki ek list di gayi hai, dono strings me sirf open + parentheses '(' ya close parentheses ')' hi hote hain. + Aapka kaam ye check karna hai ki kya in dono strings ko kisi order me concatenate karne se + resulting string acchi banegi. + Ek string S tabhi acchi maani jayegi jab usme saare parentheses balanced ho. Jaise ki: string '(())()' acchi hai, jabki string + '())' acchi nahi hai. + Agar acchi string banane ka koi tarika ho to 'Yes' return karo, aur anyatha 'No' return karo. + + Udaharan: + match_parens(['()(', ')']) == 'Yes' + match_parens([')', ')']) == 'No' +""" \ No newline at end of file diff --git a/translation/drafts/12 b/translation/drafts/12 new file mode 100644 index 00000000..d5051f03 --- /dev/null +++ b/translation/drafts/12 @@ -0,0 +1,19 @@ +""" Out of list of strings, return the longest one. Return the first one in case of multiple + strings of the same length. Return None in case the input list is empty. + >>> longest([]) + + >>> longest(['a', 'b', 'c']) + 'a' + >>> longest(['a', 'bb', 'ccc']) + 'ccc' + """ + +""" +String ki list se, sabse lamba string return karo. Agar same length ke multiple strings ho to pehla string return karo. Agar input list khali ho to None return karo. + >>> longest([]) + + >>> longest(['a', 'b', 'c']) + 'a' + >>> longest(['a', 'bb', 'ccc']) + 'ccc' +""" \ No newline at end of file diff --git a/translation/drafts/120 b/translation/drafts/120 new file mode 100644 index 00000000..b33f188c --- /dev/null +++ b/translation/drafts/120 @@ -0,0 +1,49 @@ +""" + Given an array arr of integers and a positive integer k, return a sorted list + of length k with the maximum k numbers in arr. + + Example 1: + + Input: arr = [-3, -4, 5], k = 3 + Output: [-4, -3, 5] + + Example 2: + + Input: arr = [4, -4, 4], k = 2 + Output: [4, 4] + + Example 3: + + Input: arr = [-3, 2, 1, 2, -1, -2, 1], k = 1 + Output: [2] + + Note: + 1. The length of the array will be in the range of [1, 1000]. + 2. The elements in the array will be in the range of [-1000, 1000]. + 3. 0 <= k <= len(arr) + """ + +""" +Ek array arr diya gaya hai integers ka aur ek positive integer k, return karo ek sorted list + lambai k ki maximum k numbers ke saath arr mein. + + Example 1: + + Input: arr = [-3, -4, 5], k = 3 + Output: [-4, -3, 5] + + Example 2: + + Input: arr = [4, -4, 4], k = 2 + Output: [4, 4] + + Example 3: + + Input: arr = [-3, 2, 1, 2, -1, -2, 1], k = 1 + Output: [2] + + Note: + 1. Array ki lambai range mein hogi [1, 1000]. + 2. Array ke elements range mein honge [-1000, 1000]. + 3. 0 <= k <= len(arr) +""" \ No newline at end of file diff --git a/translation/drafts/121 b/translation/drafts/121 new file mode 100644 index 00000000..cf5ae589 --- /dev/null +++ b/translation/drafts/121 @@ -0,0 +1,18 @@ +"""Given a non-empty list of integers, return the sum of all of the odd elements that are in even positions. + + + Examples + solution([5, 8, 7, 1]) ==> 12 + solution([3, 3, 3, 3, 3]) ==> 9 + solution([30, 13, 24, 321]) ==>0 + """ + +""" +Ek non-empty list di gayi hai integers ki, return karo sum of all odd elements jo even positions pe hain. + + Udaharan + solution([5, 8, 7, 1]) ==> 12 + solution([3, 3, 3, 3, 3]) ==> 9 + solution([30, 13, 24, 321]) ==>0 + +""" \ No newline at end of file diff --git a/translation/drafts/122 b/translation/drafts/122 new file mode 100644 index 00000000..5f24a166 --- /dev/null +++ b/translation/drafts/122 @@ -0,0 +1,26 @@ +""" + Given a non-empty array of integers arr and an integer k, return + the sum of the elements with at most two digits from the first k elements of arr. + + Example: + + Input: arr = [111,21,3,4000,5,6,7,8,9], k = 4 + Output: 24 # sum of 21 + 3 + + Constraints: + 1. 1 <= len(arr) <= 100 + 2. 1 <= k <= len(arr) + """ + +""" +Ek non-empty array of integers arr aur ek integer k diya gaya hai, pehle k elements mein se jinme maximum do digits hai unka sum return karo. + + Udaharan: + + Input: arr = [111,21,3,4000,5,6,7,8,9], k = 4 + Output: 24 # sum of 21 + 3 + + Constraints: + 1. 1 <= len(arr) <= 100 + 2. 1 <= k <= len(arr) +""" \ No newline at end of file diff --git a/translation/drafts/123 b/translation/drafts/123 new file mode 100644 index 00000000..5296e89f --- /dev/null +++ b/translation/drafts/123 @@ -0,0 +1,33 @@ +""" + Given a positive integer n, return a sorted list that has the odd numbers in collatz sequence. + + The Collatz conjecture is a conjecture in mathematics that concerns a sequence defined + as follows: start with any positive integer n. Then each term is obtained from the + previous term as follows: if the previous term is even, the next term is one half of + the previous term. If the previous term is odd, the next term is 3 times the previous + term plus 1. The conjecture is that no matter what value of n, the sequence will always reach 1. + + Note: + 1. Collatz(1) is [1]. + 2. returned list sorted in increasing order. + + For example: + get_odd_collatz(5) returns [1, 5] # The collatz sequence for 5 is [5, 16, 8, 4, 2, 1], so the odd numbers are only 1, and 5. + """ + +""" +Diye gaye positive integer n ke liye, ek sorted list return karo jo collatz sequence mein odd numbers ko contain karti ho. + + Collatz conjecture ek mathematics ka conjecture hai jo ek sequence ke baare mein baat karta hai + jise is prakar se define kiya gaya hai: kisi bhi positive integer n se shuru karo. Phir har term ko + previous term se is prakar se prapt kiya jata hai: agar previous term even hai, toh next term + previous term ka aadha hota hai. Agar previous term odd hai, toh next term 3 guna previous + term plus 1 hota hai. Conjecture yeh hai ki chahe n ki value kuch bhi ho, sequence hamesha 1 tak pahunchegi. + + Note: + 1. Collatz(1) is [1]. + 2. returned list badhat kram mein sorted hoti hai. + + Jaise ki: + get_odd_collatz(5) returns [1, 5] # 5 ke liye collatz sequence [5, 16, 8, 4, 2, 1] hai, toh odd numbers sirf 1, aur 5 hai. +""" \ No newline at end of file diff --git a/translation/drafts/124 b/translation/drafts/124 new file mode 100644 index 00000000..98415730 --- /dev/null +++ b/translation/drafts/124 @@ -0,0 +1,41 @@ +"""You have to write a function which validates a given date string and + returns True if the date is valid otherwise False. + The date is valid if all of the following rules are satisfied: + 1. The date string is not empty. + 2. The number of days is not less than 1 or higher than 31 days for months 1,3,5,7,8,10,12. And the number of days is not less than 1 or higher than 30 days for months 4,6,9,11. And, the number of days is not less than 1 or higher than 29 for the month 2. + 3. The months should not be less than 1 or higher than 12. + 4. The date should be in the format: mm-dd-yyyy + + for example: + valid_date('03-11-2000') => True + + valid_date('15-01-2012') => False + + valid_date('04-0-2040') => False + + valid_date('06-04-2020') => True + + valid_date('06/04/2020') => False + """ + +""" +Aapko ek function likhna hai jo diye gaye date string ko validate karta hai aur + agar date valid hai to True return karta hai, nahi to False. + Date tabhi valid hogi jab niche diye gaye saare rules satisfy ho: + 1. Date string khali nahi honi chahiye. + 2. Dinon ki sankhya 1 se kam ya 31 se adhik na ho mahino 1,3,5,7,8,10,12 ke liye. Aur dinon ki sankhya 1 se kam ya 30 se adhik na ho mahino 4,6,9,11 ke liye. Aur, dinon ki sankhya 1 se kam ya 29 se adhik na ho mahine 2 ke liye. + 3. Mahine ki sankhya 1 se kam ya 12 se adhik na ho. + 4. Date ka format aisa hona chahiye: mm-dd-yyyy + + jaise ki: + valid_date('03-11-2000') => True + + valid_date('15-01-2012') => False + + valid_date('04-0-2040') => False + + valid_date('06-04-2020') => True + + valid_date('06/04/2020') => False + +""" \ No newline at end of file diff --git a/translation/drafts/125 b/translation/drafts/125 new file mode 100644 index 00000000..a4589cd9 --- /dev/null +++ b/translation/drafts/125 @@ -0,0 +1,17 @@ +""" + Given a string of words, return a list of words split on whitespace, if no whitespaces exists in the text you + should split on commas ',' if no commas exists you should return the number of lower-case letters with odd order in the + alphabet, ord('a') = 0, ord('b') = 1, ... ord('z') = 25 + Examples + split_words("Hello world!") ➞ ["Hello", "world!"] + split_words("Hello,world!") ➞ ["Hello", "world!"] + split_words("abcdef") == 3 + """ + +""" +Ek string di gayi hai jisme words hain, aapko ek list return karni hai jisme words whitespace par split ho. Agar text me koi whitespace nahi hai toh aapko commas ',' par split karna hai. Agar koi comma bhi nahi hai toh aapko alphabet me odd order wale lower-case letters ki count return karni hai, jaise ki ord('a') = 0, ord('b') = 1, ... ord('z') = 25 + Udaharan + split_words("Hello world!") ➞ ["Hello", "world!"] + split_words("Hello,world!") ➞ ["Hello", "world!"] + split_words("abcdef") == 3 +""" \ No newline at end of file diff --git a/translation/drafts/126 b/translation/drafts/126 new file mode 100644 index 00000000..4fc513ad --- /dev/null +++ b/translation/drafts/126 @@ -0,0 +1,30 @@ +""" + Given a list of numbers, return whether or not they are sorted + in ascending order. If list has more than 1 duplicate of the same + number, return False. Assume no negative numbers and only integers. + + Examples + is_sorted([5]) ➞ True + is_sorted([1, 2, 3, 4, 5]) ➞ True + is_sorted([1, 3, 2, 4, 5]) ➞ False + is_sorted([1, 2, 3, 4, 5, 6]) ➞ True + is_sorted([1, 2, 3, 4, 5, 6, 7]) ➞ True + is_sorted([1, 3, 2, 4, 5, 6, 7]) ➞ False + is_sorted([1, 2, 2, 3, 3, 4]) ➞ True + is_sorted([1, 2, 2, 2, 3, 4]) ➞ False + """ + +""" +Ek numbers ki list di gayi hai, return karo ki kya ye ascending order mein sorted hai ya nahi. Agar list mein ek se jyada same number ke duplicate hain, to False return karo. Maan lo ki koi negative number nahi hai aur sirf integers hain. + +Udaharan +is_sorted([5]) ➞ True +is_sorted([1, 2, 3, 4, 5]) ➞ True +is_sorted([1, 3, 2, 4, 5]) ➞ False +is_sorted([1, 2, 3, 4, 5, 6]) ➞ True +is_sorted([1, 2, 3, 4, 5, 6, 7]) ➞ True +is_sorted([1, 3, 2, 4, 5, 6, 7]) ➞ False +is_sorted([1, 2, 2, 3, 3, 4]) ➞ True +is_sorted([1, 2, 2, 2, 3, 4]) ➞ False + +""" \ No newline at end of file diff --git a/translation/drafts/127 b/translation/drafts/127 new file mode 100644 index 00000000..87a460c0 --- /dev/null +++ b/translation/drafts/127 @@ -0,0 +1,40 @@ +"""You are given two intervals, + where each interval is a pair of integers. For example, interval = (start, end) = (1, 2). + The given intervals are closed which means that the interval (start, end) + includes both start and end. + For each given interval, it is assumed that its start is less or equal its end. + Your task is to determine whether the length of intersection of these two + intervals is a prime number. + Example, the intersection of the intervals (1, 3), (2, 4) is (2, 3) + which its length is 1, which not a prime number. + If the length of the intersection is a prime number, return "YES", + otherwise, return "NO". + If the two intervals don't intersect, return "NO". + + + [input/output] samples: + intersection((1, 2), (2, 3)) ==> "NO" + intersection((-1, 1), (0, 4)) ==> "NO" + intersection((-3, -1), (-5, 5)) ==> "YES" + """ + +""" +Aapko do intervals diye gaye hain, + jahan har interval ek integers ki jodi hoti hai. Jaise ki, interval = (start, end) = (1, 2). + Diye gaye intervals closed hote hain matlab ki interval (start, end) + dono start aur end ko include karta hai. + Har diye gaye interval ke liye, maan liya jata hai ki uska start uske end se kam ya barabar hota hai. + Aapka task hai yeh determine karna ki in dono + intervals ke intersection ka length ek prime number hai ya nahi. + Udaharan, intervals (1, 3), (2, 4) ka intersection (2, 3) hota hai + jiska length 1 hota hai, jo ki ek prime number nahi hai. + Agar intersection ka length ek prime number hai, to "YES" return karo, + nahi to, "NO" return karo. + Agar do intervals intersect nahi karte, to "NO" return karo. + + + [input/output] samples: + intersection((1, 2), (2, 3)) ==> "NO" + intersection((-1, 1), (0, 4)) ==> "NO" + intersection((-3, -1), (-5, 5)) ==> "YES" +""" \ No newline at end of file diff --git a/translation/drafts/128 b/translation/drafts/128 new file mode 100644 index 00000000..206c2e9b --- /dev/null +++ b/translation/drafts/128 @@ -0,0 +1,24 @@ +""" + You are given an array arr of integers and you need to return + sum of magnitudes of integers multiplied by product of all signs + of each number in the array, represented by 1, -1 or 0. + Note: return None for empty arr. + + Example: + >>> prod_signs([1, 2, 2, -4]) == -9 + >>> prod_signs([0, 1]) == 0 + >>> prod_signs([]) == None + """ + +""" +Aapko ek array arr diya gaya hai integers ka aur aapko return karna hai + integers ke magnitudes ka sum jo multiplied hoga har number ke signs ka product se + jo array me diye gaye hain, jo ki 1, -1 ya 0 se represent kiya gaya hai. + Note: Agar arr khali hai to None return karo. + + Udaharan: + >>> prod_signs([1, 2, 2, -4]) == -9 + >>> prod_signs([0, 1]) == 0 + >>> prod_signs([]) == None + +""" \ No newline at end of file diff --git a/translation/drafts/129 b/translation/drafts/129 new file mode 100644 index 00000000..c9855287 --- /dev/null +++ b/translation/drafts/129 @@ -0,0 +1,57 @@ +""" + Given a grid with N rows and N columns (N >= 2) and a positive integer k, + each cell of the grid contains a value. Every integer in the range [1, N * N] + inclusive appears exactly once on the cells of the grid. + + You have to find the minimum path of length k in the grid. You can start + from any cell, and in each step you can move to any of the neighbor cells, + in other words, you can go to cells which share an edge with you current + cell. + Please note that a path of length k means visiting exactly k cells (not + necessarily distinct). + You CANNOT go off the grid. + A path A (of length k) is considered less than a path B (of length k) if + after making the ordered lists of the values on the cells that A and B go + through (let's call them lst_A and lst_B), lst_A is lexicographically less + than lst_B, in other words, there exist an integer index i (1 <= i <= k) + such that lst_A[i] < lst_B[i] and for any j (1 <= j < i) we have + lst_A[j] = lst_B[j]. + It is guaranteed that the answer is unique. + Return an ordered list of the values on the cells that the minimum path go through. + + Examples: + + Input: grid = [ [1,2,3], [4,5,6], [7,8,9]], k = 3 + Output: [1, 2, 1] + + Input: grid = [ [5,9,3], [4,1,6], [7,8,2]], k = 1 + Output: [1] + """ + +""" +Ek grid di gayi hai N rows aur N columns ke saath (N >= 2) aur ek positive integer k, + grid ke har cell me ek value hai. Har integer range [1, N * N] + inclusive grid ke cells par exactly ek baar appear hota hai. + + Aapko grid me length k ki minimum path find karni hai. Aap kisi bhi cell se start + kar sakte ho, aur har step me aap kisi bhi neighbor cell me move kar sakte ho, + dusre shabdo me, aap un cells me ja sakte ho jo aapke current + cell se edge share karte hain. + Dhyan dijiye ki length k ki path ka matlab hai exactly k cells visit karna (not + necessarily distinct). + Aap grid ke bahar nahi ja sakte. + Ek path A (length k ki) ko path B (length k ki) se kam maana jata hai agar + cells par jin values ko A aur B go through karte hain unki ordered lists banane ke baad (unhe hum lst_A aur lst_B kehte hain), lst_A lst_B se lexicographically kam hota hai, dusre shabdo me, ek integer index i exist karta hai (1 <= i <= k) + jahan lst_A[i] < lst_B[i] aur kisi bhi j (1 <= j < i) ke liye hum + lst_A[j] = lst_B[j] rakhte hain. + Yeh guarantee ki gayi hai ki answer unique hoga. + Return karo ek ordered list of the values jin cells se minimum path go through karti hai. + + Examples: + + Input: grid = [ [1,2,3], [4,5,6], [7,8,9]], k = 3 + Output: [1, 2, 1] + + Input: grid = [ [5,9,3], [4,1,6], [7,8,2]], k = 1 + Output: [1] +""" \ No newline at end of file diff --git a/translation/drafts/13 b/translation/drafts/13 new file mode 100644 index 00000000..9feb3021 --- /dev/null +++ b/translation/drafts/13 @@ -0,0 +1,14 @@ +""" Return a greatest common divisor of two integers a and b + >>> greatest_common_divisor(3, 5) + 1 + >>> greatest_common_divisor(25, 15) + 5 + """ + +""" +Do integers a aur b ke greatest common divisor ko return karo + >>> greatest_common_divisor(3, 5) + 1 + >>> greatest_common_divisor(25, 15) + 5 +""" \ No newline at end of file diff --git a/translation/drafts/130 b/translation/drafts/130 new file mode 100644 index 00000000..efd01ec4 --- /dev/null +++ b/translation/drafts/130 @@ -0,0 +1,32 @@ +"""Everyone knows Fibonacci sequence, it was studied deeply by mathematicians in + the last couple centuries. However, what people don't know is Tribonacci sequence. + Tribonacci sequence is defined by the recurrence: + tri(1) = 3 + tri(n) = 1 + n / 2, if n is even. + tri(n) = tri(n - 1) + tri(n - 2) + tri(n + 1), if n is odd. + For example: + tri(2) = 1 + (2 / 2) = 2 + tri(4) = 3 + tri(3) = tri(2) + tri(1) + tri(4) + = 2 + 3 + 3 = 8 + You are given a non-negative integer number n, you have to a return a list of the + first n + 1 numbers of the Tribonacci sequence. + Examples: + tri(3) = [1, 3, 2, 8] + """ + +""" +Sabhi ko Fibonacci sequence ke baare mein pata hai, yeh mathematicians ne pichle kuch sadiyon mein gahrai se adhyayan kiya. Lekin, jo log nahi jaante woh hai Tribonacci sequence. + Tribonacci sequence ko define kiya gaya hai recurrence ke dwara: + tri(1) = 3 + tri(n) = 1 + n / 2, agar n even hai. + tri(n) = tri(n - 1) + tri(n - 2) + tri(n + 1), agar n odd hai. + Jaise ki: + tri(2) = 1 + (2 / 2) = 2 + tri(4) = 3 + tri(3) = tri(2) + tri(1) + tri(4) + = 2 + 3 + 3 = 8 + Aapko ek non-negative integer number n diya jayega, aapko Tribonacci sequence ke pehle n + 1 numbers ka ek list return karna hai. + Examples: + tri(3) = [1, 3, 2, 8] +""" \ No newline at end of file diff --git a/translation/drafts/131 b/translation/drafts/131 new file mode 100644 index 00000000..6a8075cf --- /dev/null +++ b/translation/drafts/131 @@ -0,0 +1,16 @@ +"""Given a positive integer n, return the product of the odd digits. + Return 0 if all digits are even. + For example: + digits(1) == 1 + digits(4) == 0 + digits(235) == 15 + """ + +""" +Ek positive integer n diya gaya hai, odd digits ka product return karo. + Agar saare digits even hain to 0 return karo. + Udaharan ke liye: + digits(1) == 1 + digits(4) == 0 + digits(235) == 15 +""" \ No newline at end of file diff --git a/translation/drafts/132 b/translation/drafts/132 new file mode 100644 index 00000000..848dfd42 --- /dev/null +++ b/translation/drafts/132 @@ -0,0 +1,26 @@ +""" + Create a function that takes a string as input which contains only square brackets. + The function should return True if and only if there is a valid subsequence of brackets + where at least one bracket in the subsequence is nested. + + is_nested('[[]]') ➞ True + is_nested('[]]]]]]][[[[[]') ➞ False + is_nested('[][]') ➞ False + is_nested('[]') ➞ False + is_nested('[[][]]') ➞ True + is_nested('[[]][[') ➞ True + """ + +""" +Ek function banao jo sirf square brackets wala string input ke roop mein leta hai. + Function tabhi True return karega jab valid subsequence of brackets ho + jisme kam se kam ek bracket nested ho. + + is_nested('[[]]') ➞ True + is_nested('[]]]]]]][[[[[]') ➞ False + is_nested('[][]') ➞ False + is_nested('[]') ➞ False + is_nested('[[][]]') ➞ True + is_nested('[[]][[') ➞ True + +""" \ No newline at end of file diff --git a/translation/drafts/133 b/translation/drafts/133 new file mode 100644 index 00000000..f38de25a --- /dev/null +++ b/translation/drafts/133 @@ -0,0 +1,25 @@ +"""You are given a list of numbers. + You need to return the sum of squared numbers in the given list, + round each element in the list to the upper int(Ceiling) first. + Examples: + For lst = [1,2,3] the output should be 14 + For lst = [1,4,9] the output should be 98 + For lst = [1,3,5,7] the output should be 84 + For lst = [1.4,4.2,0] the output should be 29 + For lst = [-2.4,1,1] the output should be 6 + + + """ + +""" +Aapko ek list di gayi hai numbers ki. + Aapko return karna hai sum of squared numbers di gayi list mein, + pehle har element ko list mein upper int(Ceiling) par round karo. + Udaharan: + Agar lst = [1,2,3] hai to output hona chahiye 14 + Agar lst = [1,4,9] hai to output hona chahiye 98 + Agar lst = [1,3,5,7] hai to output hona chahiye 84 + Agar lst = [1.4,4.2,0] hai to output hona chahiye 29 + Agar lst = [-2.4,1,1] hai to output hona chahiye 6 + +""" \ No newline at end of file diff --git a/translation/drafts/134 b/translation/drafts/134 new file mode 100644 index 00000000..235c1d8a --- /dev/null +++ b/translation/drafts/134 @@ -0,0 +1,23 @@ +""" + Create a function that returns True if the last character + of a given string is an alphabetical character and is not + a part of a word, and False otherwise. + Note: "word" is a group of characters separated by space. + + Examples: + check_if_last_char_is_a_letter("apple pie") ➞ False + check_if_last_char_is_a_letter("apple pi e") ➞ True + check_if_last_char_is_a_letter("apple pi e ") ➞ False + check_if_last_char_is_a_letter("") ➞ False + """ + +""" +Ek function banaiye jo True return kare agar diye gaye string ka last character ek alphabetical character ho aur wo kisi word ka hissa na ho, aur anyatha False return kare. + Dhyan de: "word" ek group hota hai characters ka jo space se alag hota hai. + + Udaharan: + check_if_last_char_is_a_letter("apple pie") ➞ False + check_if_last_char_is_a_letter("apple pi e") ➞ True + check_if_last_char_is_a_letter("apple pi e ") ➞ False + check_if_last_char_is_a_letter("") ➞ False +""" \ No newline at end of file diff --git a/translation/drafts/135 b/translation/drafts/135 new file mode 100644 index 00000000..fe1e0b01 --- /dev/null +++ b/translation/drafts/135 @@ -0,0 +1,21 @@ +"""Create a function which returns the largest index of an element which + is not greater than or equal to the element immediately preceding it. If + no such element exists then return -1. The given array will not contain + duplicate values. + + Examples: + can_arrange([1,2,4,3,5]) = 3 + can_arrange([1,2,3]) = -1 + """ + +""" +Ek function banaiye jo ek element ka sabse bada index return kare jo + usse turant pichle element se bada ya barabar nahi hota. Agar + aisa koi element nahi hota hai to -1 return kare. Diye gaye array me + duplicate values nahi hongi. + + Udaharan: + can_arrange([1,2,4,3,5]) = 3 + can_arrange([1,2,3]) = -1 + +""" \ No newline at end of file diff --git a/translation/drafts/136 b/translation/drafts/136 new file mode 100644 index 00000000..3be3ce37 --- /dev/null +++ b/translation/drafts/136 @@ -0,0 +1,21 @@ +""" + Create a function that returns a tuple (a, b), where 'a' is + the largest of negative integers, and 'b' is the smallest + of positive integers in a list. + If there is no negative or positive integers, return them as None. + + Examples: + largest_smallest_integers([2, 4, 1, 3, 5, 7]) == (None, 1) + largest_smallest_integers([]) == (None, None) + largest_smallest_integers([0]) == (None, None) + """ + +""" +Ek function banao jo ek tuple (a, b) return kare, jahan 'a' negative integers ka sabse bada hai, aur 'b' positive integers ka sabse chota hai ek list mein. + Agar koi negative ya positive integers nahi hai, to unhe None ke roop mein return karo. + + Udaharan: + largest_smallest_integers([2, 4, 1, 3, 5, 7]) == (None, 1) + largest_smallest_integers([]) == (None, None) + largest_smallest_integers([0]) == (None, None) +""" \ No newline at end of file diff --git a/translation/drafts/137 b/translation/drafts/137 new file mode 100644 index 00000000..039f9a70 --- /dev/null +++ b/translation/drafts/137 @@ -0,0 +1,22 @@ +""" + Create a function that takes integers, floats, or strings representing + real numbers, and returns the larger variable in its given variable type. + Return None if the values are equal. + Note: If a real number is represented as a string, the floating point might be . or , + + compare_one(1, 2.5) ➞ 2.5 + compare_one(1, "2,3") ➞ "2,3" + compare_one("5,1", "6") ➞ "6" + compare_one("1", 1) ➞ None + """ + +""" +Ek function banao jo integers, floats, ya strings jo real numbers ko represent karte hain, leta hai aur usme se bada variable uske diye gaye variable type mein return karta hai. + Agar values equal hain to None return karo. + Dhyan do: Agar ek real number ko string ke roop mein represent kiya gaya hai, to floating point . ya , ho sakta hai. + + compare_one(1, 2.5) ➞ 2.5 + compare_one(1, "2,3") ➞ "2,3" + compare_one("5,1", "6") ➞ "6" + compare_one("1", 1) ➞ None +""" \ No newline at end of file diff --git a/translation/drafts/138 b/translation/drafts/138 new file mode 100644 index 00000000..5edc0581 --- /dev/null +++ b/translation/drafts/138 @@ -0,0 +1,15 @@ +"""Evaluate whether the given number n can be written as the sum of exactly 4 positive even numbers + Example + is_equal_to_sum_even(4) == False + is_equal_to_sum_even(6) == False + is_equal_to_sum_even(8) == True + """ + +""" +Evaluate karo ki diya gaya number n kya exactly 4 positive even numbers ka sum ho sakta hai + Udaharan + is_equal_to_sum_even(4) == False + is_equal_to_sum_even(6) == False + is_equal_to_sum_even(8) == True + +""" \ No newline at end of file diff --git a/translation/drafts/139 b/translation/drafts/139 new file mode 100644 index 00000000..91310274 --- /dev/null +++ b/translation/drafts/139 @@ -0,0 +1,24 @@ +"""The Brazilian factorial is defined as: + brazilian_factorial(n) = n! * (n-1)! * (n-2)! * ... * 1! + where n > 0 + + For example: + >>> special_factorial(4) + 288 + + The function will receive an integer as input and should return the special + factorial of this integer. + """ + +""" +Brazilian factorial is defined as: + brazilian_factorial(n) = n! * (n-1)! * (n-2)! * ... * 1! + jaha n > 0 + + Jaise ki: + >>> special_factorial(4) + 288 + + Ye function ek integer input ke roop me lega aur is integer ka special + factorial return karega. +""" \ No newline at end of file diff --git a/translation/drafts/14 b/translation/drafts/14 new file mode 100644 index 00000000..c7661b29 --- /dev/null +++ b/translation/drafts/14 @@ -0,0 +1,10 @@ +""" Return list of all prefixes from shortest to longest of the input string + >>> all_prefixes('abc') + ['a', 'ab', 'abc'] + """ + +""" +Input string ke saare prefixes ko shortest se longest tak ki list return karo + >>> all_prefixes('abc') + ['a', 'ab', 'abc'] +""" \ No newline at end of file diff --git a/translation/drafts/140 b/translation/drafts/140 new file mode 100644 index 00000000..c0dbc7f9 --- /dev/null +++ b/translation/drafts/140 @@ -0,0 +1,21 @@ +""" + Given a string text, replace all spaces in it with underscores, + and if a string has more than 2 consecutive spaces, + then replace all consecutive spaces with - + + fix_spaces("Example") == "Example" + fix_spaces("Example 1") == "Example_1" + fix_spaces(" Example 2") == "_Example_2" + fix_spaces(" Example 3") == "_Example-3" + """ + +""" +Diye gaye string text mein, saare spaces ko underscores se replace karo, + aur agar ek string mein 2 se zyada consecutive spaces ho, + toh saare consecutive spaces ko - se replace karo. + + fix_spaces("Example") == "Example" + fix_spaces("Example 1") == "Example_1" + fix_spaces(" Example 2") == "_Example_2" + fix_spaces(" Example 3") == "_Example-3" +""" \ No newline at end of file diff --git a/translation/drafts/141 b/translation/drafts/141 new file mode 100644 index 00000000..ef8f1248 --- /dev/null +++ b/translation/drafts/141 @@ -0,0 +1,26 @@ +"""Create a function which takes a string representing a file's name, and returns + 'Yes' if the the file's name is valid, and returns 'No' otherwise. + A file's name is considered to be valid if and only if all the following conditions + are met: + - There should not be more than three digits ('0'-'9') in the file's name. + - The file's name contains exactly one dot '.' + - The substring before the dot should not be empty, and it starts with a letter from + the latin alphapet ('a'-'z' and 'A'-'Z'). + - The substring after the dot should be one of these: ['txt', 'exe', 'dll'] + Examples: + file_name_check("example.txt") # => 'Yes' + file_name_check("1example.dll") # => 'No' (the name should start with a latin alphapet letter) + """ + +""" +Ek function banao jo ek string leta hai jisme file ka naam hota hai, aur return karta hai + 'Yes' agar file ka naam valid hai, aur 'No' agar nahi. + Ek file ka naam tabhi maana jayega jab saare neeche diye gaye conditions meet ho: + - File ke naam me teen se zyada digits ('0'-'9') nahi hone chahiye. + - File ke naam me sirf ek dot '.' hona chahiye. + - Dot se pehle ka substring khali nahi hona chahiye, aur uska shuruat latin alphabet ('a'-'z' aur 'A'-'Z') se hona chahiye. + - Dot ke baad ka substring inme se ek hona chahiye: ['txt', 'exe', 'dll'] + Examples: + file_name_check("example.txt") # => 'Yes' + file_name_check("1example.dll") # => 'No' (naam latin alphabet letter se shuru hona chahiye) +""" \ No newline at end of file diff --git a/translation/drafts/142 b/translation/drafts/142 new file mode 100644 index 00000000..94d48f84 --- /dev/null +++ b/translation/drafts/142 @@ -0,0 +1,23 @@ +"""" + This function will take a list of integers. For all entries in the list, the function shall square the integer entry if its index is a + multiple of 3 and will cube the integer entry if its index is a multiple of 4 and not a multiple of 3. The function will not + change the entries in the list whose indexes are not a multiple of 3 or 4. The function shall then return the sum of all entries. + + Examples: + For lst = [1,2,3] the output should be 6 + For lst = [] the output should be 0 + For lst = [-1,-5,2,-1,-5] the output should be -126 + """ + +""" +" + Ye function ek integers ki list lega. List ke saare entries ke liye, function integer entry ko square karega agar uska index 3 ka + multiple hai aur cube karega agar uska index 4 ka multiple hai aur 3 ka multiple nahi hai. Function un entries ko change nahi + karega jinki indexes 3 ya 4 ka multiple nahi hai. Phir function saare entries ka sum return karega. + + Examples: + Agar lst = [1,2,3] hai to output 6 hona chahiye + Agar lst = [] hai to output 0 hona chahiye + Agar lst = [-1,-5,2,-1,-5] hai to output -126 hona chahiye + +""" \ No newline at end of file diff --git a/translation/drafts/143 b/translation/drafts/143 new file mode 100644 index 00000000..07cc57f9 --- /dev/null +++ b/translation/drafts/143 @@ -0,0 +1,40 @@ +""" + You are given a string representing a sentence, + the sentence contains some words separated by a space, + and you have to return a string that contains the words from the original sentence, + whose lengths are prime numbers, + the order of the words in the new string should be the same as the original one. + + Example 1: + Input: sentence = "This is a test" + Output: "is" + + Example 2: + Input: sentence = "lets go for swimming" + Output: "go for" + + Constraints: + * 1 <= len(sentence) <= 100 + * sentence contains only letters + """ + +""" +Aapko ek string di gayi hai jo ek sentence ko represent karti hai, + sentence mein kuch words hote hain jo space se separate hote hain, + aur aapko ek string return karni hai jo original sentence ke words ko contain karti hai, + jinki lengths prime numbers hain, + nayi string mein words ka order original wale ke jaisa hi hona chahiye. + + Example 1: + Input: sentence = "This is a test" + Output: "is" + + Example 2: + Input: sentence = "lets go for swimming" + Output: "go for" + + Constraints: + * 1 <= len(sentence) <= 100 + * sentence sirf letters contain karti hai + +""" \ No newline at end of file diff --git a/translation/drafts/144 b/translation/drafts/144 new file mode 100644 index 00000000..3d668d67 --- /dev/null +++ b/translation/drafts/144 @@ -0,0 +1,24 @@ +"""Your task is to implement a function that will simplify the expression + x * n. The function returns True if x * n evaluates to a whole number and False + otherwise. Both x and n, are string representation of a fraction, and have the following format, + / where both numerator and denominator are positive whole numbers. + + You can assume that x, and n are valid fractions, and do not have zero as denominator. + + simplify("1/5", "5/1") = True + simplify("1/6", "2/1") = False + simplify("7/10", "10/2") = False + """ + +""" +Aapka task hai ek function implement karna jo expression + x * n ko simplify karega. Yeh function True return karega agar x * n ka evaluation ek whole number hota hai aur False + otherwise. Dono x aur n, fraction ka string representation hai, aur inka format aisa hota hai, + / jahan dono numerator aur denominator positive whole numbers hote hain. + + Aap maan sakte hain ki x, aur n valid fractions hain, aur inka denominator zero nahi hota. + + simplify("1/5", "5/1") = True + simplify("1/6", "2/1") = False + simplify("7/10", "10/2") = False +""" \ No newline at end of file diff --git a/translation/drafts/145 b/translation/drafts/145 new file mode 100644 index 00000000..10fae065 --- /dev/null +++ b/translation/drafts/145 @@ -0,0 +1,20 @@ +""" + Write a function which sorts the given list of integers + in ascending order according to the sum of their digits. + Note: if there are several items with similar sum of their digits, + order them based on their index in original list. + + For example: + >>> order_by_points([1, 11, -1, -11, -12]) == [-1, -11, 1, -12, 11] + >>> order_by_points([]) == [] + """ + +""" +Ek function likho jo diye gaye integers ki list ko unke digits ka sum ke hisaab se ascending order mein sort kare. + Dhyan do: agar kuch items ke digits ka sum similar ho, + toh unhe original list ke index ke basis par order karo. + + Jaise ki: + >>> order_by_points([1, 11, -1, -11, -12]) == [-1, -11, 1, -12, 11] + >>> order_by_points([]) == [] +""" \ No newline at end of file diff --git a/translation/drafts/146 b/translation/drafts/146 new file mode 100644 index 00000000..f7214cec --- /dev/null +++ b/translation/drafts/146 @@ -0,0 +1,16 @@ +"""Write a function that takes an array of numbers as input and returns + the number of elements in the array that are greater than 10 and both + first and last digits of a number are odd (1, 3, 5, 7, 9). + For example: + specialFilter([15, -73, 14, -15]) => 1 + specialFilter([33, -2, -3, 45, 21, 109]) => 2 + """ + +""" +Ek function likho jo numbers ki array ko input ke roop mein leta hai aur return karta hai + array ke kitne elements 10 se bade hai aur jinke + pehla aur aakhri digit dono odd hai (1, 3, 5, 7, 9). + Jaise ki: + specialFilter([15, -73, 14, -15]) => 1 + specialFilter([33, -2, -3, 45, 21, 109]) => 2 +""" \ No newline at end of file diff --git a/translation/drafts/147 b/translation/drafts/147 new file mode 100644 index 00000000..ad9b7cbc --- /dev/null +++ b/translation/drafts/147 @@ -0,0 +1,27 @@ +""" + You are given a positive integer n. You have to create an integer array a of length n. + For each i (1 ≤ i ≤ n), the value of a[i] = i * i - i + 1. + Return the number of triples (a[i], a[j], a[k]) of a where i < j < k, + and a[i] + a[j] + a[k] is a multiple of 3. + + Example : + Input: n = 5 + Output: 1 + Explanation: + a = [1, 3, 7, 13, 21] + The only valid triple is (1, 7, 13). + """ + +""" +Aapko ek positive integer n diya gaya hai. Aapko ek integer array a banani hai jiski length n ho. + Har i (1 ≤ i ≤ n) ke liye, a[i] ka value hoga i * i - i + 1. + Return karo triples (a[i], a[j], a[k]) ka number jahan a[i] + a[j] + a[k] 3 ka multiple ho aur i < j < k ho. + + Udaharan : + Input: n = 5 + Output: 1 + Explanation: + a = [1, 3, 7, 13, 21] + Sirf ek valid triple hai (1, 7, 13). + +""" \ No newline at end of file diff --git a/translation/drafts/148 b/translation/drafts/148 new file mode 100644 index 00000000..1664dbcd --- /dev/null +++ b/translation/drafts/148 @@ -0,0 +1,26 @@ +""" + There are eight planets in our solar system: the closerst to the Sun + is Mercury, the next one is Venus, then Earth, Mars, Jupiter, Saturn, + Uranus, Neptune. + Write a function that takes two planet names as strings planet1 and planet2. + The function should return a tuple containing all planets whose orbits are + located between the orbit of planet1 and the orbit of planet2, sorted by + the proximity to the sun. + The function should return an empty tuple if planet1 or planet2 + are not correct planet names. + Examples + bf("Jupiter", "Neptune") ==> ("Saturn", "Uranus") + bf("Earth", "Mercury") ==> ("Venus") + bf("Mercury", "Uranus") ==> ("Venus", "Earth", "Mars", "Jupiter", "Saturn") + """ + +""" +Hamare solar system mein aath grah hain: sabse paas Suraj ke Mercury hai, uske baad Venus, phir Earth, Mars, Jupiter, Saturn, Uranus, Neptune. +Ek function likho jo do grahon ke naam planet1 aur planet2 ko strings ke roop mein leta hai. +Function ko ek tuple return karna chahiye jisme saare grah hain jinke orbits planet1 aur planet2 ke orbit ke beech mein hote hain, Suraj ke nazdeek hone ke hisaab se sort kiye gaye. +Agar planet1 ya planet2 sahi grah ke naam nahi hain to function ko ek khali tuple return karna chahiye. +Udaharan +bf("Jupiter", "Neptune") ==> ("Saturn", "Uranus") +bf("Earth", "Mercury") ==> ("Venus") +bf("Mercury", "Uranus") ==> ("Venus", "Earth", "Mars", "Jupiter", "Saturn") +""" \ No newline at end of file diff --git a/translation/drafts/149 b/translation/drafts/149 new file mode 100644 index 00000000..ad50701f --- /dev/null +++ b/translation/drafts/149 @@ -0,0 +1,30 @@ +"""Write a function that accepts a list of strings as a parameter, + deletes the strings that have odd lengths from it, + and returns the resulted list with a sorted order, + The list is always a list of strings and never an array of numbers, + and it may contain duplicates. + The order of the list should be ascending by length of each word, and you + should return the list sorted by that rule. + If two words have the same length, sort the list alphabetically. + The function should return a list of strings in sorted order. + You may assume that all words will have the same length. + For example: + assert list_sort(["aa", "a", "aaa"]) => ["aa"] + assert list_sort(["ab", "a", "aaa", "cd"]) => ["ab", "cd"] + """ + +""" +Ek function likho jo strings ki list ko parameter ke roop mein accept karta hai, + usme se odd lengths wale strings ko delete karta hai, + aur resulted list ko sorted order mein return karta hai, + List hamesha strings ki list hoti hai aur kabhi numbers ki array nahi hoti, + aur usme duplicates ho sakte hain. + List ka order har word ki length ke hisaab se ascending hona chahiye, aur aapko + us rule ke hisaab se list ko sorted return karna chahiye. + Agar do words ki length same ho, to list ko alphabetically sort karo. + Function ko sorted order mein strings ki list return karni chahiye. + Aap maan sakte ho ki sabhi words ki length same hogi. + Jaise ki: + assert list_sort(["aa", "a", "aaa"]) => ["aa"] + assert list_sort(["ab", "a", "aaa", "cd"]) => ["ab", "cd"] +""" \ No newline at end of file diff --git a/translation/drafts/15 b/translation/drafts/15 new file mode 100644 index 00000000..8df2f5ba --- /dev/null +++ b/translation/drafts/15 @@ -0,0 +1,14 @@ +""" Return a string containing space-delimited numbers starting from 0 upto n inclusive. + >>> string_sequence(0) + '0' + >>> string_sequence(5) + '0 1 2 3 4 5' + """ + +""" +Ek string return karo jisme 0 se lekar n tak ke numbers space-delimited honge. + >>> string_sequence(0) + '0' + >>> string_sequence(5) + '0 1 2 3 4 5' +""" \ No newline at end of file diff --git a/translation/drafts/150 b/translation/drafts/150 new file mode 100644 index 00000000..b8eb611f --- /dev/null +++ b/translation/drafts/150 @@ -0,0 +1,17 @@ +"""A simple program which should return the value of x if n is + a prime number and should return the value of y otherwise. + + Examples: + for x_or_y(7, 34, 12) == 34 + for x_or_y(15, 8, 5) == 5 + + """ + +""" +Ek simple program jo n ek prime number hone par x ka value return karega aur anyatha y ka value return karega. + + Udaharan: + for x_or_y(7, 34, 12) == 34 + for x_or_y(15, 8, 5) == 5 + +""" \ No newline at end of file diff --git a/translation/drafts/151 b/translation/drafts/151 new file mode 100644 index 00000000..584c0d4b --- /dev/null +++ b/translation/drafts/151 @@ -0,0 +1,23 @@ +""" + Given a list of numbers, return the sum of squares of the numbers + in the list that are odd. Ignore numbers that are negative or not integers. + + double_the_difference([1, 3, 2, 0]) == 1 + 9 + 0 + 0 = 10 + double_the_difference([-1, -2, 0]) == 0 + double_the_difference([9, -2]) == 81 + double_the_difference([0]) == 0 + + If the input list is empty, return 0. + """ + +""" +Diye gaye numbers ki list mein se, odd numbers ke squares ka sum return karo. + Negative ya non-integer numbers ko ignore karo. + + double_the_difference([1, 3, 2, 0]) == 1 + 9 + 0 + 0 = 10 + double_the_difference([-1, -2, 0]) == 0 + double_the_difference([9, -2]) == 81 + double_the_difference([0]) == 0 + + Agar input list khali ho, to 0 return karo. +""" \ No newline at end of file diff --git a/translation/drafts/152 b/translation/drafts/152 new file mode 100644 index 00000000..ed95faf1 --- /dev/null +++ b/translation/drafts/152 @@ -0,0 +1,28 @@ +"""I think we all remember that feeling when the result of some long-awaited + event is finally known. The feelings and thoughts you have at that moment are + definitely worth noting down and comparing. + Your task is to determine if a person correctly guessed the results of a number of matches. + You are given two arrays of scores and guesses of equal length, where each index shows a match. + Return an array of the same length denoting how far off each guess was. If they have guessed correctly, + the value is 0, and if not, the value is the absolute difference between the guess and the score. + + + example: + + compare([1,2,3,4,5,1],[1,2,3,4,2,-2]) -> [0,0,0,0,3,3] + compare([0,5,0,0,0,4],[4,1,1,0,0,-2]) -> [4,4,1,0,0,6] + """ + +""" +Mujhe lagta hai hum sabko woh ehsaas yaad hoga jab kisi besabri se intezaar karne wale event ka result finally pata chalta hai. Us samay jo aapke feelings aur vichar hote hain, unhe note down karna aur compare karna zaroori hota hai. + Aapka task hai yeh determine karna ki kya ek vyakti ne kisi matches ke results ko sahi tara se guess kiya hai ya nahi. + Aapko do arrays diye jayenge scores aur guesses ke, jinka length equal hoga, jahan har index ek match ko dikhata hai. + Wapas ek array return karo jiska length same ho, jo denote karta hai ki har guess kitna off tha. Agar unhone sahi guess kiya hai, + toh value 0 hogi, aur agar nahi, toh value guess aur score ke beech ka absolute difference hoga. + + + Udaharan: + + compare([1,2,3,4,5,1],[1,2,3,4,2,-2]) -> [0,0,0,0,3,3] + compare([0,5,0,0,0,4],[4,1,1,0,0,-2]) -> [4,4,1,0,0,6] +""" \ No newline at end of file diff --git a/translation/drafts/153 b/translation/drafts/153 new file mode 100644 index 00000000..0fab5e25 --- /dev/null +++ b/translation/drafts/153 @@ -0,0 +1,35 @@ +"""You will be given the name of a class (a string) and a list of extensions. + The extensions are to be used to load additional classes to the class. The + strength of the extension is as follows: Let CAP be the number of the uppercase + letters in the extension's name, and let SM be the number of lowercase letters + in the extension's name, the strength is given by the fraction CAP - SM. + You should find the strongest extension and return a string in this + format: ClassName.StrongestExtensionName. + If there are two or more extensions with the same strength, you should + choose the one that comes first in the list. + For example, if you are given "Slices" as the class and a list of the + extensions: ['SErviNGSliCes', 'Cheese', 'StuFfed'] then you should + return 'Slices.SErviNGSliCes' since 'SErviNGSliCes' is the strongest extension + (its strength is -1). + Example: + for Strongest_Extension('my_class', ['AA', 'Be', 'CC']) == 'my_class.AA' + """ + +""" +Aapko ek class ka naam (ek string) aur ek extensions ki list di jayegi. + Extensions ko additional classes ko class me load karne ke liye use kiya jata hai. Extension ki + strength is prakar hai: Maan lijiye CAP extension ke naam me uppercase + letters ki sankhya hai, aur SM extension ke naam me lowercase letters + ki sankhya hai, strength ka nirdharan CAP - SM ke fraction se hota hai. + Aapko sabse strong extension dhundhni hai aur is + format me ek string return karni hai: ClassName.StrongestExtensionName. + Agar do ya do se adhik extensions ki strength same ho, to aapko + list me sabse pehle aane wale extension ko chunna chahiye. + Udaharan ke liye, agar aapko "Slices" class di gayi hai aur extensions ki list me + hai: ['SErviNGSliCes', 'Cheese', 'StuFfed'] to aapko + 'Slices.SErviNGSliCes' return karna chahiye kyunki 'SErviNGSliCes' sabse strong extension + hai (iska strength -1 hai). + Udaharan: + for Strongest_Extension('my_class', ['AA', 'Be', 'CC']) == 'my_class.AA' + +""" \ No newline at end of file diff --git a/translation/drafts/154 b/translation/drafts/154 new file mode 100644 index 00000000..ef54d87d --- /dev/null +++ b/translation/drafts/154 @@ -0,0 +1,20 @@ +"""You are given 2 words. You need to return True if the second word or any of its rotations is a substring in the first word + cycpattern_check("abcd","abd") => False + cycpattern_check("hello","ell") => True + cycpattern_check("whassup","psus") => False + cycpattern_check("abab","baa") => True + cycpattern_check("efef","eeff") => False + cycpattern_check("himenss","simen") => True + + """ + +""" +Aapko 2 words diye gaye hain. Aapko True return karna hai agar dusra word ya uske kisi bhi rotation ko pehle word ke substring mein milta hai + cycpattern_check("abcd","abd") => False + cycpattern_check("hello","ell") => True + cycpattern_check("whassup","psus") => False + cycpattern_check("abab","baa") => True + cycpattern_check("efef","eeff") => False + cycpattern_check("himenss","simen") => True + +""" \ No newline at end of file diff --git a/translation/drafts/155 b/translation/drafts/155 new file mode 100644 index 00000000..d8e24ccc --- /dev/null +++ b/translation/drafts/155 @@ -0,0 +1,14 @@ +"""Given an integer. return a tuple that has the number of even and odd digits respectively. + + Example: + even_odd_count(-12) ==> (1, 1) + even_odd_count(123) ==> (1, 2) + """ + +""" +Ek integer diya gaya hai. Ek tuple return karo jo even aur odd digits ki sankhya ko kramashah darshata hai. + + Udaharan: + even_odd_count(-12) ==> (1, 1) + even_odd_count(123) ==> (1, 2) +""" \ No newline at end of file diff --git a/translation/drafts/156 b/translation/drafts/156 new file mode 100644 index 00000000..f13a7eb3 --- /dev/null +++ b/translation/drafts/156 @@ -0,0 +1,21 @@ +""" + Given a positive integer, obtain its roman numeral equivalent as a string, + and return it in lowercase. + Restrictions: 1 <= num <= 1000 + + Examples: + >>> int_to_mini_roman(19) == 'xix' + >>> int_to_mini_roman(152) == 'clii' + >>> int_to_mini_roman(426) == 'cdxxvi' + """ + +""" +Diye gaye positive integer ko uska roman numeral equivalent ke roop mein string ke roop mein prapt karo, + aur ise lowercase mein return karo. + Restrictions: 1 <= num <= 1000 + + Udaharan: + >>> int_to_mini_roman(19) == 'xix' + >>> int_to_mini_roman(152) == 'clii' + >>> int_to_mini_roman(426) == 'cdxxvi' +""" \ No newline at end of file diff --git a/translation/drafts/157 b/translation/drafts/157 new file mode 100644 index 00000000..769165c3 --- /dev/null +++ b/translation/drafts/157 @@ -0,0 +1,17 @@ +""" + Given the lengths of the three sides of a triangle. Return True if the three + sides form a right-angled triangle, False otherwise. + A right-angled triangle is a triangle in which one angle is right angle or + 90 degree. + Example: + right_angle_triangle(3, 4, 5) == True + right_angle_triangle(1, 2, 3) == False + """ + +""" +Trikon ke teeno sides ke lengths diye gaye hain. Agar ye teen sides ek samkon trikon banate hain to True return karo, nahi to False. + Ek samkon trikon woh hota hai jisme ek kon samkon ya 90 degree hota hai. + Udaharan: + right_angle_triangle(3, 4, 5) == True + right_angle_triangle(1, 2, 3) == False +""" \ No newline at end of file diff --git a/translation/drafts/158 b/translation/drafts/158 new file mode 100644 index 00000000..fb5a4906 --- /dev/null +++ b/translation/drafts/158 @@ -0,0 +1,18 @@ +"""Write a function that accepts a list of strings. + The list contains different words. Return the word with maximum number + of unique characters. If multiple strings have maximum number of unique + characters, return the one which comes first in lexicographical order. + + find_max(["name", "of", "string"]) == "string" + find_max(["name", "enam", "game"]) == "enam" + find_max(["aaaaaaa", "bb" ,"cc"]) == ""aaaaaaa" + """ + +""" +Ek function likho jo strings ki list ko accept karta hai. + List mein alag alag shabd hote hain. Unique characters ki maximum number wala shabd return karo. Agar multiple strings mein maximum number of unique characters ho, toh lexicographical order mein sabse pehle aane wala shabd return karo. + + find_max(["name", "of", "string"]) == "string" + find_max(["name", "enam", "game"]) == "enam" + find_max(["aaaaaaa", "bb" ,"cc"]) == "aaaaaaa" +""" \ No newline at end of file diff --git a/translation/drafts/159 b/translation/drafts/159 new file mode 100644 index 00000000..3a421fdd --- /dev/null +++ b/translation/drafts/159 @@ -0,0 +1,57 @@ +""" + You're a hungry rabbit, and you already have eaten a certain number of carrots, + but now you need to eat more carrots to complete the day's meals. + you should return an array of [ total number of eaten carrots after your meals, + the number of carrots left after your meals ] + if there are not enough remaining carrots, you will eat all remaining carrots, but will still be hungry. + + Example: + * eat(5, 6, 10) -> [11, 4] + * eat(4, 8, 9) -> [12, 1] + * eat(1, 10, 10) -> [11, 0] + * eat(2, 11, 5) -> [7, 0] + + Variables: + @number : integer + the number of carrots that you have eaten. + @need : integer + the number of carrots that you need to eat. + @remaining : integer + the number of remaining carrots thet exist in stock + + Constrain: + * 0 <= number <= 1000 + * 0 <= need <= 1000 + * 0 <= remaining <= 1000 + + Have fun :) + """ + +""" +Tum ek bhukha khargosh ho, aur tumne pehle hi kuch gajar kha liye hain, + lekin ab tumhe din bhar ke bhojan ko pura karne ke liye aur gajar khane ki zarurat hai. + tumhe ek array return karna chahiye jisme [ tumhare bhojan ke baad khaye gaye total gajar, + bhojan ke baad bache hue gajar ] ho. + Agar bache hue gajar kafi na ho, to tum saare bache hue gajar kha loge, lekin phir bhi bhukha rahoge. + + Udaharan: + * eat(5, 6, 10) -> [11, 4] + * eat(4, 8, 9) -> [12, 1] + * eat(1, 10, 10) -> [11, 0] + * eat(2, 11, 5) -> [7, 0] + + Variables: + @number : integer + gajar jo tumne pehle kha li hain. + @need : integer + gajar jo tumhe ab khane ki zarurat hai. + @remaining : integer + stock mein bache hue gajar ki sankhya + + Constrain: + * 0 <= number <= 1000 + * 0 <= need <= 1000 + * 0 <= remaining <= 1000 + + Maza karo :) +""" \ No newline at end of file diff --git a/translation/drafts/16 b/translation/drafts/16 new file mode 100644 index 00000000..41cf72f1 --- /dev/null +++ b/translation/drafts/16 @@ -0,0 +1,14 @@ +""" Given a string, find out how many distinct characters (regardless of case) does it consist of + >>> count_distinct_characters('xyzXYZ') + 3 + >>> count_distinct_characters('Jerry') + 4 + """ + +""" +Ek string di gayi hai, pata karo ki usme kitne alag-alag characters (case ki parwah kiye bina) hain + >>> count_distinct_characters('xyzXYZ') + 3 + >>> count_distinct_characters('Jerry') + 4 +""" \ No newline at end of file diff --git a/translation/drafts/160 b/translation/drafts/160 new file mode 100644 index 00000000..bc7e5721 --- /dev/null +++ b/translation/drafts/160 @@ -0,0 +1,49 @@ +""" + Given two lists operator, and operand. The first list has basic algebra operations, and + the second list is a list of integers. Use the two given lists to build the algebric + expression and return the evaluation of this expression. + + The basic algebra operations: + Addition ( + ) + Subtraction ( - ) + Multiplication ( * ) + Floor division ( // ) + Exponentiation ( ** ) + + Example: + operator['+', '*', '-'] + array = [2, 3, 4, 5] + result = 2 + 3 * 4 - 5 + => result = 9 + + Note: + The length of operator list is equal to the length of operand list minus one. + Operand is a list of of non-negative integers. + Operator list has at least one operator, and operand list has at least two operands. + + """ + +""" +Do lists diye gaye hain, operator aur operand. Pehla list basic algebra operations ka hai, aur + dusra list integers ka hai. Diye gaye do lists ka use karke algebraic + expression banaye aur is expression ka evaluation return kare. + + Basic algebra operations: + Addition ( + ) + Subtraction ( - ) + Multiplication ( * ) + Floor division ( // ) + Exponentiation ( ** ) + + Udaharan: + operator['+', '*', '-'] + array = [2, 3, 4, 5] + result = 2 + 3 * 4 - 5 + => result = 9 + + Dhyan de: + Operator list ki length operand list ki length se ek kam hoti hai. + Operand ek non-negative integers ki list hoti hai. + Operator list me kam se kam ek operator hota hai, aur operand list me kam se kam do operands hote hain. + +""" \ No newline at end of file diff --git a/translation/drafts/161 b/translation/drafts/161 new file mode 100644 index 00000000..066f5be4 --- /dev/null +++ b/translation/drafts/161 @@ -0,0 +1,22 @@ +"""You are given a string s. + if s[i] is a letter, reverse its case from lower to upper or vise versa, + otherwise keep it as it is. + If the string contains no letters, reverse the string. + The function should return the resulted string. + Examples + solve("1234") = "4321" + solve("ab") = "AB" + solve("#a@C") = "#A@c" + """ + +""" +Aapko ek string s di gayi hai. + Agar s[i] ek letter hai, to uska case reverse karo lower se upper ya vise versa, + nahi to waise hi rakho jaisa hai. + Agar string me koi letters nahi hai, to string ko reverse karo. + Function ko resulted string return karni chahiye. + Udaharan + solve("1234") = "4321" + solve("ab") = "AB" + solve("#a@C") = "#A@c" +""" \ No newline at end of file diff --git a/translation/drafts/162 b/translation/drafts/162 new file mode 100644 index 00000000..e159af42 --- /dev/null +++ b/translation/drafts/162 @@ -0,0 +1,13 @@ +""" + Given a string 'text', return its md5 hash equivalent string. + If 'text' is an empty string, return None. + + >>> string_to_md5('Hello world') == '3e25960a79dbc69b674cd4ec67a72c62' + """ + +""" +Ek string 'text' di gayi hai, uska md5 hash equivalent string return karo. + Agar 'text' ek khali string hai, to None return karo. + + >>> string_to_md5('Hello world') == '3e25960a79dbc69b674cd4ec67a72c62' +""" \ No newline at end of file diff --git a/translation/drafts/163 b/translation/drafts/163 new file mode 100644 index 00000000..44a5a6af --- /dev/null +++ b/translation/drafts/163 @@ -0,0 +1,18 @@ +""" + Given two positive integers a and b, return the even digits between a + and b, in ascending order. + + For example: + generate_integers(2, 8) => [2, 4, 6, 8] + generate_integers(8, 2) => [2, 4, 6, 8] + generate_integers(10, 14) => [] + """ + +""" +Do positive integers a aur b diye gaye hain, a aur b ke beech ke even digits ko ascending order mein return karo. + + Jaise ki: + generate_integers(2, 8) => [2, 4, 6, 8] + generate_integers(8, 2) => [2, 4, 6, 8] + generate_integers(10, 14) => [] +""" \ No newline at end of file diff --git a/translation/drafts/17 b/translation/drafts/17 new file mode 100644 index 00000000..8282b83d --- /dev/null +++ b/translation/drafts/17 @@ -0,0 +1,26 @@ +""" Input to this function is a string representing musical notes in a special ASCII format. + Your task is to parse this string and return list of integers corresponding to how many beats does each + not last. + + Here is a legend: + 'o' - whole note, lasts four beats + 'o|' - half note, lasts two beats + '.|' - quater note, lasts one beat + + >>> parse_music('o o| .| o| o| .| .| .| .| o o') + [4, 2, 1, 2, 2, 1, 1, 1, 1, 4, 4] + """ + +""" +Is function ka input ek string hota hai jo musical notes ko ek special ASCII format mein represent karta hai. + Aapka kaam hai is string ko parse karna aur ek integers ki list return karni hai jo correspond karti hai ki har note kitne beats tak chalta hai. + + Yaha ek legend hai: + 'o' - whole note, jo four beats tak chalta hai + 'o|' - half note, jo two beats tak chalta hai + '.|' - quater note, jo one beat tak chalta hai + + >>> parse_music('o o| .| o| o| .| .| .| .| o o') + [4, 2, 1, 2, 2, 1, 1, 1, 1, 4, 4] + +""" \ No newline at end of file diff --git a/translation/drafts/18 b/translation/drafts/18 new file mode 100644 index 00000000..81ddacce --- /dev/null +++ b/translation/drafts/18 @@ -0,0 +1,18 @@ +""" Find how many times a given substring can be found in the original string. Count overlaping cases. + >>> how_many_times('', 'a') + 0 + >>> how_many_times('aaa', 'a') + 3 + >>> how_many_times('aaaa', 'aa') + 3 + """ + +""" +Mool string mein diye gaye substring ko kitni baar mila ja sakta hai, yeh find karo. Overlapping cases ko bhi count karo. + >>> how_many_times('', 'a') + 0 + >>> how_many_times('aaa', 'a') + 3 + >>> how_many_times('aaaa', 'aa') + 3 +""" \ No newline at end of file diff --git a/translation/drafts/19 b/translation/drafts/19 new file mode 100644 index 00000000..e0c2131f --- /dev/null +++ b/translation/drafts/19 @@ -0,0 +1,14 @@ +""" Input is a space-delimited string of numberals from 'zero' to 'nine'. + Valid choices are 'zero', 'one', 'two', 'three', 'four', 'five', 'six', 'seven', 'eight' and 'nine'. + Return the string with numbers sorted from smallest to largest + >>> sort_numbers('three one five') + 'one three five' + """ + +""" +Input ek space-delimited string hoti hai jisme 'zero' se 'nine' tak ke numberals hote hain. + Valid choices 'zero', 'one', 'two', 'three', 'four', 'five', 'six', 'seven', 'eight' aur 'nine' hain. + Return karo string ko jisme numbers smallest se largest tak sorted honge + >>> sort_numbers('three one five') + 'one three five' +""" \ No newline at end of file diff --git a/translation/drafts/2 b/translation/drafts/2 new file mode 100644 index 00000000..d9ff5353 --- /dev/null +++ b/translation/drafts/2 @@ -0,0 +1,17 @@ +""" Given a positive floating point number, it can be decomposed into + and integer part (largest integer smaller than given number) and decimals + (leftover part always smaller than 1). + + Return the decimal part of the number. + >>> truncate_number(3.5) + 0.5 + """ + +""" +Diye gaye positive floating point number ko hum integer part (diye gaye number se chota sabse bada integer) aur decimals + (hamesha 1 se chota bacha hua part) mein decompose kar sakte hain. + + Number ka decimal part return karo. + >>> truncate_number(3.5) + 0.5 +""" \ No newline at end of file diff --git a/translation/drafts/20 b/translation/drafts/20 new file mode 100644 index 00000000..7194035f --- /dev/null +++ b/translation/drafts/20 @@ -0,0 +1,15 @@ +""" From a supplied list of numbers (of length at least two) select and return two that are the closest to each + other and return them in order (smaller number, larger number). + >>> find_closest_elements([1.0, 2.0, 3.0, 4.0, 5.0, 2.2]) + (2.0, 2.2) + >>> find_closest_elements([1.0, 2.0, 3.0, 4.0, 5.0, 2.0]) + (2.0, 2.0) + """ + +""" +Diye gaye numbers ki list se (jo ki kam se kam do numbers ki honi chahiye) do aise numbers chun ke return karo jo ek dusre ke sabse kareeb ho aur unhe order mein return karo (chota number, bada number). + >>> find_closest_elements([1.0, 2.0, 3.0, 4.0, 5.0, 2.2]) + (2.0, 2.2) + >>> find_closest_elements([1.0, 2.0, 3.0, 4.0, 5.0, 2.0]) + (2.0, 2.0) +""" \ No newline at end of file diff --git a/translation/drafts/21 b/translation/drafts/21 new file mode 100644 index 00000000..b6931140 --- /dev/null +++ b/translation/drafts/21 @@ -0,0 +1,12 @@ +""" Given list of numbers (of at least two elements), apply a linear transform to that list, + such that the smallest number will become 0 and the largest will become 1 + >>> rescale_to_unit([1.0, 2.0, 3.0, 4.0, 5.0]) + [0.0, 0.25, 0.5, 0.75, 1.0] + """ + +""" +Diye gaye numbers ki list (kam se kam do elements ki) par ek linear transform apply karo, + aisa ki sabse chota number 0 ban jaye aur sabse bada number 1 ban jaye + >>> rescale_to_unit([1.0, 2.0, 3.0, 4.0, 5.0]) + [0.0, 0.25, 0.5, 0.75, 1.0] +""" \ No newline at end of file diff --git a/translation/drafts/22 b/translation/drafts/22 new file mode 100644 index 00000000..9d22b232 --- /dev/null +++ b/translation/drafts/22 @@ -0,0 +1,14 @@ +""" Filter given list of any python values only for integers + >>> filter_integers(['a', 3.14, 5]) + [5] + >>> filter_integers([1, 2, 3, 'abc', {}, []]) + [1, 2, 3] + """ + +""" +Diye gaye python values ki list ko sirf integers ke liye filter karo + >>> filter_integers(['a', 3.14, 5]) + [5] + >>> filter_integers([1, 2, 3, 'abc', {}, []]) + [1, 2, 3] +""" \ No newline at end of file diff --git a/translation/drafts/23 b/translation/drafts/23 new file mode 100644 index 00000000..b4686728 --- /dev/null +++ b/translation/drafts/23 @@ -0,0 +1,14 @@ +""" Return length of given string + >>> strlen('') + 0 + >>> strlen('abc') + 3 + """ + +""" +Diye gaye string ki length return karo + >>> strlen('') + 0 + >>> strlen('abc') + 3 +""" \ No newline at end of file diff --git a/translation/drafts/24 b/translation/drafts/24 new file mode 100644 index 00000000..4dbd2183 --- /dev/null +++ b/translation/drafts/24 @@ -0,0 +1,10 @@ +""" For a given number n, find the largest number that divides n evenly, smaller than n + >>> largest_divisor(15) + 5 + """ + +""" +Diye gaye number n ke liye, sabse bada number dhundo jo n ko evenly divide karta ho, jo ki n se chota ho. + >>> largest_divisor(15) + 5 +""" \ No newline at end of file diff --git a/translation/drafts/25 b/translation/drafts/25 new file mode 100644 index 00000000..b90cbfe7 --- /dev/null +++ b/translation/drafts/25 @@ -0,0 +1,22 @@ +""" Return list of prime factors of given integer in the order from smallest to largest. + Each of the factors should be listed number of times corresponding to how many times it appeares in factorization. + Input number should be equal to the product of all factors + >>> factorize(8) + [2, 2, 2] + >>> factorize(25) + [5, 5] + >>> factorize(70) + [2, 5, 7] + """ + +""" +Diye gaye integer ke prime factors ki list return karo, order chhote se bade tak hona chahiye. + Har ek factor ko utni baar list mein hona chahiye jitni baar wo factorization mein aata hai. + Input number sabhi factors ka product hona chahiye + >>> factorize(8) + [2, 2, 2] + >>> factorize(25) + [5, 5] + >>> factorize(70) + [2, 5, 7] +""" \ No newline at end of file diff --git a/translation/drafts/26 b/translation/drafts/26 new file mode 100644 index 00000000..0214348b --- /dev/null +++ b/translation/drafts/26 @@ -0,0 +1,12 @@ +""" From a list of integers, remove all elements that occur more than once. + Keep order of elements left the same as in the input. + >>> remove_duplicates([1, 2, 3, 2, 4]) + [1, 3, 4] + """ + +""" +Ek integers ki list se, saare elements hata do jo ek se zyada baar occur karte hain. + Bache hue elements ka order input ke jaisa hi rakho. + >>> remove_duplicates([1, 2, 3, 2, 4]) + [1, 3, 4] +""" \ No newline at end of file diff --git a/translation/drafts/27 b/translation/drafts/27 new file mode 100644 index 00000000..506b00f5 --- /dev/null +++ b/translation/drafts/27 @@ -0,0 +1,10 @@ +""" For a given string, flip lowercase characters to uppercase and uppercase to lowercase. + >>> flip_case('Hello') + 'hELLO' + """ + +""" +Diye gaye string ke liye, lowercase characters ko uppercase me aur uppercase characters ko lowercase me flip karo. + >>> flip_case('Hello') + 'hELLO' +""" \ No newline at end of file diff --git a/translation/drafts/28 b/translation/drafts/28 new file mode 100644 index 00000000..aaf11641 --- /dev/null +++ b/translation/drafts/28 @@ -0,0 +1,14 @@ +""" Concatenate list of strings into a single string + >>> concatenate([]) + '' + >>> concatenate(['a', 'b', 'c']) + 'abc' + """ + +""" +Strings ki list ko ek single string mein jodo + >>> concatenate([]) + '' + >>> concatenate(['a', 'b', 'c']) + 'abc' +""" \ No newline at end of file diff --git a/translation/drafts/29 b/translation/drafts/29 new file mode 100644 index 00000000..d92a1758 --- /dev/null +++ b/translation/drafts/29 @@ -0,0 +1,14 @@ +""" Filter an input list of strings only for ones that start with a given prefix. + >>> filter_by_prefix([], 'a') + [] + >>> filter_by_prefix(['abc', 'bcd', 'cde', 'array'], 'a') + ['abc', 'array'] + """ + +""" +Diye gaye prefix se shuru hone wale strings ke liye input list ko filter karo. + >>> filter_by_prefix([], 'a') + [] + >>> filter_by_prefix(['abc', 'bcd', 'cde', 'array'], 'a') + ['abc', 'array'] +""" \ No newline at end of file diff --git a/translation/drafts/3 b/translation/drafts/3 new file mode 100644 index 00000000..8f98a7c0 --- /dev/null +++ b/translation/drafts/3 @@ -0,0 +1,16 @@ +""" You're given a list of deposit and withdrawal operations on a bank account that starts with + zero balance. Your task is to detect if at any point the balance of account fallls below zero, and + at that point function should return True. Otherwise it should return False. + >>> below_zero([1, 2, 3]) + False + >>> below_zero([1, 2, -4, 5]) + True + """ + +""" +Aapko ek list di gayi hai jisme bank account ke deposit aur withdrawal operations hain, jiska shuruat zero balance se hota hai. Aapka task hai detect karna ki kya kisi bhi point pe account ka balance zero se kam ho jata hai, aur us point pe function ko True return karna chahiye. Varna ise False return karna chahiye. + >>> below_zero([1, 2, 3]) + False + >>> below_zero([1, 2, -4, 5]) + True +""" \ No newline at end of file diff --git a/translation/drafts/30 b/translation/drafts/30 new file mode 100644 index 00000000..f6f8fcfc --- /dev/null +++ b/translation/drafts/30 @@ -0,0 +1,14 @@ +"""Return only positive numbers in the list. + >>> get_positive([-1, 2, -4, 5, 6]) + [2, 5, 6] + >>> get_positive([5, 3, -5, 2, -3, 3, 9, 0, 123, 1, -10]) + [5, 3, 2, 3, 9, 123, 1] + """ + +""" +List mein se sirf positive numbers return karo. + >>> get_positive([-1, 2, -4, 5, 6]) + [2, 5, 6] + >>> get_positive([5, 3, -5, 2, -3, 3, 9, 0, 123, 1, -10]) + [5, 3, 2, 3, 9, 123, 1] +""" \ No newline at end of file diff --git a/translation/drafts/31 b/translation/drafts/31 new file mode 100644 index 00000000..393982c4 --- /dev/null +++ b/translation/drafts/31 @@ -0,0 +1,34 @@ +"""Return true if a given number is prime, and false otherwise. + >>> is_prime(6) + False + >>> is_prime(101) + True + >>> is_prime(11) + True + >>> is_prime(13441) + True + >>> is_prime(61) + True + >>> is_prime(4) + False + >>> is_prime(1) + False + """ + +""" +Agar diya gaya number prime hai to true return karo, aur anyatha false. + >>> is_prime(6) + False + >>> is_prime(101) + True + >>> is_prime(11) + True + >>> is_prime(13441) + True + >>> is_prime(61) + True + >>> is_prime(4) + False + >>> is_prime(1) + False +""" \ No newline at end of file diff --git a/translation/drafts/32 b/translation/drafts/32 new file mode 100644 index 00000000..35bdbb98 --- /dev/null +++ b/translation/drafts/32 @@ -0,0 +1,9 @@ +""" + Evaluates polynomial with coefficients xs at point x. + return xs[0] + xs[1] * x + xs[1] * x^2 + .... xs[n] * x^n + """ + +""" +Polynomial ko evaluate karta hai coefficients xs ke saath point x par. + return xs[0] + xs[1] * x + xs[1] * x^2 + .... xs[n] * x^n +""" \ No newline at end of file diff --git a/translation/drafts/33 b/translation/drafts/33 new file mode 100644 index 00000000..b6a07147 --- /dev/null +++ b/translation/drafts/33 @@ -0,0 +1,18 @@ +"""This function takes a list l and returns a list l' such that + l' is identical to l in the indicies that are not divisible by three, while its values at the indicies that are divisible by three are equal + to the values of the corresponding indicies of l, but sorted. + >>> sort_third([1, 2, 3]) + [1, 2, 3] + >>> sort_third([5, 6, 3, 4, 8, 9, 2]) + [2, 6, 3, 4, 8, 9, 5] + """ + +""" +Yeh function ek list l leta hai aur ek list l' return karta hai aisa ki + l' wahi hai jaisa l hai un indices par jo three se divisible nahi hote, jabki uske values un indices par jo three se divisible hote hain, wahi hoti hain + jaisi corresponding indices ki values l ki hoti hain, lekin sorted. + >>> sort_third([1, 2, 3]) + [1, 2, 3] + >>> sort_third([5, 6, 3, 4, 8, 9, 2]) + [2, 6, 3, 4, 8, 9, 5] +""" \ No newline at end of file diff --git a/translation/drafts/34 b/translation/drafts/34 new file mode 100644 index 00000000..e5504bf9 --- /dev/null +++ b/translation/drafts/34 @@ -0,0 +1,10 @@ +"""Return sorted unique elements in a list + >>> unique([5, 3, 5, 2, 3, 3, 9, 0, 123]) + [0, 2, 3, 5, 9, 123] + """ + +""" +Ek list mein sorted unique elements return karo + >>> unique([5, 3, 5, 2, 3, 3, 9, 0, 123]) + [0, 2, 3, 5, 9, 123] +""" \ No newline at end of file diff --git a/translation/drafts/35 b/translation/drafts/35 new file mode 100644 index 00000000..b984ca0f --- /dev/null +++ b/translation/drafts/35 @@ -0,0 +1,15 @@ +"""Return maximum element in the list. + >>> max_element([1, 2, 3]) + 3 + >>> max_element([5, 3, -5, 2, -3, 3, 9, 0, 123, 1, -10]) + 123 + """ + +""" +List mein se maximum element return karo. + >>> max_element([1, 2, 3]) + 3 + >>> max_element([5, 3, -5, 2, -3, 3, 9, 0, 123, 1, -10]) + 123 + +""" \ No newline at end of file diff --git a/translation/drafts/36 b/translation/drafts/36 new file mode 100644 index 00000000..8da097d1 --- /dev/null +++ b/translation/drafts/36 @@ -0,0 +1,18 @@ +"""Return the number of times the digit 7 appears in integers less than n which are divisible by 11 or 13. + >>> fizz_buzz(50) + 0 + >>> fizz_buzz(78) + 2 + >>> fizz_buzz(79) + 3 + """ + +""" +n se kam integers mein, jo 11 ya 13 se divisible hain, usme digit 7 kitni baar aata hai, uska count return karo. + >>> fizz_buzz(50) + 0 + >>> fizz_buzz(78) + 2 + >>> fizz_buzz(79) + 3 +""" \ No newline at end of file diff --git a/translation/drafts/37 b/translation/drafts/37 new file mode 100644 index 00000000..71301121 --- /dev/null +++ b/translation/drafts/37 @@ -0,0 +1,18 @@ +"""This function takes a list l and returns a list l' such that + l' is identical to l in the odd indicies, while its values at the even indicies are equal + to the values of the even indicies of l, but sorted. + >>> sort_even([1, 2, 3]) + [1, 2, 3] + >>> sort_even([5, 6, 3, 4]) + [3, 6, 5, 4] + """ + +""" +Yeh function ek list l leta hai aur ek list l' return karta hai aisa ki + l' l ke odd indices ke saath identical hota hai, jabki uske even indices ke values + l ke even indices ke values ke barabar hoti hai, lekin sorted. + >>> sort_even([1, 2, 3]) + [1, 2, 3] + >>> sort_even([5, 6, 3, 4]) + [3, 6, 5, 4] +""" \ No newline at end of file diff --git a/translation/drafts/38 b/translation/drafts/38 new file mode 100644 index 00000000..e7c7f4f2 --- /dev/null +++ b/translation/drafts/38 @@ -0,0 +1,7 @@ +""" + returns encoded string by cycling groups of three characters. + """ + +""" +teen characters ke groups ko cycle karke encoded string return karta hai. +""" \ No newline at end of file diff --git a/translation/drafts/39 b/translation/drafts/39 new file mode 100644 index 00000000..70cd3386 --- /dev/null +++ b/translation/drafts/39 @@ -0,0 +1,27 @@ +""" + prime_fib returns n-th number that is a Fibonacci number and it's also prime. + >>> prime_fib(1) + 2 + >>> prime_fib(2) + 3 + >>> prime_fib(3) + 5 + >>> prime_fib(4) + 13 + >>> prime_fib(5) + 89 + """ + +""" +prime_fib woh n-th number return karta hai jo ek Fibonacci number bhi hai aur prime number bhi. + >>> prime_fib(1) + 2 + >>> prime_fib(2) + 3 + >>> prime_fib(3) + 5 + >>> prime_fib(4) + 13 + >>> prime_fib(5) + 89 +""" \ No newline at end of file diff --git a/translation/drafts/4 b/translation/drafts/4 new file mode 100644 index 00000000..b9f2bf99 --- /dev/null +++ b/translation/drafts/4 @@ -0,0 +1,16 @@ +""" For a given list of input numbers, calculate Mean Absolute Deviation + around the mean of this dataset. + Mean Absolute Deviation is the average absolute difference between each + element and a centerpoint (mean in this case): + MAD = average | x - x_mean | + >>> mean_absolute_deviation([1.0, 2.0, 3.0, 4.0]) + 1.0 + """ + +""" +Diye gaye input numbers ki list ke liye, dataset ka Mean Absolute Deviation calculate karo. + Mean Absolute Deviation woh average absolute difference hota hai jo har element aur ek centerpoint (is case mein mean) ke beech hota hai: + MAD = average | x - x_mean | + >>> mean_absolute_deviation([1.0, 2.0, 3.0, 4.0]) + 1.0 +""" \ No newline at end of file diff --git a/translation/drafts/40 b/translation/drafts/40 new file mode 100644 index 00000000..daf5031e --- /dev/null +++ b/translation/drafts/40 @@ -0,0 +1,34 @@ +""" + triples_sum_to_zero takes a list of integers as an input. + it returns True if there are three distinct elements in the list that + sum to zero, and False otherwise. + + >>> triples_sum_to_zero([1, 3, 5, 0]) + False + >>> triples_sum_to_zero([1, 3, -2, 1]) + True + >>> triples_sum_to_zero([1, 2, 3, 7]) + False + >>> triples_sum_to_zero([2, 4, -5, 3, 9, 7]) + True + >>> triples_sum_to_zero([1]) + False + """ + +""" +triples_sum_to_zero ek integers ki list ko input ke roop mein leta hai. + Yeh True return karta hai agar list mein teen distinct elements hain jo + zero ke barabar sum karte hain, aur anyatha False. + + >>> triples_sum_to_zero([1, 3, 5, 0]) + False + >>> triples_sum_to_zero([1, 3, -2, 1]) + True + >>> triples_sum_to_zero([1, 2, 3, 7]) + False + >>> triples_sum_to_zero([2, 4, -5, 3, 9, 7]) + True + >>> triples_sum_to_zero([1]) + False + +""" \ No newline at end of file diff --git a/translation/drafts/41 b/translation/drafts/41 new file mode 100644 index 00000000..27644877 --- /dev/null +++ b/translation/drafts/41 @@ -0,0 +1,23 @@ +""" + Imagine a road that's a perfectly straight infinitely long line. + n cars are driving left to right; simultaneously, a different set of n cars + are driving right to left. The two sets of cars start out being very far from + each other. All cars move in the same speed. Two cars are said to collide + when a car that's moving left to right hits a car that's moving right to left. + However, the cars are infinitely sturdy and strong; as a result, they continue moving + in their trajectory as if they did not collide. + + This function outputs the number of such collisions. + """ + +""" +Socho ek road ko jo ek perfectly straight aur infinitely long line hai. + n cars left se right ki taraf ja rahi hain; saath hi, ek alag set of n cars + right se left ki taraf ja rahi hain. Dono set of cars shuruat mein ek dusre se bahut door hoti hain. + Saari cars same speed mein move karti hain. Do cars tab takraati hain jab + ek car jo left se right ja rahi hoti hai, right se left ja rahi car se takraati hai. + Lekin, cars infinitely sturdy aur strong hoti hain; isliye, unka movement + unke trajectory mein continue hota hai jaise ki unka collision hua hi nahi. + + Ye function aise collisions ki sankhya output karta hai. +""" \ No newline at end of file diff --git a/translation/drafts/42 b/translation/drafts/42 new file mode 100644 index 00000000..d992746a --- /dev/null +++ b/translation/drafts/42 @@ -0,0 +1,14 @@ +"""Return list with elements incremented by 1. + >>> incr_list([1, 2, 3]) + [2, 3, 4] + >>> incr_list([5, 3, 5, 2, 3, 3, 9, 0, 123]) + [6, 4, 6, 3, 4, 4, 10, 1, 124] + """ + +""" +Elements ko 1 se badhakar wala list return karo. + >>> incr_list([1, 2, 3]) + [2, 3, 4] + >>> incr_list([5, 3, 5, 2, 3, 3, 9, 0, 123]) + [6, 4, 6, 3, 4, 4, 10, 1, 124] +""" \ No newline at end of file diff --git a/translation/drafts/43 b/translation/drafts/43 new file mode 100644 index 00000000..3d4813d2 --- /dev/null +++ b/translation/drafts/43 @@ -0,0 +1,32 @@ +""" + pairs_sum_to_zero takes a list of integers as an input. + it returns True if there are two distinct elements in the list that + sum to zero, and False otherwise. + >>> pairs_sum_to_zero([1, 3, 5, 0]) + False + >>> pairs_sum_to_zero([1, 3, -2, 1]) + False + >>> pairs_sum_to_zero([1, 2, 3, 7]) + False + >>> pairs_sum_to_zero([2, 4, -5, 3, 5, 7]) + True + >>> pairs_sum_to_zero([1]) + False + """ + +""" +pairs_sum_to_zero ek integers ki list ko input ke roop mein leta hai. + Yeh True return karta hai agar list mein do alag elements hote hain jo + zero ke barabar sum karte hain, aur anyatha False. + >>> pairs_sum_to_zero([1, 3, 5, 0]) + False + >>> pairs_sum_to_zero([1, 3, -2, 1]) + False + >>> pairs_sum_to_zero([1, 2, 3, 7]) + False + >>> pairs_sum_to_zero([2, 4, -5, 3, 5, 7]) + True + >>> pairs_sum_to_zero([1]) + False + +""" \ No newline at end of file diff --git a/translation/drafts/44 b/translation/drafts/44 new file mode 100644 index 00000000..cf31a952 --- /dev/null +++ b/translation/drafts/44 @@ -0,0 +1,22 @@ +"""Change numerical base of input number x to base. + return string representation after the conversion. + base numbers are less than 10. + >>> change_base(8, 3) + '22' + >>> change_base(8, 2) + '1000' + >>> change_base(7, 2) + '111' + """ + +""" +Input number x ka numerical base, base me badal do. + Conversion ke baad string representation return karo. + Base numbers 10 se kam hote hain. + >>> change_base(8, 3) + '22' + >>> change_base(8, 2) + '1000' + >>> change_base(7, 2) + '111' +""" \ No newline at end of file diff --git a/translation/drafts/45 b/translation/drafts/45 new file mode 100644 index 00000000..f80a62f6 --- /dev/null +++ b/translation/drafts/45 @@ -0,0 +1,10 @@ +"""Given length of a side and high return area for a triangle. + >>> triangle_area(5, 3) + 7.5 + """ + +""" +Ek side ki length aur height di gayi ho to, triangle ka area return karo. + >>> triangle_area(5, 3) + 7.5 +""" \ No newline at end of file diff --git a/translation/drafts/46 b/translation/drafts/46 new file mode 100644 index 00000000..92a58b9c --- /dev/null +++ b/translation/drafts/46 @@ -0,0 +1,31 @@ +"""The Fib4 number sequence is a sequence similar to the Fibbonacci sequnece that's defined as follows: + fib4(0) -> 0 + fib4(1) -> 0 + fib4(2) -> 2 + fib4(3) -> 0 + fib4(n) -> fib4(n-1) + fib4(n-2) + fib4(n-3) + fib4(n-4). + Please write a function to efficiently compute the n-th element of the fib4 number sequence. Do not use recursion. + >>> fib4(5) + 4 + >>> fib4(6) + 8 + >>> fib4(7) + 14 + """ + +""" +Fib4 number sequence ek sequence hai jo Fibbonacci sequence ke saman hai, jo is prakar se define kiya gaya hai: + fib4(0) -> 0 + fib4(1) -> 0 + fib4(2) -> 2 + fib4(3) -> 0 + fib4(n) -> fib4(n-1) + fib4(n-2) + fib4(n-3) + fib4(n-4). + Kripya ek function likhe jo efficiently fib4 number sequence ka n-th element compute kare. Recursion ka use na kare. + >>> fib4(5) + 4 + >>> fib4(6) + 8 + >>> fib4(7) + 14 + +""" \ No newline at end of file diff --git a/translation/drafts/47 b/translation/drafts/47 new file mode 100644 index 00000000..b4855df6 --- /dev/null +++ b/translation/drafts/47 @@ -0,0 +1,14 @@ +"""Return median of elements in the list l. + >>> median([3, 1, 2, 4, 5]) + 3 + >>> median([-10, 4, 6, 1000, 10, 20]) + 15.0 + """ + +""" +List l ke elements ka median return karo. + >>> median([3, 1, 2, 4, 5]) + 3 + >>> median([-10, 4, 6, 1000, 10, 20]) + 15.0 +""" \ No newline at end of file diff --git a/translation/drafts/48 b/translation/drafts/48 new file mode 100644 index 00000000..85c6b7ad --- /dev/null +++ b/translation/drafts/48 @@ -0,0 +1,23 @@ +""" + Checks if given string is a palindrome + >>> is_palindrome('') + True + >>> is_palindrome('aba') + True + >>> is_palindrome('aaaaa') + True + >>> is_palindrome('zbcd') + False + """ + +""" +Diye gaye string ko check karta hai ki kya yeh palindrome hai + >>> is_palindrome('') + True + >>> is_palindrome('aba') + True + >>> is_palindrome('aaaaa') + True + >>> is_palindrome('zbcd') + False +""" \ No newline at end of file diff --git a/translation/drafts/49 b/translation/drafts/49 new file mode 100644 index 00000000..e2f302ea --- /dev/null +++ b/translation/drafts/49 @@ -0,0 +1,26 @@ +"""Return 2^n modulo p (be aware of numerics). + >>> modp(3, 5) + 3 + >>> modp(1101, 101) + 2 + >>> modp(0, 101) + 1 + >>> modp(3, 11) + 8 + >>> modp(100, 101) + 1 + """ + +""" +2^n modulo p return karo (numerics ka dhyan rakho). + >>> modp(3, 5) + 3 + >>> modp(1101, 101) + 2 + >>> modp(0, 101) + 1 + >>> modp(3, 11) + 8 + >>> modp(100, 101) + 1 +""" \ No newline at end of file diff --git a/translation/drafts/5 b/translation/drafts/5 new file mode 100644 index 00000000..f52e1309 --- /dev/null +++ b/translation/drafts/5 @@ -0,0 +1,14 @@ +""" Insert a number 'delimeter' between every two consecutive elements of input list `numbers' + >>> intersperse([], 4) + [] + >>> intersperse([1, 2, 3], 4) + [1, 4, 2, 4, 3] + """ + +""" +Input list `numbers' ke har do consecutive elements ke beech mein ek number 'delimeter' insert karo. + >>> intersperse([], 4) + [] + >>> intersperse([1, 2, 3], 4) + [1, 4, 2, 4, 3] +""" \ No newline at end of file diff --git a/translation/drafts/50 b/translation/drafts/50 new file mode 100644 index 00000000..67d9b248 --- /dev/null +++ b/translation/drafts/50 @@ -0,0 +1,7 @@ +""" + returns encoded string by shifting every character by 5 in the alphabet. + """ + +""" +Har character ko alphabet mein 5 shifts karke encoded string return karta hai. +""" \ No newline at end of file diff --git a/translation/drafts/51 b/translation/drafts/51 new file mode 100644 index 00000000..7af38e96 --- /dev/null +++ b/translation/drafts/51 @@ -0,0 +1,31 @@ +""" + remove_vowels is a function that takes string and returns string without vowels. + >>> remove_vowels('') + '' + >>> remove_vowels("abcdef\nghijklm") + 'bcdf\nghjklm' + >>> remove_vowels('abcdef') + 'bcdf' + >>> remove_vowels('aaaaa') + '' + >>> remove_vowels('aaBAA') + 'B' + >>> remove_vowels('zbcd') + 'zbcd' + """ + +""" +remove_vowels ek function hai jo string leta hai aur vowels ke bina string return karta hai. + >>> remove_vowels('') + '' + >>> remove_vowels("abcdef\nghijklm") + 'bcdf\nghjklm' + >>> remove_vowels('abcdef') + 'bcdf' + >>> remove_vowels('aaaaa') + '' + >>> remove_vowels('aaBAA') + 'B' + >>> remove_vowels('zbcd') + 'zbcd' +""" \ No newline at end of file diff --git a/translation/drafts/52 b/translation/drafts/52 new file mode 100644 index 00000000..6079f35c --- /dev/null +++ b/translation/drafts/52 @@ -0,0 +1,14 @@ +"""Return True if all numbers in the list l are below threshold t. + >>> below_threshold([1, 2, 4, 10], 100) + True + >>> below_threshold([1, 20, 4, 10], 5) + False + """ + +""" +Agar list l mein saare numbers threshold t se kam hai to True return karo. + >>> below_threshold([1, 2, 4, 10], 100) + True + >>> below_threshold([1, 20, 4, 10], 5) + False +""" \ No newline at end of file diff --git a/translation/drafts/53 b/translation/drafts/53 new file mode 100644 index 00000000..334fcc32 --- /dev/null +++ b/translation/drafts/53 @@ -0,0 +1,14 @@ +"""Add two numbers x and y + >>> add(2, 3) + 5 + >>> add(5, 7) + 12 + """ + +""" +Do numbers x aur y ko jodo + >>> add(2, 3) + 5 + >>> add(5, 7) + 12 +""" \ No newline at end of file diff --git a/translation/drafts/54 b/translation/drafts/54 new file mode 100644 index 00000000..5099f577 --- /dev/null +++ b/translation/drafts/54 @@ -0,0 +1,31 @@ +""" + Check if two words have the same characters. + >>> same_chars('eabcdzzzz', 'dddzzzzzzzddeddabc') + True + >>> same_chars('abcd', 'dddddddabc') + True + >>> same_chars('dddddddabc', 'abcd') + True + >>> same_chars('eabcd', 'dddddddabc') + False + >>> same_chars('abcd', 'dddddddabce') + False + >>> same_chars('eabcdzzzz', 'dddzzzzzzzddddabc') + False + """ + +""" +Dekho ki do shabd me same characters hai ya nahi. + >>> same_chars('eabcdzzzz', 'dddzzzzzzzddeddabc') + True + >>> same_chars('abcd', 'dddddddabc') + True + >>> same_chars('dddddddabc', 'abcd') + True + >>> same_chars('eabcd', 'dddddddabc') + False + >>> same_chars('abcd', 'dddddddabce') + False + >>> same_chars('eabcdzzzz', 'dddzzzzzzzddddabc') + False +""" \ No newline at end of file diff --git a/translation/drafts/55 b/translation/drafts/55 new file mode 100644 index 00000000..37c0d947 --- /dev/null +++ b/translation/drafts/55 @@ -0,0 +1,18 @@ +"""Return n-th Fibonacci number. + >>> fib(10) + 55 + >>> fib(1) + 1 + >>> fib(8) + 21 + """ + +""" +n-th Fibonacci number return karo. + >>> fib(10) + 55 + >>> fib(1) + 1 + >>> fib(8) + 21 +""" \ No newline at end of file diff --git a/translation/drafts/56 b/translation/drafts/56 new file mode 100644 index 00000000..1d1d3d21 --- /dev/null +++ b/translation/drafts/56 @@ -0,0 +1,26 @@ +""" brackets is a string of "<" and ">". + return True if every opening bracket has a corresponding closing bracket. + + >>> correct_bracketing("<") + False + >>> correct_bracketing("<>") + True + >>> correct_bracketing("<<><>>") + True + >>> correct_bracketing("><<>") + False + """ + +""" +brackets ek string hai "<" aur ">" ka. + return True agar har opening bracket ka ek corresponding closing bracket ho. + + >>> correct_bracketing("<") + False + >>> correct_bracketing("<>") + True + >>> correct_bracketing("<<><>>") + True + >>> correct_bracketing("><<>") + False +""" \ No newline at end of file diff --git a/translation/drafts/57 b/translation/drafts/57 new file mode 100644 index 00000000..82a7122f --- /dev/null +++ b/translation/drafts/57 @@ -0,0 +1,18 @@ +"""Return True is list elements are monotonically increasing or decreasing. + >>> monotonic([1, 2, 4, 20]) + True + >>> monotonic([1, 20, 4, 10]) + False + >>> monotonic([4, 1, 0, -10]) + True + """ + +""" +True return karo agar list ke elements monotonically badh rahe ho ya ghat rahe ho. + >>> monotonic([1, 2, 4, 20]) + True + >>> monotonic([1, 20, 4, 10]) + False + >>> monotonic([4, 1, 0, -10]) + True +""" \ No newline at end of file diff --git a/translation/drafts/58 b/translation/drafts/58 new file mode 100644 index 00000000..2042ea2b --- /dev/null +++ b/translation/drafts/58 @@ -0,0 +1,16 @@ +"""Return sorted unique common elements for two lists. + >>> common([1, 4, 3, 34, 653, 2, 5], [5, 7, 1, 5, 9, 653, 121]) + [1, 5, 653] + >>> common([5, 3, 2, 8], [3, 2]) + [2, 3] + + """ + +""" +Do lists ke liye sorted unique common elements return karo. + >>> common([1, 4, 3, 34, 653, 2, 5], [5, 7, 1, 5, 9, 653, 121]) + [1, 5, 653] + >>> common([5, 3, 2, 8], [3, 2]) + [2, 3] + +""" \ No newline at end of file diff --git a/translation/drafts/59 b/translation/drafts/59 new file mode 100644 index 00000000..e77656b6 --- /dev/null +++ b/translation/drafts/59 @@ -0,0 +1,14 @@ +"""Return the largest prime factor of n. Assume n > 1 and is not a prime. + >>> largest_prime_factor(13195) + 29 + >>> largest_prime_factor(2048) + 2 + """ + +""" +n ka sabse bada prime factor return karo. Maan lo ki n > 1 hai aur yeh prime nahi hai. + >>> largest_prime_factor(13195) + 29 + >>> largest_prime_factor(2048) + 2 +""" \ No newline at end of file diff --git a/translation/drafts/6 b/translation/drafts/6 new file mode 100644 index 00000000..ad203e95 --- /dev/null +++ b/translation/drafts/6 @@ -0,0 +1,17 @@ +""" Input to this function is a string represented multiple groups for nested parentheses separated by spaces. + For each of the group, output the deepest level of nesting of parentheses. + E.g. (()()) has maximum two levels of nesting while ((())) has three. + + >>> parse_nested_parens('(()()) ((())) () ((())()())') + [2, 3, 1, 3] + """ + +""" +Is function ka input ek string hota hai jisme multiple groups hote hain jo nested parentheses se alag kiye gaye hote hain spaces ke dwara. + Har group ke liye, sabse gehri level ki nesting of parentheses ka output do. + Jaise ki, (()()) ka maximum do levels ki nesting hoti hai jabki ((())) ki teen hoti hai. + + >>> parse_nested_parens('(()()) ((())) () ((())()())') + [2, 3, 1, 3] + +""" \ No newline at end of file diff --git a/translation/drafts/60 b/translation/drafts/60 new file mode 100644 index 00000000..fb2723c1 --- /dev/null +++ b/translation/drafts/60 @@ -0,0 +1,27 @@ +"""sum_to_n is a function that sums numbers from 1 to n. + >>> sum_to_n(30) + 465 + >>> sum_to_n(100) + 5050 + >>> sum_to_n(5) + 15 + >>> sum_to_n(10) + 55 + >>> sum_to_n(1) + 1 + """ + +""" +sum_to_n ek function hai jo 1 se lekar n tak ke numbers ka sum karta hai. + >>> sum_to_n(30) + 465 + >>> sum_to_n(100) + 5050 + >>> sum_to_n(5) + 15 + >>> sum_to_n(10) + 55 + >>> sum_to_n(1) + 1 + +""" \ No newline at end of file diff --git a/translation/drafts/61 b/translation/drafts/61 new file mode 100644 index 00000000..808439ee --- /dev/null +++ b/translation/drafts/61 @@ -0,0 +1,26 @@ +""" brackets is a string of "(" and ")". + return True if every opening bracket has a corresponding closing bracket. + + >>> correct_bracketing("(") + False + >>> correct_bracketing("()") + True + >>> correct_bracketing("(()())") + True + >>> correct_bracketing(")(()") + False + """ + +""" +brackets ek string hai "(" aur ")" ka. + return True agar har opening bracket ka ek corresponding closing bracket ho. + + >>> correct_bracketing("(") + False + >>> correct_bracketing("()") + True + >>> correct_bracketing("(()())") + True + >>> correct_bracketing(")(()") + False +""" \ No newline at end of file diff --git a/translation/drafts/62 b/translation/drafts/62 new file mode 100644 index 00000000..01f7aca9 --- /dev/null +++ b/translation/drafts/62 @@ -0,0 +1,18 @@ +""" xs represent coefficients of a polynomial. + xs[0] + xs[1] * x + xs[2] * x^2 + .... + Return derivative of this polynomial in the same form. + >>> derivative([3, 1, 2, 4, 5]) + [1, 4, 12, 20] + >>> derivative([1, 2, 3]) + [2, 6] + """ + +""" +xs ek polynomial ke coefficients ko represent karte hain. + xs[0] + xs[1] * x + xs[2] * x^2 + .... + Is polynomial ka derivative same form mein return karo. + >>> derivative([3, 1, 2, 4, 5]) + [1, 4, 12, 20] + >>> derivative([1, 2, 3]) + [2, 6] +""" \ No newline at end of file diff --git a/translation/drafts/63 b/translation/drafts/63 new file mode 100644 index 00000000..36068122 --- /dev/null +++ b/translation/drafts/63 @@ -0,0 +1,29 @@ +"""The FibFib number sequence is a sequence similar to the Fibbonacci sequnece that's defined as follows: + fibfib(0) == 0 + fibfib(1) == 0 + fibfib(2) == 1 + fibfib(n) == fibfib(n-1) + fibfib(n-2) + fibfib(n-3). + Please write a function to efficiently compute the n-th element of the fibfib number sequence. + >>> fibfib(1) + 0 + >>> fibfib(5) + 4 + >>> fibfib(8) + 24 + """ + +""" +FibFib number sequence ek sequence hai jo Fibbonacci sequence ke saman hai aur iska definition is prakar hai: + fibfib(0) == 0 + fibfib(1) == 0 + fibfib(2) == 1 + fibfib(n) == fibfib(n-1) + fibfib(n-2) + fibfib(n-3). + Kripya ek function likhe jo efficiently fibfib number sequence ka n-th element compute kare. + >>> fibfib(1) + 0 + >>> fibfib(5) + 4 + >>> fibfib(8) + 24 + +""" \ No newline at end of file diff --git a/translation/drafts/64 b/translation/drafts/64 new file mode 100644 index 00000000..361995bd --- /dev/null +++ b/translation/drafts/64 @@ -0,0 +1,7 @@ +""" +Add more test cases. +""" + +""" +Aur test cases jodo. +""" \ No newline at end of file diff --git a/translation/drafts/65 b/translation/drafts/65 new file mode 100644 index 00000000..401437eb --- /dev/null +++ b/translation/drafts/65 @@ -0,0 +1,18 @@ +"""Circular shift the digits of the integer x, shift the digits right by shift + and return the result as a string. + If shift > number of digits, return digits reversed. + >>> circular_shift(12, 1) + "21" + >>> circular_shift(12, 2) + "12" + """ + +""" +Integer x ke digits ko circular shift karo, digits ko right mein shift karo by shift + aur result ko string ke roop mein return karo. + Agar shift > digits ki number ho, toh reversed digits return karo. + >>> circular_shift(12, 1) + "21" + >>> circular_shift(12, 2) + "12" +""" \ No newline at end of file diff --git a/translation/drafts/66 b/translation/drafts/66 new file mode 100644 index 00000000..0fa03997 --- /dev/null +++ b/translation/drafts/66 @@ -0,0 +1,27 @@ +"""Task + Write a function that takes a string as input and returns the sum of the upper characters only' + ASCII codes. + + Examples: + digitSum("") => 0 + digitSum("abAB") => 131 + digitSum("abcCd") => 67 + digitSum("helloE") => 69 + digitSum("woArBld") => 131 + digitSum("aAaaaXa") => 153 + """ + +""" +Task + Ek function likho jo ek string ko input ke roop mein leta hai aur sirf upper characters' + ASCII codes ka sum return karta hai. + + Udaharan: + digitSum("") => 0 + digitSum("abAB") => 131 + digitSum("abcCd") => 67 + digitSum("helloE") => 69 + digitSum("woArBld") => 131 + digitSum("aAaaaXa") => 153 + +""" \ No newline at end of file diff --git a/translation/drafts/67 b/translation/drafts/67 new file mode 100644 index 00000000..66b0364a --- /dev/null +++ b/translation/drafts/67 @@ -0,0 +1,21 @@ +""" + In this task, you will be given a string that represents a number of apples and oranges + that are distributed in a basket of fruit this basket contains + apples, oranges, and mango fruits. Given the string that represents the total number of + the oranges and apples and an integer that represent the total number of the fruits + in the basket return the number of the mango fruits in the basket. + for examble: + fruit_distribution("5 apples and 6 oranges", 19) ->19 - 5 - 6 = 8 + fruit_distribution("0 apples and 1 oranges",3) -> 3 - 0 - 1 = 2 + fruit_distribution("2 apples and 3 oranges", 100) -> 100 - 2 - 3 = 95 + fruit_distribution("100 apples and 1 oranges",120) -> 120 - 100 - 1 = 19 + """ + +""" +Is task mein, aapko ek string di jayegi jo ek fruit basket mein distribute kiye gaye apples aur oranges ki sankhya ko darshati hai. Ye basket mein apples, oranges, aur mango fruits hote hain. Diye gaye string se jo total number of oranges aur apples ko darshati hai aur ek integer jo basket mein total fruits ki sankhya ko darshati hai, use use karke basket mein mango fruits ki sankhya return karo. + Jaise ki: + fruit_distribution("5 apples and 6 oranges", 19) ->19 - 5 - 6 = 8 + fruit_distribution("0 apples and 1 oranges",3) -> 3 - 0 - 1 = 2 + fruit_distribution("2 apples and 3 oranges", 100) -> 100 - 2 - 3 = 95 + fruit_distribution("100 apples and 1 oranges",120) -> 120 - 100 - 1 = 19 +""" \ No newline at end of file diff --git a/translation/drafts/68 b/translation/drafts/68 new file mode 100644 index 00000000..e3eaa938 --- /dev/null +++ b/translation/drafts/68 @@ -0,0 +1,68 @@ +""" + "Given an array representing a branch of a tree that has non-negative integer nodes + your task is to pluck one of the nodes and return it. + The plucked node should be the node with the smallest even value. + If multiple nodes with the same smallest even value are found return the node that has smallest index. + + The plucked node should be returned in a list, [ smalest_value, its index ], + If there are no even values or the given array is empty, return []. + + Example 1: + Input: [4,2,3] + Output: [2, 1] + Explanation: 2 has the smallest even value, and 2 has the smallest index. + + Example 2: + Input: [1,2,3] + Output: [2, 1] + Explanation: 2 has the smallest even value, and 2 has the smallest index. + + Example 3: + Input: [] + Output: [] + + Example 4: + Input: [5, 0, 3, 0, 4, 2] + Output: [0, 1] + Explanation: 0 is the smallest value, but there are two zeros, + so we will choose the first zero, which has the smallest index. + + Constraints: + * 1 <= nodes.length <= 10000 + * 0 <= node.value + """ + +""" +"Ek array diya gaya hai jo ek tree ki branch ko represent karta hai jisme non-negative integer nodes hote hain + aapka task hai ek node ko pluck karke return karna. + Plucked node woh hona chahiye jiska sabse chhota even value ho. + Agar multiple nodes milte hain jinka same sabse chhota even value ho toh woh node return karo jiska sabse chhota index ho. + + Plucked node ko ek list me return karna chahiye, [ sabse_chhota_value, uska index ], + Agar koi bhi even values na ho ya diya gaya array khali ho, toh [] return karo. + + Example 1: + Input: [4,2,3] + Output: [2, 1] + Explanation: 2 ka sabse chhota even value hai, aur 2 ka sabse chhota index hai. + + Example 2: + Input: [1,2,3] + Output: [2, 1] + Explanation: 2 ka sabse chhota even value hai, aur 2 ka sabse chhota index hai. + + Example 3: + Input: [] + Output: [] + + Example 4: + Input: [5, 0, 3, 0, 4, 2] + Output: [0, 1] + Explanation: 0 sabse chhota value hai, lekin yahan do zeros hain, + isliye hum pehla zero choose karenge, jiska sabse chhota index hai. + + Constraints: + * 1 <= nodes.length <= 10000 + * 0 <= node.value + +""" \ No newline at end of file diff --git a/translation/drafts/69 b/translation/drafts/69 new file mode 100644 index 00000000..e3052999 --- /dev/null +++ b/translation/drafts/69 @@ -0,0 +1,22 @@ +""" + You are given a non-empty list of positive integers. Return the greatest integer that is greater than + zero, and has a frequency greater than or equal to the value of the integer itself. + The frequency of an integer is the number of times it appears in the list. + If no such a value exist, return -1. + Examples: + search([4, 1, 2, 2, 3, 1]) == 2 + search([1, 2, 2, 3, 3, 3, 4, 4, 4]) == 3 + search([5, 5, 4, 4, 4]) == -1 + """ + +""" +Aapko ek non-empty list di gayi hai positive integers ki. Return karo sabse bada integer jo zero se bada ho, + aur uska frequency us integer ke value ke barabar ya usse zyada ho. + Ek integer ka frequency uski list mein kitni baar aane ki sankhya hoti hai. + Agar aisa koi value nahi hai, to -1 return karo. + Udaharan: + search([4, 1, 2, 2, 3, 1]) == 2 + search([1, 2, 2, 3, 3, 3, 4, 4, 4]) == 3 + search([5, 5, 4, 4, 4]) == -1 + +""" \ No newline at end of file diff --git a/translation/drafts/7 b/translation/drafts/7 new file mode 100644 index 00000000..723ad1cf --- /dev/null +++ b/translation/drafts/7 @@ -0,0 +1,14 @@ +""" Filter an input list of strings only for ones that contain given substring + >>> filter_by_substring([], 'a') + [] + >>> filter_by_substring(['abc', 'bacd', 'cde', 'array'], 'a') + ['abc', 'bacd', 'array'] + """ + +""" +Diye gaye input list ko sirf un strings ke liye filter karo jo diye gaye substring ko contain karti hain + >>> filter_by_substring([], 'a') + [] + >>> filter_by_substring(['abc', 'bacd', 'cde', 'array'], 'a') + ['abc', 'bacd', 'array'] +""" \ No newline at end of file diff --git a/translation/drafts/70 b/translation/drafts/70 new file mode 100644 index 00000000..ec973f94 --- /dev/null +++ b/translation/drafts/70 @@ -0,0 +1,22 @@ +""" + Given list of integers, return list in strange order. + Strange sorting, is when you start with the minimum value, + then maximum of the remaining integers, then minimum and so on. + + Examples: + strange_sort_list([1, 2, 3, 4]) == [1, 4, 2, 3] + strange_sort_list([5, 5, 5, 5]) == [5, 5, 5, 5] + strange_sort_list([]) == [] + """ + +""" +Diye gaye integers ki list ko, strange order mein return karo. + Strange sorting, tab hoti hai jab aap minimum value se start karte ho, + phir remaining integers ki maximum value, phir minimum aur aise hi aage badhte ho. + + Udaharan: + strange_sort_list([1, 2, 3, 4]) == [1, 4, 2, 3] + strange_sort_list([5, 5, 5, 5]) == [5, 5, 5, 5] + strange_sort_list([]) == [] + +""" \ No newline at end of file diff --git a/translation/drafts/71 b/translation/drafts/71 new file mode 100644 index 00000000..bf5d10cb --- /dev/null +++ b/translation/drafts/71 @@ -0,0 +1,19 @@ +""" + Given the lengths of the three sides of a triangle. Return the area of + the triangle rounded to 2 decimal points if the three sides form a valid triangle. + Otherwise return -1 + Three sides make a valid triangle when the sum of any two sides is greater + than the third side. + Example: + triangle_area(3, 4, 5) == 6.00 + triangle_area(1, 2, 10) == -1 + """ + +""" +Trikon ke teeno sides ke lengths diye gaye hain. Agar teeno sides ek valid trikon banate hain to trikon ka area 2 decimal points tak round off karke return karo. + Anyatha -1 return karo. + Teen sides tabhi ek valid trikon banati hain jab kisi bhi do sides ka yog teesri side se adhik hota hai. + Udaharan: + triangle_area(3, 4, 5) == 6.00 + triangle_area(1, 2, 10) == -1 +""" \ No newline at end of file diff --git a/translation/drafts/72 b/translation/drafts/72 new file mode 100644 index 00000000..8cca5bf2 --- /dev/null +++ b/translation/drafts/72 @@ -0,0 +1,35 @@ +""" + Write a function that returns True if the object q will fly, and False otherwise. + The object q will fly if it's balanced (it is a palindromic list) and the sum of its elements is less than or equal the maximum possible weight w. + + Example: + will_it_fly([1, 2], 5) ➞ False + # 1+2 is less than the maximum possible weight, but it's unbalanced. + + will_it_fly([3, 2, 3], 1) ➞ False + # it's balanced, but 3+2+3 is more than the maximum possible weight. + + will_it_fly([3, 2, 3], 9) ➞ True + # 3+2+3 is less than the maximum possible weight, and it's balanced. + + will_it_fly([3], 5) ➞ True + # 3 is less than the maximum possible weight, and it's balanced. + """ + +""" +Ek function likho jo True return kare agar object q udega, aur False otherwise. + Object q tabhi udega jab vo balanced ho (yani ki ek palindromic list ho) aur uske elements ka sum maximum possible weight w se kam ya barabar ho. + + Udaharan: + will_it_fly([1, 2], 5) ➞ False + # 1+2 maximum possible weight se kam hai, lekin ye balanced nahi hai. + + will_it_fly([3, 2, 3], 1) ➞ False + # ye balanced hai, lekin 3+2+3 maximum possible weight se jyada hai. + + will_it_fly([3, 2, 3], 9) ➞ True + # 3+2+3 maximum possible weight se kam hai, aur ye balanced hai. + + will_it_fly([3], 5) ➞ True + # 3 maximum possible weight se kam hai, aur ye balanced hai. +""" \ No newline at end of file diff --git a/translation/drafts/73 b/translation/drafts/73 new file mode 100644 index 00000000..47fdb684 --- /dev/null +++ b/translation/drafts/73 @@ -0,0 +1,22 @@ +""" + Given an array arr of integers, find the minimum number of elements that + need to be changed to make the array palindromic. A palindromic array is an array that + is read the same backwards and forwards. In one change, you can change one element to any other element. + + For example: + smallest_change([1,2,3,5,4,7,9,6]) == 4 + smallest_change([1, 2, 3, 4, 3, 2, 2]) == 1 + smallest_change([1, 2, 3, 2, 1]) == 0 + """ + +""" +Ek array arr diya gaya hai integers ka, usme se minimum kitne elements ko change karna padega + taaki array palindromic ban jaye. Ek palindromic array woh hota hai jo aage se bhi aur peeche se bhi + same padhta hai. Ek change me, aap ek element ko kisi bhi dusre element se replace kar sakte ho. + + Jaise ki: + smallest_change([1,2,3,5,4,7,9,6]) == 4 + smallest_change([1, 2, 3, 4, 3, 2, 2]) == 1 + smallest_change([1, 2, 3, 2, 1]) == 0 + +""" \ No newline at end of file diff --git a/translation/drafts/74 b/translation/drafts/74 new file mode 100644 index 00000000..24d4cc21 --- /dev/null +++ b/translation/drafts/74 @@ -0,0 +1,27 @@ +""" + Write a function that accepts two lists of strings and returns the list that has + total number of chars in the all strings of the list less than the other list. + + if the two lists have the same number of chars, return the first list. + + Examples + total_match([], []) ➞ [] + total_match(['hi', 'admin'], ['hI', 'Hi']) ➞ ['hI', 'Hi'] + total_match(['hi', 'admin'], ['hi', 'hi', 'admin', 'project']) ➞ ['hi', 'admin'] + total_match(['hi', 'admin'], ['hI', 'hi', 'hi']) ➞ ['hI', 'hi', 'hi'] + total_match(['4'], ['1', '2', '3', '4', '5']) ➞ ['4'] + """ + +""" +Ek function likho jo do string ki lists ko accept kare aur woh list return kare jisme + total number of chars saare strings me dusre list se kam ho. + + Agar dono lists me same number of chars ho, toh pehli list return karo. + + Udaharan + total_match([], []) ➞ [] + total_match(['hi', 'admin'], ['hI', 'Hi']) ➞ ['hI', 'Hi'] + total_match(['hi', 'admin'], ['hi', 'hi', 'admin', 'project']) ➞ ['hi', 'admin'] + total_match(['hi', 'admin'], ['hI', 'hi', 'hi']) ➞ ['hI', 'hi', 'hi'] + total_match(['4'], ['1', '2', '3', '4', '5']) ➞ ['4'] +""" \ No newline at end of file diff --git a/translation/drafts/75 b/translation/drafts/75 new file mode 100644 index 00000000..5950b064 --- /dev/null +++ b/translation/drafts/75 @@ -0,0 +1,16 @@ +"""Write a function that returns true if the given number is the multiplication of 3 prime numbers + and false otherwise. + Knowing that (a) is less then 100. + Example: + is_multiply_prime(30) == True + 30 = 2 * 3 * 5 + """ + +""" +Ek function likho jo true return kare agar diya gaya number 3 prime numbers ka multiplication hai + aur false agar aisa nahi hai. + Jahan (a) 100 se kam hai. + Udaharan: + is_multiply_prime(30) == True + 30 = 2 * 3 * 5 +""" \ No newline at end of file diff --git a/translation/drafts/76 b/translation/drafts/76 new file mode 100644 index 00000000..29bb8b49 --- /dev/null +++ b/translation/drafts/76 @@ -0,0 +1,25 @@ +"""Your task is to write a function that returns true if a number x is a simple + power of n and false in other cases. + x is a simple power of n if n**int=x + For example: + is_simple_power(1, 4) => true + is_simple_power(2, 2) => true + is_simple_power(8, 2) => true + is_simple_power(3, 2) => false + is_simple_power(3, 1) => false + is_simple_power(5, 3) => false + """ + +""" +Aapka task hai ek function likhna jo true return kare agar number x n ka simple + power hai aur false return kare anya cases mein. + x n ka simple power hai agar n**int=x + Jaise ki: + is_simple_power(1, 4) => true + is_simple_power(2, 2) => true + is_simple_power(8, 2) => true + is_simple_power(3, 2) => false + is_simple_power(3, 1) => false + is_simple_power(5, 3) => false + +""" \ No newline at end of file diff --git a/translation/drafts/77 b/translation/drafts/77 new file mode 100644 index 00000000..94834953 --- /dev/null +++ b/translation/drafts/77 @@ -0,0 +1,25 @@ +""" + Write a function that takes an integer a and returns True + if this ingeger is a cube of some integer number. + Note: you may assume the input is always valid. + Examples: + iscube(1) ==> True + iscube(2) ==> False + iscube(-1) ==> True + iscube(64) ==> True + iscube(0) ==> True + iscube(180) ==> False + """ + +""" +Ek function likho jo ek integer a leta hai aur True return karta hai + agar yeh integer kisi integer number ka cube hai. + Dhyan de: aap maan sakte ho ki input hamesha valid hoga. + Udaharan: + iscube(1) ==> True + iscube(2) ==> False + iscube(-1) ==> True + iscube(64) ==> True + iscube(0) ==> True + iscube(180) ==> False +""" \ No newline at end of file diff --git a/translation/drafts/78 b/translation/drafts/78 new file mode 100644 index 00000000..84986140 --- /dev/null +++ b/translation/drafts/78 @@ -0,0 +1,31 @@ +"""You have been tasked to write a function that receives + a hexadecimal number as a string and counts the number of hexadecimal + digits that are primes (prime number, or a prime, is a natural number + greater than 1 that is not a product of two smaller natural numbers). + Hexadecimal digits are 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, A, B, C, D, E, F. + Prime numbers are 2, 3, 5, 7, 11, 13, 17,... + So you have to determine a number of the following digits: 2, 3, 5, 7, + B (=decimal 11), D (=decimal 13). + Note: you may assume the input is always correct or empty string, + and symbols A,B,C,D,E,F are always uppercase. + Examples: + For num = "AB" the output should be 1. + For num = "1077E" the output should be 2. + For num = "ABED1A33" the output should be 4. + For num = "123456789ABCDEF0" the output should be 6. + For num = "2020" the output should be 2. + """ + +""" +Aapko ek function likhna hai jo ek hexadecimal number ko string ke roop mein leta hai aur ginata hai ki kitne hexadecimal digits prime hain (prime number, ya prime, ek natural number hota hai jo 1 se bada hota hai aur do chote natural numbers ka product nahi hota). + Hexadecimal digits hote hain 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, A, B, C, D, E, F. + Prime numbers hote hain 2, 3, 5, 7, 11, 13, 17,... + To aapko ye determine karna hai ki nimn digits ki sankhya kitni hai: 2, 3, 5, 7, B (=decimal 11), D (=decimal 13). + Note: aap maan sakte hain ki input hamesha sahi ya empty string hoga, aur symbols A,B,C,D,E,F hamesha uppercase mein honge. + Examples: + Agar num = "AB" hai to output 1 hona chahiye. + Agar num = "1077E" hai to output 2 hona chahiye. + Agar num = "ABED1A33" hai to output 4 hona chahiye. + Agar num = "123456789ABCDEF0" hai to output 6 hona chahiye. + Agar num = "2020" hai to output 2 hona chahiye. +""" \ No newline at end of file diff --git a/translation/drafts/79 b/translation/drafts/79 new file mode 100644 index 00000000..a085fe68 --- /dev/null +++ b/translation/drafts/79 @@ -0,0 +1,24 @@ +"""You will be given a number in decimal form and your task is to convert it to + binary format. The function should return a string, with each character representing a binary + number. Each character in the string will be '0' or '1'. + + There will be an extra couple of characters 'db' at the beginning and at the end of the string. + The extra characters are there to help with the format. + + Examples: + decimal_to_binary(15) # returns "db1111db" + decimal_to_binary(32) # returns "db100000db" + """ + +""" +Aapko ek number decimal form mein diya jayega aur aapka task hai use + binary format mein convert karna. Function ek string return karega, jisme har character ek binary + number ko represent karega. String mein har character '0' ya '1' hoga. + + String ke shuru aur ant mein 'db' naam ke kuch extra characters honge. + Ye extra characters format ke liye diye gaye hain. + + Udaharan: + decimal_to_binary(15) # returns "db1111db" + decimal_to_binary(32) # returns "db100000db" +""" \ No newline at end of file diff --git a/translation/drafts/8 b/translation/drafts/8 new file mode 100644 index 00000000..66769731 --- /dev/null +++ b/translation/drafts/8 @@ -0,0 +1,16 @@ +""" For a given list of integers, return a tuple consisting of a sum and a product of all the integers in a list. + Empty sum should be equal to 0 and empty product should be equal to 1. + >>> sum_product([]) + (0, 1) + >>> sum_product([1, 2, 3, 4]) + (10, 24) + """ + +""" +Diye gaye integer list ke liye, ek tuple return karo jo list ke saare integers ka sum aur product ho. + Empty sum ko 0 aur empty product ko 1 ke barabar hona chahiye. + >>> sum_product([]) + (0, 1) + >>> sum_product([1, 2, 3, 4]) + (10, 24) +""" \ No newline at end of file diff --git a/translation/drafts/80 b/translation/drafts/80 new file mode 100644 index 00000000..98c903bc --- /dev/null +++ b/translation/drafts/80 @@ -0,0 +1,24 @@ +"""You are given a string s. + Your task is to check if the string is happy or not. + A string is happy if its length is at least 3 and every 3 consecutive letters are distinct + For example: + is_happy(a) => False + is_happy(aa) => False + is_happy(abcd) => True + is_happy(aabb) => False + is_happy(adb) => True + is_happy(xyy) => False + """ + +""" +Aapko ek string s di gayi hai. + Aapka task hai check karna ki string happy hai ya nahi. + Ek string tabhi happy hogi jab uski length kam se kam 3 ho aur har 3 consecutive letters distinct ho. + Jaise ki: + is_happy(a) => False + is_happy(aa) => False + is_happy(abcd) => True + is_happy(aabb) => False + is_happy(adb) => True + is_happy(xyy) => False +""" \ No newline at end of file diff --git a/translation/drafts/81 b/translation/drafts/81 new file mode 100644 index 00000000..d480db83 --- /dev/null +++ b/translation/drafts/81 @@ -0,0 +1,51 @@ +"""It is the last week of the semester and the teacher has to give the grades + to students. The teacher has been making her own algorithm for grading. + The only problem is, she has lost the code she used for grading. + She has given you a list of GPAs for some students and you have to write + a function that can output a list of letter grades using the following table: + GPA | Letter grade + 4.0 A+ + > 3.7 A + > 3.3 A- + > 3.0 B+ + > 2.7 B + > 2.3 B- + > 2.0 C+ + > 1.7 C + > 1.3 C- + > 1.0 D+ + > 0.7 D + > 0.0 D- + 0.0 E + + + Example: + grade_equation([4.0, 3, 1.7, 2, 3.5]) ==> ['A+', 'B', 'C-', 'C', 'A-'] + """ + +""" +Yeh semester ka aakhri week hai aur teacher ko students ko grades dena hai. + Teacher ne apna khud ka algorithm banaya hai grading ke liye. + Sirf ek problem hai, unhone jo code use kiya tha grading ke liye, woh kho gaya hai. + Unhone aapko kuch students ke GPAs ki list di hai aur aapko ek function likhna hai + jo letter grades ki list output kar sake, neeche diye gaye table ke hisaab se: + GPA | Letter grade + 4.0 A+ + > 3.7 A + > 3.3 A- + > 3.0 B+ + > 2.7 B + > 2.3 B- + > 2.0 C+ + > 1.7 C + > 1.3 C- + > 1.0 D+ + > 0.7 D + > 0.0 D- + 0.0 E + + + Example: + grade_equation([4.0, 3, 1.7, 2, 3.5]) ==> ['A+', 'B', 'C-', 'C', 'A-'] + +""" \ No newline at end of file diff --git a/translation/drafts/82 b/translation/drafts/82 new file mode 100644 index 00000000..e79c2f60 --- /dev/null +++ b/translation/drafts/82 @@ -0,0 +1,18 @@ +"""Write a function that takes a string and returns True if the string + length is a prime number or False otherwise + Examples + prime_length('Hello') == True + prime_length('abcdcba') == True + prime_length('kittens') == True + prime_length('orange') == False + """ + +""" +Ek function likho jo ek string leta hai aur return karta hai True agar string + ki length ek prime number hai ya False otherwise + Udaharan + prime_length('Hello') == True + prime_length('abcdcba') == True + prime_length('kittens') == True + prime_length('orange') == False +""" \ No newline at end of file diff --git a/translation/drafts/83 b/translation/drafts/83 new file mode 100644 index 00000000..dbc732c8 --- /dev/null +++ b/translation/drafts/83 @@ -0,0 +1,8 @@ +""" + Given a positive integer n, return the count of the numbers of n-digit + positive integers that start or end with 1. + """ + +""" +Diye gaye positive integer n ke liye, n-digit wale positive integers ki ginti return karo jo 1 se start hote hain ya 1 pe end hote hain. +""" \ No newline at end of file diff --git a/translation/drafts/84 b/translation/drafts/84 new file mode 100644 index 00000000..9e935e98 --- /dev/null +++ b/translation/drafts/84 @@ -0,0 +1,29 @@ +"""Given a positive integer N, return the total sum of its digits in binary. + + Example + For N = 1000, the sum of digits will be 1 the output should be "1". + For N = 150, the sum of digits will be 6 the output should be "110". + For N = 147, the sum of digits will be 12 the output should be "1100". + + Variables: + @N integer + Constraints: 0 ≤ N ≤ 10000. + Output: + a string of binary number + """ + +""" +Diye gaye positive integer N ka, uske digits ka total sum binary mein return karo. + + Udaharan + Agar N = 1000 hai, to digits ka sum hoga 1 aur output honi chahiye "1". + Agar N = 150 hai, to digits ka sum hoga 6 aur output honi chahiye "110". + Agar N = 147 hai, to digits ka sum hoga 12 aur output honi chahiye "1100". + + Variables: + @N integer + Constraints: 0 ≤ N ≤ 10000. + Output: + binary number ka ek string + +""" \ No newline at end of file diff --git a/translation/drafts/85 b/translation/drafts/85 new file mode 100644 index 00000000..aad0875a --- /dev/null +++ b/translation/drafts/85 @@ -0,0 +1,13 @@ +"""Given a non-empty list of integers lst. add the even elements that are at odd indices.. + + + Examples: + add([4, 2, 6, 7]) ==> 2 + """ + +""" +Ek non-empty list di gayi hai integers ki lst. Add karo even elements ko jo odd indices pe hai. + + Udaharan: + add([4, 2, 6, 7]) ==> 2 +""" \ No newline at end of file diff --git a/translation/drafts/86 b/translation/drafts/86 new file mode 100644 index 00000000..e0cee1aa --- /dev/null +++ b/translation/drafts/86 @@ -0,0 +1,25 @@ +""" + Write a function that takes a string and returns an ordered version of it. + Ordered version of string, is a string where all words (separated by space) + are replaced by a new word where all the characters arranged in + ascending order based on ascii value. + Note: You should keep the order of words and blank spaces in the sentence. + + For example: + anti_shuffle('Hi') returns 'Hi' + anti_shuffle('hello') returns 'ehllo' + anti_shuffle('Hello World!!!') returns 'Hello !!!Wdlor' + """ + +""" +Ek function likho jo ek string leta hai aur uska ordered version return karta hai. + Ordered version of string, woh string hoti hai jahan saare words (space se separated) + ko ek naye word se replace kiya jata hai jahan saare characters ko + unke ascii value ke basis pe ascending order mein arrange kiya jata hai. + Dhyan do: Aapko words aur blank spaces ki order sentence mein maintain karni chahiye. + + Jaise ki: + anti_shuffle('Hi') returns 'Hi' + anti_shuffle('hello') returns 'ehllo' + anti_shuffle('Hello World!!!') returns 'Hello !!!Wdlor' +""" \ No newline at end of file diff --git a/translation/drafts/87 b/translation/drafts/87 new file mode 100644 index 00000000..585af3a1 --- /dev/null +++ b/translation/drafts/87 @@ -0,0 +1,39 @@ +""" + You are given a 2 dimensional data, as a nested lists, + which is similar to matrix, however, unlike matrices, + each row may contain a different number of columns. + Given lst, and integer x, find integers x in the list, + and return list of tuples, [(x1, y1), (x2, y2) ...] such that + each tuple is a coordinate - (row, columns), starting with 0. + Sort coordinates initially by rows in ascending order. + Also, sort coordinates of the row by columns in descending order. + + Examples: + get_row([ + [1,2,3,4,5,6], + [1,2,3,4,1,6], + [1,2,3,4,5,1] + ], 1) == [(0, 0), (1, 4), (1, 0), (2, 5), (2, 0)] + get_row([], 1) == [] + get_row([[], [1], [1, 2, 3]], 3) == [(2, 2)] + """ + +""" +Aapko ek 2 dimensional data diya gaya hai, ek nested lists ke roop mein, + jo matrix ke saman hai, lekin, matrices ke unlike, + har row mein alag number of columns ho sakte hain. + Diye gaye lst, aur integer x, list mein integers x ko dhundho, + aur tuples ki list return karo, [(x1, y1), (x2, y2) ...] aisa ki + har tuple ek coordinate ho - (row, columns), shuru karte hue 0 se. + Coordinates ko pehle rows ke hisaab se ascending order mein sort karo. + Saath hi, row ke coordinates ko columns ke hisaab se descending order mein sort karo. + + Examples: + get_row([ + [1,2,3,4,5,6], + [1,2,3,4,1,6], + [1,2,3,4,5,1] + ], 1) == [(0, 0), (1, 4), (1, 0), (2, 5), (2, 0)] + get_row([], 1) == [] + get_row([[], [1], [1, 2, 3]], 3) == [(2, 2)] +""" \ No newline at end of file diff --git a/translation/drafts/88 b/translation/drafts/88 new file mode 100644 index 00000000..f9912fb2 --- /dev/null +++ b/translation/drafts/88 @@ -0,0 +1,29 @@ +""" + Given an array of non-negative integers, return a copy of the given array after sorting, + you will sort the given array in ascending order if the sum( first index value, last index value) is odd, + or sort it in descending order if the sum( first index value, last index value) is even. + + Note: + * don't change the given array. + + Examples: + * sort_array([]) => [] + * sort_array([5]) => [5] + * sort_array([2, 4, 3, 0, 1, 5]) => [0, 1, 2, 3, 4, 5] + * sort_array([2, 4, 3, 0, 1, 5, 6]) => [6, 5, 4, 3, 2, 1, 0] + """ + +""" +Non-negative integers ki ek array di gayi hai, return karo us array ka copy sort karne ke baad, + aapko di gayi array ko ascending order mein sort karna hai agar sum( pehle index ki value, last index ki value) odd hai, + ya fir descending order mein sort karna hai agar sum( pehle index ki value, last index ki value) even hai. + + Dhyan do: + * di gayi array ko change mat karo. + + Examples: + * sort_array([]) => [] + * sort_array([5]) => [5] + * sort_array([2, 4, 3, 0, 1, 5]) => [0, 1, 2, 3, 4, 5] + * sort_array([2, 4, 3, 0, 1, 5, 6]) => [6, 5, 4, 3, 2, 1, 0] +""" \ No newline at end of file diff --git a/translation/drafts/89 b/translation/drafts/89 new file mode 100644 index 00000000..51e66a3a --- /dev/null +++ b/translation/drafts/89 @@ -0,0 +1,22 @@ +"""Create a function encrypt that takes a string as an argument and + returns a string encrypted with the alphabet being rotated. + The alphabet should be rotated in a manner such that the letters + shift down by two multiplied to two places. + For example: + encrypt('hi') returns 'lm' + encrypt('asdfghjkl') returns 'ewhjklnop' + encrypt('gf') returns 'kj' + encrypt('et') returns 'ix' + """ + +""" +Ek function banaiye encrypt jo ek string ko argument ke roop mein leta hai aur + ek encrypted string return karta hai jisme alphabet ko rotate kiya gaya ho. + Alphabet ko aise rotate karna chahiye ki letters + do se multiply kiye gaye do places ke neeche shift ho jaye. + Jaise ki: + encrypt('hi') returns 'lm' + encrypt('asdfghjkl') returns 'ewhjklnop' + encrypt('gf') returns 'kj' + encrypt('et') returns 'ix' +""" \ No newline at end of file diff --git a/translation/drafts/9 b/translation/drafts/9 new file mode 100644 index 00000000..747a2014 --- /dev/null +++ b/translation/drafts/9 @@ -0,0 +1,11 @@ +""" From a given list of integers, generate a list of rolling maximum element found until given moment + in the sequence. + >>> rolling_max([1, 2, 3, 2, 3, 4, 2]) + [1, 2, 3, 3, 3, 4, 4] + """ + +""" +Diye gaye integers ki list se, sequence me diye gaye moment tak paye gaye rolling maximum element ki list generate karo. + >>> rolling_max([1, 2, 3, 2, 3, 4, 2]) + [1, 2, 3, 3, 3, 4, 4] +""" \ No newline at end of file diff --git a/translation/drafts/90 b/translation/drafts/90 new file mode 100644 index 00000000..dca77f4c --- /dev/null +++ b/translation/drafts/90 @@ -0,0 +1,22 @@ +""" + You are given a list of integers. + Write a function next_smallest() that returns the 2nd smallest element of the list. + Return None if there is no such element. + + next_smallest([1, 2, 3, 4, 5]) == 2 + next_smallest([5, 1, 4, 3, 2]) == 2 + next_smallest([]) == None + next_smallest([1, 1]) == None + """ + +""" +Aapko ek list di gayi hai integers ki. + Ek function likho next_smallest() jo list ka 2nd sabse chhota element return kare. + Agar aisa koi element nahi hai to None return kare. + + next_smallest([1, 2, 3, 4, 5]) == 2 + next_smallest([5, 1, 4, 3, 2]) == 2 + next_smallest([]) == None + next_smallest([1, 1]) == None + +""" \ No newline at end of file diff --git a/translation/drafts/91 b/translation/drafts/91 new file mode 100644 index 00000000..de303445 --- /dev/null +++ b/translation/drafts/91 @@ -0,0 +1,22 @@ +""" + You'll be given a string of words, and your task is to count the number + of boredoms. A boredom is a sentence that starts with the word "I". + Sentences are delimited by '.', '?' or '!'. + + For example: + >>> is_bored("Hello world") + 0 + >>> is_bored("The sky is blue. The sun is shining. I love this weather") + 1 + """ + +""" +Aapko ek string di jayegi jisme words honge, aur aapka task hai ginna ki kitne boredoms hai. Ek boredom woh sentence hota hai jo "I" word se start hota hai. + Sentences ko '.' , '?' ya '!' se alag kiya jata hai. + + Udaharan ke liye: + >>> is_bored("Hello world") + 0 + >>> is_bored("The sky is blue. The sun is shining. I love this weather") + 1 +""" \ No newline at end of file diff --git a/translation/drafts/92 b/translation/drafts/92 new file mode 100644 index 00000000..b58c3b55 --- /dev/null +++ b/translation/drafts/92 @@ -0,0 +1,33 @@ +""" + Create a function that takes 3 numbers. + Returns true if one of the numbers is equal to the sum of the other two, and all numbers are integers. + Returns false in any other cases. + + Examples + any_int(5, 2, 7) ➞ True + + any_int(3, 2, 2) ➞ False + + any_int(3, -2, 1) ➞ True + + any_int(3.6, -2.2, 2) ➞ False + + + + """ + +""" +Ek function banao jo 3 numbers leta hai. + Agar koi ek number doosre do numbers ka sum ho, aur saare numbers integers ho, toh true return kare. + Kisi bhi aur case mein false return kare. + + Udaharan + any_int(5, 2, 7) ➞ True + + any_int(3, 2, 2) ➞ False + + any_int(3, -2, 1) ➞ True + + any_int(3.6, -2.2, 2) ➞ False + +""" \ No newline at end of file diff --git a/translation/drafts/93 b/translation/drafts/93 new file mode 100644 index 00000000..5ea6a2e6 --- /dev/null +++ b/translation/drafts/93 @@ -0,0 +1,26 @@ +""" + Write a function that takes a message, and encodes in such a + way that it swaps case of all letters, replaces all vowels in + the message with the letter that appears 2 places ahead of that + vowel in the english alphabet. + Assume only letters. + + Examples: + >>> encode('test') + 'TGST' + >>> encode('This is a message') + 'tHKS KS C MGSSCGG' + """ + +""" +Ek function likho jo ek message leta hai, aur usko aise encode karta hai + ki wo saare letters ki case ko swap kar deta hai, saare vowels ko + unke aage wale 2nd letter se replace kar deta hai english alphabet mein. + Sirf letters maan lo. + + Udaharan: + >>> encode('test') + 'TGST' + >>> encode('This is a message') + 'tHKS KS C MGSSCGG' +""" \ No newline at end of file diff --git a/translation/drafts/94 b/translation/drafts/94 new file mode 100644 index 00000000..1cd03ffb --- /dev/null +++ b/translation/drafts/94 @@ -0,0 +1,25 @@ +"""You are given a list of integers. + You need to find the largest prime value and return the sum of its digits. + + Examples: + For lst = [0,3,2,1,3,5,7,4,5,5,5,2,181,32,4,32,3,2,32,324,4,3] the output should be 10 + For lst = [1,0,1,8,2,4597,2,1,3,40,1,2,1,2,4,2,5,1] the output should be 25 + For lst = [1,3,1,32,5107,34,83278,109,163,23,2323,32,30,1,9,3] the output should be 13 + For lst = [0,724,32,71,99,32,6,0,5,91,83,0,5,6] the output should be 11 + For lst = [0,81,12,3,1,21] the output should be 3 + For lst = [0,8,1,2,1,7] the output should be 7 + """ + +""" +Aapko ek list di gayi hai integers ki. + Aapko sabse bada prime value dhundna hai aur uske digits ka sum return karna hai. + + Udaharan: + Agar lst = [0,3,2,1,3,5,7,4,5,5,5,2,181,32,4,32,3,2,32,324,4,3] hai to output hona chahiye 10 + Agar lst = [1,0,1,8,2,4597,2,1,3,40,1,2,1,2,4,2,5,1] hai to output hona chahiye 25 + Agar lst = [1,3,1,32,5107,34,83278,109,163,23,2323,32,30,1,9,3] hai to output hona chahiye 13 + Agar lst = [0,724,32,71,99,32,6,0,5,91,83,0,5,6] hai to output hona chahiye 11 + Agar lst = [0,81,12,3,1,21] hai to output hona chahiye 3 + Agar lst = [0,8,1,2,1,7] hai to output hona chahiye 7 + +""" \ No newline at end of file diff --git a/translation/drafts/95 b/translation/drafts/95 new file mode 100644 index 00000000..6c8139ac --- /dev/null +++ b/translation/drafts/95 @@ -0,0 +1,22 @@ +""" + Given a dictionary, return True if all keys are strings in lower + case or all keys are strings in upper case, else return False. + The function should return False is the given dictionary is empty. + Examples: + check_dict_case({"a":"apple", "b":"banana"}) should return True. + check_dict_case({"a":"apple", "A":"banana", "B":"banana"}) should return False. + check_dict_case({"a":"apple", 8:"banana", "a":"apple"}) should return False. + check_dict_case({"Name":"John", "Age":"36", "City":"Houston"}) should return False. + check_dict_case({"STATE":"NC", "ZIP":"12345" }) should return True. + """ + +""" +Ek dictionary di gayi hai, return karo True agar saare keys lower case strings hai ya saare keys upper case strings hai, nahi to return karo False. + Agar di gayi dictionary khali hai to function False return karega. + Udaharan: + check_dict_case({"a":"apple", "b":"banana"}) ka return hona chahiye True. + check_dict_case({"a":"apple", "A":"banana", "B":"banana"}) ka return hona chahiye False. + check_dict_case({"a":"apple", 8:"banana", "a":"apple"}) ka return hona chahiye False. + check_dict_case({"Name":"John", "Age":"36", "City":"Houston"}) ka return hona chahiye False. + check_dict_case({"STATE":"NC", "ZIP":"12345" }) ka return hona chahiye True. +""" \ No newline at end of file diff --git a/translation/drafts/96 b/translation/drafts/96 new file mode 100644 index 00000000..a40f61fb --- /dev/null +++ b/translation/drafts/96 @@ -0,0 +1,23 @@ +"""Implement a function that takes an non-negative integer and returns an array of the first n + integers that are prime numbers and less than n. + for example: + count_up_to(5) => [2,3] + count_up_to(11) => [2,3,5,7] + count_up_to(0) => [] + count_up_to(20) => [2,3,5,7,11,13,17,19] + count_up_to(1) => [] + count_up_to(18) => [2,3,5,7,11,13,17] + """ + +""" +Ek function implement karo jo ek non-negative integer leta hai aur return karta hai ek array jisme pehle n + integers hote hai jo prime numbers hai aur n se kam hai. + Jaise ki: + count_up_to(5) => [2,3] + count_up_to(11) => [2,3,5,7] + count_up_to(0) => [] + count_up_to(20) => [2,3,5,7,11,13,17,19] + count_up_to(1) => [] + count_up_to(18) => [2,3,5,7,11,13,17] + +""" \ No newline at end of file diff --git a/translation/drafts/97 b/translation/drafts/97 new file mode 100644 index 00000000..f6af90b5 --- /dev/null +++ b/translation/drafts/97 @@ -0,0 +1,19 @@ +"""Complete the function that takes two integers and returns + the product of their unit digits. + Assume the input is always valid. + Examples: + multiply(148, 412) should return 16. + multiply(19, 28) should return 72. + multiply(2020, 1851) should return 0. + multiply(14,-15) should return 20. + """ + +""" +Do integers ka input lekar unke unit digits ka product return karega ye function. + Maan lo ki input hamesha valid hoga. + Udaharan: + multiply(148, 412) ka return hoga 16. + multiply(19, 28) ka return hoga 72. + multiply(2020, 1851) ka return hoga 0. + multiply(14,-15) ka return hoga 20. +""" \ No newline at end of file diff --git a/translation/drafts/98 b/translation/drafts/98 new file mode 100644 index 00000000..07cebd17 --- /dev/null +++ b/translation/drafts/98 @@ -0,0 +1,17 @@ +""" + Given a string s, count the number of uppercase vowels in even indices. + + For example: + count_upper('aBCdEf') returns 1 + count_upper('abcdefg') returns 0 + count_upper('dBBE') returns 0 + """ + +""" +Diye gaye string s mein, even indices par kitne uppercase vowels hai, unhe count karo. + +Jaise ki: +count_upper('aBCdEf') returns 1 +count_upper('abcdefg') returns 0 +count_upper('dBBE') returns 0 +""" \ No newline at end of file diff --git a/translation/drafts/99 b/translation/drafts/99 new file mode 100644 index 00000000..86b5d22d --- /dev/null +++ b/translation/drafts/99 @@ -0,0 +1,35 @@ +""" + Create a function that takes a value (string) representing a number + and returns the closest integer to it. If the number is equidistant + from two integers, round it away from zero. + + Examples + >>> closest_integer("10") + 10 + >>> closest_integer("15.3") + 15 + + Note: + Rounding away from zero means that if the given number is equidistant + from two integers, the one you should return is the one that is the + farthest from zero. For example closest_integer("14.5") should + return 15 and closest_integer("-14.5") should return -15. + """ + +""" +Ek function banaiye jo ek value (string) leta hai jo ek number represent karta hai + aur uska sabse close integer return karta hai. Agar number do integers ke beech + samanantar hai, toh use zero se door round karo. + + Udaharan + >>> closest_integer("10") + 10 + >>> closest_integer("15.3") + 15 + + Dhyan Dijiye: + Zero se door round karne ka matlab hai ki agar diya gaya number do integers ke beech + samanantar hai, toh aapko woh integer return karna chahiye jo zero se sabse door hai. + Jaise ki closest_integer("14.5") ko 15 return karna chahiye aur closest_integer("-14.5") + ko -15 return karna chahiye. +""" \ No newline at end of file