###Story
Sometimes we are faced with problems when we have a big nested dictionary with which it's hard to work. Now, we need to solve this problem by writing a function that will flatten a given dictionary.

###Info
Python dictionaries are a convenient data type to store and process configurations. They allow you to store data by keys to create nested structures. You are given a dictionary where the keys are strings and the values are strings or dictionaries. The goal is flatten the dictionary, but save the structures in the keys. The result should be a dictionary without the nested dictionaries. The keys should contain paths that contain the parent keys from the original dictionary. The keys in the path are separated by a `/`. If a value is an empty dictionary, then it should be replaced by an empty string `""`.

###Examples
```python
{
    "name": {
        "first": "One",
        "last": "Drone"
    },
    "job": "scout",
    "recent": {},
    "additional": {
        "place": {
            "zone": "1",
            "cell": "2"
        }
    }
}
```
The result will be:
```python
{"name/first": "One",           #one parent
 "name/last": "Drone",
 "job": "scout",                #root key
 "recent": "",                  #empty dict
 "additional/place/zone": "1",  #third level
 "additional/place/cell": "2"}
```

***`Input: An original dictionary as a dict.`***
***`Output: The flattened dictionary as a dict.`***
***`Precondition:
Keys in a dictionary are non-empty strings.
Values in a dictionary are strings or dicts.
root_dictionary != {}`***

```python
flatten({"key": "value"}) == {"key": "value"}
flatten({"key": {"deeper": {"more": {"enough": "value"}}}}) == {"key/deeper/more/enough": "value"}
flatten({"empty": {}}) == {"empty": ""}
```

Difficulty: EASY
Starter code: def flatten(dictionary):
	

Solutions:
def flatten(dictionary):
	stack = [((), dictionary)]
	result = {}
	while stack:
		(path, current) = stack.pop()
		for (k, v) in current.items():
			if v == {}:
				result['/'.join(path + (k,))] = ''
			if isinstance(v, dict):
				stack.append((path + (k,), v))
			else:
				result['/'.join(path + (k,))] = v
	return result


def flatten(dictionary):
	result = {}
	for (k, v) in dictionary.items():
		if v == {}:
			result[k] = ''
		elif isinstance(v, dict):
			for (l, w) in flatten(v).items():
				result[k + '/' + l] = w
		else:
			result[k] = v
	return result


def flatten(d):
	result = {}
	for (key, value) in d.items():
		if value and isinstance(value, dict):
			for (k, v) in flatten(value).items():
				result[key + '/' + k] = v
		else:
			result[key] = value or ''
	return result


def flatten(dictionary, prefix=[]):
	res = {}
	for key in dictionary.keys():
		if isinstance(dictionary[key], dict) and dictionary[key]:
			res.update(flatten(dictionary[key], prefix + [key]))
		else:
			res['/'.join(prefix + [key])] = dictionary[key] or ''
	return res


def flatten(dct):

	def extract(dct):
		for (k, v) in dct.items():
			stk.append(k)
			if isinstance(v, dict) and v:
				yield from extract(v)
			else:
				yield ('/'.join(stk), v or '')
			stk.pop()
	stk = []
	return dict(extract(dct))


def flatten(dictionary):
	result = {}
	for (k1, v1) in dictionary.items():
		if type(v1) == str:
			result[k1] = v1
		elif v1:
			for (k2, v2) in flatten(v1).items():
				result[f'{k1}/{k2}'] = v2
		else:
			result[k1] = ''
	return result


def flatten(d):
	r = {}
	for (x, y) in d.items():
		if isinstance(y, dict):
			r.update({f'{x}/{X}': Y for (X, Y) in flatten(y).items()} if y else {x: ''})
		else:
			r[x] = y
	return r


def flatten(dictionary):
	stack = [('', dictionary)]
	result = {}
	while stack:
		(path, current) = stack.pop()
		if current:
			if type(current) == dict:
				if path:
					path += '/'
				for key in current:
					stack.append((path + key, current[key]))
			else:
				result[path] = current
		elif path:
			result[path] = ''
	return result


def flatten(d):
	result = []
	for key in d:
		if isinstance(d[key], str):
			result.append((key, d[key]))
		elif len(d[key]) == 0:
			result.append((key, ''))
		else:
			for (key2, value2) in list(flatten(d[key]).items()):
				result.append((key + '/' + key2, value2))
	return dict(result)