Skip to content

Instantly share code, notes, and snippets.

@tlkahn
Created June 14, 2017 05:53
Show Gist options
  • Select an option

  • Save tlkahn/4b26ddbba4cb63ff5f9c8418b61febd8 to your computer and use it in GitHub Desktop.

Select an option

Save tlkahn/4b26ddbba4cb63ff5f9c8418b61febd8 to your computer and use it in GitHub Desktop.
Hackerland Radio Transmitters python
def solution(k, arr, origin=0):
arr = sorted(list(set(arr)))
result = 1
cur = 0
origin = 0
for i in range(1, len(arr)):
f = False
if arr[i] - arr[origin] <= k:
pass
else:
origin = i - 1
j = 1
while origin + j < len(arr):
if arr[origin + j] - arr[origin] <= k:
pass
else:
origin = origin + j
i = origin + j + 1
result += 1
f = True
break
j += 1
if f: continue
return result
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment