Created
August 22, 2017 07:09
-
-
Save rouseguy/3cdcf3fe0b6516608475c5f273abafe5 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import numpy as np | |
def fizzbuzz(number): | |
if number % 15 == 0: | |
return np.array(["fizzbuzz"], dtype="object") | |
elif number % 5 == 0: | |
return np.array(["buzz"], dtype="object") | |
elif number % 3 == 0: | |
return np.array(["fizz"], dtype="object") | |
else: | |
return np.array([str(number)], dtype="object") | |
fizzbuzz_vectorized = np.vectorize(fizzbuzz) | |
n = 30 | |
input_data = np.array([a+1 for a in range(n)]) | |
fizzbuzz_output = fizzbuzz_vectorized(input_data).ravel() | |
fizzbuzz_output |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Sir whatsapp marketting at very much of a cheap sir. Please contact 9742020706