Type-check an expressionFixing a logic systemSolve an algebraic expressionExpand the variadic expressionJimmy these arrays downConvert a logical expression to conjunctive normal formRegular expression parserIs it a valid number theory expression?Ordinal string checkPrimality testing formulaLet's play Peg Solitaire

How is CoreiX like Corei5, i7 is related to Haswell, Ivy Bridge?

Is it bad writing or bad story telling if first person narrative contains more information than the narrator knows?

Is it a good idea to copy a trader when investing?

Would encrypting a database protect against a compromised admin account?

Does the 500 feet falling cap apply per fall, or per turn?

What's the difference between const array and static const array in C/C++

Why are parallelograms defined as quadrilaterals? What term would encompass polygons with greater than two parallel pairs?

What can cause an unfrozen indoor copper drain pipe to crack?

Peculiarities in low dimensions or low order or etc

Was the Highlands Ranch shooting the 115th mass shooting in the US in 2019

Is there an application which does HTTP PUT?

Is every story set in the future "science fiction"?

Program for finding longest run of zeros from a list of 100 random integers which are either 0 or 1

Why did Captain America age?

Was Mohammed the most popular first name for boys born in Berlin in 2018?

Why is the Sun made of light elements only?

When quoting someone, is it proper to change "gotta" to "got to" without modifying the rest of the quote?

How to evaluate sum with one million summands?

What is wrong with my code? RGB potentiometer

Why is it wrong to *implement* myself a known, published, widely believed to be secure crypto algorithm?

Why are low spin tetrahedral complexes so rare?

What does this quote in Small Gods refer to?

What does formal training in a field mean?

Why was wildfire not used during the Battle of Winterfell?



Type-check an expression


Fixing a logic systemSolve an algebraic expressionExpand the variadic expressionJimmy these arrays downConvert a logical expression to conjunctive normal formRegular expression parserIs it a valid number theory expression?Ordinal string checkPrimality testing formulaLet's play Peg Solitaire













8












$begingroup$


Given an infix expression, determine whether all constants are of the same type.



