Advent of Code is back! Unwrap daily challenges to sharpen your Alteryx skills and earn badges along the way! Learn more now.
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
SOLVED

Challenge #135: Locker Problem

JoeM
Alteryx Alumni (Retired)

Thank you for participating in the Grand Prix challenges last week!

 

 

Next week's challenge will be posted during @NicoleJohnson's Inspire Europe Weekly Challenge (10:30AM on Wednesday 10/10)! Finally, those on GMT challengers will finally have first crack at the challenge. Unless @patrick_digan wakes up at 5:30AM Eastern. 

 

Onto this week's challenge!

 

There are 1000 lockers in a high school with 1000 students. The problem begins with the first student opening all 1000 lockers; the second student closes lockers 2,4,6,8,10 and so on to locker 1000; the third student changes the state (opens lockers closed, closes lockers open) on lockers 3,6,9,12,15 and so on; the fourth student changes the state of lockers 4,8,12,16 and so on. This goes on until
every student has had a turn.

When all 1,000 students have finished, which locker doors are open?

NicoleJohnson
ACE Emeritus
ACE Emeritus

Back to school! My solution :)

 

Spoiler
My favorite - iterative macros!! This was a fun one... and ended up with a pleasantly low number of tools!

Workflow - Fun using the Generate Rows tool without an input, rarely have had opportunities to do that.Workflow - Fun using the Generate Rows tool without an input, rarely have had opportunities to do that.
Locker Macro, using a Floor formula to determine which lockers to open/close!Locker Macro, using a Floor formula to determine which lockers to open/close!

Cheers,

NJ

bdaniels
8 - Asteroid
Spoiler
Screen Shot 2018-10-01 at 11.31.31 AM.png

Kind of messy

patrick_digan
17 - Castor
17 - Castor

I've got my alarm set for 5:30 am next wednesday!

Spoiler
I went with the iterative macro approach
Capture.PNG

There are some really creative solutions when @Ned posted this problem a few years ago.
ggruccio
ACE Emeritus
ACE Emeritus

I'm imagining this is a very loud exercise!  

 

 

Spoiler
Helps to use the modulo (mod) function in the macro.Modulo.JPG

 

danilang
19 - Altair
19 - Altair

Fun challenge. 

 

 

Ok, all you Math gurus.  Can anyone explain why, iteratively applying the sieve of Eratosthenes, should generate that particular, very familiar, sequence of numbers?  Is all of math beautifully connected at a level just below what common folk like me can see? 

 

And what's up with Euler's Identity anywaye^{i\pi }+1=0

 

 

Spoiler
MacroMain

 

Dan

GarthG
7 - Meteor

Went macro-less this week!

jasperlch
12 - Quasar

Solution attached.

KOBoyle
11 - Bolide

Solution attached.

 

Spoiler
Used an iterative macro with an app to allow for user specified locker count.

challenge_135_spoiler_1.png

challenge_135_spoiler_2_macro.png

PhilipMannering
16 - Nebula
16 - Nebula
Spoiler
I used the R tool to loop over all the lockers and change their state.


WorkflowWorkflow