Community Spring Cleaning week is here! Join your fellow Maveryx in digging through your old posts and marking comments on them as solved. Learn more here!

Weekly Challenges

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

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

Want to get involved? We're always looking for ideas and content for Weekly Challenges.

SUBMIT YOUR IDEA

Challenge #187: Generate Prime Numbers

PhilipMannering
16 - Nebula
16 - Nebula

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
11 - Bolide

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)
Inactive User
Not applicable
 
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