![](http://www.grindtv.com/wp-content/uploads/2015/08/drone.jpg)

The other day I saw an amazing video where a guy hacked some wifi controlled lightbulbs by flying a drone past them. Brilliant.

In this kata we will recreate that stunt... sort of.

You will be given two strings: `lamps` and `drone`. `lamps` represents a row of lamps, currently off, each represented by `x`. When these lamps are on, they should be represented by `o`.

The `drone` string represents the position of the drone `T` (any better suggestion for character??) and its flight path up until this point `=`. The drone always flies left to right, and always begins at the start of the row of lamps. Anywhere the drone has flown, including its current position, will result in the lamp at that position switching on.

Return the resulting `lamps` string. See example tests for more clarity.

Source: codewars | Difficulty: EASY
Tags: String algorithms

Fundamentals

Data structures

Starter code: def fly_by(lamps, drone):
	

Solutions:
def fly_by(lamps, drone):
	return lamps.replace('x', 'o', drone.count('=') + 1)


def fly_by(lamps, drone):
	l = len(lamps)
	d = len(drone)
	if d >= l:
		return 'o' * l
	return 'o' * d + 'x' * (l - d)


def fly_by(lamps, drone):
	newlamps = []
	for x in lamps:
		newlamps.append(x)
	for y in range(len(drone)):
		try:
			if y <= len(newlamps):
				newlamps[y] = 'o'
			else:
				pass
		except:
			pass
	return ''.join(newlamps)
fly_by('xxxxxx', '===T')


def fly_by(lamps, drone):
	on = drone.find('T') + 1
	return lamps.replace('x', 'o', on)


def fly_by(lamps, drone):
	ld = len(drone)
	ll = len(lamps)
	return 'o' * min(ld, ll) + 'x' * (ll - ld)


def fly_by(lamps, drone):
	(s1, s2) = (len(drone), len(lamps))
	return 'o' * min(s1, s2) + 'x' * (s2 - s1)


def fly_by(lamps, drone):
	os = min(len(drone), len(lamps))
	xs = len(lamps) - len(drone)
	return os * 'o' + xs * 'x'


def fly_by(lamps, drone):
	count = len(drone)
	if lamps:
		first_sec = lamps[:count]
		second_sec = lamps[count:]
		final_1st = lamps[:count].replace('x', 'o')
		return final_1st + second_sec


def fly_by(lamps, drone):
	return 'o' * min(len(drone), len(lamps)) + lamps[len(drone):]


def fly_by(lamps, drone):
	x = len(lamps)
	o = min(len(drone), x)
	x = (x - o) * 'x'
	o = o * 'o'
	return (o + x, ''.join((o, x)), '%s%s' % (o, x), '{}{}'.format(o, x), f'{o}{x}')[__import__('random').randint(0, 4)]