Shortest Script Challenge – Collatz Conjecture?

The Collatz Conjecture is an interesting sequence.

Counting the number of files and directories recursively in your current working directory, can you print out the Collatz sequence for that number?


$A = (Get-ChildItem -Recurse).count 

Example if $A is 56.

Expected output would be:

28 14 7 22 11 34 17 52 26 13 40 20 10 5 16 8 4 2 1 

You can include the original number as the first of the sequence, or not – it’s up to you.


  1. Only output like the example (you don’t have to include the original number if you don’t want to), no other information, no errors.
  2. Do not include enumerating $A in your script unless you add to it (score will only include additions to the enumeration).
  3. If you don’t have enough files or directories to do this…change directory to somewhere you do 😉
  4. Do not put anything you see or do here into a production script.
  5. Please explode your code so others can read along.
  6. If the script can’t be run again without clearing values please state so.
  7. Enjoy yourselves.

Current Leadership board:

  1. /u/bukem 43 40
  2. /u/ka-splam 41
  3. /u/purplemonkeymad 48

submitted by /u/allywilson
[link] [comments]

Leave a Reply