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

                    Club Baloncesto Breogán Índice Historia | Pavillón | Nome | O Breogán na cultura popular | Xogadores | Adestradores | Presidentes | Palmarés | Historial | Líderes | Notas | Véxase tamén | Menú de navegacióncbbreogan.galCadroGuía oficial da ACB 2009-10, páxina 201Guía oficial ACB 1992, páxina 183. Editorial DB.É de 6.500 espectadores sentados axeitándose á última normativa"Estudiantes Junior, entre as mellores canteiras"o orixinalHemeroteca El Mundo Deportivo, 16 setembro de 1970, páxina 12Historia do BreogánAlfredo Pérez, o último canoneiroHistoria C.B. BreogánHemeroteca de El Mundo DeportivoJimmy Wright, norteamericano do Breogán deixará Lugo por ameazas de morteResultados de Breogán en 1986-87Resultados de Breogán en 1990-91Ficha de Velimir Perasović en acb.comResultados de Breogán en 1994-95Breogán arrasa al Barça. "El Mundo Deportivo", 27 de setembro de 1999, páxina 58CB Breogán - FC BarcelonaA FEB invita a participar nunha nova Liga EuropeaCharlie Bell na prensa estatalMáximos anotadores 2005Tempada 2005-06 : Tódolos Xogadores da Xornada""Non quero pensar nunha man negra, mais pregúntome que está a pasar""o orixinalRaúl López, orgulloso dos xogadores, presume da boa saúde económica do BreogánJulio González confirma que cesa como presidente del BreogánHomenaxe a Lisardo GómezA tempada do rexurdimento celesteEntrevista a Lisardo GómezEl COB dinamita el Pazo para forzar el quinto (69-73)Cafés Candelas, patrocinador del CB Breogán"Suso Lázare, novo presidente do Breogán"o orixinalCafés Candelas Breogán firma el mayor triunfo de la historiaEl Breogán realizará 17 homenajes por su cincuenta aniversario"O Breogán honra ao seu fundador e primeiro presidente"o orixinalMiguel Giao recibiu a homenaxe do PazoHomenaxe aos primeiros gladiadores celestesO home que nos amosa como ver o Breo co corazónTita Franco será homenaxeada polos #50anosdeBreoJulio Vila recibirá unha homenaxe in memoriam polos #50anosdeBreo"O Breogán homenaxeará aos seus aboados máis veteráns"Pechada ovación a «Capi» Sanmartín e Ricardo «Corazón de González»Homenaxe por décadas de informaciónPaco García volve ao Pazo con motivo do 50 aniversario"Resultados y clasificaciones""O Cafés Candelas Breogán, campión da Copa Princesa""O Cafés Candelas Breogán, equipo ACB"C.B. Breogán"Proxecto social"o orixinal"Centros asociados"o orixinalFicha en imdb.comMario Camus trata la recuperación del amor en 'La vieja música', su última película"Páxina web oficial""Club Baloncesto Breogán""C. B. Breogán S.A.D."eehttp://www.fegaba.com

                    Vilaño, A Laracha Índice Patrimonio | Lugares e parroquias | Véxase tamén | Menú de navegación43°14′52″N 8°36′03″O / 43.24775, -8.60070

                    Cegueira Índice Epidemioloxía | Deficiencia visual | Tipos de cegueira | Principais causas de cegueira | Tratamento | Técnicas de adaptación e axudas | Vida dos cegos | Primeiros auxilios | Crenzas respecto das persoas cegas | Crenzas das persoas cegas | O neno deficiente visual | Aspectos psicolóxicos da cegueira | Notas | Véxase tamén | Menú de navegación54.054.154.436928256blindnessDicionario da Real Academia GalegaPortal das Palabras"International Standards: Visual Standards — Aspects and Ranges of Vision Loss with Emphasis on Population Surveys.""Visual impairment and blindness""Presentan un plan para previr a cegueira"o orixinalACCDV Associació Catalana de Cecs i Disminuïts Visuals - PMFTrachoma"Effect of gene therapy on visual function in Leber's congenital amaurosis"1844137110.1056/NEJMoa0802268Cans guía - os mellores amigos dos cegosArquivadoEscola de cans guía para cegos en Mortágua, PortugalArquivado"Tecnología para ciegos y deficientes visuales. Recopilación de recursos gratuitos en la Red""Colorino""‘COL.diesis’, escuchar los sonidos del color""COL.diesis: Transforming Colour into Melody and Implementing the Result in a Colour Sensor Device"o orixinal"Sistema de desarrollo de sinestesia color-sonido para invidentes utilizando un protocolo de audio""Enseñanza táctil - geometría y color. Juegos didácticos para niños ciegos y videntes""Sistema Constanz"L'ocupació laboral dels cecs a l'Estat espanyol està pràcticament equiparada a la de les persones amb visió, entrevista amb Pedro ZuritaONCE (Organización Nacional de Cegos de España)Prevención da cegueiraDescrición de deficiencias visuais (Disc@pnet)Braillín, un boneco atractivo para calquera neno, con ou sen discapacidade, que permite familiarizarse co sistema de escritura e lectura brailleAxudas Técnicas36838ID00897494007150-90057129528256DOID:1432HP:0000618D001766C10.597.751.941.162C97109C0155020