Given an array of arguments, representing system call arguments keys and values, join it into a single, space-delimited string. You don't need to care about the application name -- your task is only about parameters.

Each element of the given array can be:
* a single string,
* a single string array,
* an array of two strings

In the last case (array of two strings) the first string should have a `"--"` prefix if it is more than one character long; or a `"-"` prefix otherwise; e.g.:
  * `["foo", "bar"]` becomes `"--foo bar"`
  * `["f", "bar"]` becomes `"-f bar"`

You may assume that all strings are non-empty and have no spaces.

## Examples

```python
["foo", "bar"]                    #  "foo bar"
[["foo", "bar"]]                  #  "--foo bar"
[["f", "bar"]]                    #  "-f bar"
[["foo", "bar"], "baz"]           #  "--foo bar baz"
[["foo"], ["bar", "baz"], "qux"]  #  "foo --bar baz qux"
```

Source: codewars | Difficulty: EASY
Tags: String algorithms

Fundamentals

Starter code: def args_to_string(args):
	

Solutions:
def args_to_string(args):
	L = []
	for arg in args:
		if isinstance(arg, str):
			L.append(arg)
		elif len(arg) == 1:
			L.append(arg[0])
		elif len(arg[0]) == 1:
			L.append('-' + ' '.join(arg))
		else:
			L.append('--' + ' '.join(arg))
	return ' '.join(L)


def args_to_string(A):
	return ' '.join((e if isinstance(e, str) else e[0] if len(e) == 1 else '-' + (len(e[0]) > 1) * '-' + ' '.join(e) for e in A))


def args_to_string(args):
	return ' '.join((x if type(x) == str else ' '.join((('-' if len(v) == 1 else '--') + v if k == 0 and len(x) > 1 else v for (k, v) in enumerate(x))) for x in args))


def args_to_string(args):
	return ' '.join(('-' * (len(a) > 1 and 1 + (len(a[0]) > 1)) + ' '.join(a) if type(a) == list else a for a in args))


def args_to_string(args):
	for i in args:
		if len(i) > 1 and type(i) != str:
			i[0] = f'--{i[0]}' if len(i[0]) > 1 else f'-{i[0]}'
	return ' '.join((i if type(i) != list else ' '.join(i) for i in args))


def args_to_string(args):
	params = []
	for arg in args:
		if isinstance(arg, str):
			params.append(arg)
		elif arg:
			first = arg.pop(0)
			if arg:
				if len(first) == 1:
					first = '-' + first
				else:
					first = '--' + first
			params.append(first)
			for a in arg:
				params.append(a)
	return ' '.join(params)


def args_to_string(args):
	ls = []
	for i in args:
		if type(i) == list and len(i) == 2:
			if len(i[0]) > 1:
				i[0] = '--' + i[0]
				ls.extend(i)
			else:
				i[0] = '-' + i[0]
				ls.extend(i)
		else:
			ls.append(i) if type(i) != list else ls.extend(i)
	return ' '.join(ls)


def args_to_string(args):
	r = []
	for a in args:
		if type(a) == list:
			if len(a) == 1:
				r += (a[0],)
			else:
				s = '-'
				if len(a[0]) > 1:
					s += '-'
				r += (s + ' '.join(a),)
		else:
			r += (a,)
	return ' '.join(r)


def args_to_string(args):
	res = []
	for chunk in args:
		if type(chunk) == str:
			res.append(chunk)
		elif len(chunk) == 1:
			res.append(chunk[0])
		else:
			res.append(f"{'-' * (1 + (len(chunk[0]) > 1))}{' '.join((s for s in chunk))}")
	return ' '.join(res)


def args_to_string(args):
	s = []
	for i in args:
		if type(i) == str:
			s.append(i)
		elif type(i) == list and len(i) == 2:
			s.append('-' * (1 if len(i[0]) == 1 else 2) + ' '.join(i))
		else:
			s += i
	return ' '.join(s)