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

deleted 47 characters in body
Source Link
nwellnhof
  • 10.6k
  • 1
  • 20
  • 38

Perl 6, (削除) 36 (削除ここまで) (削除) 34 (削除ここまで) 33(削除) 33 (削除ここまで) 31 bytes

-1 byte thanks to Jo King
-2 bytes thanks to Phil H

*.sort:{sort 1,|set -<<.abs.comb<<m:g/\d/}

Try it online! Try it online!

Explanation

 { } # Map each number, e.g. -373
 .abs # Absolute value to remove minus signm: 373
 .combg/\d/ # Split intoExtract digits: (3, 7, 3)
 -<< # Negate each digit: (-3, -7, -3)
 set # Convert to set to remove duplicates
 | # Pass as list of pairs: (-3 => True, -7 => True)
 1, # Prepend 1 for "none": (1, -3 => True, -7 => True)
 sort # Sort (compares 1 and pair by string value): (-7 => True, -3 => True, 1)
*.sort: # Sort lexicographically

Perl 6, (削除) 36 (削除ここまで) (削除) 34 (削除ここまで) 33 bytes

-1 byte thanks to Jo King

*.sort:{sort 1,|set -<<.abs.comb}

Try it online!

Explanation

 { } # Map each number, e.g. -373
 .abs # Absolute value to remove minus sign: 373
 .comb # Split into digits: (3, 7, 3)
 -<< # Negate each digit: (-3, -7, -3)
 set # Convert to set to remove duplicates
 | # Pass as list of pairs: (-3 => True, -7 => True)
 1, # Prepend 1 for "none": (1, -3 => True, -7 => True)
 sort # Sort (compares 1 and pair by string value): (-7 => True, -3 => True, 1)
*.sort: # Sort lexicographically

Perl 6, (削除) 36 (削除ここまで) (削除) 34 (削除ここまで) (削除) 33 (削除ここまで) 31 bytes

-1 byte thanks to Jo King
-2 bytes thanks to Phil H

*.sort:{sort 1,|set -<<m:g/\d/}

Try it online!

Explanation

 { } # Map each number, e.g. -373
 m:g/\d/ # Extract digits: (3, 7, 3)
 -<< # Negate each digit: (-3, -7, -3)
 set # Convert to set to remove duplicates
 | # Pass as list of pairs: (-3 => True, -7 => True)
 1, # Prepend 1 for "none": (1, -3 => True, -7 => True)
 sort # Sort (compares 1 and pair by string value): (-7 => True, -3 => True, 1)
*.sort: # Sort lexicographically
deleted 3 characters in body
Source Link
nwellnhof
  • 10.6k
  • 1
  • 20
  • 38

Perl 6, (削除) 36 (削除ここまで) (削除) 34 (削除ここまで) 33 bytes

-1 byte thanks to Jo King

*.sort:{sort 1,|set -<<.abs.comb}

Try it online!

Explanation

 {  }  # Map each number, e.g. -373
 .abs # Absolute value to remove minus sign: 373
 .comb # Split into digits: (3, 7, 3)
 -<< # Negate each digit: (-3, -7, -3)
 set # Convert to set to remove duplicates
 | # Pass as list of pairs: (-3 => True, -7 => True)
 1, # Prepend 1 for "none": (1, -3 => True, -7 => True)
 sort # Sort (compares 1 and pair by string value): (-7 => True, -3 => True, 1)
*.sort:{ } # Sort lexicographically

Perl 6, (削除) 36 (削除ここまで) (削除) 34 (削除ここまで) 33 bytes

-1 byte thanks to Jo King

*.sort:{sort 1,|set -<<.abs.comb}

Try it online!

Explanation

 # Map each number, e.g. -373
 .abs # Absolute value to remove minus sign: 373
 .comb # Split into digits: (3, 7, 3)
 -<< # Negate each digit: (-3, -7, -3)
 set # Convert to set to remove duplicates
 | # Pass as list of pairs: (-3 => True, -7 => True)
 1, # Prepend 1 for "none": (1, -3 => True, -7 => True)
 sort # Sort (compares 1 and pair by string value): (-7 => True, -3 => True, 1)
*.sort:{ } # Sort lexicographically

Perl 6, (削除) 36 (削除ここまで) (削除) 34 (削除ここまで) 33 bytes

-1 byte thanks to Jo King

*.sort:{sort 1,|set -<<.abs.comb}

Try it online!

Explanation

 {  }  # Map each number, e.g. -373
 .abs # Absolute value to remove minus sign: 373
 .comb # Split into digits: (3, 7, 3)
 -<< # Negate each digit: (-3, -7, -3)
 set # Convert to set to remove duplicates
 | # Pass as list of pairs: (-3 => True, -7 => True)
 1, # Prepend 1 for "none": (1, -3 => True, -7 => True)
 sort # Sort (compares 1 and pair by string value): (-7 => True, -3 => True, 1)
*.sort: # Sort lexicographically
deleted 3 characters in body
Source Link
nwellnhof
  • 10.6k
  • 1
  • 20
  • 38

Perl 6, (削除) 36 (削除ここまで) (削除) 34 (削除ここまで) 33 bytes

-1 byte thanks to Jo King

*.sort:{sort 1,|set -<<.abs.comb}

Try it online!

Explanation

 # Map each number, e.g. -373
 .abs # Absolute value to remove minus sign: 373
 .comb # Split into digits: (3, 7, 3)
 -<< # Negate each digit: (-3, -7, -3)
 set # Convert to set to remove duplicates
 | # ConvertPass toas list of pairs: (-3 => True, -7 => True)
 1, # Prepend 1 for "none": (1, -3 => True, -7 => True)
 sort # Sort (compares 1 and pair by string value): (-7 => True, -3 => True, 1)
*.sort:{ } # Sort lexicographically

Perl 6, (削除) 36 (削除ここまで) (削除) 34 (削除ここまで) 33 bytes

-1 byte thanks to Jo King

*.sort:{sort 1,|set -<<.abs.comb}

Try it online!

Explanation

 # Map each number, e.g. -373
 .abs # Absolute value to remove minus sign: 373
 .comb # Split into digits: (3, 7, 3)
 -<< # Negate each digit: (-3, -7, -3)
 set # Convert to set to remove duplicates
 | # Convert to list of pairs: (-3 => True, -7 => True)
 1, # Prepend 1 for "none": (1, -3 => True, -7 => True)
 sort # Sort (compares 1 and pair by string value): (-7 => True, -3 => True, 1)
*.sort:{ } # Sort lexicographically

Perl 6, (削除) 36 (削除ここまで) (削除) 34 (削除ここまで) 33 bytes

-1 byte thanks to Jo King

*.sort:{sort 1,|set -<<.abs.comb}

Try it online!

Explanation

 # Map each number, e.g. -373
 .abs # Absolute value to remove minus sign: 373
 .comb # Split into digits: (3, 7, 3)
 -<< # Negate each digit: (-3, -7, -3)
 set # Convert to set to remove duplicates
 | # Pass as list of pairs: (-3 => True, -7 => True)
 1, # Prepend 1 for "none": (1, -3 => True, -7 => True)
 sort # Sort (compares 1 and pair by string value): (-7 => True, -3 => True, 1)
*.sort:{ } # Sort lexicographically
added 61 characters in body
Source Link
nwellnhof
  • 10.6k
  • 1
  • 20
  • 38
Loading
added 117 characters in body
Source Link
nwellnhof
  • 10.6k
  • 1
  • 20
  • 38
Loading
deleted 40 characters in body
Source Link
nwellnhof
  • 10.6k
  • 1
  • 20
  • 38
Loading
added 450 characters in body
Source Link
nwellnhof
  • 10.6k
  • 1
  • 20
  • 38
Loading
Source Link
nwellnhof
  • 10.6k
  • 1
  • 20
  • 38
Loading

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