Ad
  • Default User Avatar

    Short and sweet, but not best practices. I think this is a cute and clever solution for a simple string, but not efficient if the input was 100s or 1000s of characters long. I'd prefer a solution that returned false as soon as a lowercase character was found. In this case this solution is O(n) yet always the worst case, meaning that it always has to reach the last item (ALL characters must be uppercased) before it can determine the boolean value. This is more of a JS like solution than an Elixir solution. Elixir has better "tools" for working with strings.

  • Custom User Avatar
  • Custom User Avatar
                          x
                          x
                           x       xxxx          xx
                            xxxx xxxxxxxxxx     xx
                       xxxx  x             xxxxx
                    xxx             2       xxxx
                  xxx           x         x x   xxx
                 xx                     xx        xx
                xx                x   xx           xx
                x                  xxx               x
                x                  xx                 x
               x       1         xx   x                x
               x                x      x      3         x
               x               xx       xx              x
               x              x    5     xx              x
               x             x             xx            x
           xx xx xx x xx x  x xxxxxxxx xxxx xxxxxxx xxxx xx x xx xx xx x x x x x xxxx xxxxxx
               x           x                 xx          x
               x         x                    xx         x
                x   6                           x    4   x
                xx      x         7              x      xx
                 xx                               x     x
                  xx  x                            x   x
                    xxx                             x x
                   x  xxxx                         xxx
                          xxxxx                xxxx   x
                xx              x xxxxxxxxxxx x       x
                x                                      x
                                                        x
                                                        x
                                                         x
                                                         x