CREATE PROCEDURE testCheck() SELECT id, IF (given_answer IS NULL, "no answer", CASE WHEN given_answer = correct_answer THEN "correct" ELSE "incorrect" END) AS checks FROM answers ORDER BY id;
19 January 2018
testCheck
My solution:
Labels:
Arcade,
CodeSignal,
Databases,
MySQL,
Would you LIKE the Second Meal?
newsSubscribers
My solution:
CREATE PROCEDURE newsSubscribers() BEGIN SELECT DISTINCT subscriber FROM full_year WHERE full_year.newspaper LIKE "%Daily%" UNION SELECT DISTINCT subscriber FROM half_year WHERE half_year.newspaper LIKE "%Daily%" ORDER BY subscriber ASC; END
Labels:
Arcade,
CodeSignal,
Databases,
MySQL,
Would you LIKE the Second Meal?
15 August 2017
List Beautifier
My solution:
Previous
def listBeautifier(a): res = a[:] while res and res[0] != res[-1]: b, *res, c = res return res
Previous
Labels:
Arcade,
CodeSignal,
Meet Python,
Python,
Python 3
Mex Function
My solution:
Previous Next
def mexFunction(s, upperBound): found = -1 for i in range(upperBound): if not i in s: found = i break else: found = upperBound return found
Previous Next
Labels:
Arcade,
CodeSignal,
Meet Python,
Python,
Python 3
Base Conversion
My solution:
Previous Next
def baseConversion(n, x): return hex(sum((int(n[i]) if n[i] <= '9' else ord(n[i]) - ord('a') + 10) * x ** (len(n) - 1 - i) for i in range(len(n))))[2:]
Previous Next
Labels:
Arcade,
CodeSignal,
Meet Python,
Python,
Python 3
Simple Sort
My solution:
Previous Next
def simpleSort(arr): n = len(arr) for i in range(n): j = 0 stop = n - i while j < stop - 1: if arr[j] > arr[j + 1]: arr[j + 1], arr[j] = arr[j], arr[j + 1] j += 1 return arr
Previous Next
Labels:
Arcade,
CodeSignal,
Meet Python,
Python,
Python 3
Subscribe to:
Posts (Atom)