Weekly Challenge

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

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

Submit Feedback
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.

Challenge #187: Generate Prime Numbers

Highlighted
6 - Meteoroid

Very interesting challenge - I'm sure everyone went about it in a different way. Here's mine:

 

Spoiler
fguardini_2-1572352033608.png

I calculated the root of the input number, 50, to get the list of integers to use for testing - 2 to 7. I created the list of numbers to be tested, 2 to 50. I excluded the single-integer prime numbers for simplicity. For the others, I checked which ones have a remainder when divided by one of the numbers between 2 and 7. I joined the two lists for a full list of integer numbers between 2 and 50.

One step includes removing numbers equals to the dividends, this makes the workflow usable for very large numbers as well. It's still quite fast with numbers in the thousands

Highlighted
Alteryx Certified Partner

A fun challenge for sure! Great to approach these fundamental concepts through the lense of Alteryx. 

 

Spoiler
187.png
Highlighted
8 - Asteroid

Hi Christine,

 

 

 

please find attached my solution.

 

Spoiler
Kucsi_0-1572353756203.png

 

Thanks,

Kucsi

Highlighted
17 - Castor
17 - Castor

Good challenge. Here's an iterative macro implementation of the Sieve of Eratosthenes.  The trade off is speed vs memory use by not requiring the X join at the start that the divisor method requires.  The table is never bigger that N-1 rows but gets iterated over once for every prime less than SQRT(N)

Spoiler
m.png



Dan

 

 

 

 

Highlighted
8 - Asteroid

Here is my solution!

 

Spoiler
s.PNG
Highlighted
Alteryx Certified Partner

Hi!

I tried to minimize the number of checks.

 

As there is only 1 odd prime, which is 2, I decreased the generate rows by the following loop expression:
if Number < 3 then Number + 1 else Number+ 2 endif.

 

Further the range which we need to check if a division can be made starts with 3
(no uneven number can be divided by 2, and is maximized on 1/3 * [number].

 

So as you can see in the workflow, it works quite fast.
But even then finding all the primes under 25000 generates around 26 mio checks!

 

 

Highlighted
8 - Asteroid

Hi! Here my solution

Highlighted
7 - Meteor
 
Highlighted
12 - Quasar
12 - Quasar

Fun challenge! Definitely curious to see how others did this as I don't think my solution is the most efficient.

Spoiler
Challenge 187.PNG
Highlighted
8 - Asteroid

Here is my solution