code
stringlengths 0
672k
| language
stringclasses 2
values | AST_depth
int64 -1
40
| alphanumeric_fraction
float64 0
1
| max_line_length
int64 0
672k
| avg_line_length
float64 0
267k
| num_lines
int64 0
4.06k
| task
stringlengths 7
14k
| source
stringclasses 2
values |
---|---|---|---|---|---|---|---|---|
class Solution:
def minimum_Number(self, s):
j = sorted(s)
p = ''
if j[0] != '0':
return p.join(j)
else:
for i in range(len(j)):
if j[i] != '0':
temp = j[0]
j[0] = j[i]
j[i] = temp
break
return p.join(j)
| python | 15 | 0.47561 | 29 | 15.4 | 15 | Given a number s(in string form). Find the Smallest number (Not leading Zeros) which can be obtained by rearranging the digits of given number.
Example 1:
Input: s = "846903"
Output: 304689
Explanation: 304689 is the smallest number
by rearranging the digits.
Example 2:
Input: s = "55010"
Output: 10055
Explanation: 10055 is the smallest number
by rearranging the digts.
Your Task:
You don't need to read or print anything. Your task is to complete the function minimum_number() which takes the number as input parameter and returns the smallest number than can be formed without leading zeros by rearranging the digits of the number.
Expected Time Complexity: O(N * log(N)) where N is the number of digits of the given number
Expected Space Complexity: O(1)
Constraints:
1 <= N <= 10^{5} | taco |
class Solution:
def minimum_Number(self, s):
m = sorted(s)
for i in range(len(m)):
if int(m[i]) > 0:
(m[0], m[i]) = (m[i], m[0])
break
sr = ''
for i in m:
sr += i
return sr
| python | 13 | 0.492462 | 31 | 15.583333 | 12 | Given a number s(in string form). Find the Smallest number (Not leading Zeros) which can be obtained by rearranging the digits of given number.
Example 1:
Input: s = "846903"
Output: 304689
Explanation: 304689 is the smallest number
by rearranging the digits.
Example 2:
Input: s = "55010"
Output: 10055
Explanation: 10055 is the smallest number
by rearranging the digts.
Your Task:
You don't need to read or print anything. Your task is to complete the function minimum_number() which takes the number as input parameter and returns the smallest number than can be formed without leading zeros by rearranging the digits of the number.
Expected Time Complexity: O(N * log(N)) where N is the number of digits of the given number
Expected Space Complexity: O(1)
Constraints:
1 <= N <= 10^{5} | taco |
class Solution:
def minimum_Number(self, s):
lst = list(s)
lst.sort()
tmp = ''
for (i, n) in enumerate(lst):
if n != '0':
tmp = lst.pop(i)
break
return str(tmp) + ''.join(lst)
| python | 13 | 0.547739 | 32 | 17.090909 | 11 | Given a number s(in string form). Find the Smallest number (Not leading Zeros) which can be obtained by rearranging the digits of given number.
Example 1:
Input: s = "846903"
Output: 304689
Explanation: 304689 is the smallest number
by rearranging the digits.
Example 2:
Input: s = "55010"
Output: 10055
Explanation: 10055 is the smallest number
by rearranging the digts.
Your Task:
You don't need to read or print anything. Your task is to complete the function minimum_number() which takes the number as input parameter and returns the smallest number than can be formed without leading zeros by rearranging the digits of the number.
Expected Time Complexity: O(N * log(N)) where N is the number of digits of the given number
Expected Space Complexity: O(1)
Constraints:
1 <= N <= 10^{5} | taco |
class Solution:
def minimum_Number(self, s):
l = list(s)
l.sort()
tmp = ''
for (i, ele) in enumerate(l):
if ele != '0':
tmp = str(l.pop(i))
break
return str(tmp) + ''.join(l)
| python | 15 | 0.535354 | 31 | 17 | 11 | Given a number s(in string form). Find the Smallest number (Not leading Zeros) which can be obtained by rearranging the digits of given number.
Example 1:
Input: s = "846903"
Output: 304689
Explanation: 304689 is the smallest number
by rearranging the digits.
Example 2:
Input: s = "55010"
Output: 10055
Explanation: 10055 is the smallest number
by rearranging the digts.
Your Task:
You don't need to read or print anything. Your task is to complete the function minimum_number() which takes the number as input parameter and returns the smallest number than can be formed without leading zeros by rearranging the digits of the number.
Expected Time Complexity: O(N * log(N)) where N is the number of digits of the given number
Expected Space Complexity: O(1)
Constraints:
1 <= N <= 10^{5} | taco |
class Solution:
def minimum_Number(self, s):
n = len(s)
lst = list(map(int, s))
lst.sort()
for i in range(n):
if lst[i] != 0:
(lst[0], lst[i]) = (lst[i], lst[0])
break
ans = ''
for i in lst:
ans += str(i)
return ans
| python | 13 | 0.520325 | 39 | 16.571429 | 14 | Given a number s(in string form). Find the Smallest number (Not leading Zeros) which can be obtained by rearranging the digits of given number.
Example 1:
Input: s = "846903"
Output: 304689
Explanation: 304689 is the smallest number
by rearranging the digits.
Example 2:
Input: s = "55010"
Output: 10055
Explanation: 10055 is the smallest number
by rearranging the digts.
Your Task:
You don't need to read or print anything. Your task is to complete the function minimum_number() which takes the number as input parameter and returns the smallest number than can be formed without leading zeros by rearranging the digits of the number.
Expected Time Complexity: O(N * log(N)) where N is the number of digits of the given number
Expected Space Complexity: O(1)
Constraints:
1 <= N <= 10^{5} | taco |
import functools
class Solution:
def minimum_Number(self, s):
c = 0
arr = []
for i in s:
if i != 0:
arr.append(i)
if i == '0':
c += 1
if c == len(s):
return s
def fuc(a, b):
if a + b > b + a:
return 1
else:
return -1
arr.sort()
news = str(int(''.join(arr)))
if c == 0:
return news
else:
return news[0] + '0' * c + news[1:]
| python | 14 | 0.489529 | 38 | 13.692308 | 26 | Given a number s(in string form). Find the Smallest number (Not leading Zeros) which can be obtained by rearranging the digits of given number.
Example 1:
Input: s = "846903"
Output: 304689
Explanation: 304689 is the smallest number
by rearranging the digits.
Example 2:
Input: s = "55010"
Output: 10055
Explanation: 10055 is the smallest number
by rearranging the digts.
Your Task:
You don't need to read or print anything. Your task is to complete the function minimum_number() which takes the number as input parameter and returns the smallest number than can be formed without leading zeros by rearranging the digits of the number.
Expected Time Complexity: O(N * log(N)) where N is the number of digits of the given number
Expected Space Complexity: O(1)
Constraints:
1 <= N <= 10^{5} | taco |
class Solution:
def minimum_Number(self, s):
num = sorted(s)
t = 0
for i in num:
if i == '0':
t += 1
else:
break
num = num[t:]
if len(num) > 0:
x = num[0]
else:
return '0' * t
num = ['0'] * t + num[1:]
num.insert(0, x)
return ''.join(num)
| python | 11 | 0.487455 | 29 | 14.5 | 18 | Given a number s(in string form). Find the Smallest number (Not leading Zeros) which can be obtained by rearranging the digits of given number.
Example 1:
Input: s = "846903"
Output: 304689
Explanation: 304689 is the smallest number
by rearranging the digits.
Example 2:
Input: s = "55010"
Output: 10055
Explanation: 10055 is the smallest number
by rearranging the digts.
Your Task:
You don't need to read or print anything. Your task is to complete the function minimum_number() which takes the number as input parameter and returns the smallest number than can be formed without leading zeros by rearranging the digits of the number.
Expected Time Complexity: O(N * log(N)) where N is the number of digits of the given number
Expected Space Complexity: O(1)
Constraints:
1 <= N <= 10^{5} | taco |
class Solution:
def minimum_Number(self, s):
g = s.count('0')
l = s.replace('0', '')
if len(l) == 0:
return s
l = sorted(l)
l.sort()
h = [l[0]]
for i in range(g):
h.append('0')
for i in range(1, len(l)):
h.append(l[i])
return ''.join(h)
| python | 11 | 0.518797 | 29 | 16.733333 | 15 | Given a number s(in string form). Find the Smallest number (Not leading Zeros) which can be obtained by rearranging the digits of given number.
Example 1:
Input: s = "846903"
Output: 304689
Explanation: 304689 is the smallest number
by rearranging the digits.
Example 2:
Input: s = "55010"
Output: 10055
Explanation: 10055 is the smallest number
by rearranging the digts.
Your Task:
You don't need to read or print anything. Your task is to complete the function minimum_number() which takes the number as input parameter and returns the smallest number than can be formed without leading zeros by rearranging the digits of the number.
Expected Time Complexity: O(N * log(N)) where N is the number of digits of the given number
Expected Space Complexity: O(1)
Constraints:
1 <= N <= 10^{5} | taco |
class Solution:
def minimum_Number(self, s):
x = [i for i in s]
x.sort()
c = 0
for i in range(len(x)):
if x[i] != '0':
c = i
break
(x[0], x[c]) = (x[c], x[0])
return ''.join(x)
| python | 11 | 0.475248 | 29 | 15.833333 | 12 | Given a number s(in string form). Find the Smallest number (Not leading Zeros) which can be obtained by rearranging the digits of given number.
Example 1:
Input: s = "846903"
Output: 304689
Explanation: 304689 is the smallest number
by rearranging the digits.
Example 2:
Input: s = "55010"
Output: 10055
Explanation: 10055 is the smallest number
by rearranging the digts.
Your Task:
You don't need to read or print anything. Your task is to complete the function minimum_number() which takes the number as input parameter and returns the smallest number than can be formed without leading zeros by rearranging the digits of the number.
Expected Time Complexity: O(N * log(N)) where N is the number of digits of the given number
Expected Space Complexity: O(1)
Constraints:
1 <= N <= 10^{5} | taco |
class Solution:
def minimum_Number(self, s):
snum = sorted(list(s))
czero = snum.count('0')
if czero == len(snum):
return s
snum[0] = snum[czero]
snum[czero] = '0'
return ''.join(snum)
| python | 11 | 0.608911 | 29 | 19.2 | 10 | Given a number s(in string form). Find the Smallest number (Not leading Zeros) which can be obtained by rearranging the digits of given number.
Example 1:
Input: s = "846903"
Output: 304689
Explanation: 304689 is the smallest number
by rearranging the digits.
Example 2:
Input: s = "55010"
Output: 10055
Explanation: 10055 is the smallest number
by rearranging the digts.
Your Task:
You don't need to read or print anything. Your task is to complete the function minimum_number() which takes the number as input parameter and returns the smallest number than can be formed without leading zeros by rearranging the digits of the number.
Expected Time Complexity: O(N * log(N)) where N is the number of digits of the given number
Expected Space Complexity: O(1)
Constraints:
1 <= N <= 10^{5} | taco |
class Solution:
def minimum_Number(self, s):
lst = []
for c in s:
lst.append(c)
lst.sort()
n = len(lst)
i = 0
while i < n and lst[i] == '0':
i += 1
if i == n:
return int(''.join(lst))
else:
(lst[0], lst[i]) = (lst[i], lst[0])
return int(''.join(lst))
| python | 14 | 0.503521 | 38 | 16.75 | 16 | Given a number s(in string form). Find the Smallest number (Not leading Zeros) which can be obtained by rearranging the digits of given number.
Example 1:
Input: s = "846903"
Output: 304689
Explanation: 304689 is the smallest number
by rearranging the digits.
Example 2:
Input: s = "55010"
Output: 10055
Explanation: 10055 is the smallest number
by rearranging the digts.
Your Task:
You don't need to read or print anything. Your task is to complete the function minimum_number() which takes the number as input parameter and returns the smallest number than can be formed without leading zeros by rearranging the digits of the number.
Expected Time Complexity: O(N * log(N)) where N is the number of digits of the given number
Expected Space Complexity: O(1)
Constraints:
1 <= N <= 10^{5} | taco |
class Solution:
def minimum_Number(self, s):
s = sorted(s)
ans = ''
temp = ''
flag = 1
for i in s:
if i == '0':
temp = temp + i
flag = 0
else:
ans = ans + i
if flag == 0:
ans = ans + temp
flag = 1
if len(ans) == 0:
return temp
return ans
if __name__ == '__main__':
T = int(input())
for i in range(T):
s = input()
ob = Solution()
ans = ob.minimum_Number(s)
print(ans)
| python | 15 | 0.5 | 29 | 15.461538 | 26 | Given a number s(in string form). Find the Smallest number (Not leading Zeros) which can be obtained by rearranging the digits of given number.
Example 1:
Input: s = "846903"
Output: 304689
Explanation: 304689 is the smallest number
by rearranging the digits.
Example 2:
Input: s = "55010"
Output: 10055
Explanation: 10055 is the smallest number
by rearranging the digts.
Your Task:
You don't need to read or print anything. Your task is to complete the function minimum_number() which takes the number as input parameter and returns the smallest number than can be formed without leading zeros by rearranging the digits of the number.
Expected Time Complexity: O(N * log(N)) where N is the number of digits of the given number
Expected Space Complexity: O(1)
Constraints:
1 <= N <= 10^{5} | taco |
class Solution:
def minimum_Number(self, s):
l = list(s)
l.sort()
for i in range(len(l)):
if int(l[i]) > 0:
(l[0], l[i]) = (l[i], l[0])
break
n = ''
for i in l:
n += i
return n
if __name__ == '__main__':
T = int(input())
for i in range(T):
s = input()
ob = Solution()
ans = ob.minimum_Number(s)
print(ans)
| python | 13 | 0.5 | 31 | 16.2 | 20 | Given a number s(in string form). Find the Smallest number (Not leading Zeros) which can be obtained by rearranging the digits of given number.
Example 1:
Input: s = "846903"
Output: 304689
Explanation: 304689 is the smallest number
by rearranging the digits.
Example 2:
Input: s = "55010"
Output: 10055
Explanation: 10055 is the smallest number
by rearranging the digts.
Your Task:
You don't need to read or print anything. Your task is to complete the function minimum_number() which takes the number as input parameter and returns the smallest number than can be formed without leading zeros by rearranging the digits of the number.
Expected Time Complexity: O(N * log(N)) where N is the number of digits of the given number
Expected Space Complexity: O(1)
Constraints:
1 <= N <= 10^{5} | taco |
class Solution:
def minimum_Number(self, s):
x = list(sorted(s))
k = ''
for i in x:
if i != '0':
k += i
break
if len(k) == 0:
return s
x.remove(k[0])
for i in x:
k += i
return k
if __name__ == '__main__':
T = int(input())
for i in range(T):
s = input()
ob = Solution()
ans = ob.minimum_Number(s)
print(ans)
| python | 11 | 0.508571 | 29 | 14.909091 | 22 | Given a number s(in string form). Find the Smallest number (Not leading Zeros) which can be obtained by rearranging the digits of given number.
Example 1:
Input: s = "846903"
Output: 304689
Explanation: 304689 is the smallest number
by rearranging the digits.
Example 2:
Input: s = "55010"
Output: 10055
Explanation: 10055 is the smallest number
by rearranging the digts.
Your Task:
You don't need to read or print anything. Your task is to complete the function minimum_number() which takes the number as input parameter and returns the smallest number than can be formed without leading zeros by rearranging the digits of the number.
Expected Time Complexity: O(N * log(N)) where N is the number of digits of the given number
Expected Space Complexity: O(1)
Constraints:
1 <= N <= 10^{5} | taco |
class Solution:
def minimum_Number(self, s):
arr = list(s)
arr.sort()
for i in range(len(arr)):
if arr[i] != '0':
temp = arr[i]
arr.pop(i)
break
if len(arr) == len(s):
return s
else:
return temp + ''.join(arr)
| python | 13 | 0.547325 | 29 | 16.357143 | 14 | Given a number s(in string form). Find the Smallest number (Not leading Zeros) which can be obtained by rearranging the digits of given number.
Example 1:
Input: s = "846903"
Output: 304689
Explanation: 304689 is the smallest number
by rearranging the digits.
Example 2:
Input: s = "55010"
Output: 10055
Explanation: 10055 is the smallest number
by rearranging the digts.
Your Task:
You don't need to read or print anything. Your task is to complete the function minimum_number() which takes the number as input parameter and returns the smallest number than can be formed without leading zeros by rearranging the digits of the number.
Expected Time Complexity: O(N * log(N)) where N is the number of digits of the given number
Expected Space Complexity: O(1)
Constraints:
1 <= N <= 10^{5} | taco |
class Solution:
def minimum_Number(self, s):
res = [int(x) for x in str(s)]
mo = ''
res.sort()
if res[len(res) - 2] == 0:
res.sort(reverse=True)
for s in res:
mo = mo + str(s)
return int(mo)
if res[0] == 0:
for i in range(len(res) - 1):
if res[i] > 0:
res[0] = res[i]
res[i] = 0
break
for s in res:
mo = mo + str(s)
return int(mo)
| python | 14 | 0.511688 | 32 | 18.25 | 20 | Given a number s(in string form). Find the Smallest number (Not leading Zeros) which can be obtained by rearranging the digits of given number.
Example 1:
Input: s = "846903"
Output: 304689
Explanation: 304689 is the smallest number
by rearranging the digits.
Example 2:
Input: s = "55010"
Output: 10055
Explanation: 10055 is the smallest number
by rearranging the digts.
Your Task:
You don't need to read or print anything. Your task is to complete the function minimum_number() which takes the number as input parameter and returns the smallest number than can be formed without leading zeros by rearranging the digits of the number.
Expected Time Complexity: O(N * log(N)) where N is the number of digits of the given number
Expected Space Complexity: O(1)
Constraints:
1 <= N <= 10^{5} | taco |
class Solution:
def minimum_Number(self, s):
s = list(s)
s.sort()
ind = 0
leng = len(s)
while ind < leng and s[ind] == '0':
ind += 1
if ind == leng:
return int(''.join(s))
p = s.pop(ind)
s.insert(0, p)
return int(''.join(s))
| python | 13 | 0.537849 | 37 | 16.928571 | 14 | Given a number s(in string form). Find the Smallest number (Not leading Zeros) which can be obtained by rearranging the digits of given number.
Example 1:
Input: s = "846903"
Output: 304689
Explanation: 304689 is the smallest number
by rearranging the digits.
Example 2:
Input: s = "55010"
Output: 10055
Explanation: 10055 is the smallest number
by rearranging the digts.
Your Task:
You don't need to read or print anything. Your task is to complete the function minimum_number() which takes the number as input parameter and returns the smallest number than can be formed without leading zeros by rearranging the digits of the number.
Expected Time Complexity: O(N * log(N)) where N is the number of digits of the given number
Expected Space Complexity: O(1)
Constraints:
1 <= N <= 10^{5} | taco |
class Solution:
def minimum_Number(self, s):
dic = {}
for el in range(10):
dic[str(el)] = 0
if s[0] != '-':
for el in s:
dic[el] += 1
newS = ''
for el in range(1, 10):
newS += str(el) * dic[str(el)]
if dic['0'] != 0 and len(newS) > 0:
newS = newS[0] + '0' * dic['0'] + newS[1:]
elif dic['0'] != 0 and len(newS) == 0:
newS += '0' * dic['0']
return newS
else:
for el in s[1:]:
dic[el] += 1
newS = ''
for el in range(9, -1, -1):
newS += str(el) * dic[str(el)]
newS = '-' + newS
return newS
| python | 16 | 0.472172 | 46 | 21.28 | 25 | Given a number s(in string form). Find the Smallest number (Not leading Zeros) which can be obtained by rearranging the digits of given number.
Example 1:
Input: s = "846903"
Output: 304689
Explanation: 304689 is the smallest number
by rearranging the digits.
Example 2:
Input: s = "55010"
Output: 10055
Explanation: 10055 is the smallest number
by rearranging the digts.
Your Task:
You don't need to read or print anything. Your task is to complete the function minimum_number() which takes the number as input parameter and returns the smallest number than can be formed without leading zeros by rearranging the digits of the number.
Expected Time Complexity: O(N * log(N)) where N is the number of digits of the given number
Expected Space Complexity: O(1)
Constraints:
1 <= N <= 10^{5} | taco |
class Solution:
def minimum_Number(self, s):
s = sorted(s)
if s[-1] == '0':
return ''.join(s)
i = 0
while s[i] == '0':
i += 1
(s[i], s[0]) = (s[0], s[i])
return ''.join(s)
| python | 11 | 0.463542 | 29 | 16.454545 | 11 | Given a number s(in string form). Find the Smallest number (Not leading Zeros) which can be obtained by rearranging the digits of given number.
Example 1:
Input: s = "846903"
Output: 304689
Explanation: 304689 is the smallest number
by rearranging the digits.
Example 2:
Input: s = "55010"
Output: 10055
Explanation: 10055 is the smallest number
by rearranging the digts.
Your Task:
You don't need to read or print anything. Your task is to complete the function minimum_number() which takes the number as input parameter and returns the smallest number than can be formed without leading zeros by rearranging the digits of the number.
Expected Time Complexity: O(N * log(N)) where N is the number of digits of the given number
Expected Space Complexity: O(1)
Constraints:
1 <= N <= 10^{5} | taco |
class Solution:
def minimum_Number(self, s):
n = len(s)
s = list(s)
s = sorted(s)
i = 0
while i < n - 1 and s[i] == '0':
i += 1
if i == 0:
return ''.join(s)
else:
(s[0], s[i]) = (s[i], s[0])
return ''.join(s)
| python | 12 | 0.461864 | 34 | 15.857143 | 14 | Given a number s(in string form). Find the Smallest number (Not leading Zeros) which can be obtained by rearranging the digits of given number.
Example 1:
Input: s = "846903"
Output: 304689
Explanation: 304689 is the smallest number
by rearranging the digits.
Example 2:
Input: s = "55010"
Output: 10055
Explanation: 10055 is the smallest number
by rearranging the digts.
Your Task:
You don't need to read or print anything. Your task is to complete the function minimum_number() which takes the number as input parameter and returns the smallest number than can be formed without leading zeros by rearranging the digits of the number.
Expected Time Complexity: O(N * log(N)) where N is the number of digits of the given number
Expected Space Complexity: O(1)
Constraints:
1 <= N <= 10^{5} | taco |
class Solution:
def minimum_Number(self, s):
lst = list(s)
num = sorted(lst)
num = ''.join(num)
num = list(num)
for i in range(len(num)):
if num[i] == '0':
continue
(num[i], num[0]) = (num[0], num[i])
return ''.join(num)
return ''.join(num)
| python | 11 | 0.552239 | 38 | 19.615385 | 13 | Given a number s(in string form). Find the Smallest number (Not leading Zeros) which can be obtained by rearranging the digits of given number.
Example 1:
Input: s = "846903"
Output: 304689
Explanation: 304689 is the smallest number
by rearranging the digits.
Example 2:
Input: s = "55010"
Output: 10055
Explanation: 10055 is the smallest number
by rearranging the digts.
Your Task:
You don't need to read or print anything. Your task is to complete the function minimum_number() which takes the number as input parameter and returns the smallest number than can be formed without leading zeros by rearranging the digits of the number.
Expected Time Complexity: O(N * log(N)) where N is the number of digits of the given number
Expected Space Complexity: O(1)
Constraints:
1 <= N <= 10^{5} | taco |
class Solution:
def minimum_Number(self, n):
arr = sorted([int(i) for i in list(str(n))])
zcount = arr.count(0)
if zcount == 0:
return int(''.join(arr))
elif zcount == len(arr):
return 0
else:
s = str(arr[zcount])
for _ in range(zcount):
s += '0'
for i in arr[zcount + 1:]:
s += str(i)
return int(s)
| python | 15 | 0.56213 | 46 | 20.125 | 16 | Given a number s(in string form). Find the Smallest number (Not leading Zeros) which can be obtained by rearranging the digits of given number.
Example 1:
Input: s = "846903"
Output: 304689
Explanation: 304689 is the smallest number
by rearranging the digits.
Example 2:
Input: s = "55010"
Output: 10055
Explanation: 10055 is the smallest number
by rearranging the digts.
Your Task:
You don't need to read or print anything. Your task is to complete the function minimum_number() which takes the number as input parameter and returns the smallest number than can be formed without leading zeros by rearranging the digits of the number.
Expected Time Complexity: O(N * log(N)) where N is the number of digits of the given number
Expected Space Complexity: O(1)
Constraints:
1 <= N <= 10^{5} | taco |
import heapq
class Solution:
def minimum_Number(self, s):
s = list(s)
s.sort()
s.append('-1')
i = 0
while s[i] == '0':
i += 1
if i == len(s) - 1:
return 0
s.pop()
(s[0], s[i]) = (s[i], s[0])
return ''.join(s)
| python | 10 | 0.483051 | 29 | 13.75 | 16 | Given a number s(in string form). Find the Smallest number (Not leading Zeros) which can be obtained by rearranging the digits of given number.
Example 1:
Input: s = "846903"
Output: 304689
Explanation: 304689 is the smallest number
by rearranging the digits.
Example 2:
Input: s = "55010"
Output: 10055
Explanation: 10055 is the smallest number
by rearranging the digts.
Your Task:
You don't need to read or print anything. Your task is to complete the function minimum_number() which takes the number as input parameter and returns the smallest number than can be formed without leading zeros by rearranging the digits of the number.
Expected Time Complexity: O(N * log(N)) where N is the number of digits of the given number
Expected Space Complexity: O(1)
Constraints:
1 <= N <= 10^{5} | taco |
class Solution:
def minimum_Number(self, s):
n = len(s)
ls = list(s)
ls.sort()
i = 0
while i < n and ls[i] == '0':
i += 1
if i < n:
(ls[0], ls[i]) = (ls[i], ls[0])
return ''.join(ls)
| python | 11 | 0.478049 | 34 | 16.083333 | 12 | Given a number s(in string form). Find the Smallest number (Not leading Zeros) which can be obtained by rearranging the digits of given number.
Example 1:
Input: s = "846903"
Output: 304689
Explanation: 304689 is the smallest number
by rearranging the digits.
Example 2:
Input: s = "55010"
Output: 10055
Explanation: 10055 is the smallest number
by rearranging the digts.
Your Task:
You don't need to read or print anything. Your task is to complete the function minimum_number() which takes the number as input parameter and returns the smallest number than can be formed without leading zeros by rearranging the digits of the number.
Expected Time Complexity: O(N * log(N)) where N is the number of digits of the given number
Expected Space Complexity: O(1)
Constraints:
1 <= N <= 10^{5} | taco |
class Solution:
def minTime(self, arr, n, k):
def numofPainter(maxLen):
painters = 1
total = 0
for board in arr:
total += board
if total > maxLen:
total = board
painters += 1
return painters
(low, high) = (max(arr), sum(arr))
while low < high:
p = low + (high - low) // 2
curr_painters = numofPainter(p)
if curr_painters <= k:
high = p
else:
low = p + 1
return low
| python | 13 | 0.570423 | 36 | 18.363636 | 22 | Dilpreet wants to paint his dog's home that has n boards with different lengths. The length of i^{th }board is given by arr[i] where arr[] is an array of n integers. He hired k painters for this work and each painter takes 1 unit time to paint 1 unit of the board.
The problem is to find the minimum time to get this job done if all painters start together with the constraint that any painter will only paint continuous boards, say boards numbered {2,3,4} or only board {1} or nothing but not boards {2,4,5}.
Example 1:
Input:
n = 5
k = 3
arr[] = {5,10,30,20,15}
Output: 35
Explanation: The most optimal way will be:
Painter 1 allocation : {5,10}
Painter 2 allocation : {30}
Painter 3 allocation : {20,15}
Job will be done when all painters finish
i.e. at time = max(5+10, 30, 20+15) = 35
Example 2:
Input:
n = 4
k = 2
arr[] = {10,20,30,40}
Output: 60
Explanation: The most optimal way to paint:
Painter 1 allocation : {10,20,30}
Painter 2 allocation : {40}
Job will be complete at time = 60
Your task:
Your task is to complete the function minTime() which takes the integers n and k and the array arr[] as input and returns the minimum time required to paint all partitions.
Expected Time Complexity: O(n log m) , m = sum of all boards' length
Expected Auxiliary Space: O(1)
Constraints:
1 ≤ n ≤ 10^{5}
1 ≤ k ≤ 10^{5}
1 ≤ arr[i] ≤ 10^{5} | taco |
class Solution:
def minTime(self, arr, n, k):
def numOfPainter(maxLen):
painters = 1
total = 0
for board in arr:
total += board
if total > maxLen:
total = board
painters += 1
return painters
(low, high) = (max(arr), sum(arr))
while low < high:
pivot = low + (high - low) // 2
currPainters = numOfPainter(pivot)
if currPainters <= k:
high = pivot
else:
low = pivot + 1
return low
| python | 13 | 0.588636 | 37 | 19 | 22 | Dilpreet wants to paint his dog's home that has n boards with different lengths. The length of i^{th }board is given by arr[i] where arr[] is an array of n integers. He hired k painters for this work and each painter takes 1 unit time to paint 1 unit of the board.
The problem is to find the minimum time to get this job done if all painters start together with the constraint that any painter will only paint continuous boards, say boards numbered {2,3,4} or only board {1} or nothing but not boards {2,4,5}.
Example 1:
Input:
n = 5
k = 3
arr[] = {5,10,30,20,15}
Output: 35
Explanation: The most optimal way will be:
Painter 1 allocation : {5,10}
Painter 2 allocation : {30}
Painter 3 allocation : {20,15}
Job will be done when all painters finish
i.e. at time = max(5+10, 30, 20+15) = 35
Example 2:
Input:
n = 4
k = 2
arr[] = {10,20,30,40}
Output: 60
Explanation: The most optimal way to paint:
Painter 1 allocation : {10,20,30}
Painter 2 allocation : {40}
Job will be complete at time = 60
Your task:
Your task is to complete the function minTime() which takes the integers n and k and the array arr[] as input and returns the minimum time required to paint all partitions.
Expected Time Complexity: O(n log m) , m = sum of all boards' length
Expected Auxiliary Space: O(1)
Constraints:
1 ≤ n ≤ 10^{5}
1 ≤ k ≤ 10^{5}
1 ≤ arr[i] ≤ 10^{5} | taco |
class Solution:
def numberOfPainters(self, arr, n, maxLen):
total = 0
numPainters = 1
for i in arr:
total += i
if total > maxLen:
total = i
numPainters += 1
return numPainters
def minTime(self, arr, n, k):
lo = max(arr)
hi = sum(arr)
while lo < hi:
mid = lo + (hi - lo) // 2
requiredPainters = self.numberOfPainters(arr, n, mid)
if requiredPainters <= k:
hi = mid
else:
lo = mid + 1
return lo
| python | 13 | 0.595078 | 56 | 18.434783 | 23 | Dilpreet wants to paint his dog's home that has n boards with different lengths. The length of i^{th }board is given by arr[i] where arr[] is an array of n integers. He hired k painters for this work and each painter takes 1 unit time to paint 1 unit of the board.
The problem is to find the minimum time to get this job done if all painters start together with the constraint that any painter will only paint continuous boards, say boards numbered {2,3,4} or only board {1} or nothing but not boards {2,4,5}.
Example 1:
Input:
n = 5
k = 3
arr[] = {5,10,30,20,15}
Output: 35
Explanation: The most optimal way will be:
Painter 1 allocation : {5,10}
Painter 2 allocation : {30}
Painter 3 allocation : {20,15}
Job will be done when all painters finish
i.e. at time = max(5+10, 30, 20+15) = 35
Example 2:
Input:
n = 4
k = 2
arr[] = {10,20,30,40}
Output: 60
Explanation: The most optimal way to paint:
Painter 1 allocation : {10,20,30}
Painter 2 allocation : {40}
Job will be complete at time = 60
Your task:
Your task is to complete the function minTime() which takes the integers n and k and the array arr[] as input and returns the minimum time required to paint all partitions.
Expected Time Complexity: O(n log m) , m = sum of all boards' length
Expected Auxiliary Space: O(1)
Constraints:
1 ≤ n ≤ 10^{5}
1 ≤ k ≤ 10^{5}
1 ≤ arr[i] ≤ 10^{5} | taco |
class Solution:
def ifpossible(self, arr, n, k, mid):
load = 0
painter = 1
for board in arr:
load += board
if load > mid:
painter += 1
load = board
return painter <= k
def recursion(self, arr, n, k, start, end, ans):
if start > end:
return ans
mid = (start + end) // 2
output = self.ifpossible(arr, n, k, mid)
if output:
ans = mid
end = mid - 1
return self.recursion(arr, n, k, start, end, ans)
else:
start = mid + 1
return self.recursion(arr, n, k, start, end, ans)
def minTime(self, arr, n, k):
(start, end) = (max(arr), sum(arr))
ans = -1
return self.recursion(arr, n, k, start, end, ans)
| python | 11 | 0.590214 | 52 | 21.551724 | 29 | Dilpreet wants to paint his dog's home that has n boards with different lengths. The length of i^{th }board is given by arr[i] where arr[] is an array of n integers. He hired k painters for this work and each painter takes 1 unit time to paint 1 unit of the board.
The problem is to find the minimum time to get this job done if all painters start together with the constraint that any painter will only paint continuous boards, say boards numbered {2,3,4} or only board {1} or nothing but not boards {2,4,5}.
Example 1:
Input:
n = 5
k = 3
arr[] = {5,10,30,20,15}
Output: 35
Explanation: The most optimal way will be:
Painter 1 allocation : {5,10}
Painter 2 allocation : {30}
Painter 3 allocation : {20,15}
Job will be done when all painters finish
i.e. at time = max(5+10, 30, 20+15) = 35
Example 2:
Input:
n = 4
k = 2
arr[] = {10,20,30,40}
Output: 60
Explanation: The most optimal way to paint:
Painter 1 allocation : {10,20,30}
Painter 2 allocation : {40}
Job will be complete at time = 60
Your task:
Your task is to complete the function minTime() which takes the integers n and k and the array arr[] as input and returns the minimum time required to paint all partitions.
Expected Time Complexity: O(n log m) , m = sum of all boards' length
Expected Auxiliary Space: O(1)
Constraints:
1 ≤ n ≤ 10^{5}
1 ≤ k ≤ 10^{5}
1 ≤ arr[i] ≤ 10^{5} | taco |
class Solution:
def isPossible(arr, n, k, mid):
time_sum = 0
painter_count = 1
for i in range(n):
if time_sum + arr[i] <= mid:
time_sum += arr[i]
else:
painter_count += 1
if painter_count > k or arr[i] > mid:
return False
time_sum = arr[i]
return True
def minTime(self, arr, n, k):
low = 0
high = sum(arr)
mid = int(low + (high - low) / 2)
ans = -1
while low <= high:
if Solution.isPossible(arr, n, k, mid):
ans = mid
high = mid - 1
else:
low = mid + 1
mid = int(low + (high - low) / 2)
return ans
| python | 15 | 0.547368 | 42 | 19.357143 | 28 | Dilpreet wants to paint his dog's home that has n boards with different lengths. The length of i^{th }board is given by arr[i] where arr[] is an array of n integers. He hired k painters for this work and each painter takes 1 unit time to paint 1 unit of the board.
The problem is to find the minimum time to get this job done if all painters start together with the constraint that any painter will only paint continuous boards, say boards numbered {2,3,4} or only board {1} or nothing but not boards {2,4,5}.
Example 1:
Input:
n = 5
k = 3
arr[] = {5,10,30,20,15}
Output: 35
Explanation: The most optimal way will be:
Painter 1 allocation : {5,10}
Painter 2 allocation : {30}
Painter 3 allocation : {20,15}
Job will be done when all painters finish
i.e. at time = max(5+10, 30, 20+15) = 35
Example 2:
Input:
n = 4
k = 2
arr[] = {10,20,30,40}
Output: 60
Explanation: The most optimal way to paint:
Painter 1 allocation : {10,20,30}
Painter 2 allocation : {40}
Job will be complete at time = 60
Your task:
Your task is to complete the function minTime() which takes the integers n and k and the array arr[] as input and returns the minimum time required to paint all partitions.
Expected Time Complexity: O(n log m) , m = sum of all boards' length
Expected Auxiliary Space: O(1)
Constraints:
1 ≤ n ≤ 10^{5}
1 ≤ k ≤ 10^{5}
1 ≤ arr[i] ≤ 10^{5} | taco |
class Solution:
def minTime(self, arr, n, k):
s = 0
sumi = 0
ans = -1
for i in arr:
sumi = sumi + i
e = sumi
mid = (s + e) // 2
while s <= e:
if n == 1:
return arr[0]
if self.ispossible(arr, n, k, mid):
ans = mid
e = mid - 1
else:
s = mid + 1
mid = (s + e) // 2
return ans
def ispossible(self, arr, n, k, mid):
sc = 1
ps = 0
for i in range(len(arr)):
if ps + arr[i] <= mid:
ps += arr[i]
else:
sc += 1
if sc > k or arr[i] > mid:
return False
ps = arr[i]
return True
| python | 14 | 0.480944 | 38 | 15.69697 | 33 | Dilpreet wants to paint his dog's home that has n boards with different lengths. The length of i^{th }board is given by arr[i] where arr[] is an array of n integers. He hired k painters for this work and each painter takes 1 unit time to paint 1 unit of the board.
The problem is to find the minimum time to get this job done if all painters start together with the constraint that any painter will only paint continuous boards, say boards numbered {2,3,4} or only board {1} or nothing but not boards {2,4,5}.
Example 1:
Input:
n = 5
k = 3
arr[] = {5,10,30,20,15}
Output: 35
Explanation: The most optimal way will be:
Painter 1 allocation : {5,10}
Painter 2 allocation : {30}
Painter 3 allocation : {20,15}
Job will be done when all painters finish
i.e. at time = max(5+10, 30, 20+15) = 35
Example 2:
Input:
n = 4
k = 2
arr[] = {10,20,30,40}
Output: 60
Explanation: The most optimal way to paint:
Painter 1 allocation : {10,20,30}
Painter 2 allocation : {40}
Job will be complete at time = 60
Your task:
Your task is to complete the function minTime() which takes the integers n and k and the array arr[] as input and returns the minimum time required to paint all partitions.
Expected Time Complexity: O(n log m) , m = sum of all boards' length
Expected Auxiliary Space: O(1)
Constraints:
1 ≤ n ≤ 10^{5}
1 ≤ k ≤ 10^{5}
1 ≤ arr[i] ≤ 10^{5} | taco |
def isValid(mid, arr, n, k):
sum_ = 0
count = 1
for i in arr:
sum_ += i
if sum_ > mid:
count += 1
sum_ = i
if count > k:
return False
return True
class Solution:
def minTime(self, arr, n, k):
(l, r) = (max(arr), sum(arr))
while l <= r:
mid = l + (r - l) // 2
if isValid(mid, arr, n, k):
r = mid - 1
else:
l = mid + 1
return l
| python | 13 | 0.49866 | 31 | 15.217391 | 23 | Dilpreet wants to paint his dog's home that has n boards with different lengths. The length of i^{th }board is given by arr[i] where arr[] is an array of n integers. He hired k painters for this work and each painter takes 1 unit time to paint 1 unit of the board.
The problem is to find the minimum time to get this job done if all painters start together with the constraint that any painter will only paint continuous boards, say boards numbered {2,3,4} or only board {1} or nothing but not boards {2,4,5}.
Example 1:
Input:
n = 5
k = 3
arr[] = {5,10,30,20,15}
Output: 35
Explanation: The most optimal way will be:
Painter 1 allocation : {5,10}
Painter 2 allocation : {30}
Painter 3 allocation : {20,15}
Job will be done when all painters finish
i.e. at time = max(5+10, 30, 20+15) = 35
Example 2:
Input:
n = 4
k = 2
arr[] = {10,20,30,40}
Output: 60
Explanation: The most optimal way to paint:
Painter 1 allocation : {10,20,30}
Painter 2 allocation : {40}
Job will be complete at time = 60
Your task:
Your task is to complete the function minTime() which takes the integers n and k and the array arr[] as input and returns the minimum time required to paint all partitions.
Expected Time Complexity: O(n log m) , m = sum of all boards' length
Expected Auxiliary Space: O(1)
Constraints:
1 ≤ n ≤ 10^{5}
1 ≤ k ≤ 10^{5}
1 ≤ arr[i] ≤ 10^{5} | taco |
class Solution:
def minTime(self, arr, n, k):
l = 0
r = 0
for i in range(len(arr)):
r = r + arr[i]
mid = l + (r - l) // 2
ans = -1
def ispossible(mid, arr, k):
pc = 1
cs = 0
for i in range(len(arr)):
if cs + arr[i] <= mid:
cs = cs + arr[i]
else:
pc = pc + 1
if pc > k or arr[i] > mid:
return False
cs = arr[i]
return True
while l <= r:
mid = l + (r - l) // 2
if ispossible(mid, arr, k):
ans = mid
r = mid - 1
else:
l = mid + 1
return ans
| python | 16 | 0.462998 | 31 | 16.566667 | 30 | Dilpreet wants to paint his dog's home that has n boards with different lengths. The length of i^{th }board is given by arr[i] where arr[] is an array of n integers. He hired k painters for this work and each painter takes 1 unit time to paint 1 unit of the board.
The problem is to find the minimum time to get this job done if all painters start together with the constraint that any painter will only paint continuous boards, say boards numbered {2,3,4} or only board {1} or nothing but not boards {2,4,5}.
Example 1:
Input:
n = 5
k = 3
arr[] = {5,10,30,20,15}
Output: 35
Explanation: The most optimal way will be:
Painter 1 allocation : {5,10}
Painter 2 allocation : {30}
Painter 3 allocation : {20,15}
Job will be done when all painters finish
i.e. at time = max(5+10, 30, 20+15) = 35
Example 2:
Input:
n = 4
k = 2
arr[] = {10,20,30,40}
Output: 60
Explanation: The most optimal way to paint:
Painter 1 allocation : {10,20,30}
Painter 2 allocation : {40}
Job will be complete at time = 60
Your task:
Your task is to complete the function minTime() which takes the integers n and k and the array arr[] as input and returns the minimum time required to paint all partitions.
Expected Time Complexity: O(n log m) , m = sum of all boards' length
Expected Auxiliary Space: O(1)
Constraints:
1 ≤ n ≤ 10^{5}
1 ≤ k ≤ 10^{5}
1 ≤ arr[i] ≤ 10^{5} | taco |
class Solution:
def minTime(self, arr, n, k):
sum = 0
for i in arr:
sum += i
low = 0
high = sum
mid = (low + high) // 2
ans = -1
while low <= high:
if possible(arr, n, k, mid):
ans = mid
high = mid - 1
else:
low = mid + 1
mid = (low + high) // 2
return ans
def possible(arr, n, k, mid):
c = 1
sum = 0
for i in range(n):
if sum + arr[i] <= mid:
sum = sum + arr[i]
else:
sum = arr[i]
c = c + 1
if c > k or arr[i] > mid:
return False
return True
| python | 13 | 0.503922 | 31 | 15.451613 | 31 | Dilpreet wants to paint his dog's home that has n boards with different lengths. The length of i^{th }board is given by arr[i] where arr[] is an array of n integers. He hired k painters for this work and each painter takes 1 unit time to paint 1 unit of the board.
The problem is to find the minimum time to get this job done if all painters start together with the constraint that any painter will only paint continuous boards, say boards numbered {2,3,4} or only board {1} or nothing but not boards {2,4,5}.
Example 1:
Input:
n = 5
k = 3
arr[] = {5,10,30,20,15}
Output: 35
Explanation: The most optimal way will be:
Painter 1 allocation : {5,10}
Painter 2 allocation : {30}
Painter 3 allocation : {20,15}
Job will be done when all painters finish
i.e. at time = max(5+10, 30, 20+15) = 35
Example 2:
Input:
n = 4
k = 2
arr[] = {10,20,30,40}
Output: 60
Explanation: The most optimal way to paint:
Painter 1 allocation : {10,20,30}
Painter 2 allocation : {40}
Job will be complete at time = 60
Your task:
Your task is to complete the function minTime() which takes the integers n and k and the array arr[] as input and returns the minimum time required to paint all partitions.
Expected Time Complexity: O(n log m) , m = sum of all boards' length
Expected Auxiliary Space: O(1)
Constraints:
1 ≤ n ≤ 10^{5}
1 ≤ k ≤ 10^{5}
1 ≤ arr[i] ≤ 10^{5} | taco |
def is_anagram(test, original):
return sorted(original.lower()) == sorted(test.lower())
| python | 9 | 0.719101 | 56 | 43.5 | 2 | An **anagram** is the result of rearranging the letters of a word to produce a new word.
**Note:** anagrams are case insensitive
Complete the function to return `true` if the two arguments given are anagrams of each other; return `false` otherwise.
## Examples
* `"foefet"` is an anagram of `"toffee"`
* `"Buckethead"` is an anagram of `"DeathCubeK"` | taco |
from collections import Counter
def is_anagram(test, original):
return Counter(test.lower()) == Counter(original.lower())
| python | 9 | 0.758065 | 58 | 30 | 4 | An **anagram** is the result of rearranging the letters of a word to produce a new word.
**Note:** anagrams are case insensitive
Complete the function to return `true` if the two arguments given are anagrams of each other; return `false` otherwise.
## Examples
* `"foefet"` is an anagram of `"toffee"`
* `"Buckethead"` is an anagram of `"DeathCubeK"` | taco |
def is_anagram(test, original):
return sorted(test.upper()) == sorted(original.upper())
| python | 9 | 0.719101 | 56 | 43.5 | 2 | An **anagram** is the result of rearranging the letters of a word to produce a new word.
**Note:** anagrams are case insensitive
Complete the function to return `true` if the two arguments given are anagrams of each other; return `false` otherwise.
## Examples
* `"foefet"` is an anagram of `"toffee"`
* `"Buckethead"` is an anagram of `"DeathCubeK"` | taco |
def is_anagram(test, original):
(test_dict, original_dict) = ({}, {})
for i in test.lower():
test_dict[i] = test_dict.get(i, 0) + 1
for i in original.lower():
original_dict[i] = original_dict.get(i, 0) + 1
return test_dict == original_dict
| python | 10 | 0.637097 | 48 | 34.428571 | 7 | An **anagram** is the result of rearranging the letters of a word to produce a new word.
**Note:** anagrams are case insensitive
Complete the function to return `true` if the two arguments given are anagrams of each other; return `false` otherwise.
## Examples
* `"foefet"` is an anagram of `"toffee"`
* `"Buckethead"` is an anagram of `"DeathCubeK"` | taco |
def is_anagram(test, original):
if len(test) != len(original):
return False
count = [0] * 26
for i in range(len(test)):
count[(ord(test[i]) & 31) - 1] += 1
count[(ord(original[i]) & 31) - 1] -= 1
return not any(count)
| python | 14 | 0.596491 | 41 | 27.5 | 8 | An **anagram** is the result of rearranging the letters of a word to produce a new word.
**Note:** anagrams are case insensitive
Complete the function to return `true` if the two arguments given are anagrams of each other; return `false` otherwise.
## Examples
* `"foefet"` is an anagram of `"toffee"`
* `"Buckethead"` is an anagram of `"DeathCubeK"` | taco |
def is_anagram(test, original):
a = sorted(test.lower())
b = sorted(original.lower())
c = ''.join(a)
d = ''.join(b)
if c == d:
return True
else:
return False
| python | 9 | 0.60119 | 31 | 17.666667 | 9 | An **anagram** is the result of rearranging the letters of a word to produce a new word.
**Note:** anagrams are case insensitive
Complete the function to return `true` if the two arguments given are anagrams of each other; return `false` otherwise.
## Examples
* `"foefet"` is an anagram of `"toffee"`
* `"Buckethead"` is an anagram of `"DeathCubeK"` | taco |
def is_anagram(test, original):
go = len(test) == len(original)
arr = []
if go:
for i in test:
arr.append(i.lower() in original.lower())
return False not in arr
else:
return False
| python | 13 | 0.647668 | 44 | 20.444444 | 9 | An **anagram** is the result of rearranging the letters of a word to produce a new word.
**Note:** anagrams are case insensitive
Complete the function to return `true` if the two arguments given are anagrams of each other; return `false` otherwise.
## Examples
* `"foefet"` is an anagram of `"toffee"`
* `"Buckethead"` is an anagram of `"DeathCubeK"` | taco |
def is_anagram(test, original):
if len(test) != len(original):
return False
for l in test.lower():
if l not in original.lower():
return False
return True
| python | 9 | 0.682927 | 31 | 22.428571 | 7 | An **anagram** is the result of rearranging the letters of a word to produce a new word.
**Note:** anagrams are case insensitive
Complete the function to return `true` if the two arguments given are anagrams of each other; return `false` otherwise.
## Examples
* `"foefet"` is an anagram of `"toffee"`
* `"Buckethead"` is an anagram of `"DeathCubeK"` | taco |
from operator import eq
from collections import Counter
def is_anagram(test, original):
return eq(*map(Counter, map(str.lower, (test, original))))
| python | 12 | 0.758389 | 59 | 28.8 | 5 | An **anagram** is the result of rearranging the letters of a word to produce a new word.
**Note:** anagrams are case insensitive
Complete the function to return `true` if the two arguments given are anagrams of each other; return `false` otherwise.
## Examples
* `"foefet"` is an anagram of `"toffee"`
* `"Buckethead"` is an anagram of `"DeathCubeK"` | taco |
def is_anagram(test, original):
if len(test) != len(original):
return False
return sorted(test.lower()) == sorted(original.lower())
| python | 9 | 0.698529 | 56 | 33 | 4 | An **anagram** is the result of rearranging the letters of a word to produce a new word.
**Note:** anagrams are case insensitive
Complete the function to return `true` if the two arguments given are anagrams of each other; return `false` otherwise.
## Examples
* `"foefet"` is an anagram of `"toffee"`
* `"Buckethead"` is an anagram of `"DeathCubeK"` | taco |
def is_anagram(test, original):
if sorted(test.lower()) == sorted(original.lower()):
return True
else:
return False
| python | 9 | 0.696721 | 53 | 23.4 | 5 | An **anagram** is the result of rearranging the letters of a word to produce a new word.
**Note:** anagrams are case insensitive
Complete the function to return `true` if the two arguments given are anagrams of each other; return `false` otherwise.
## Examples
* `"foefet"` is an anagram of `"toffee"`
* `"Buckethead"` is an anagram of `"DeathCubeK"` | taco |
is_anagram = lambda t, o: sorted(t.lower()) == sorted(o.lower())
| python | 9 | 0.630769 | 64 | 64 | 1 | An **anagram** is the result of rearranging the letters of a word to produce a new word.
**Note:** anagrams are case insensitive
Complete the function to return `true` if the two arguments given are anagrams of each other; return `false` otherwise.
## Examples
* `"foefet"` is an anagram of `"toffee"`
* `"Buckethead"` is an anagram of `"DeathCubeK"` | taco |
aprime = {'a': 2, 'c': 5, 'b': 3, 'e': 11, 'd': 7, 'g': 17, 'f': 13, 'i': 23, 'h': 19, 'k': 31, 'j': 29, 'm': 41, 'l': 37, 'o': 47, 'n': 43, 'q': 59, 'p': 53, 's': 67, 'r': 61, 'u': 73, 't': 71, 'w': 83, 'v': 79, 'y': 97, 'x': 89, 'z': 101}
def aprime_sum(str):
strChList = list(str.lower())
return sum([aprime[x] for x in strChList])
def is_anagram(test, original):
if aprime_sum(test) == aprime_sum(original):
return True
else:
return False
| python | 9 | 0.505519 | 240 | 40.181818 | 11 | An **anagram** is the result of rearranging the letters of a word to produce a new word.
**Note:** anagrams are case insensitive
Complete the function to return `true` if the two arguments given are anagrams of each other; return `false` otherwise.
## Examples
* `"foefet"` is an anagram of `"toffee"`
* `"Buckethead"` is an anagram of `"DeathCubeK"` | taco |
def is_anagram(test, original):
return set(original.lower()) == set(test.lower()) if len(test) == len(original) else False
| python | 10 | 0.701613 | 91 | 61 | 2 | An **anagram** is the result of rearranging the letters of a word to produce a new word.
**Note:** anagrams are case insensitive
Complete the function to return `true` if the two arguments given are anagrams of each other; return `false` otherwise.
## Examples
* `"foefet"` is an anagram of `"toffee"`
* `"Buckethead"` is an anagram of `"DeathCubeK"` | taco |
def is_anagram(test, original):
a = list(test.lower())
s = list(original.lower())
if len(a) != len(s):
return False
else:
for i in a:
cond = False
k = 0
while k != len(s) and cond == False:
if i == s[k]:
a.remove(i)
s.remove(i)
cond = True
k += 1
if cond == False:
return False
if len(a) != len(s):
return False
else:
return True
| python | 15 | 0.540052 | 39 | 17.428571 | 21 | An **anagram** is the result of rearranging the letters of a word to produce a new word.
**Note:** anagrams are case insensitive
Complete the function to return `true` if the two arguments given are anagrams of each other; return `false` otherwise.
## Examples
* `"foefet"` is an anagram of `"toffee"`
* `"Buckethead"` is an anagram of `"DeathCubeK"` | taco |
def is_anagram(test, original):
flag = 0
if len(test) != len(original):
return False
else:
for i in test.lower():
if i not in original.lower():
flag = 1
else:
continue
if flag == 1:
return False
else:
return True
| python | 12 | 0.610656 | 32 | 16.428571 | 14 | An **anagram** is the result of rearranging the letters of a word to produce a new word.
**Note:** anagrams are case insensitive
Complete the function to return `true` if the two arguments given are anagrams of each other; return `false` otherwise.
## Examples
* `"foefet"` is an anagram of `"toffee"`
* `"Buckethead"` is an anagram of `"DeathCubeK"` | taco |
def is_anagram(test, original):
def to_dict(word):
dictionary = {}
for w in word.lower():
if w not in dictionary:
dictionary[w] = 0
else:
dictionary[w] += 1
return dictionary
return to_dict(test) == to_dict(original)
| python | 13 | 0.641667 | 42 | 20.818182 | 11 | An **anagram** is the result of rearranging the letters of a word to produce a new word.
**Note:** anagrams are case insensitive
Complete the function to return `true` if the two arguments given are anagrams of each other; return `false` otherwise.
## Examples
* `"foefet"` is an anagram of `"toffee"`
* `"Buckethead"` is an anagram of `"DeathCubeK"` | taco |
is_anagram = lambda a, b, s=sorted: s(a.lower()) == s(b.lower())
| python | 9 | 0.584615 | 64 | 64 | 1 | An **anagram** is the result of rearranging the letters of a word to produce a new word.
**Note:** anagrams are case insensitive
Complete the function to return `true` if the two arguments given are anagrams of each other; return `false` otherwise.
## Examples
* `"foefet"` is an anagram of `"toffee"`
* `"Buckethead"` is an anagram of `"DeathCubeK"` | taco |
def is_anagram(s, l):
n = len(s)
if len(l) != n:
return False
s = s.lower()
l = l.lower()
h = [0 for x in range(26)]
for i in range(n):
h[ord(s[i]) - 97] += 1
h[ord(l[i]) - 97] -= 1
return h.count(0) == 26
| python | 12 | 0.506849 | 27 | 18.909091 | 11 | An **anagram** is the result of rearranging the letters of a word to produce a new word.
**Note:** anagrams are case insensitive
Complete the function to return `true` if the two arguments given are anagrams of each other; return `false` otherwise.
## Examples
* `"foefet"` is an anagram of `"toffee"`
* `"Buckethead"` is an anagram of `"DeathCubeK"` | taco |
def is_anagram(test: str, original: str) -> bool:
return all([all([_ in original.lower() for _ in test.lower()]), len(test) == len(original)])
| python | 13 | 0.645833 | 93 | 71 | 2 | An **anagram** is the result of rearranging the letters of a word to produce a new word.
**Note:** anagrams are case insensitive
Complete the function to return `true` if the two arguments given are anagrams of each other; return `false` otherwise.
## Examples
* `"foefet"` is an anagram of `"toffee"`
* `"Buckethead"` is an anagram of `"DeathCubeK"` | taco |
def is_anagram(test, original):
test = test.lower()
original = original.lower()
testcount = 0
for i in test:
if i in original:
testcount += 1
originalcount = 0
for i in original:
if i in test:
originalcount += 1
if testcount == originalcount and testcount == len(test) and (originalcount == len(original)):
return True
else:
return False
| python | 9 | 0.686111 | 95 | 23 | 15 | An **anagram** is the result of rearranging the letters of a word to produce a new word.
**Note:** anagrams are case insensitive
Complete the function to return `true` if the two arguments given are anagrams of each other; return `false` otherwise.
## Examples
* `"foefet"` is an anagram of `"toffee"`
* `"Buckethead"` is an anagram of `"DeathCubeK"` | taco |
def is_anagram(test, original):
if len(test) == len(original):
test = test.lower()
original = original.lower()
count = 0
for char in test:
if char in original:
count += 1
if count == len(test):
return True
else:
return False
else:
return False
| python | 11 | 0.6337 | 31 | 18.5 | 14 | An **anagram** is the result of rearranging the letters of a word to produce a new word.
**Note:** anagrams are case insensitive
Complete the function to return `true` if the two arguments given are anagrams of each other; return `false` otherwise.
## Examples
* `"foefet"` is an anagram of `"toffee"`
* `"Buckethead"` is an anagram of `"DeathCubeK"` | taco |
def is_anagram(test, original):
test_list = []
original_list = []
for i in test.lower():
test_list.append(i)
for i in original.lower():
original_list.append(i)
test_list.sort()
original_list.sort()
print(test_list)
print(original_list)
if test_list == original_list:
return True
else:
return False
| python | 8 | 0.686709 | 31 | 20.066667 | 15 | An **anagram** is the result of rearranging the letters of a word to produce a new word.
**Note:** anagrams are case insensitive
Complete the function to return `true` if the two arguments given are anagrams of each other; return `false` otherwise.
## Examples
* `"foefet"` is an anagram of `"toffee"`
* `"Buckethead"` is an anagram of `"DeathCubeK"` | taco |
def is_anagram(test, original):
if len(test) != len(original):
return False
letters = {}
for i in test.lower():
if i in letters:
letters[i] += 1
else:
letters[i] = 1
for i in original.lower():
if i not in letters:
return False
if original.lower().count(i) != letters[i]:
return False
return True
| python | 11 | 0.637771 | 45 | 20.533333 | 15 | An **anagram** is the result of rearranging the letters of a word to produce a new word.
**Note:** anagrams are case insensitive
Complete the function to return `true` if the two arguments given are anagrams of each other; return `false` otherwise.
## Examples
* `"foefet"` is an anagram of `"toffee"`
* `"Buckethead"` is an anagram of `"DeathCubeK"` | taco |
def is_anagram(t, o):
return sorted([*t.lower()]) == sorted([*o.lower()])
| python | 11 | 0.586667 | 52 | 36.5 | 2 | An **anagram** is the result of rearranging the letters of a word to produce a new word.
**Note:** anagrams are case insensitive
Complete the function to return `true` if the two arguments given are anagrams of each other; return `false` otherwise.
## Examples
* `"foefet"` is an anagram of `"toffee"`
* `"Buckethead"` is an anagram of `"DeathCubeK"` | taco |
def is_anagram(test, original):
x = list(test.lower())
y = list(original.lower())
x = sorted(x)
y = sorted(y)
if x == y:
return True
else:
return False
| python | 9 | 0.623457 | 31 | 17 | 9 | An **anagram** is the result of rearranging the letters of a word to produce a new word.
**Note:** anagrams are case insensitive
Complete the function to return `true` if the two arguments given are anagrams of each other; return `false` otherwise.
## Examples
* `"foefet"` is an anagram of `"toffee"`
* `"Buckethead"` is an anagram of `"DeathCubeK"` | taco |
def is_anagram(test, original):
if len(test) != len(original):
return False
a = sorted(test.lower())
b = sorted(original.lower())
if a == b:
return True
else:
return False
| python | 9 | 0.655738 | 31 | 19.333333 | 9 | An **anagram** is the result of rearranging the letters of a word to produce a new word.
**Note:** anagrams are case insensitive
Complete the function to return `true` if the two arguments given are anagrams of each other; return `false` otherwise.
## Examples
* `"foefet"` is an anagram of `"toffee"`
* `"Buckethead"` is an anagram of `"DeathCubeK"` | taco |
def is_anagram(test, original):
sorted_test = sorted(list(test.lower()))
sorted_original = sorted(list(original.lower()))
return sorted_test == sorted_original
| python | 11 | 0.736196 | 49 | 39.75 | 4 | An **anagram** is the result of rearranging the letters of a word to produce a new word.
**Note:** anagrams are case insensitive
Complete the function to return `true` if the two arguments given are anagrams of each other; return `false` otherwise.
## Examples
* `"foefet"` is an anagram of `"toffee"`
* `"Buckethead"` is an anagram of `"DeathCubeK"` | taco |
def is_anagram(test, original):
letters = [c for c in test.lower()]
for char in original.lower():
if char in letters:
del letters[letters.index(char)]
else:
return False
return not bool(len(letters))
| python | 11 | 0.694836 | 36 | 25.625 | 8 | An **anagram** is the result of rearranging the letters of a word to produce a new word.
**Note:** anagrams are case insensitive
Complete the function to return `true` if the two arguments given are anagrams of each other; return `false` otherwise.
## Examples
* `"foefet"` is an anagram of `"toffee"`
* `"Buckethead"` is an anagram of `"DeathCubeK"` | taco |
import collections
def is_anagram(test, original):
return collections.Counter([i.lower() for i in sorted(test)]) == collections.Counter([i.lower() for i in sorted(original)])
| python | 11 | 0.740113 | 124 | 43.25 | 4 | An **anagram** is the result of rearranging the letters of a word to produce a new word.
**Note:** anagrams are case insensitive
Complete the function to return `true` if the two arguments given are anagrams of each other; return `false` otherwise.
## Examples
* `"foefet"` is an anagram of `"toffee"`
* `"Buckethead"` is an anagram of `"DeathCubeK"` | taco |
def is_anagram(test, original):
test_set = sorted(test.lower())
original_set = sorted(original.lower())
if test_set == original_set:
return True
else:
return False
| python | 9 | 0.703488 | 40 | 23.571429 | 7 | An **anagram** is the result of rearranging the letters of a word to produce a new word.
**Note:** anagrams are case insensitive
Complete the function to return `true` if the two arguments given are anagrams of each other; return `false` otherwise.
## Examples
* `"foefet"` is an anagram of `"toffee"`
* `"Buckethead"` is an anagram of `"DeathCubeK"` | taco |
def is_anagram(test, original):
t = sorted(test.lower())
o = sorted(original.lower())
if t == o:
return True
else:
return False
| python | 9 | 0.654412 | 31 | 18.428571 | 7 | An **anagram** is the result of rearranging the letters of a word to produce a new word.
**Note:** anagrams are case insensitive
Complete the function to return `true` if the two arguments given are anagrams of each other; return `false` otherwise.
## Examples
* `"foefet"` is an anagram of `"toffee"`
* `"Buckethead"` is an anagram of `"DeathCubeK"` | taco |
def is_anagram(test, original):
new_test = test.lower()
new_original = original.lower()
sortedTest = sorted(new_test)
sortedOriginal = sorted(new_original)
for letters in new_test:
if letters in new_original and len(new_test) == len(new_original) and (sortedOriginal == sortedTest):
return True
else:
return False
| python | 11 | 0.723404 | 103 | 31.9 | 10 | An **anagram** is the result of rearranging the letters of a word to produce a new word.
**Note:** anagrams are case insensitive
Complete the function to return `true` if the two arguments given are anagrams of each other; return `false` otherwise.
## Examples
* `"foefet"` is an anagram of `"toffee"`
* `"Buckethead"` is an anagram of `"DeathCubeK"` | taco |
def is_anagram(test, original):
test_word_freq = {}
original_word_freq = {}
test = test.lower()
original = original.lower()
if len(test) == len(original):
for (idx, letter) in enumerate(test):
if letter not in test_word_freq:
test_word_freq[letter] = 1
else:
test_word_freq[letter] += 1
for (idx, lett) in enumerate(original):
if lett not in original_word_freq:
original_word_freq[lett] = 1
else:
original_word_freq[lett] += 1
print(original_word_freq)
print(test_word_freq)
for (k, v) in list(test_word_freq.items()):
if k not in original_word_freq:
return False
if v != original_word_freq[k]:
return False
return True
else:
return False
| python | 13 | 0.654779 | 45 | 25.961538 | 26 | An **anagram** is the result of rearranging the letters of a word to produce a new word.
**Note:** anagrams are case insensitive
Complete the function to return `true` if the two arguments given are anagrams of each other; return `false` otherwise.
## Examples
* `"foefet"` is an anagram of `"toffee"`
* `"Buckethead"` is an anagram of `"DeathCubeK"` | taco |
def is_anagram(test, original):
first = [i.lower() for i in test]
second = [i.lower() for i in original]
return sorted(first) == sorted(second)
| python | 8 | 0.680272 | 39 | 35.75 | 4 | An **anagram** is the result of rearranging the letters of a word to produce a new word.
**Note:** anagrams are case insensitive
Complete the function to return `true` if the two arguments given are anagrams of each other; return `false` otherwise.
## Examples
* `"foefet"` is an anagram of `"toffee"`
* `"Buckethead"` is an anagram of `"DeathCubeK"` | taco |
def is_anagram(test, original):
list_test = []
list_original = []
for i in test.lower():
list_test += i
for i in original.lower():
list_original += i
if len(list_test) == len(list_original):
list_test.sort()
list_original.sort()
if list_test == list_original:
return True
else:
return False
else:
return False
| python | 9 | 0.64881 | 41 | 20 | 16 | An **anagram** is the result of rearranging the letters of a word to produce a new word.
**Note:** anagrams are case insensitive
Complete the function to return `true` if the two arguments given are anagrams of each other; return `false` otherwise.
## Examples
* `"foefet"` is an anagram of `"toffee"`
* `"Buckethead"` is an anagram of `"DeathCubeK"` | taco |
def is_anagram(test, original):
return True if sorted([letter for letter in test.lower()]) == sorted([letter for letter in original.lower()]) else False
| python | 12 | 0.733766 | 121 | 76 | 2 | An **anagram** is the result of rearranging the letters of a word to produce a new word.
**Note:** anagrams are case insensitive
Complete the function to return `true` if the two arguments given are anagrams of each other; return `false` otherwise.
## Examples
* `"foefet"` is an anagram of `"toffee"`
* `"Buckethead"` is an anagram of `"DeathCubeK"` | taco |
def is_anagram(test, original):
t = list(test.lower())
to = ''.join(sorted(t))
o = list(original.lower())
oo = ''.join(sorted(o))
if to == oo:
return True
else:
return False
| python | 9 | 0.61413 | 31 | 19.444444 | 9 | An **anagram** is the result of rearranging the letters of a word to produce a new word.
**Note:** anagrams are case insensitive
Complete the function to return `true` if the two arguments given are anagrams of each other; return `false` otherwise.
## Examples
* `"foefet"` is an anagram of `"toffee"`
* `"Buckethead"` is an anagram of `"DeathCubeK"` | taco |
def is_anagram(test, original):
letterCount = dict.fromkeys('abcdefghijklmnopqrstuvwxyz', 0)
for c in test.lower():
letterCount[c] += 1
for c in original.lower():
letterCount[c] -= 1
for value in list(letterCount.values()):
if value != 0:
return False
return True
| python | 8 | 0.697842 | 61 | 26.8 | 10 | An **anagram** is the result of rearranging the letters of a word to produce a new word.
**Note:** anagrams are case insensitive
Complete the function to return `true` if the two arguments given are anagrams of each other; return `false` otherwise.
## Examples
* `"foefet"` is an anagram of `"toffee"`
* `"Buckethead"` is an anagram of `"DeathCubeK"` | taco |
def is_anagram(a_str, b_str):
if len(a_str) == len(b_str):
a_list = list(a_str.lower())
b_list = list(b_str.lower())
for char in a_list:
if char in b_list:
b_list.remove(char)
if not b_list:
return True
else:
return False
else:
return False
| python | 12 | 0.61194 | 30 | 19.615385 | 13 | An **anagram** is the result of rearranging the letters of a word to produce a new word.
**Note:** anagrams are case insensitive
Complete the function to return `true` if the two arguments given are anagrams of each other; return `false` otherwise.
## Examples
* `"foefet"` is an anagram of `"toffee"`
* `"Buckethead"` is an anagram of `"DeathCubeK"` | taco |
def is_anagram(test, original):
if len(test) != len(original):
return False
else:
test = test.lower()
original = original.lower()
counter_original = [0] * 26
counter_test = [0] * 26
for i in test:
counter_test[ord(i) - 97] += 1
for i in original:
counter_original[ord(i) - 97] += 1
return counter_test == counter_original
| python | 14 | 0.64058 | 40 | 25.538462 | 13 | An **anagram** is the result of rearranging the letters of a word to produce a new word.
**Note:** anagrams are case insensitive
Complete the function to return `true` if the two arguments given are anagrams of each other; return `false` otherwise.
## Examples
* `"foefet"` is an anagram of `"toffee"`
* `"Buckethead"` is an anagram of `"DeathCubeK"` | taco |
def is_anagram(test, original):
test = test.lower()
original = original.lower()
newList = [ord(c) for c in test]
newList.sort()
newList2 = [ord(b) for b in original]
newList2.sort()
if newList == newList2:
return True
else:
return False
| python | 8 | 0.682731 | 38 | 21.636364 | 11 | An **anagram** is the result of rearranging the letters of a word to produce a new word.
**Note:** anagrams are case insensitive
Complete the function to return `true` if the two arguments given are anagrams of each other; return `false` otherwise.
## Examples
* `"foefet"` is an anagram of `"toffee"`
* `"Buckethead"` is an anagram of `"DeathCubeK"` | taco |
def is_anagram(test, original):
counterTest = [0] * 255
counterOri = [0] * 255
for i in range(len(test)):
counterTest[ord(test[i].lower())] += 1
for i in range(len(original)):
counterOri[ord(original[i].lower())] += 1
if counterOri == counterTest:
return True
else:
return False
| python | 13 | 0.662116 | 43 | 25.636364 | 11 | An **anagram** is the result of rearranging the letters of a word to produce a new word.
**Note:** anagrams are case insensitive
Complete the function to return `true` if the two arguments given are anagrams of each other; return `false` otherwise.
## Examples
* `"foefet"` is an anagram of `"toffee"`
* `"Buckethead"` is an anagram of `"DeathCubeK"` | taco |
def is_anagram(test, original):
test = test.upper()
original = original.upper()
if sorted(test) == sorted(original):
return True
else:
return False
| python | 7 | 0.698718 | 37 | 21.285714 | 7 | An **anagram** is the result of rearranging the letters of a word to produce a new word.
**Note:** anagrams are case insensitive
Complete the function to return `true` if the two arguments given are anagrams of each other; return `false` otherwise.
## Examples
* `"foefet"` is an anagram of `"toffee"`
* `"Buckethead"` is an anagram of `"DeathCubeK"` | taco |
def is_anagram(test, original):
if len(test) == len(original):
test = test.lower()
original = original.lower()
for i in test:
if original.find(i) == -1:
return False
else:
test.replace(i, '')
original.replace(i, '')
else:
return False
return True
| python | 14 | 0.623188 | 31 | 20.230769 | 13 | An **anagram** is the result of rearranging the letters of a word to produce a new word.
**Note:** anagrams are case insensitive
Complete the function to return `true` if the two arguments given are anagrams of each other; return `false` otherwise.
## Examples
* `"foefet"` is an anagram of `"toffee"`
* `"Buckethead"` is an anagram of `"DeathCubeK"` | taco |
def is_anagram(test, original):
counter1 = [0] * 255
counter2 = [0] * 255
for i in range(len(test)):
counter1[ord(test[i].lower())] += 1
for i in range(len(original)):
counter2[ord(original[i].lower())] += 1
return counter1 == counter2
| python | 13 | 0.644898 | 41 | 29.625 | 8 | An **anagram** is the result of rearranging the letters of a word to produce a new word.
**Note:** anagrams are case insensitive
Complete the function to return `true` if the two arguments given are anagrams of each other; return `false` otherwise.
## Examples
* `"foefet"` is an anagram of `"toffee"`
* `"Buckethead"` is an anagram of `"DeathCubeK"` | taco |
def is_anagram(test, original):
test = test.lower()
original = original.lower()
for x in range(len(test)):
if test.count(test[x]) != original.count(test[x]):
return False
for x in range(len(original)):
if test.count(original[x]) != original.count(original[x]):
return False
return True
| python | 10 | 0.684385 | 60 | 29.1 | 10 | An **anagram** is the result of rearranging the letters of a word to produce a new word.
**Note:** anagrams are case insensitive
Complete the function to return `true` if the two arguments given are anagrams of each other; return `false` otherwise.
## Examples
* `"foefet"` is an anagram of `"toffee"`
* `"Buckethead"` is an anagram of `"DeathCubeK"` | taco |
def is_anagram(test, original):
test = test.lower()
original = original.lower()
nT = len(test)
nO = len(original)
if nO == nT:
counterT = [0] * (255 + 1)
counterO = [0] * (255 + 1)
for x in range(nT):
counterT[ord(test[x])] += 1
counterO[ord(original[x])] += 1
if counterT == counterO:
return True
else:
return False
else:
return False
| python | 13 | 0.603825 | 34 | 20.529412 | 17 | An **anagram** is the result of rearranging the letters of a word to produce a new word.
**Note:** anagrams are case insensitive
Complete the function to return `true` if the two arguments given are anagrams of each other; return `false` otherwise.
## Examples
* `"foefet"` is an anagram of `"toffee"`
* `"Buckethead"` is an anagram of `"DeathCubeK"` | taco |
def is_anagram(test, original):
n = len(original)
if n != len(test):
return False
counterTest = [0] * 255
counterOrig = [0] * 255
for i in range(n):
counterTest[ord(test[i].lower())] += 1
counterOrig[ord(original[i].lower())] += 1
return True if ''.join(map(str, counterTest)) == ''.join(map(str, counterOrig)) else False
| python | 13 | 0.646707 | 91 | 32.4 | 10 | An **anagram** is the result of rearranging the letters of a word to produce a new word.
**Note:** anagrams are case insensitive
Complete the function to return `true` if the two arguments given are anagrams of each other; return `false` otherwise.
## Examples
* `"foefet"` is an anagram of `"toffee"`
* `"Buckethead"` is an anagram of `"DeathCubeK"` | taco |
def is_anagram(test, original):
return sorted([n.lower() for n in test]) == sorted([n.lower() for n in original])
| python | 10 | 0.678261 | 82 | 56.5 | 2 | An **anagram** is the result of rearranging the letters of a word to produce a new word.
**Note:** anagrams are case insensitive
Complete the function to return `true` if the two arguments given are anagrams of each other; return `false` otherwise.
## Examples
* `"foefet"` is an anagram of `"toffee"`
* `"Buckethead"` is an anagram of `"DeathCubeK"` | taco |
def is_anagram(word_o, test_o):
is_anagram = True
word = word_o.lower()
test = test_o.lower()
if len(word) != len(test):
is_anagram = False
alist = list(test.lower())
pos1 = 0
while pos1 < len(word) and is_anagram:
pos2 = 0
found = False
while pos2 < len(alist) and (not found):
if word[pos1] == alist[pos2]:
found = True
else:
pos2 = pos2 + 1
if found:
alist[pos2] = None
else:
is_anagram = False
pos1 = pos1 + 1
return is_anagram
| python | 13 | 0.611814 | 42 | 20.545455 | 22 | An **anagram** is the result of rearranging the letters of a word to produce a new word.
**Note:** anagrams are case insensitive
Complete the function to return `true` if the two arguments given are anagrams of each other; return `false` otherwise.
## Examples
* `"foefet"` is an anagram of `"toffee"`
* `"Buckethead"` is an anagram of `"DeathCubeK"` | taco |
def is_anagram(test, original):
l1 = list(test.lower())
l2 = list(original.lower())
if len(l1) == len(l2):
for i in l1:
if i in l2:
l2.remove(i)
else:
return False
else:
return False
return True
| python | 12 | 0.614679 | 31 | 17.166667 | 12 | An **anagram** is the result of rearranging the letters of a word to produce a new word.
**Note:** anagrams are case insensitive
Complete the function to return `true` if the two arguments given are anagrams of each other; return `false` otherwise.
## Examples
* `"foefet"` is an anagram of `"toffee"`
* `"Buckethead"` is an anagram of `"DeathCubeK"` | taco |
def is_anagram(test, original):
for i in test.lower():
if i in original.lower() and len(test) == len(original):
continue
else:
return False
return True
| python | 10 | 0.676829 | 58 | 22.428571 | 7 | An **anagram** is the result of rearranging the letters of a word to produce a new word.
**Note:** anagrams are case insensitive
Complete the function to return `true` if the two arguments given are anagrams of each other; return `false` otherwise.
## Examples
* `"foefet"` is an anagram of `"toffee"`
* `"Buckethead"` is an anagram of `"DeathCubeK"` | taco |
def is_anagram(test, original):
test_list = [letter1 for letter1 in test.lower()]
orig_list = [letter2 for letter2 in original.lower()]
if sorted(test_list) == sorted(orig_list):
return True
else:
return False
| python | 9 | 0.711009 | 54 | 30.142857 | 7 | An **anagram** is the result of rearranging the letters of a word to produce a new word.
**Note:** anagrams are case insensitive
Complete the function to return `true` if the two arguments given are anagrams of each other; return `false` otherwise.
## Examples
* `"foefet"` is an anagram of `"toffee"`
* `"Buckethead"` is an anagram of `"DeathCubeK"` | taco |
def is_anagram(test, original):
t = sorted(test.lower())
o = sorted(original.lower())
if t == o:
print('true')
return True
else:
print('false')
return False
| python | 10 | 0.639053 | 31 | 17.777778 | 9 | An **anagram** is the result of rearranging the letters of a word to produce a new word.
**Note:** anagrams are case insensitive
Complete the function to return `true` if the two arguments given are anagrams of each other; return `false` otherwise.
## Examples
* `"foefet"` is an anagram of `"toffee"`
* `"Buckethead"` is an anagram of `"DeathCubeK"` | taco |
def is_anagram(test, original):
test = [i.lower() for i in test]
original = [j.lower() for j in original]
test.sort()
original.sort()
return test == original
| python | 8 | 0.674847 | 41 | 26.166667 | 6 | An **anagram** is the result of rearranging the letters of a word to produce a new word.
**Note:** anagrams are case insensitive
Complete the function to return `true` if the two arguments given are anagrams of each other; return `false` otherwise.
## Examples
* `"foefet"` is an anagram of `"toffee"`
* `"Buckethead"` is an anagram of `"DeathCubeK"` | taco |
def is_anagram(test, original):
test = test.lower()
original = original.lower()
if len(test) != len(original):
return False
for x in test:
if test.count(x) == original.count(x):
continue
else:
return False
return True
| python | 9 | 0.67234 | 40 | 20.363636 | 11 | An **anagram** is the result of rearranging the letters of a word to produce a new word.
**Note:** anagrams are case insensitive
Complete the function to return `true` if the two arguments given are anagrams of each other; return `false` otherwise.
## Examples
* `"foefet"` is an anagram of `"toffee"`
* `"Buckethead"` is an anagram of `"DeathCubeK"` | taco |
def is_anagram(test, original):
test = test.lower()
original = original.lower()
new_test = list(test)
new_original = list(original)
new_test.sort()
new_original.sort()
if new_test == new_original:
return True
return False
pass
| python | 7 | 0.701681 | 31 | 20.636364 | 11 | An **anagram** is the result of rearranging the letters of a word to produce a new word.
**Note:** anagrams are case insensitive
Complete the function to return `true` if the two arguments given are anagrams of each other; return `false` otherwise.
## Examples
* `"foefet"` is an anagram of `"toffee"`
* `"Buckethead"` is an anagram of `"DeathCubeK"` | taco |
def is_anagram(test, original):
return set(test.upper()) == set(original.upper()) and len(test) == len(original)
| python | 10 | 0.692982 | 81 | 56 | 2 | An **anagram** is the result of rearranging the letters of a word to produce a new word.
**Note:** anagrams are case insensitive
Complete the function to return `true` if the two arguments given are anagrams of each other; return `false` otherwise.
## Examples
* `"foefet"` is an anagram of `"toffee"`
* `"Buckethead"` is an anagram of `"DeathCubeK"` | taco |
is_anagram = lambda test, original: True if sorted(original.lower()) == sorted(test.lower()) else False
| python | 10 | 0.730769 | 103 | 103 | 1 | An **anagram** is the result of rearranging the letters of a word to produce a new word.
**Note:** anagrams are case insensitive
Complete the function to return `true` if the two arguments given are anagrams of each other; return `false` otherwise.
## Examples
* `"foefet"` is an anagram of `"toffee"`
* `"Buckethead"` is an anagram of `"DeathCubeK"` | taco |
def is_anagram(test, original):
originalLower = [val for val in original.lower()]
arr = test.lower()
if len(arr) != len(originalLower):
return False
for element in arr:
if element not in originalLower:
return False
else:
originalLower.remove(element)
return True
| python | 11 | 0.717857 | 50 | 24.454545 | 11 | An **anagram** is the result of rearranging the letters of a word to produce a new word.
**Note:** anagrams are case insensitive
Complete the function to return `true` if the two arguments given are anagrams of each other; return `false` otherwise.
## Examples
* `"foefet"` is an anagram of `"toffee"`
* `"Buckethead"` is an anagram of `"DeathCubeK"` | taco |
def is_anagram(test, original):
n1 = len(test)
n2 = len(original)
if n1 != n2:
return False
str1 = sorted(test.lower())
str2 = sorted(original.lower())
for i in range(0, n1):
if str1[i] != str2[i]:
return False
return True
| python | 9 | 0.64135 | 32 | 20.545455 | 11 | An **anagram** is the result of rearranging the letters of a word to produce a new word.
**Note:** anagrams are case insensitive
Complete the function to return `true` if the two arguments given are anagrams of each other; return `false` otherwise.
## Examples
* `"foefet"` is an anagram of `"toffee"`
* `"Buckethead"` is an anagram of `"DeathCubeK"` | taco |
def is_anagram(test, original):
test_l = list(test.lower())
original_l = list(original.lower())
test_l.sort()
original_l.sort()
if test_l == original_l:
return True
else:
return False
| python | 9 | 0.675258 | 36 | 20.555556 | 9 | An **anagram** is the result of rearranging the letters of a word to produce a new word.
**Note:** anagrams are case insensitive
Complete the function to return `true` if the two arguments given are anagrams of each other; return `false` otherwise.
## Examples
* `"foefet"` is an anagram of `"toffee"`
* `"Buckethead"` is an anagram of `"DeathCubeK"` | taco |
def is_anagram(test, original):
test = list(test.lower())
original = list(original.lower())
if len(test) != len(original):
return False
for word in test:
for word2 in original:
if word == word2:
original.remove(word2)
break
if len(original) == 0:
return True
else:
return False
| python | 12 | 0.666667 | 34 | 20.642857 | 14 | An **anagram** is the result of rearranging the letters of a word to produce a new word.
**Note:** anagrams are case insensitive
Complete the function to return `true` if the two arguments given are anagrams of each other; return `false` otherwise.
## Examples
* `"foefet"` is an anagram of `"toffee"`
* `"Buckethead"` is an anagram of `"DeathCubeK"` | taco |
def is_anagram(test, original):
a = sorted(list(test.lower()))
b = sorted(list(original.lower()))
if a == b:
print(f'The word {test} is an anagram of {original}')
return True
else:
print(f'Characters do not match for test case {test}, {original}')
return False
| python | 11 | 0.673993 | 68 | 29.333333 | 9 | An **anagram** is the result of rearranging the letters of a word to produce a new word.
**Note:** anagrams are case insensitive
Complete the function to return `true` if the two arguments given are anagrams of each other; return `false` otherwise.
## Examples
* `"foefet"` is an anagram of `"toffee"`
* `"Buckethead"` is an anagram of `"DeathCubeK"` | taco |
def is_anagram(test, original):
def to_list(string):
listed = []
for i in range(len(string)):
listed.append(string[i])
return listed
return str(sorted(to_list(test.lower()))) == str(sorted(to_list(original.lower())))
| python | 13 | 0.672489 | 84 | 27.625 | 8 | An **anagram** is the result of rearranging the letters of a word to produce a new word.
**Note:** anagrams are case insensitive
Complete the function to return `true` if the two arguments given are anagrams of each other; return `false` otherwise.
## Examples
* `"foefet"` is an anagram of `"toffee"`
* `"Buckethead"` is an anagram of `"DeathCubeK"` | taco |
def is_anagram(test, original):
test = list(test.lower())
test.sort()
original = list(original.lower())
original.sort()
if original != test or len(test) != len(original):
return False
else:
return True
| python | 9 | 0.683962 | 51 | 22.555556 | 9 | An **anagram** is the result of rearranging the letters of a word to produce a new word.
**Note:** anagrams are case insensitive
Complete the function to return `true` if the two arguments given are anagrams of each other; return `false` otherwise.
## Examples
* `"foefet"` is an anagram of `"toffee"`
* `"Buckethead"` is an anagram of `"DeathCubeK"` | taco |