Skip to main content
Tweeted twitter.com/#!/StackCodeGolf/status/605200427727089664
Squares to boxes.
Source Link
xnor
  • 146.6k
  • 26
  • 279
  • 652

A Young diagram is a collectionan arrangement of squaresboxes in left-justified rows and top-justified columns. For each squarebox, all the spaces above it and to its left are occupied.

XXXXX
XXX
XXX
X

The hook length of a squarebox is the number of squaresboxes to its right in its row, and below it in its column, also counting itself once. For example, the second squarebox has a hook length of 6:

X****
X*X
X*X
X

Here are all the hook lengths:

86521
532
421
1

Your goal is compute the product of the hook lengths, here 8*6*5*2*1*5*3*2*4*2*1*1 = 115200.

(Read about the hook length formula if you're interested in why this expression matters.)

Input: A collection of row-sizes as numbers like [5,3,3,1] or as a repeated unary symbol like [[1,1,1,1,1], [1,1,1], [1,1,1], [1]] or "XXXXX XXX XXX X". You can expect the list to be sorted ascending or descending, as you wish. The list will be non-empty and only contain positive integers.

Output: The product of hook lengths, which is a positive integer. Don't worry about integer overflows or runtime.

Built-ins dealing specifically with Young diagrams or integer partitions are not allowed.

Test cases:

[1] 1
[2] 2
[1, 1] 2
[5] 120
[2, 1] 3
[5, 4, 3, 2, 1] 4465125
[5, 3, 3, 1] 115200
[10, 5] 798336000

A Young diagram is a collection of squares in left-justified rows and top-justified columns. For each square, all the spaces above it and to its left are occupied.

XXXXX
XXX
XXX
X

The hook length of a square is the number of squares to its right in its row, and below it in its column, also counting itself once. For example, the second square has a hook length of 6:

X****
X*X
X*X
X

Here are all the hook lengths:

86521
532
421
1

Your goal is compute the product of the hook lengths, here 8*6*5*2*1*5*3*2*4*2*1*1 = 115200.

(Read about the hook length formula if you're interested in why this expression matters.)

Input: A collection of row-sizes as numbers like [5,3,3,1] or as a repeated unary symbol like [[1,1,1,1,1], [1,1,1], [1,1,1], [1]] or "XXXXX XXX XXX X". You can expect the list to be sorted ascending or descending, as you wish. The list will be non-empty and only contain positive integers.

Output: The product of hook lengths, which is a positive integer. Don't worry about integer overflows or runtime.

Built-ins dealing specifically with Young diagrams or integer partitions are not allowed.

Test cases:

[1] 1
[2] 2
[1, 1] 2
[5] 120
[2, 1] 3
[5, 4, 3, 2, 1] 4465125
[5, 3, 3, 1] 115200
[10, 5] 798336000

A Young diagram is an arrangement of boxes in left-justified rows and top-justified columns. For each box, all the spaces above it and to its left are occupied.

XXXXX
XXX
XXX
X

The hook length of a box is the number of boxes to its right in its row, and below it in its column, also counting itself once. For example, the second box has a hook length of 6:

X****
X*X
X*X
X

Here are all the hook lengths:

86521
532
421
1

Your goal is compute the product of the hook lengths, here 8*6*5*2*1*5*3*2*4*2*1*1 = 115200.

(Read about the hook length formula if you're interested in why this expression matters.)

Input: A collection of row-sizes as numbers like [5,3,3,1] or as a repeated unary symbol like [[1,1,1,1,1], [1,1,1], [1,1,1], [1]] or "XXXXX XXX XXX X". You can expect the list to be sorted ascending or descending, as you wish. The list will be non-empty and only contain positive integers.

Output: The product of hook lengths, which is a positive integer. Don't worry about integer overflows or runtime.

Built-ins dealing specifically with Young diagrams or integer partitions are not allowed.

Test cases:

[1] 1
[2] 2
[1, 1] 2
[5] 120
[2, 1] 3
[5, 4, 3, 2, 1] 4465125
[5, 3, 3, 1] 115200
[10, 5] 798336000
added 93 characters in body
Source Link
xnor
  • 146.6k
  • 26
  • 279
  • 652

A Young diagram is a collection of squares in left-justified rows and top-justified columns. For each square, all the spaces above it and to its left are occupied.

XXXXX
XXX
XXX
X

The hook length of a square is the number of squares to its right in its row, and below it in its column, also counting itself once. For example, the second square has a hook length of 6:

X****
X*X
X*X
X

Here are all the hook lengths:

86521
532
421
1

Your goal is compute the product of the hook lengths, here 8*6*5*2*1*5*3*2*4*2*1*1 = 115200.

(Read about the hook length formula if you're interested in why this expression matters.)

Input: The listA collection of row-sizes as a collection of counts as numbers like [5,3,3,1] or as a repeated unary symbol like [[1,1,1,1,1], [1,1,1], [1,1,1], [1]] or "XXXXX XXX XXX X". You can expect the list to be sorted ascending or descending, as you wish. The list will be non-empty and only contain positive integers.

Output: The product of hook lengths, which is a positive integer. Don't worry about integer overflows or runtime.

Built-ins dealing specifically with Young diagrams or integer partitions are not allowed.

Test cases:

[1] 1
[2] 2
[1, 1] 2
[5] 120
[2, 1] 3
[5, 4, 3, 2, 1] 4465125
[5, 3, 3, 1] 115200
[10, 5] 798336000

A Young diagram is a collection of squares in left-justified rows and top-justified columns. For each square, all the spaces above it and to its left are occupied.

XXXXX
XXX
XXX
X

The hook length of a square is the number of squares to its right in its row, and below it in its column, also counting itself once. For example, the second square has a hook length of 6:

X****
X*X
X*X
X

Here are all the hook lengths:

86521
532
421
1

Your goal is compute the product of the hook lengths, here 8*6*5*2*1*5*3*2*4*2*1*1 = 115200.

(Read about the hook length formula if you're interested in why this expression matters.)

Input: The list of row-sizes as a collection of counts as numbers like [5,3,3,1] or as a repeated unary symbol like [[1,1,1,1,1], [1,1,1], [1,1,1], [1]] or "XXXXX XXX XXX X". You can expect the list to be sorted ascending or descending, as you wish. The list will be non-empty and only contain positive integers.

Output: The product of hook lengths, which is a positive integer. Don't worry about integer overflows or runtime.

Test cases:

[1] 1
[2] 2
[1, 1] 2
[5] 120
[2, 1] 3
[5, 4, 3, 2, 1] 4465125
[5, 3, 3, 1] 115200
[10, 5] 798336000

A Young diagram is a collection of squares in left-justified rows and top-justified columns. For each square, all the spaces above it and to its left are occupied.

XXXXX
XXX
XXX
X

The hook length of a square is the number of squares to its right in its row, and below it in its column, also counting itself once. For example, the second square has a hook length of 6:

X****
X*X
X*X
X

Here are all the hook lengths:

86521
532
421
1

Your goal is compute the product of the hook lengths, here 8*6*5*2*1*5*3*2*4*2*1*1 = 115200.

(Read about the hook length formula if you're interested in why this expression matters.)

Input: A collection of row-sizes as numbers like [5,3,3,1] or as a repeated unary symbol like [[1,1,1,1,1], [1,1,1], [1,1,1], [1]] or "XXXXX XXX XXX X". You can expect the list to be sorted ascending or descending, as you wish. The list will be non-empty and only contain positive integers.

Output: The product of hook lengths, which is a positive integer. Don't worry about integer overflows or runtime.

Built-ins dealing specifically with Young diagrams or integer partitions are not allowed.

Test cases:

[1] 1
[2] 2
[1, 1] 2
[5] 120
[2, 1] 3
[5, 4, 3, 2, 1] 4465125
[5, 3, 3, 1] 115200
[10, 5] 798336000
edited tags
Link
xnor
  • 146.6k
  • 26
  • 279
  • 652
Source Link
xnor
  • 146.6k
  • 26
  • 279
  • 652
Loading