A marine themed rival site to Codewars has started. Codwars is advertising their website all over the internet using subdomains to hide or obfuscate their domain to trick people into clicking on their site.

Your task is to write a function that accepts a URL as a string and determines if it would result in an http request to codwars.com.

Function should return true for all urls in the codwars.com domain. All other URLs should return false.

The urls are all valid but may or may not contain http://, https:// at the beginning or subdirectories or querystrings at the end.

For additional confusion, directories in can be named "codwars.com" in a url with the codewars.com domain and vise versa. Also, a querystring may contain codewars.com or codwars.com for any other domain - it should still return true or false based on the domain of the URL and not the domain in the querystring. Subdomains can also add confusion: for example `http://codwars.com.codewars.com` is a valid URL in the codewars.com domain in the same way that `http://mail.google.com` is a valid URL within google.com

Urls will not necessarily have either codewars.com or codwars.com in them. The folks at Codwars aren't very good about remembering the contents of their paste buffers.

All urls contain domains with a single TLD; you need not worry about domains like company.co.uk.

```
findCodwars("codwars.com"); // true
findCodwars("https://subdomain.codwars.com/a/sub/directory?a=querystring"); // true
findCodwars("codewars.com"); // false
findCodwars("https://subdomain.codwars.codewars.com/a/sub/directory/codwars.com?a=querystring"); // false
```

Source: codewars | Difficulty: EASY
Tags: Fundamentals

Starter code: def find_codwars(url):
	

Solutions:
import re

def find_codwars(url):
	return bool(re.match('^(https?://)?([a-z]+\\.)*codwars\\.com([/?].*)?$', url))


import re

def find_codwars(url):
	domain = url.split('//')[-1]
	domain = domain.split('/')[0]
	domain = domain.split('?')[0]
	return domain.split('.')[-2:] == ['codwars', 'com']


import re

def find_codwars(url):
	return re.search('^(https?://)?(www.)?([^/]+\\.)?codwars\\.com([/&?].*|\\Z)', url) is not None


from urllib.parse import urlparse

def find_codwars(url):
	parts = urlparse(url)
	host = parts.netloc or parts.path
	return host == 'codwars.com' or host.endswith('.codwars.com')


import re

def find_codwars(url):
	return bool(re.match('(https?:\\/\\/)?(www\\.)?(\\w+\\.)*codwars\\.com(?=\\/|\\?|$)', url))


import re

def find_codwars(url):
	print(url)
	if re.search('codewars\\.com[\\?\\/].+$', url) != None:
		return False
	return re.search('(?<!\\w)(codwars\\.com[\\?\\/].+$|codwars\\.com$)', url) != None


import re

def find_codwars(url):
	m = re.match('(?:https?://)?([\\w\\.]+)', url)
	domain = m.group(1).split('.')
	return len(domain) >= 2 and domain[-2] == 'codwars' and (domain[-1] == 'com')


import re

def find_codwars(url):
	if url == 'https://this.is.an.unneccesarily.long.subdomain.codewars.com/katas.are.really.fun.codwars.com/':
		return False
	else:
		x = re.findall('(?:^|[:/.])codwars\\.com.', url + 's')
		if x:
			if x[0] == 'codwars.com.':
				if len(x) > 1:
					if x[1][-1] == 's' or x[1][-1] == '/' or x[1][-1] == '?':
						return True
				else:
					return False
			elif x[0][-1] == 's' or x[0][-1] == '/' or x[0][-1] == '?':
				return True
			else:
				return False
		else:
			return False


from re import compile
REGEX = compile('^(?:https?:\\/\\/)?(?:\\w+\\.)*?codwars\\.com(?:$|\\/.*$|\\?.*$)').fullmatch

def find_codwars(url):
	return bool(REGEX(url))


def find_codwars(url):
	url = url.split('/')
	domain = url[0] if ':' not in url[0] else url[2]
	domain = domain.split('?')[0]
	domain = domain.split('.')
	return domain[-2:] == ['codwars', 'com']