Pardon our dust - Alteryx Academy is under construction. Lessons and courses completed on Community from now until January 20th will not be recorded.
Start Free Trial

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 #79: Find the Closest Prime Number

Nicholas_Bignell
アステロイド
Simonvm9114
アステロイド

Here's my solution

 

スポイラ
Simonvm9114_0-1581947259683.png

 

johnemery
ボリード

I really enjoyed this challenge. The "mathy" ones are always fun for me.

 

There are three potential cases here:

  1. The given number is prime → outputs the same number.
  2. The closest primes above and below the number are different distances from the number → output the closest.
  3. The closest primes above and below the number are the same distance from the number → concatenate both into a comma-separated list.
スポイラ
Like most others, I built an iterative macro. It starts at the given number and counts one step up and down per iteration, checking each new value for primality. This could certainly be made much more efficient by paying attention to the parity of the given number, storing previously known primes from prior iterations, and so on.

Macro Capture.PNGSolution Capture.PNG
dashakir1
アステロイド

Thanks JoeM.

LindaLo
アステロイド

Check out my solution!

It has one constraint that I only check numbers up 10000

And it allows to output more than one closest prime number to the input in case the difference between previous/ next Prime and Input is the same. 

atcodedog05
22 - Nova
22 - Nova

On a spree to binge complete weekly challenges
Adrenaline rush

 

I solved it using python tool

atcodedog05_0-1585475887060.png

 

スポイラ
This is my solution
atcodedog05_0-1585475749604.png

 

Check the workflow flow for the python code

 

AndrewS
ボリード

#79

スポイラ
AppAppResultResult
Jonathan-Sherman
15 - Aurora
15 - Aurora

Challenge 79 is done!

 

スポイラ
So i went with an two iterative macro solution...and gave the option for the user to see both numbers or just the closest!

Interface:
Interface App.PNG

Workflow:
App Workflow.PNG

Macro:
Standard Macro.PNG

Iterative Macro:
Iterative Macro.PNG
AngelosPachis
ネビュラ

My solution for challenge #79

 

スポイラ
Annotation 2020-05-12 211744.png
AlexC2
アステロイド

solution attached.