Skip to content

Instantly share code, notes, and snippets.

@joaojeronimo
Created September 27, 2012 07:36
Show Gist options
  • Save joaojeronimo/3792704 to your computer and use it in GitHub Desktop.
Save joaojeronimo/3792704 to your computer and use it in GitHub Desktop.
Using CrowdProces' API with Python
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
}
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