Created
September 27, 2012 07:36
-
-
Save joaojeronimo/3792704 to your computer and use it in GitHub Desktop.
Using CrowdProces' API with Python
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
function CPmap (taskInput) { | |
// taskInput will be a string of numbers, like "1,2,3,4,5" | |
var arrayOfNumbers = taskInput.split(","); // "1,2,3,4,5" -> ["1","2","3","4","5"] | |
var n = arrayOfNumbers.length; // the number of elements in the array | |
var sum = 0; | |
while (n--) { // Loop through the contents of the array | |
sum += Number(arrayOfNumbers[n]); // Add to the variable sum this specific element of the array | |
} | |
return (sum); // Return the result of this task | |
} |
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
from random import random | |
f = open("numbers.csv", "w") | |
for x in xrange(0,1000000): | |
number = x * random() | |
f.write(str(number)+",") | |
print("Created 1M random numbers") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment