Skip to main content
Bugfix
Source Link
Kevin Cruijssen
  • 131.4k
  • 13
  • 144
  • 384

05AB1E, 63 61 61 62 bytes

Try it online +1 byte as bug-fix for inputs like "u", "l", "LL", etc. (thanks for noticing @Neil)

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

ʒ                   # Filter this list by:
 Å¿                 #  Where the (implicit) input ends with this string
}н                  # After the filter: only leave the first (longest) one
  õ.;               # And remove the first occurrence of this in the (implicit) input
Ð ÐD                  # Triplicate + duplicate (so there are 4 copies on the stringstack now)
 ć ć                 # Extract head; pop and push remainder-string and first character
                    # separated to the stack
  _i _i               # If this first character is a 0:
    l l              #  Convert the remainder-string to lowercase
     D D             #  Duplicate it †¹
      ć ć            #  Extract head again
       'xQi 'xQi       '#  If it's equal to "x":
           A A       #   Push the lowercase alphabet
                  #   Only leave the first 6 characters: "abcdef"
              м м    #   Remove all those characters from the string
               Ð Ð   #   Triplicate it †²
                þ þ  #   Only keep all digits in the copy
                 Q Q #   And check that the two are still the same
                    #   (thus it's a non-negative integer without decimal .0s)
          ë         #  Else:
           \        #   Discard the remainder-string
            7Ý      #   Push list [0,1,2,3,4,5,6,7]
              K     #   Remove all those digits
               õQ   #   Check what remains is an empty string
   ë                # Else:
    \               #  Discard the remainder-string
     þ              #  Only keep all digits
      Q             #  And check that the two are still the same
                    #  (thus it's a non-negative integer without decimal .0s)
   }s               # After the if-else: Swap the two values on the stack
                    # (this will get the remaining copy of †² for "0x" cases,
                    #  or the implicitremaining inputcopy of †¹ for other cases)
     õÊ             # Check that this is NOT an empty string
       *            # And check that both are truthy
                    # (after which the result is output implicitly)

05AB1E, 63 61 bytes

Try it online or verify all test cases.

ʒ                   # Filter this list by:
 Å¿                 #  Where the (implicit) input ends with this string
}н                  # After the filter: only leave the first (longest) one
  õ.;               # And remove the first occurrence of this in the (implicit) input
Ð                   # Triplicate the string
 ć                  # Extract head; pop and push remainder-string and first character
                    # separated to the stack
  _i                # If this first character is a 0:
    l               #  Convert the remainder-string to lowercase
     D              #  Duplicate it
      ć             #  Extract head again
       'xQi        '#  If it's equal to "x":
           A        #   Push the lowercase alphabet
                  #   Only leave the first 6 characters: "abcdef"
              м     #   Remove all those characters from the string
               Ð    #   Triplicate it
                þ   #   Only keep all digits in the copy
                 Q  #   And check that the two are still the same
                    #   (thus it's a non-negative integer without decimal .0s)
          ë         #  Else:
           \        #   Discard the remainder-string
            7Ý      #   Push list [0,1,2,3,4,5,6,7]
              K     #   Remove all those digits
               õQ   #   Check what remains is an empty string
   ë                # Else:
    \               #  Discard the remainder-string
     þ              #  Only keep all digits
      Q             #  And check that the two are still the same
                    #  (thus it's a non-negative integer without decimal .0s)
   }s               # After the if-else: Swap the two values on the stack
                    # (this will get the remaining copy for "0x" cases,
                    #  or the implicit input for other cases)
     õÊ             # Check that this is NOT an empty string
       *            # And check that both are truthy
                    # (after which the result is output implicitly)

05AB1E, 63 61 62 bytes

+1 byte as bug-fix for inputs like "u", "l", "LL", etc. (thanks for noticing @Neil)

Try it online or verify all test cases.

ʒ                   # Filter this list by:
 Å¿                 #  Where the (implicit) input ends with this string
}н                  # After the filter: only leave the first (longest) one
  õ.;               # And remove the first occurrence of this in the (implicit) input
ÐD                  # Triplicate + duplicate (so there are 4 copies on the stack now)
  ć                 # Extract head; pop and push remainder-string and first character
                    # separated to the stack
   _i               # If this first character is a 0:
     l              #  Convert the remainder-string to lowercase
      D             #  Duplicate it †¹
       ć            #  Extract head again
        'xQi       '#  If it's equal to "x":
            A       #   Push the lowercase alphabet
                  #   Only leave the first 6 characters: "abcdef"
               м    #   Remove all those characters from the string
                Ð   #   Triplicate it †²
                 þ  #   Only keep all digits in the copy
                  Q #   And check that the two are still the same
                    #   (thus it's a non-negative integer without decimal .0s)
          ë         #  Else:
           \        #   Discard the remainder-string
            7Ý      #   Push list [0,1,2,3,4,5,6,7]
              K     #   Remove all those digits
               õQ   #   Check what remains is an empty string
   ë                # Else:
    \               #  Discard the remainder-string
     þ              #  Only keep all digits
      Q             #  And check that the two are still the same
                    #  (thus it's a non-negative integer without decimal .0s)
   }s               # After the if-else: Swap the two values on the stack
                    # (this will get the remaining copy of †² for "0x" cases,
                    #  or the remaining copy of †¹ for other cases)
     õÊ             # Check that this is NOT an empty string
       *            # And check that both are truthy
                    # (after which the result is output implicitly)
deleted 39 characters in body
Source Link
Kevin Cruijssen
  • 131.4k
  • 13
  • 144
  • 384

05AB1E, 63 63 61 bytes

„Uuõª„LLæDl«âDí«JéRʒÅ¿}нõ.;Ðć_ilDć'xQiA6£мÐþQsë\7ÝKõQIë\þQI;Ðć_ilDć'xQiA6£мÐþQë\7ÝKõQë\þQ}õÊ*sõÊ*

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

ʒ                   # Filter this list by:
 Å¿                 #  Where the (implicit) input ends with this string
}н                  # After the filter: only leave the first (longest) one
  õ.;               # And remove the first occurrence of this in the (implicit) input
Ð                   # Triplicate the string
 ć                  # Extract head; pop and push remainder-string and first character
                    # separated to the stack
  _i                # If this first character is a 0:
    l               #  Convert the remainder-string to lowercase
     D              #  Duplicate it
      ć             #  Extract head again
       'xQi        '#  If it's equal to "x":
           A        #   Push the lowercase alphabet
            6£      #   Only leave the first 6 characters: "abcdef"
              м     #   Remove all those characters from the string
               Ð    #   Triplicate it
                þ   #   Only keep all digits in the copy
                 Q  #   And check that the two are still the same
                    #   (thus it's a non-negative integer without decimal .0s)
                  s #   Swap, so the remaining copy is at the top of the stack
          ë         #  Else:
           \        #   Discard the remainder-string
            7Ý      #   Push list [0,1,2,3,4,5,6,7]
              K     #   Remove all those digits
               õQ   #   Check what remains is an empty string
                 I  #   And then push the input again
   ë                # Else:
    \               #  Discard the remainder-string
     þ              #  Only keep all digits
      Q             #  And check that the two are still the same
                    #  (thus it's a non-negative integer without decimal .0s)
    }s   I            # After Andthe thenif-else: pushSwap the inputtwo againvalues on the stack
   }                 # After(this will get the if-else:remaining copy for "0x" cases,
    õÊ                # Check thator the topimplicit ofinput thefor stackother cases)
     õÊ             # Check that this is NOT an empty string
      * *            # And check that both are truthy
                    # (after which the result is output implicitly)

05AB1E, 63 bytes

„Uuõª„LLæDl«âDí«JéRʒÅ¿}нõ.;Ðć_ilDć'xQiA6£мÐþQsë\7ÝKõQIë\þQI}õÊ*

Try it online or verify all test cases.

ʒ                   # Filter this list by:
 Å¿                 #  Where the (implicit) input ends with this string
}н                  # After the filter: only leave the first (longest) one
  õ.;               # And remove the first occurrence of this in the (implicit) input
Ð                   # Triplicate the string
 ć                  # Extract head; pop and push remainder-string and first character
                    # separated to the stack
  _i                # If this first character is a 0:
    l               #  Convert the remainder-string to lowercase
     D              #  Duplicate it
      ć             #  Extract head again
       'xQi        '#  If it's equal to "x":
           A        #   Push the lowercase alphabet
            6£      #   Only leave the first 6 characters: "abcdef"
              м     #   Remove all those characters from the string
               Ð    #   Triplicate it
                þ   #   Only keep all digits in the copy
                 Q  #   And check that the two are still the same
                    #   (thus it's a non-negative integer without decimal .0s)
                  s #   Swap, so the remaining copy is at the top of the stack
          ë         #  Else:
           \        #   Discard the remainder-string
            7Ý      #   Push list [0,1,2,3,4,5,6,7]
              K     #   Remove all those digits
               õQ   #   Check what remains is an empty string
                 I  #   And then push the input again
   ë                # Else:
    \               #  Discard the remainder-string
     þ              #  Only keep all digits
      Q             #  And check that the two are still the same
                    #  (thus it's a non-negative integer without decimal .0s)
       I            #  And then push the input again
   }                # After the if-else:
    õÊ              # Check that the top of the stack is NOT an empty string
      *             # And check that both are truthy
                    # (after which the result is output implicitly)

05AB1E, 63 61 bytes

„Uuõª„LLæDl«âDí«JéRʒÅ¿}нõ.;Ðć_ilDć'xQiA6£мÐþQë\7ÝKõQë\þQ}sõÊ*

Try it online or verify all test cases.

ʒ                   # Filter this list by:
 Å¿                 #  Where the (implicit) input ends with this string
}н                  # After the filter: only leave the first (longest) one
  õ.;               # And remove the first occurrence of this in the (implicit) input
Ð                   # Triplicate the string
 ć                  # Extract head; pop and push remainder-string and first character
                    # separated to the stack
  _i                # If this first character is a 0:
    l               #  Convert the remainder-string to lowercase
     D              #  Duplicate it
      ć             #  Extract head again
       'xQi        '#  If it's equal to "x":
           A        #   Push the lowercase alphabet
            6£      #   Only leave the first 6 characters: "abcdef"
              м     #   Remove all those characters from the string
               Ð    #   Triplicate it
                þ   #   Only keep all digits in the copy
                 Q  #   And check that the two are still the same
                    #   (thus it's a non-negative integer without decimal .0s)
          ë         #  Else:
           \        #   Discard the remainder-string
            7Ý      #   Push list [0,1,2,3,4,5,6,7]
              K     #   Remove all those digits
               õQ   #   Check what remains is an empty string
   ë                # Else:
    \               #  Discard the remainder-string
     þ              #  Only keep all digits
      Q             #  And check that the two are still the same
                    #  (thus it's a non-negative integer without decimal .0s)
   }s               # After the if-else: Swap the two values on the stack
                    # (this will get the remaining copy for "0x" cases,
                    #  or the implicit input for other cases)
     õÊ             # Check that this is NOT an empty string
       *            # And check that both are truthy
                    # (after which the result is output implicitly)
Post Undeleted by Kevin Cruijssen
Fixed edge case "0x"
Source Link
Kevin Cruijssen
  • 131.4k
  • 13
  • 144
  • 384

05AB1E, 63 6163 bytes

„Uuõª„LLæDl«âDí«JéRʒÅ¿}нõ.;Ðć_ilDć'xQiA6£мDþQë\7ÝKõQë\þQ;Ðć_ilDć'xQiA6£мÐþQsë\7ÝKõQIë\þQI}IõÊ*õÊ*

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

ʒ                   # Filter this list by:
 Å¿                 #  Where the (implicit) input ends with this string
}н                  # After the filter: only leave the first (longest) one
  õ.;               # And remove the first occurrence of this in the (implicit) input
Ð                   # Triplicate the string
 ć                  # Extract head; pop and push remainder-string and first character
                    # separated to the stack
  _i                # If this first character is a 0:
    l               #  Convert the remainder-string to lowercase
     D              #  Duplicate it
      ć             #  Extract head again
       'xQi        '#  If it's equal to "x":
           A        #   Push the lowercase alphabet
            6£      #   Only leave the first 6 characters: "abcdef"
              м     #   Remove all those characters from the string
               DÐ    #   DuplicateTriplicate it
                þ   #   Only keep all digits in the copy
                 Q  #   And check that the two are still the same
                    #   (thus it's a non-negative integer without decimal .0s)
                  s #   Swap, so the remaining copy is at the top of the stack
          ë         #  Else:
           \        #   Discard the remainder-string
            7Ý      #   Push list [0,1,2,3,4,5,6,7]
              K     #   Remove all those digits
               õQ   #   And checkCheck what remains is an empty string
                 I  #   And then push the input again
   ë                # Else:
    \               #  Discard the remainder-string
     þ              #  Only keep all digits
      Q             #  And check that the two are still the same
                    #  (thus it's a non-negative integer without decimal .0s)
   }I    I            # After theAnd if-else:then push the input again
   }                # After the if-else:
    õÊ              # Check that it'sthe top of the stack is NOT an empty string
       *             # And check that both are truthy
                    # (after which the result is output implicitly)

05AB1E, 63 61 bytes

„Uuõª„LLæDl«âDí«JéRʒÅ¿}нõ.;Ðć_ilDć'xQiA6£мDþQë\7ÝKõQë\þQ}IõÊ*

Try it online or verify all test cases.

ʒ                   # Filter this list by:
 Å¿                 #  Where the (implicit) input ends with this string
}н                  # After the filter: only leave the first (longest) one
  õ.;               # And remove the first occurrence of this in the (implicit) input
Ð                   # Triplicate the string
 ć                  # Extract head; pop and push remainder-string and first character
                    # separated to the stack
  _i                # If this first character is a 0:
    l               #  Convert the remainder-string to lowercase
     D              #  Duplicate it
      ć             #  Extract head again
       'xQi        '#  If it's equal to "x":
           A        #   Push the lowercase alphabet
            6£      #   Only leave the first 6 characters: "abcdef"
              м     #   Remove all those characters from the string
               D    #   Duplicate it
                þ   #   Only keep all digits in the copy
                 Q  #   And check that the two are still the same
                    #   (thus it's a non-negative integer without decimal .0s)
          ë         #  Else:
           \        #   Discard the remainder-string
            7Ý      #   Push list [0,1,2,3,4,5,6,7]
              K     #   Remove all those digits
               õQ   #   And check what remains is an empty string
   ë                # Else:
    \               #  Discard the remainder-string
     þ              #  Only keep all digits
      Q             #  And check that the two are still the same
                    #  (thus it's a non-negative integer without decimal .0s)
   }I               # After the if-else: push the input again
     õÊ             # Check that it's NOT an empty string
       *            # And check that both are truthy
                    # (after which the result is output implicitly)

05AB1E, 63 bytes

„Uuõª„LLæDl«âDí«JéRʒÅ¿}нõ.;Ðć_ilDć'xQiA6£мÐþQsë\7ÝKõQIë\þQI}õÊ*

Try it online or verify all test cases.

ʒ                   # Filter this list by:
 Å¿                 #  Where the (implicit) input ends with this string
}н                  # After the filter: only leave the first (longest) one
  õ.;               # And remove the first occurrence of this in the (implicit) input
Ð                   # Triplicate the string
 ć                  # Extract head; pop and push remainder-string and first character
                    # separated to the stack
  _i                # If this first character is a 0:
    l               #  Convert the remainder-string to lowercase
     D              #  Duplicate it
      ć             #  Extract head again
       'xQi        '#  If it's equal to "x":
           A        #   Push the lowercase alphabet
            6£      #   Only leave the first 6 characters: "abcdef"
              м     #   Remove all those characters from the string
               Ð    #   Triplicate it
                þ   #   Only keep all digits in the copy
                 Q  #   And check that the two are still the same
                    #   (thus it's a non-negative integer without decimal .0s)
                  s #   Swap, so the remaining copy is at the top of the stack
          ë         #  Else:
           \        #   Discard the remainder-string
            7Ý      #   Push list [0,1,2,3,4,5,6,7]
              K     #   Remove all those digits
               õQ   #   Check what remains is an empty string
                 I  #   And then push the input again
   ë                # Else:
    \               #  Discard the remainder-string
     þ              #  Only keep all digits
      Q             #  And check that the two are still the same
                    #  (thus it's a non-negative integer without decimal .0s)
       I            #  And then push the input again
   }                # After the if-else:
    õÊ              # Check that the top of the stack is NOT an empty string
      *             # And check that both are truthy
                    # (after which the result is output implicitly)
Post Deleted by Kevin Cruijssen
added 2911 characters in body
Source Link
Kevin Cruijssen
  • 131.4k
  • 13
  • 144
  • 384
Loading
Source Link
Kevin Cruijssen
  • 131.4k
  • 13
  • 144
  • 384
Loading