Operators will consist only of these dyadic operators: +-/*



Your program or function should take a valid expression string as input, and output a truthy value if the constants in the expression are of the same time, and a falsey value otherwise.



The expression will consist solely of constants, and may contain any of the following types:



  • String, of the form "String" (Always double quotes, can be empty, no escape characters, may contain any ASCII text)

  • Integer, of the form 14 (Always positive or zero)

  • Float, of the form 7.3f (Always positive or zero, always has a decimal component, eg 14.0f)

  • Byte, of the form 0x42 (0-255, Always 2 hexadecimal characters)

  • Boolean, of the form true (true or false, case insensitive)

The expression will not contain parentheses, as order of operation doesn't affect type when no type coercion is present.



A lone constant with no operators is a valid expression.



An empty expression is not a valid expression.



You may assume that the expression string contains no whitespace outside of string literals.
Note: Alternatively you may assume that there will always be spaces between constants and operators, as seen in the testcases. If you make this assumption, please specify as such in your answer



You do not have to handle invalid expressions such as 1 +.



Scoring



This is code-golf, so fewest bytes wins!



Test cases



(Whitespace added for readability)



2 + 3
True

"Hello" / "World"
True

true * false
True

"Hello" + 4
False

"Hello" + "4"
True

3 + 2.4f / 8
False

0xff * 0xff
True

0xff + 2
False

6
True

" " + ""
True

"4 + false" + "word"
True









share|improve this question











$endgroup$







  • 4




    $begingroup$
    Does "case insensitive" for Boolean values mean that we have to support all cases? Or that we can decide which case to use?
    $endgroup$
    – Arnauld
    Apr 30 at 16:09










  • $begingroup$
    @Arnauld must support all cases
    $endgroup$
    – Skidsdev
    Apr 30 at 16:31










  • $begingroup$
    @JonathanAllan my interpretation was that we had to handle any mixture of cases (e.g. truE+fALSe). If not I can save two bytes in my solution.
    $endgroup$
    – Nick Kennedy
    Apr 30 at 19:50















8












$begingroup$


Given an infix expression, determine whether all constants are of the same type.



Operators will consist only of these dyadic operators: +-/*



Your program or function should take a valid expression string as input, and output a truthy value if the constants in the expression are of the same time, and a falsey value otherwise.



The expression will consist solely of constants, and may contain any of the following types:



  • String, of the form "String" (Always double quotes, can be empty, no escape characters, may contain any ASCII text)

  • Integer, of the form 14 (Always positive or zero)

  • Float, of the form 7.3f (Always positive or zero, always has a decimal component, eg 14.0f)

  • Byte, of the form 0x42 (0-255, Always 2 hexadecimal characters)

  • Boolean, of the form true (true or false, case insensitive)

The expression will not contain parentheses, as order of operation doesn't affect type when no type coercion is present.



A lone constant with no operators is a valid expression.



An empty expression is not a valid expression.



You may assume that the expression string contains no whitespace outside of string literals.
Note: Alternatively you may assume that there will always be spaces between constants and operators, as seen in the testcases. If you make this assumption, please specify as such in your answer



You do not have to handle invalid expressions such as 1 +.



Scoring



This is code-golf, so fewest bytes wins!



Test cases



(Whitespace added for readability)



2 + 3
True

"Hello" / "World"
True

true * false
True

"Hello" + 4
False

"Hello" + "4"
True

3 + 2.4f / 8
False

0xff * 0xff
True

0xff + 2
False

6
True

" " + ""
True

"4 + false" + "word"
True









share|improve this question











$endgroup$







  • 4




    $begingroup$
    Does "case insensitive" for Boolean values mean that we have to support all cases? Or that we can decide which case to use?
    $endgroup$
    – Arnauld
    Apr 30 at 16:09










  • $begingroup$
    @Arnauld must support all cases
    $endgroup$
    – Skidsdev
    Apr 30 at 16:31










  • $begingroup$
    @JonathanAllan my interpretation was that we had to handle any mixture of cases (e.g. truE+fALSe). If not I can save two bytes in my solution.
    $endgroup$
    – Nick Kennedy
    Apr 30 at 19:50













8












8








8


1



$begingroup$


Given an infix expression, determine whether all constants are of the same type.



Operators will consist only of these dyadic operators: +-/*



Your program or function should take a valid expression string as input, and output a truthy value if the constants in the expression are of the same time, and a falsey value otherwise.



The expression will consist solely of constants, and may contain any of the following types:



  • String, of the form "String" (Always double quotes, can be empty, no escape characters, may contain any ASCII text)

  • Integer, of the form 14 (Always positive or zero)

  • Float, of the form 7.3f (Always positive or zero, always has a decimal component, eg 14.0f)

  • Byte, of the form 0x42 (0-255, Always 2 hexadecimal characters)

  • Boolean, of the form true (true or false, case insensitive)

The expression will not contain parentheses, as order of operation doesn't affect type when no type coercion is present.



A lone constant with no operators is a valid expression.



An empty expression is not a valid expression.



You may assume that the expression string contains no whitespace outside of string literals.
Note: Alternatively you may assume that there will always be spaces between constants and operators, as seen in the testcases. If you make this assumption, please specify as such in your answer



You do not have to handle invalid expressions such as 1 +.



Scoring



This is code-golf, so fewest bytes wins!



Test cases



(Whitespace added for readability)



2 + 3
True

"Hello" / "World"
True

true * false
True

"Hello" + 4
False

"Hello" + "4"
True

3 + 2.4f / 8
False

0xff * 0xff
True

0xff + 2
False

6
True

" " + ""
True

"4 + false" + "word"
True









share|improve this question











$endgroup$




Given an infix expression, determine whether all constants are of the same type.



Operators will consist only of these dyadic operators: +-/*



Your program or function should take a valid expression string as input, and output a truthy value if the constants in the expression are of the same time, and a falsey value otherwise.



The expression will consist solely of constants, and may contain any of the following types:



  • String, of the form "String" (Always double quotes, can be empty, no escape characters, may contain any ASCII text)

  • Integer, of the form 14 (Always positive or zero)

  • Float, of the form 7.3f (Always positive or zero, always has a decimal component, eg 14.0f)

  • Byte, of the form 0x42 (0-255, Always 2 hexadecimal characters)

  • Boolean, of the form true (true or false, case insensitive)

The expression will not contain parentheses, as order of operation doesn't affect type when no type coercion is present.



A lone constant with no operators is a valid expression.



An empty expression is not a valid expression.



You may assume that the expression string contains no whitespace outside of string literals.
Note: Alternatively you may assume that there will always be spaces between constants and operators, as seen in the testcases. If you make this assumption, please specify as such in your answer



You do not have to handle invalid expressions such as 1 +.



Scoring



This is code-golf, so fewest bytes wins!



Test cases



(Whitespace added for readability)



2 + 3
True

"Hello" / "World"
True

true * false
True

"Hello" + 4
False

"Hello" + "4"
True

3 + 2.4f / 8
False

0xff * 0xff
True

0xff + 2
False

6
True

" " + ""
True

"4 + false" + "word"
True






code-golf string decision-problem parsing






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited May 1 at 14:26









DJMcMayhem

40.7k12150316




40.7k12150316










asked Apr 30 at 14:47









SkidsdevSkidsdev

6,7952977




6,7952977







  • 4




    $begingroup$
    Does "case insensitive" for Boolean values mean that we have to support all cases? Or that we can decide which case to use?
    $endgroup$
    – Arnauld
    Apr 30 at 16:09










  • $begingroup$
    @Arnauld must support all cases
    $endgroup$
    – Skidsdev
    Apr 30 at 16:31










  • $begingroup$
    @JonathanAllan my interpretation was that we had to handle any mixture of cases (e.g. truE+fALSe). If not I can save two bytes in my solution.
    $endgroup$
    – Nick Kennedy
    Apr 30 at 19:50












  • 4




    $begingroup$
    Does "case insensitive" for Boolean values mean that we have to support all cases? Or that we can decide which case to use?
    $endgroup$
    – Arnauld
    Apr 30 at 16:09










  • $begingroup$
    @Arnauld must support all cases
    $endgroup$
    – Skidsdev
    Apr 30 at 16:31










  • $begingroup$
    @JonathanAllan my interpretation was that we had to handle any mixture of cases (e.g. truE+fALSe). If not I can save two bytes in my solution.
    $endgroup$
    – Nick Kennedy
    Apr 30 at 19:50







4




4




$begingroup$
Does "case insensitive" for Boolean values mean that we have to support all cases? Or that we can decide which case to use?
$endgroup$
– Arnauld
Apr 30 at 16:09




$begingroup$
Does "case insensitive" for Boolean values mean that we have to support all cases? Or that we can decide which case to use?
$endgroup$
– Arnauld
Apr 30 at 16:09












$begingroup$
@Arnauld must support all cases
$endgroup$
– Skidsdev
Apr 30 at 16:31




$begingroup$
@Arnauld must support all cases
$endgroup$
– Skidsdev
Apr 30 at 16:31












$begingroup$
@JonathanAllan my interpretation was that we had to handle any mixture of cases (e.g. truE+fALSe). If not I can save two bytes in my solution.
$endgroup$
– Nick Kennedy
Apr 30 at 19:50




$begingroup$
@JonathanAllan my interpretation was that we had to handle any mixture of cases (e.g. truE+fALSe). If not I can save two bytes in my solution.
$endgroup$
– Nick Kennedy
Apr 30 at 19:50










8 Answers
8






active

oldest

votes


















8












$begingroup$

JavaScript (ES6),  79 77  75 bytes



Saved 2 bytes thanks to @ExpiredData



Expects whitespace around operators. Returns a Boolean value.





s=>![/".*?"/g,/0x../g,/S+f/g,/d/,/e/i].filter(e=>s!=(s=s.split(e)+''))[1]


Try it online!



How?



  1. We remove all strings, using /".*?"/g

  2. We remove all bytes, using /0x../g

  3. We remove all floats, using /S+f/g

  4. We look for a remaining digit with /d/; if we do find one, there must be at least one integer

  5. We look for a remaining "e" or "E" with /e/i; if we do find one, there must be at least one Boolean value

All removed expressions are actually replaced with a comma, which is harmless.



We filter out the regular expressions causing no change to the input string and test whether less than two of them remain at the end of the process.






share|improve this answer











$endgroup$












  • $begingroup$
    true and false are marked as being case insensitive, I think that means you need to make your regex ignore case when searching for these t and s (I could be wrong though).
    $endgroup$
    – Jonathan Allan
    Apr 30 at 16:03






  • 1




    $begingroup$
    @JonathanAllan I've put a temporary fix and asked the OP.
    $endgroup$
    – Arnauld
    Apr 30 at 16:09











  • $begingroup$
    75 bytes
    $endgroup$
    – Expired Data
    May 1 at 7:57










  • $begingroup$
    @ExpiredData Nice. :) Thanks!
    $endgroup$
    – Arnauld
    May 1 at 8:08


















3












$begingroup$


Perl 5 -p, 73 bytes





for$f(qw/".*?" d+.d+f 0x.. ....?e d+/)s/$f//gi&&last$_=/^[+/* -]*$/


Try it online!



How?



Attempt to remove strings, floats, hex, boolean, and integers, in that order. Stop as soon as something is removed. After stopping, check to see if the remaining string consists only of operators and whitespace. It if does, the trype check is true; if not, it's false.



First attempt: Perl 5 -MList::Util=all -p, 99 bytes





s/".*?"/!/g;for$f(qw/! d+ d+.d+f 0x[0-9a-f]2 (true|false)/)$}improve this answer











$endgroup$












  • $begingroup$
    108 bytes
    $endgroup$
    – Expired Data
    May 1 at 7:42









share|improve this answer











$endgroup$




















    0












    $begingroup$


    Python 2, 102 bytes





    import re
    def f(s):
    m=map(eval,re.split('[*+-/]',s))
    return all(map(lambda t:type(t)==type(m[0]),m))


    Try it online!



    Not entirely sure how to represent some of these types in Python. For example, 0xff and 2 are both treated as integers. And 2.4f isn't a valid type in Python, I think. Capitalized True and False for testing Booleans.



    Edit: Grammar






    share|improve this answer









    $endgroup$








    • 3




      $begingroup$
      Will fail the last test case
      $endgroup$
      – Embodiment of Ignorance
      Apr 30 at 16:08










    • $begingroup$
      ...and (as it stands) the true * false one.
      $endgroup$
      – Jonathan Allan
      Apr 30 at 18:46










    • $begingroup$
      It passes for "True * False". I can try to make it work with lower case, but I figured since bools are always capitalized in python it would be sufficient.
      $endgroup$
      – GotCubes
      Apr 30 at 19:12






    • 2




      $begingroup$
      Currently this does not fulfill the challenge criteria. Namely: It does not handle booleans case insensitively, it errors on floats, and it incorrectly returns true when given an expression consisting of bytes and integers
      $endgroup$
      – Skidsdev
      May 1 at 13:38



















    0












    $begingroup$


    Stax, 26 bytes



    ïd"┬Z¡►L!8$lm╗╕╤☻ú≡╝ò6Å>^


    Run and debug it



    This program expects spaces around the operators. In general, it works by applying a few transformations to the input such that the maximum character for each expression type is distinct.



    Unpacked, ungolfed, and commented, it looks like this.



    i suppress automatic evaluation of input
    '"/2::'s* replace quoted strings with 's'
    .d'9R replace all digits with '9'
    .ez|t replace 'e' with 'z'
    j2:: split on spaces, and discard alternating groups (operators)
     














    0












    $begingroup$


    Japt -!, 36 bytes



    `".*?" 0x.. %S+f %d eimprove this answer











    $endgroup$












    • $begingroup$
      $_=/^[+/* -]*$/ may be changed by $_=!y#-+/* ##c, and ....?e by .*e
      $endgroup$
      – Nahuel Fouilleul
      May 2 at 9:11











    • $begingroup$
      otherwise in one regex, 63 bytes
      $endgroup$
      – Nahuel Fouilleul
      May 2 at 9:22











    • $begingroup$
      58 bytes assuming there will always be spaces between constants and operators
      $endgroup$
      – Nahuel Fouilleul
      May 2 at 9:37

















    $endgroup$












    • $begingroup$
      $_=/^[+/* -]*$/ may be changed by $_=!y#-+/* ##c, and ....?e by .*e
      $endgroup$
      – Nahuel Fouilleul
      May 2 at 9:11











    • $begingroup$
      otherwise in one regex, 63 bytes
      $endgroup$
      – Nahuel Fouilleul
      May 2 at 9:22











    • $begingroup$
      58 bytes assuming there will always be spaces between constants and operators
      $endgroup$
      – Nahuel Fouilleul
      May 2 at 9:37










    shareË


    -26 bytes by making a port of @NickKennedy's Jelly answer, so make sure to upvote him!!



    Expects input with spaces at the operands.



    Try it online or verify all (plus some more) test cases.



    Explanation:





    '"¡ '# Split the (implicit) input-string by '"'
    āÉÏ # Only keep all values at 0-based even indices
    » # Join them by newlines
    l # Converted to lowercase (for `true`/`false`)
    ð¡ # Split by spaces (NOTE: `#` cannot be used here, since inputs without
    # operands wouldn't be wrapped inside a list)
    āÉÏ # Keep all values at 0-based even indices again
    ε".e
    x"Så} # Check for each item for each of [".","e","n","x"] if it's in the item
    Ë # Check if all inner lists are the same
    # (which is output implicitly as result)





    share|improve this answer











    $endgroup$

















      1












      $begingroup$


      05AB1E, 50 24 bytes



      '"¡āÉÏ»lð¡āÉÏε".e
      x"Så}Ë


      -26 bytes by making a port of @NickKennedy's Jelly answer, so make sure to upvote him!!



      Expects input with spaces at the operands.



      Try it online or verify all (plus some more) test cases.



      Explanation:





      '"¡ '# Split the (implicit) input-string by '"'
      āÉÏ # Only keep all values at 0-based even indices
      » # Join them by newlines
      l # Converted to lowercase (for `true`/`false`)
      ð¡ # Split by spaces (NOTE: `#` cannot be used here, since inputs without
      # operands wouldn't be wrapped inside a list)
      āÉÏ # Keep all values at 0-based even indices again
      ε".e
      x"Så} # Check for each item for each of [".","e","n","x"] if it's in the item
      Ë # Check if all inner lists are the same
      # (which is output implicitly as result)





      share|improve this answer











      $endgroup$















        1












        1








        1





        $begingroup$


        05AB1E, 50 24 bytes



        '"¡āÉÏ»lð¡āÉÏε".e
        x"Så}Ë


        -26 bytes by making a port of @NickKennedy's Jelly answer, so make sure to upvote him!!



        Expects input with spaces at the operands.



        Try it online or verify all (plus some more) test cases.



        Explanation:





        '"¡ '# Split the (implicit) input-string by '"'
        āÉÏ # Only keep all values at 0-based even indices
        » # Join them by newlines
        l # Converted to lowercase (for `true`/`false`)
        ð¡ # Split by spaces (NOTE: `#` cannot be used here, since inputs without
        # operands wouldn't be wrapped inside a list)
        āÉÏ # Keep all values at 0-based even indices again
        ε".e
        x"Så} # Check for each item for each of [".","e","n","x"] if it's in the item
        Ë # Check if all inner lists are the same
        # (which is output implicitly as result)





        share|improve this answer











        $endgroup$




        05AB1E, 50 24 bytes



        '"¡āÉÏ»lð¡āÉÏε".e
        x"Så}Ë


        -26 bytes by making a port of @NickKennedy's Jelly answer, so make sure to upvote him!!



        Expects input with spaces at the operands.



        Try it online or verify all (plus some more) test cases.



        Explanation:





        '"¡ '# Split the (implicit) input-string by '"'
        āÉÏ # Only keep all values at 0-based even indices
        » # Join them by newlines
        l # Converted to lowercase (for `true`/`false`)
        ð¡ # Split by spaces (NOTE: `#` cannot be used here, since inputs without
        # operands wouldn't be wrapped inside a list)
        āÉÏ # Keep all values at 0-based even indices again
        ε".e
        x"Så} # Check for each item for each of [".","e","n","x"] if it's in the item
        Ë # Check if all inner lists are the same
        # (which is output implicitly as result)






        share|improve this answer














        share|improve this answer



        share|improve this answer








        edited May 1 at 7:25

























        answered Apr 30 at 17:15









        Kevin CruijssenKevin Cruijssen

        44.4k575224




        44.4k575224





















            0












            $begingroup$


            Python 2, 102 bytes





            import re
            def f(s):
            m=map(eval,re.split('[*+-/]',s))
            return all(map(lambda t:type(t)==type(m[0]),m))


            Try it online!



            Not entirely sure how to represent some of these types in Python. For example, 0xff and 2 are both treated as integers. And 2.4f isn't a valid type in Python, I think. Capitalized True and False for testing Booleans.



            Edit: Grammar






            share|improve this answer









            $endgroup$








            • 3




              $begingroup$
              Will fail the last test case
              $endgroup$
              – Embodiment of Ignorance
              Apr 30 at 16:08










            • $begingroup$
              ...and (as it stands) the true * false one.
              $endgroup$
              – Jonathan Allan
              Apr 30 at 18:46










            • $begingroup$
              It passes for "True * False". I can try to make it work with lower case, but I figured since bools are always capitalized in python it would be sufficient.
              $endgroup$
              – GotCubes
              Apr 30 at 19:12






            • 2




              $begingroup$
              Currently this does not fulfill the challenge criteria. Namely: It does not handle booleans case insensitively, it errors on floats, and it incorrectly returns true when given an expression consisting of bytes and integers
              $endgroup$
              – Skidsdev
              May 1 at 13:38
















            0












            $begingroup$


            Python 2, 102 bytes





            import re
            def f(s):
            m=map(eval,re.split('[*+-/]',s))
            return all(map(lambda t:type(t)==type(m[0]),m))


            Try it online!



            Not entirely sure how to represent some of these types in Python. For example, 0xff and 2 are both treated as integers. And 2.4f isn't a valid type in Python, I think. Capitalized True and False for testing Booleans.



            Edit: Grammar






            share|improve this answer









            $endgroup$








            • 3




              $begingroup$
              Will fail the last test case
              $endgroup$
              – Embodiment of Ignorance
              Apr 30 at 16:08










            • $begingroup$
              ...and (as it stands) the true * false one.
              $endgroup$
              – Jonathan Allan
              Apr 30 at 18:46










            • $begingroup$
              It passes for "True * False". I can try to make it work with lower case, but I figured since bools are always capitalized in python it would be sufficient.
              $endgroup$
              – GotCubes
              Apr 30 at 19:12






            • 2




              $begingroup$
              Currently this does not fulfill the challenge criteria. Namely: It does not handle booleans case insensitively, it errors on floats, and it incorrectly returns true when given an expression consisting of bytes and integers
              $endgroup$
              – Skidsdev
              May 1 at 13:38














            0












            0








            0





            $begingroup$


            Python 2, 102 bytes





            import re
            def f(s):
            m=map(eval,re.split('[*+-/]',s))
            return all(map(lambda t:type(t)==type(m[0]),m))


            Try it online!



            Not entirely sure how to represent some of these types in Python. For example, 0xff and 2 are both treated as integers. And 2.4f isn't a valid type in Python, I think. Capitalized True and False for testing Booleans.



            Edit: Grammar






            share|improve this answer









            $endgroup$




            Python 2, 102 bytes





            import re
            def f(s):
            m=map(eval,re.split('[*+-/]',s))
            return all(map(lambda t:type(t)==type(m[0]),m))


            Try it online!



            Not entirely sure how to represent some of these types in Python. For example, 0xff and 2 are both treated as integers. And 2.4f isn't a valid type in Python, I think. Capitalized True and False for testing Booleans.



            Edit: Grammar







            share|improve this answer












            share|improve this answer



            share|improve this answer










            answered Apr 30 at 16:06









            GotCubesGotCubes

            593




            593







            • 3




              $begingroup$
              Will fail the last test case
              $endgroup$
              – Embodiment of Ignorance
              Apr 30 at 16:08










            • $begingroup$
              ...and (as it stands) the true * false one.
              $endgroup$
              – Jonathan Allan
              Apr 30 at 18:46










            • $begingroup$
              It passes for "True * False". I can try to make it work with lower case, but I figured since bools are always capitalized in python it would be sufficient.
              $endgroup$
              – GotCubes
              Apr 30 at 19:12






            • 2




              $begingroup$
              Currently this does not fulfill the challenge criteria. Namely: It does not handle booleans case insensitively, it errors on floats, and it incorrectly returns true when given an expression consisting of bytes and integers
              $endgroup$
              – Skidsdev
              May 1 at 13:38













            • 3




              $begingroup$
              Will fail the last test case
              $endgroup$
              – Embodiment of Ignorance
              Apr 30 at 16:08










            • $begingroup$
              ...and (as it stands) the true * false one.
              $endgroup$
              – Jonathan Allan
              Apr 30 at 18:46










            • $begingroup$
              It passes for "True * False". I can try to make it work with lower case, but I figured since bools are always capitalized in python it would be sufficient.
              $endgroup$
              – GotCubes
              Apr 30 at 19:12






            • 2




              $begingroup$
              Currently this does not fulfill the challenge criteria. Namely: It does not handle booleans case insensitively, it errors on floats, and it incorrectly returns true when given an expression consisting of bytes and integers
              $endgroup$
              – Skidsdev
              May 1 at 13:38








            3




            3




            $begingroup$
            Will fail the last test case
            $endgroup$
            – Embodiment of Ignorance
            Apr 30 at 16:08




            $begingroup$
            Will fail the last test case
            $endgroup$
            – Embodiment of Ignorance
            Apr 30 at 16:08












            $begingroup$
            ...and (as it stands) the true * false one.
            $endgroup$
            – Jonathan Allan
            Apr 30 at 18:46




            $begingroup$
            ...and (as it stands) the true * false one.
            $endgroup$
            – Jonathan Allan
            Apr 30 at 18:46












            $begingroup$
            It passes for "True * False". I can try to make it work with lower case, but I figured since bools are always capitalized in python it would be sufficient.
            $endgroup$
            – GotCubes
            Apr 30 at 19:12




            $begingroup$
            It passes for "True * False". I can try to make it work with lower case, but I figured since bools are always capitalized in python it would be sufficient.
            $endgroup$
            – GotCubes
            Apr 30 at 19:12




            2




            2




            $begingroup$
            Currently this does not fulfill the challenge criteria. Namely: It does not handle booleans case insensitively, it errors on floats, and it incorrectly returns true when given an expression consisting of bytes and integers
            $endgroup$
            – Skidsdev
            May 1 at 13:38





            $begingroup$
            Currently this does not fulfill the challenge criteria. Namely: It does not handle booleans case insensitively, it errors on floats, and it incorrectly returns true when given an expression consisting of bytes and integers
            $endgroup$
            – Skidsdev
            May 1 at 13:38












            0












            $begingroup$


            Stax, 26 bytes



            ïd"┬Z¡►L!8$lm╗╕╤☻ú≡╝ò6Å>^


            Run and debug it



            This program expects spaces around the operators. In general, it works by applying a few transformations to the input such that the maximum character for each expression type is distinct.



            Unpacked, ungolfed, and commented, it looks like this.



            i suppress automatic evaluation of input
            '"/2::'s* replace quoted strings with 's'
            .d'9R replace all digits with '9'
            .ez|t replace 'e' with 'z'
            j2:: split on spaces, and discard alternating groups (operators)
            {|Mm calculate the maximum character in each remaining group
            :u resulting array contains exactly one distinct value


            Run this one






            share|improve this answer











            $endgroup$

















              0












              $begingroup$


              Stax, 26 bytes



              ïd"┬Z¡►L!8$lm╗╕╤☻ú≡╝ò6Å>^


              Run and debug it



              This program expects spaces around the operators. In general, it works by applying a few transformations to the input such that the maximum character for each expression type is distinct.



              Unpacked, ungolfed, and commented, it looks like this.



              i suppress automatic evaluation of input
              '"/2::'s* replace quoted strings with 's'
              .d'9R replace all digits with '9'
              .ez|t replace 'e' with 'z'
              j2:: split on spaces, and discard alternating groups (operators)
              {|Mm calculate the maximum character in each remaining group
              :u resulting array contains exactly one distinct value


              Run this one






              share|improve this answer











              $endgroup$















                0












                0








                0





                $begingroup$


                Stax, 26 bytes



                ïd"┬Z¡►L!8$lm╗╕╤☻ú≡╝ò6Å>^


                Run and debug it



                This program expects spaces around the operators. In general, it works by applying a few transformations to the input such that the maximum character for each expression type is distinct.



                Unpacked, ungolfed, and commented, it looks like this.



                i suppress automatic evaluation of input
                '"/2::'s* replace quoted strings with 's'
                .d'9R replace all digits with '9'
                .ez|t replace 'e' with 'z'
                j2:: split on spaces, and discard alternating groups (operators)
                {|Mm calculate the maximum character in each remaining group
                :u resulting array contains exactly one distinct value


                Run this one






                share|improve this answer











                $endgroup$




                Stax, 26 bytes



                ïd"┬Z¡►L!8$lm╗╕╤☻ú≡╝ò6Å>^


                Run and debug it



                This program expects spaces around the operators. In general, it works by applying a few transformations to the input such that the maximum character for each expression type is distinct.



                Unpacked, ungolfed, and commented, it looks like this.



                i suppress automatic evaluation of input
                '"/2::'s* replace quoted strings with 's'
                .d'9R replace all digits with '9'
                .ez|t replace 'e' with 'z'
                j2:: split on spaces, and discard alternating groups (operators)
                {|Mm calculate the maximum character in each remaining group
                :u resulting array contains exactly one distinct value


                Run this one







                share|improve this answer














                share|improve this answer



                share|improve this answer








                edited Apr 30 at 20:50

























                answered Apr 30 at 20:45









                recursiverecursive

                5,7741322




                5,7741322





















                    0












                    $begingroup$


                    Japt -!, 36 bytes



                    `".*?" 0x.. %S+f %d e|E`¸è@UÀ(U=rXÃÉ


                    Try it






                    share|improve this answer









                    $endgroup$












                    • $begingroup$
                      33 bytes?
                      $endgroup$
                      – Shaggy
                      May 1 at 22:31
















                    0












                    $begingroup$


                    Japt -!, 36 bytes



                    `".*?" 0x.. %S+f %d e|E`¸è@UÀ(U=rXÃÉ


                    Try it






                    share|improve this answer









                    $endgroup$












                    • $begingroup$
                      33 bytes?
                      $endgroup$
                      – Shaggy
                      May 1 at 22:31














                    0












                    0








                    0





                    $begingroup$


                    Japt -!, 36 bytes



                    `".*?" 0x.. %S+f %d e|E`¸è@UÀ(U=rXÃÉ


                    Try it






                    share|improve this answer









                    $endgroup$




                    Japt -!, 36 bytes



                    `".*?" 0x.. %S+f %d e|E`¸è@UÀ(U=rXÃÉ


                    Try it







                    share|improve this answer












                    share|improve this answer



                    share|improve this answer










                    answered May 1 at 5:18









                    Embodiment of IgnoranceEmbodiment of Ignorance

                    3,459128




                    3,459128











                    • $begingroup$
                      33 bytes?
                      $endgroup$
                      – Shaggy
                      May 1 at 22:31

















                    • $begingroup$
                      33 bytes?
                      $endgroup$
                      – Shaggy
                      May 1 at 22:31
















                    $begingroup$
                    33 bytes?
                    $endgroup$
                    – Shaggy
                    May 1 at 22:31





                    $begingroup$
                    33 bytes?
                    $endgroup$
                    – Shaggy
                    May 1 at 22:31


















                    draft saved

                    draft discarded
















































                    If this is an answer to a challenge…



                    • …Be sure to follow the challenge specification. However, please refrain from exploiting obvious loopholes. Answers abusing any of the standard loopholes are considered invalid. If you think a specification is unclear or underspecified, comment on the question instead.


                    • …Try to optimize your score. For instance, answers to code-golf challenges should attempt to be as short as possible. You can always include a readable version of the code in addition to the competitive one.
                      Explanations of your answer make it more interesting to read and are very much encouraged.


                    • …Include a short header which indicates the language(s) of your code and its score, as defined by the challenge.


                    More generally…



                    • …Please make sure to answer the question and provide sufficient detail.


                    • …Avoid asking for help, clarification or responding to other answers (use comments instead).




                    draft saved


                    draft discarded














                    StackExchange.ready(
                    function ()
                    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fcodegolf.stackexchange.com%2fquestions%2f184961%2ftype-check-an-expression%23new-answer', 'question_page');

                    );

                    Post as a guest















                    Required, but never shown





















































                    Required, but never shown














                    Required, but never shown












                    Required, but never shown







                    Required, but never shown

































                    Required, but never shown














                    Required, but never shown












                    Required, but never shown







                    Required, but never shown







                    Popular posts from this blog

                    Wikipedia:Vital articles Мазмуну Biography - Өмүр баян Philosophy and psychology - Философия жана психология Religion - Дин Social sciences - Коомдук илимдер Language and literature - Тил жана адабият Science - Илим Technology - Технология Arts and recreation - Искусство жана эс алуу History and geography - Тарых жана география Навигация менюсу

                    Bruxelas-Capital Índice Historia | Composición | Situación lingüística | Clima | Cidades irmandadas | Notas | Véxase tamén | Menú de navegacióneO uso das linguas en Bruxelas e a situación do neerlandés"Rexión de Bruxelas Capital"o orixinalSitio da rexiónPáxina de Bruselas no sitio da Oficina de Promoción Turística de Valonia e BruxelasMapa Interactivo da Rexión de Bruxelas-CapitaleeWorldCat332144929079854441105155190212ID28008674080552-90000 0001 0666 3698n94104302ID540940339365017018237

                    What should I write in an apology letter, since I have decided not to join a company after accepting an offer letterShould I keep looking after accepting a job offer?What should I do when I've been verbally told I would get an offer letter, but still haven't gotten one after 4 weeks?Do I accept an offer from a company that I am not likely to join?New job hasn't confirmed starting date and I want to give current employer as much notice as possibleHow should I address my manager in my resignation letter?HR delayed background verification, now jobless as resignedNo email communication after accepting a formal written offer. How should I phrase the call?What should I do if after receiving a verbal offer letter I am informed that my written job offer is put on hold due to some internal issues?Should I inform the current employer that I am about to resign within 1-2 weeks since I have signed the offer letter and waiting for visa?What company will do, if I send their offer letter to another company