We've recently made an accessibility improvement to the community and therefore posts without any content are no longer allowed. Please use the spoiler feature or add a short message in the message body in order to submit your weekly challenge.

Weekly Challenge

Solve the challenge, share your solution and summit the ranks of our Community!

Also available in | Français | Português | Español | 日本語
IDEAS WANTED

We're actively looking for ideas on how to improve Weekly Challenges and would love to hear what you think!

Submit Feedback

Challenge #187: Generate Prime Numbers

PhilipMannering
14 - Magnetar
14 - Magnetar

A prime example of a good weekly challenge.

 

In one line of Python,

[i for i in range(2,50) if 0 not in (i%j for j in range(2,i))]

 

Otherwise,

Spoiler
WorkflowWorkflow

CodeCode

 

 

Ki
5 - Atom

Here's my solution

 

Spoiler
187 sol.PNG
ch12345
7 - Meteor

This solution is very inefficient and generates a lot of waste data:

 

 

Spoiler
Capture.PNG
JohnJPS
15 - Aurora

@elliotyoung - I used the R tool here.

Greg_Murray
12 - Quasar

No pretty, but I got there. 

 

solution attached. 

hanykowska
10 - Fireball

I liked this one!

 

Spoiler
image.png
dsmdavid
11 - Bolide

A good old sieve. 998 iterations in ~1 min for primes under 1 000 000 all in Alteryx

Spoiler
1. Main Workflow generates the rows and feeds the iterative macro, then filter primes1. Main Workflow generates the rows and feeds the iterative macro, then filter primes2. Loop through the integers that are still prime until SQRT(Target) and flag whether number is divisible (discard) or not (keep)2. Loop through the integers that are still prime until SQRT(Target) and flag whether number is divisible (discard) or not (keep)
CharlotteEarps
8 - Asteroid
 
echuong1
Alteryx Alumni (Retired)

Think my solution may be a little too simplistic, but it gets the job done! 2 tools.

 

echuong1_0-1572964644531.png

Alexandru_Bostan
5 - Atom

Here's my solution, it is based on trial division method. For very large numbers it will be slow to generate the data required but it will work.

 

Spoiler
Alexandru_Bostan_0-1573037425616.png