Skip to main content
We’ve updated our Terms of Service. A new AI Addendum clarifies how Stack Overflow utilizes AI interactions.
Code Golf

Return to Answer

added 144 characters in body
Source Link
Kevin Cruijssen
  • 136.2k
  • 14
  • 154
  • 394
{ # Sort the (implicit) input-pair from lowest to highest
 R # Reverse it from highest to lowest
[ # Start an infinite loop:
 D # Duplicate the current pair
 ` # Pop one and push both values separated to the stack
 ‰ # Divmod: a,b → [a//b,a%b]
 « # Merge this to the currentpairs pairtogether: [a,b,a//b,a%b]
 Â # Bifurcate this quadruplet; short for Duplicate & Reverse copy
 ` # Pop and push the reversed items separated to the stack
 "ÿ=(ÿ*ÿ)+ÿ" # Push this string, where the `ÿ` are one by one filled with the values
 , # Pop and output it with trailing newline
 ¤ # Push the last value (`a%b`), without popping
 _ # If this is 0:
 # # Stop the infinite loop
 # (else)
 ι # Uninterleave it into two parts: [a,b,ca//b,d]a%b] → [[a,c]a//b],[b,d]]a%b]]
 θ # Pop and keep the last pair (`[b,d]`a%b]`)
} # After the infinite loop:
 1è # Pop the final quadruplet, and leave its second item: `b`
 , # Pop and output it with trailing newline as well
{ # Sort the (implicit) input-pair from lowest to highest
 R # Reverse it from highest to lowest
[ # Start an infinite loop:
 D # Duplicate the current pair
 ` # Pop one and push both values separated to the stack
 ‰ # Divmod: a,b → [a/b,a%b]
 « # Merge this to the current pair
 Â # Bifurcate this quadruplet; short for Duplicate & Reverse copy
 ` # Pop and push the reversed items separated to the stack
 "ÿ=(ÿ*ÿ)+ÿ" # Push this string, where the `ÿ` are one by one filled with the values
 , # Pop and output it with trailing newline
 ¤ # Push the last value (`a%b`), without popping
 _ # If this is 0:
 # # Stop the infinite loop
 # (else)
 ι # Uninterleave it into two parts: [a,b,c,d] → [[a,c],[b,d]]
 θ # Pop and keep the last pair (`[b,d]`)
} # After the infinite loop:
 1è # Pop the final quadruplet, and leave its second item
 , # Pop and output it with trailing newline as well
{ # Sort the (implicit) input-pair from lowest to highest
 R # Reverse it from highest to lowest
[ # Start an infinite loop:
 D # Duplicate the current pair
 ` # Pop one and push both values separated to the stack
 ‰ # Divmod: a,b → [a//b,a%b]
 « # Merge the pairs together: [a,b,a//b,a%b]
 Â # Bifurcate this quadruplet; short for Duplicate & Reverse copy
 ` # Pop and push the reversed items separated to the stack
 "ÿ=(ÿ*ÿ)+ÿ" # Push this string, where the `ÿ` are one by one filled with the values
 , # Pop and output it with trailing newline
 ¤ # Push the last value (`a%b`), without popping
 _ # If this is 0:
 # # Stop the infinite loop
 # (else)
 ι # Uninterleave it into two parts: [a,b,a//b,a%b] → [[a,a//b],[b,a%b]]
 θ # Pop and keep the last pair (`[b,a%b]`)
} # After the infinite loop:
 1è # Pop the final quadruplet, and leave its second item: `b`
 , # Pop and output it with trailing newline as well
added 144 characters in body
Source Link
Kevin Cruijssen
  • 136.2k
  • 14
  • 154
  • 394

05AB1E, 32 (削除) 32 (削除ここまで) 30 bytes

{R[D`‰«Â`"ÿ=(ÿ*ÿ)+ÿ",¤_#¤UDιθ¤_#ιθ}X,

Try it online Try it online or verify all test cases verify all test cases.

Try it online or verify all test cases verify all test cases.

{ # Sort the (implicit) input-pair from lowest to highest
 R # Reverse it from highest to lowest
[ # Start an infinite loop:
 D # Duplicate the current pair
 ` # Pop one and push both values separated to the stack
 ‰ # Divmod: a,b → [a/b,a%b]
 « # Merge this to the current pair
 Â # Bifurcate this quadruplet; short for Duplicate & Reverse copy
 ` # Pop and push the reversed items separated to the stack
 "ÿ=(ÿ*ÿ)+ÿ" # Push this string, where the `ÿ` are one by one filled with the values
 , # Pop and output it with trailing newline
 ¤ # Push the last value (`a%b`), without popping
 _ # If this is 0:
 # # Stop the infinite loop
 # (else)
 ¤ι # Push theUninterleave lastit valueinto (`a%b`)two withoutparts: popping[a,b,c,d] yet again[[a,c],[b,d]]
 Uθ # Pop and storekeep itthe inlast variablepair `X`(`[b,d]`)
} D # After the Duplicateinfinite loop:
 1è  # Pop the final quadruplet, and leave its second item
 , ι # Pop and Uninterleaveoutput it into twowith parts:trailing [a,b,c,d]newline as [[a,c],[b,d]]well
{R[D`‰« θ # Similar as above
¤_#  # Similar Popas andabove keepas well
 ¤  # Push the last pairitem (`[b,d]`)without popping again
}X, U  # After thePop infiniteand loop:store Outputit valuein variable `X` with trailing newline
{R[D`‰« D  # Similar asDuplicate abovethe quadruplet
¤_#¤UDιθ ιθ} # Similar as above as well
) # Wrap the quadruplets of the stack into a list
 ø # Zip/transpose; swapping rows/columns
 ε # Map over each inner list
 § # Cast every integer to a string (†bug work-around for builtin `j`)
 Z # Push the largest integer, without popping
 g # Pop and push its length
 j # Potentially add leading spaces so all values in the list are of this length
 }ø # After the map: zip/transpose back
 ε # Map over each inner list:
 R` # Push the items in reverse order to the stack
 "ÿ = (ÿ * ÿ) + ÿ"
 # Push this string, where the `ÿ` are one by one filled with the values
 }Xa # After the map: append value `X`
 » # Join this list by newlines
 „( # Push string "( "
 Â # Bifurcate; short for Duplicate & Reverse copy: " ("
 : # Infinitely replace "( " to " ("
 # (after which the string is output implicitly as result)

05AB1E, 32 bytes

{R[D`‰«Â`"ÿ=(ÿ*ÿ)+ÿ",¤_#¤UDιθ}X,

Try it online or verify all test cases.

Try it online or verify all test cases.

{ # Sort the (implicit) input-pair from lowest to highest
 R # Reverse it from highest to lowest
[ # Start an infinite loop:
 D # Duplicate the current pair
 ` # Pop and push both values separated to the stack
 ‰ # Divmod: a,b → [a/b,a%b]
 « # Merge this to the current pair
 Â # Bifurcate this quadruplet; short for Duplicate & Reverse copy
 ` # Pop and push the reversed items separated to the stack
 "ÿ=(ÿ*ÿ)+ÿ" # Push this string, where the `ÿ` are one by one filled with the values
 , # Pop and output it with trailing newline
 ¤ # Push the last value (`a%b`), without popping
 _ # If this is 0:
 # # Stop the infinite loop
 # (else)
 ¤ # Push the last value (`a%b`) without popping yet again
 U # Pop and store it in variable `X`
 D # Duplicate the quadruplet
 ι # Uninterleave it into two parts: [a,b,c,d]  [[a,c],[b,d]]
 θ # Pop and keep the last pair (`[b,d]`)
}X, # After the infinite loop: Output value `X` with trailing newline
{R[D`‰« # Similar as above
¤_#¤UDιθ} # Similar as above as well
) # Wrap the quadruplets of the stack into a list
 ø # Zip/transpose; swapping rows/columns
 ε # Map over each inner list
 § # Cast every integer to a string (†bug work-around for builtin `j`)
 Z # Push the largest integer, without popping
 g # Pop and push its length
 j # Potentially add leading spaces so all values in the list are of this length
 }ø # After the map: zip/transpose back
 ε # Map over each inner list:
 R` # Push the items in reverse order to the stack
 "ÿ = (ÿ * ÿ) + ÿ"
 # Push this string, where the `ÿ` are one by one filled with the values
 }Xa # After the map: append value `X`
 » # Join this list by newlines
 „( # Push string "( "
 Â # Bifurcate; short for Duplicate & Reverse copy: " ("
 : # Infinitely replace "( " to " ("
 # (after which the string is output implicitly as result)

05AB1E, (削除) 32 (削除ここまで) 30 bytes

{R[D`‰«Â`"ÿ=(ÿ*ÿ)+ÿ",¤_#ιθ},

Try it online or verify all test cases.

Try it online or verify all test cases.

{ # Sort the (implicit) input-pair from lowest to highest
 R # Reverse it from highest to lowest
[ # Start an infinite loop:
 D # Duplicate the current pair
 ` # Pop one and push both values separated to the stack
 ‰ # Divmod: a,b → [a/b,a%b]
 « # Merge this to the current pair
 Â # Bifurcate this quadruplet; short for Duplicate & Reverse copy
 ` # Pop and push the reversed items separated to the stack
 "ÿ=(ÿ*ÿ)+ÿ" # Push this string, where the `ÿ` are one by one filled with the values
 , # Pop and output it with trailing newline
 ¤ # Push the last value (`a%b`), without popping
 _ # If this is 0:
 # # Stop the infinite loop
 # (else)
 ι # Uninterleave it into two parts: [a,b,c,d]  [[a,c],[b,d]]
 θ # Pop and keep the last pair (`[b,d]`)
} # After the infinite loop:
 1è  # Pop the final quadruplet, and leave its second item
 , # Pop and output it with trailing newline as well
{R[D`‰« # Similar as above
¤_#  # Similar as above as well
 ¤  # Push the last item without popping again
 U  # Pop and store it in variable `X`  D  # Duplicate the quadruplet
 ιθ} # Similar as above as well
) # Wrap the quadruplets of the stack into a list
 ø # Zip/transpose; swapping rows/columns
 ε # Map over each inner list
 § # Cast every integer to a string (†bug work-around for builtin `j`)
 Z # Push the largest integer, without popping
 g # Pop and push its length
 j # Potentially add leading spaces so all values in the list are of this length
 }ø # After the map: zip/transpose back
 ε # Map over each inner list:
 R` # Push the items in reverse order to the stack
 "ÿ = (ÿ * ÿ) + ÿ"
 # Push this string, where the `ÿ` are one by one filled with the values
 }Xa # After the map: append value `X`
 » # Join this list by newlines
 „( # Push string "( "
 Â # Bifurcate; short for Duplicate & Reverse copy: " ("
 : # Infinitely replace "( " to " ("
 # (after which the string is output implicitly as result)
Source Link
Kevin Cruijssen
  • 136.2k
  • 14
  • 154
  • 394

05AB1E, 32 bytes

{R[D`‰«Â`"ÿ=(ÿ*ÿ)+ÿ",¤_#¤UDιθ}X,

Inputs as a pair [i,j]. Output is without spaces.

Try it online or verify all test cases.

The -10% bonus isn't worth it to output in the correct format, but here it is anyway:
48.6 bytes (54 bytes - 10% bonus)
† Should have been -1 byte by removing the §, but there is a bug with j and integer-lists.

{R[D`‰«¤_#¤UDιθ})øε§Zgj}øεR`"ÿ = (ÿ * ÿ) + ÿ"}Xa»„( Â:

Try it online or verify all test cases.

Explanation:

{ # Sort the (implicit) input-pair from lowest to highest
 R # Reverse it from highest to lowest
[ # Start an infinite loop:
 D # Duplicate the current pair
 ` # Pop and push both values separated to the stack
 ‰ # Divmod: a,b → [a/b,a%b]
 « # Merge this to the current pair
 Â # Bifurcate this quadruplet; short for Duplicate & Reverse copy
 ` # Pop and push the reversed items separated to the stack
 "ÿ=(ÿ*ÿ)+ÿ" # Push this string, where the `ÿ` are one by one filled with the values
 , # Pop and output it with trailing newline
 ¤ # Push the last value (`a%b`), without popping
 _ # If this is 0:
 # # Stop the infinite loop
 # (else)
 ¤ # Push the last value (`a%b`) without popping yet again
 U # Pop and store it in variable `X`
 D # Duplicate the quadruplet
 ι # Uninterleave it into two parts: [a,b,c,d] → [[a,c],[b,d]]
 θ # Pop and keep the last pair (`[b,d]`)
}X, # After the infinite loop: Output value `X` with trailing newline
{R[D`‰« # Similar as above
¤_#¤UDιθ} # Similar as above as well
) # Wrap the quadruplets of the stack into a list
 ø # Zip/transpose; swapping rows/columns
 ε # Map over each inner list
 § # Cast every integer to a string (†bug work-around for builtin `j`)
 Z # Push the largest integer, without popping
 g # Pop and push its length
 j # Potentially add leading spaces so all values in the list are of this length
 }ø # After the map: zip/transpose back
 ε # Map over each inner list:
 R` # Push the items in reverse order to the stack
 "ÿ = (ÿ * ÿ) + ÿ"
 # Push this string, where the `ÿ` are one by one filled with the values
 }Xa # After the map: append value `X`
 » # Join this list by newlines
 „( # Push string "( "
 Â # Bifurcate; short for Duplicate & Reverse copy: " ("
 : # Infinitely replace "( " to " ("
 # (after which the string is output implicitly as result)

AltStyle によって変換されたページ (->オリジナル) /