kandi background
Explore Kits

pattern | Machine | Machine Learning library

 by   Cascading Java Version: Current License: Non-SPDX

 by   Cascading Java Version: Current License: Non-SPDX

Download this library from

kandi X-RAY | pattern Summary

pattern is a Java library typically used in Artificial Intelligence, Machine Learning applications. pattern has no vulnerabilities, it has build file available and it has low support. However pattern has 1 bugs and it has a Non-SPDX License. You can download it from GitHub.
Pattern is a Cascading framework and library for machine learning model scoring at scale. Pattern can read PMML models as workflow specifications for generating Cascading flows which can run on Apache Hadoop. Pattern is still under active development under the wip-1.0 branch. Thus all wip releases are made available from the files.concurrentinc.com domain. When Pattern hits 1.0 and beyond, final releases will be under files.cascading.org. See the pattern-examples subdirectory for sample apps. For more information, visit: http://www.cascading.org/pattern/.
Support
Support
Quality
Quality
Security
Security
License
License
Reuse
Reuse

kandi-support Support

  • pattern has a low active ecosystem.
  • It has 82 star(s) with 25 fork(s). There are 22 watchers for this library.
  • It had no major release in the last 12 months.
  • There are 3 open issues and 2 have been closed. On average issues are closed in 1 days. There are no pull requests.
  • It has a neutral sentiment in the developer community.
  • The latest version of pattern is current.
pattern Support
Best in #Machine Learning
Average in #Machine Learning
pattern Support
Best in #Machine Learning
Average in #Machine Learning

quality kandi Quality

  • pattern has 1 bugs (0 blocker, 1 critical, 0 major, 0 minor) and 220 code smells.
pattern Quality
Best in #Machine Learning
Average in #Machine Learning
pattern Quality
Best in #Machine Learning
Average in #Machine Learning

securitySecurity

  • pattern has no vulnerabilities reported, and its dependent libraries have no vulnerabilities reported.
  • pattern code analysis shows 0 unresolved vulnerabilities.
  • There are 2 security hotspots that need review.
pattern Security
Best in #Machine Learning
Average in #Machine Learning
pattern Security
Best in #Machine Learning
Average in #Machine Learning

license License

  • pattern has a Non-SPDX License.
  • Non-SPDX licenses can be open source with a non SPDX compliant license, or non open source licenses, and you need to review them closely before use.
pattern License
Best in #Machine Learning
Average in #Machine Learning
pattern License
Best in #Machine Learning
Average in #Machine Learning

buildReuse

  • pattern releases are not available. You will need to build from source code and install.
  • Build file is available. You can build the component from source.
  • Installation instructions are not available. Examples and code snippets are available.
  • It has 8190 lines of code, 439 functions and 110 files.
  • It has medium code complexity. Code complexity directly impacts maintainability of the code.
pattern Reuse
Best in #Machine Learning
Average in #Machine Learning
pattern Reuse
Best in #Machine Learning
Average in #Machine Learning
Top functions reviewed by kandi - BETA

kandi has reviewed pattern and discovered the below as its top functions. This is intended to give you an instant insight into pattern implemented functionality, and help decide if they suit your requirements.

  • Returns a SimplePredicate for the given Predicate
    • Tokenize a String
      • Gets all fields with a specific usage type .
        • Starts the flow connector .
          • Creates the regression table .
            • Creates an assembly for the assembly .
              • Converts a regression table into a Regression table .
                • Gets declared fields .
                  • Parse an array type .
                    • Returns an array of ExpressionEvaluators for the regression table .

                      Get all kandi verified functions for this library.

                      Get all kandi verified functions for this library.

                      pattern Key Features

                      Machine Learning for Cascading

                      pattern Examples and Code Snippets

                      See all related Code Snippets

                      Using

                      copy iconCopydownload iconDownload
                      <dependency>
                        <groupId>cascading</groupId>
                        <artifactId>pattern-core</artifactId>
                        <version>x.y.z</version>
                      </dependency>
                      

                      Developing

                      copy iconCopydownload iconDownload
                      > gradle idea
                      

                      Repeatedly removing the maximum average subarray

                      copy iconCopydownload iconDownload
                      # Lengths of the segments in the upper convex hull
                      # of the cumulative sum graph
                      def upperSumHullLengths(arr):
                          if len(arr) < 2:
                              if len(arr) < 1:
                                  return []
                              else:
                                  return [1]
                          
                          hull = [(0, 0),(1, arr[0])]
                          for x in range(2, len(arr)+1):
                              # this has x coordinate x-1
                              prevPoint = hull[len(hull) - 1]
                              # next point in cumulative sum
                              point = (x, prevPoint[1] + arr[x-1])
                              # remove points not on the convex hull
                              while len(hull) >= 2:
                                  p0 = hull[len(hull)-2]
                                  dx0 = prevPoint[0] - p0[0]
                                  dy0 = prevPoint[1] - p0[1]
                                  dx1 = x - prevPoint[0]
                                  dy1 = point[1] - prevPoint[1]
                                  if dy1*dx0 < dy0*dx1:
                                      break
                                  hull.pop()
                                  prevPoint = p0
                              hull.append(point)
                          
                          return [hull[i+1][0] - hull[i][0] for i in range(0, len(hull)-1)]
                      
                      
                      print(upperSumHullLengths([  1,   7,   8,   4,   2,   1,   4]))
                      
                      [3, 1, 3]
                      
                      # Lengths of the segments in the upper convex hull
                      # of the cumulative sum graph
                      def upperSumHullLengths(arr):
                          if len(arr) < 2:
                              if len(arr) < 1:
                                  return []
                              else:
                                  return [1]
                          
                          hull = [(0, 0),(1, arr[0])]
                          for x in range(2, len(arr)+1):
                              # this has x coordinate x-1
                              prevPoint = hull[len(hull) - 1]
                              # next point in cumulative sum
                              point = (x, prevPoint[1] + arr[x-1])
                              # remove points not on the convex hull
                              while len(hull) >= 2:
                                  p0 = hull[len(hull)-2]
                                  dx0 = prevPoint[0] - p0[0]
                                  dy0 = prevPoint[1] - p0[1]
                                  dx1 = x - prevPoint[0]
                                  dy1 = point[1] - prevPoint[1]
                                  if dy1*dx0 < dy0*dx1:
                                      break
                                  hull.pop()
                                  prevPoint = p0
                              hull.append(point)
                          
                          return [hull[i+1][0] - hull[i][0] for i in range(0, len(hull)-1)]
                      
                      
                      print(upperSumHullLengths([  1,   7,   8,   4,   2,   1,   4]))
                      
                      [3, 1, 3]
                      
                      from itertools import accumulate, pairwise
                      
                      def Matt_Pychoed(arr):
                          hull = [(0, 0)]
                          for x, y in enumerate(accumulate(arr), 1):
                              while len(hull) >= 2:
                                  (x0, y0), (x1, y1) = hull[-2:]
                                  dx0 = x1 - x0
                                  dy0 = y1 - y0
                                  dx1 = x - x1
                                  dy1 = y - y1
                                  if dy1*dx0 < dy0*dx1:
                                      break
                                  hull.pop()
                              hull.append((x, y))
                          return [q[0] - p[0] for p, q in pairwise(hull)]
                      
                      from itertools import accumulate, count
                      from operator import truediv
                      
                      def kc_Pychoed_2(nums):
                          removals = []
                          while nums:
                              averages = map(truediv, accumulate(nums), count(1))
                              remove = max(zip(averages, count(1)))[1]
                              removals.append(remove)
                              nums = nums[remove:]
                          return removals
                      
                        min   median   mean     max  
                       65 ms  164 ms  159 ms  249 ms  kc
                       38 ms   98 ms   92 ms  146 ms  kc_Pychoed_1
                       58 ms  127 ms  120 ms  189 ms  kc_Pychoed_2
                      134 ms  137 ms  138 ms  157 ms  Matt
                      101 ms  102 ms  103 ms  111 ms  Matt_Pychoed
                      
                        min   median   mean     max  
                      102 ms  106 ms  107 ms  116 ms  kc
                       60 ms   61 ms   61 ms   62 ms  kc_Pychoed_1
                       76 ms   77 ms   77 ms   86 ms  kc_Pychoed_2
                        0 ms    1 ms    1 ms    1 ms  Matt
                        0 ms    0 ms    0 ms    0 ms  Matt_Pychoed
                      
                      from timeit import default_timer as timer
                      from statistics import mean, median
                      import random
                      from typing import List, Tuple
                      import math
                      from itertools import accumulate, count
                      from operator import truediv
                      
                      def kc(nums: List[int]) -> List[int]:
                          """Return list of lengths of max average prefix reductions."""
                      
                          def max_prefix_avg(arr: List[int]) -> Tuple[float, int]:
                              """Return value and length of max average prefix in arr"""
                              if len(arr) == 0:
                                  return (-math.inf, 0)
                              
                              best_length = 1
                              best_average = -math.inf
                              running_sum = 0.0
                      
                              for i, x in enumerate(arr, 1):
                                  running_sum += x
                                  new_average = running_sum / i
                                  
                                  if (new_average >= best_average
                                      or math.isclose(new_average, best_average)):
                                      
                                      best_average = new_average
                                      best_length = i
                      
                              return (best_average, best_length)
                      
                          removed_lengths = []
                          total_removed = 0
                      
                          while total_removed < len(nums):
                              _, new_removal = max_prefix_avg(nums[total_removed:])
                              removed_lengths.append(new_removal)
                              total_removed += new_removal
                      
                          return removed_lengths
                      
                      def kc_Pychoed_1(nums: List[int]) -> List[int]:
                          """Return list of lengths of max average prefix reductions."""
                      
                          def max_prefix_avg(arr: List[int]) -> Tuple[float, int]:
                              """Return value and length of max average prefix in arr"""
                              if len(arr) == 0:
                                  return (-math.inf, 0)
                              
                              best_length = 1
                              best_average = -math.inf
                              running_sum = 0
                      
                              for i, x in enumerate(arr, 1):
                                  running_sum += x
                                  new_average = running_sum / i
                                  
                                  if new_average >= best_average:
                                      
                                      best_average = new_average
                                      best_length = i
                      
                              return (best_average, best_length)
                      
                          removed_lengths = []
                          total_removed = 0
                      
                          while total_removed < len(nums):
                              _, new_removal = max_prefix_avg(nums[total_removed:])
                              removed_lengths.append(new_removal)
                              total_removed += new_removal
                      
                          return removed_lengths
                      
                      def kc_Pychoed_2(nums):
                          removals = []
                          while nums:
                              averages = map(truediv, accumulate(nums), count(1))
                              remove = max(zip(averages, count(1)))[1]
                              removals.append(remove)
                              nums = nums[remove:]
                          return removals
                      
                      # Lengths of the segments in the upper convex hull
                      # of the cumulative sum graph
                      def Matt(arr):
                          if len(arr) < 2:
                              if len(arr) < 1:
                                  return []
                              else:
                                  return [1]
                          
                          hull = [(0, 0),(1, arr[0])]
                          for x in range(2, len(arr)+1):
                              # this has x coordinate x-1
                              prevPoint = hull[len(hull) - 1]
                              # next point in cumulative sum
                              point = (x, prevPoint[1] + arr[x-1])
                              # remove points not on the convex hull
                              while len(hull) >= 2:
                                  p0 = hull[len(hull)-2]
                                  dx0 = prevPoint[0] - p0[0]
                                  dy0 = prevPoint[1] - p0[1]
                                  dx1 = x - prevPoint[0]
                                  dy1 = point[1] - prevPoint[1]
                                  if dy1*dx0 < dy0*dx1:
                                      break
                                  hull.pop()
                                  prevPoint = p0
                              hull.append(point)
                          
                          return [hull[i+1][0] - hull[i][0] for i in range(0, len(hull)-1)]
                      
                      def pairwise(lst):
                          return zip(lst, lst[1:])
                      
                      def Matt_Pychoed(arr):
                          hull = [(0, 0)]
                          for x, y in enumerate(accumulate(arr), 1):
                              while len(hull) >= 2:
                                  (x0, y0), (x1, y1) = hull[-2:]
                                  dx0 = x1 - x0
                                  dy0 = y1 - y0
                                  dx1 = x - x1
                                  dy1 = y - y1
                                  if dy1*dx0 < dy0*dx1:
                                      break
                                  hull.pop()
                              hull.append((x, y))
                          return [q[0] - p[0] for p, q in pairwise(hull)]
                      
                      funcs = kc, kc_Pychoed_1, kc_Pychoed_2, Matt, Matt_Pychoed
                      stats = min, median, mean, max
                      tss = [[] for _ in funcs]
                      for r in range(1, 21):
                          print(f'After round {r}:')
                          arr = random.choices(range(1, 1001), k=100_000)
                          # arr = list(range(1000, 1, -1))
                          expect = None
                          print(*(f'{stat.__name__:^7}' for stat in stats))
                          for func, ts in zip(funcs, tss):
                              t0 = timer()
                              result = func(arr)
                              t1 = timer()
                              ts.append(t1 - t0)
                              if expect is None:
                                  expect = result
                              assert result == expect
                              print(*('%3d ms ' % (stat(ts) * 1e3) for stat in stats), func.__name__)
                          print()
                      
                      from itertools import accumulate, pairwise
                      
                      def Matt_Pychoed(arr):
                          hull = [(0, 0)]
                          for x, y in enumerate(accumulate(arr), 1):
                              while len(hull) >= 2:
                                  (x0, y0), (x1, y1) = hull[-2:]
                                  dx0 = x1 - x0
                                  dy0 = y1 - y0
                                  dx1 = x - x1
                                  dy1 = y - y1
                                  if dy1*dx0 < dy0*dx1:
                                      break
                                  hull.pop()
                              hull.append((x, y))
                          return [q[0] - p[0] for p, q in pairwise(hull)]
                      
                      from itertools import accumulate, count
                      from operator import truediv
                      
                      def kc_Pychoed_2(nums):
                          removals = []
                          while nums:
                              averages = map(truediv, accumulate(nums), count(1))
                              remove = max(zip(averages, count(1)))[1]
                              removals.append(remove)
                              nums = nums[remove:]
                          return removals
                      
                        min   median   mean     max  
                       65 ms  164 ms  159 ms  249 ms  kc
                       38 ms   98 ms   92 ms  146 ms  kc_Pychoed_1
                       58 ms  127 ms  120 ms  189 ms  kc_Pychoed_2
                      134 ms  137 ms  138 ms  157 ms  Matt
                      101 ms  102 ms  103 ms  111 ms  Matt_Pychoed
                      
                        min   median   mean     max  
                      102 ms  106 ms  107 ms  116 ms  kc
                       60 ms   61 ms   61 ms   62 ms  kc_Pychoed_1
                       76 ms   77 ms   77 ms   86 ms  kc_Pychoed_2
                        0 ms    1 ms    1 ms    1 ms  Matt
                        0 ms    0 ms    0 ms    0 ms  Matt_Pychoed
                      
                      from timeit import default_timer as timer
                      from statistics import mean, median
                      import random
                      from typing import List, Tuple
                      import math
                      from itertools import accumulate, count
                      from operator import truediv
                      
                      def kc(nums: List[int]) -> List[int]:
                          """Return list of lengths of max average prefix reductions."""
                      
                          def max_prefix_avg(arr: List[int]) -> Tuple[float, int]:
                              """Return value and length of max average prefix in arr"""
                              if len(arr) == 0:
                                  return (-math.inf, 0)
                              
                              best_length = 1
                              best_average = -math.inf
                              running_sum = 0.0
                      
                              for i, x in enumerate(arr, 1):
                                  running_sum += x
                                  new_average = running_sum / i
                                  
                                  if (new_average >= best_average
                                      or math.isclose(new_average, best_average)):
                                      
                                      best_average = new_average
                                      best_length = i
                      
                              return (best_average, best_length)
                      
                          removed_lengths = []
                          total_removed = 0
                      
                          while total_removed < len(nums):
                              _, new_removal = max_prefix_avg(nums[total_removed:])
                              removed_lengths.append(new_removal)
                              total_removed += new_removal
                      
                          return removed_lengths
                      
                      def kc_Pychoed_1(nums: List[int]) -> List[int]:
                          """Return list of lengths of max average prefix reductions."""
                      
                          def max_prefix_avg(arr: List[int]) -> Tuple[float, int]:
                              """Return value and length of max average prefix in arr"""
                              if len(arr) == 0:
                                  return (-math.inf, 0)
                              
                              best_length = 1
                              best_average = -math.inf
                              running_sum = 0
                      
                              for i, x in enumerate(arr, 1):
                                  running_sum += x
                                  new_average = running_sum / i
                                  
                                  if new_average >= best_average:
                                      
                                      best_average = new_average
                                      best_length = i
                      
                              return (best_average, best_length)
                      
                          removed_lengths = []
                          total_removed = 0
                      
                          while total_removed < len(nums):
                              _, new_removal = max_prefix_avg(nums[total_removed:])
                              removed_lengths.append(new_removal)
                              total_removed += new_removal
                      
                          return removed_lengths
                      
                      def kc_Pychoed_2(nums):
                          removals = []
                          while nums:
                              averages = map(truediv, accumulate(nums), count(1))
                              remove = max(zip(averages, count(1)))[1]
                              removals.append(remove)
                              nums = nums[remove:]
                          return removals
                      
                      # Lengths of the segments in the upper convex hull
                      # of the cumulative sum graph
                      def Matt(arr):
                          if len(arr) < 2:
                              if len(arr) < 1:
                                  return []
                              else:
                                  return [1]
                          
                          hull = [(0, 0),(1, arr[0])]
                          for x in range(2, len(arr)+1):
                              # this has x coordinate x-1
                              prevPoint = hull[len(hull) - 1]
                              # next point in cumulative sum
                              point = (x, prevPoint[1] + arr[x-1])
                              # remove points not on the convex hull
                              while len(hull) >= 2:
                                  p0 = hull[len(hull)-2]
                                  dx0 = prevPoint[0] - p0[0]
                                  dy0 = prevPoint[1] - p0[1]
                                  dx1 = x - prevPoint[0]
                                  dy1 = point[1] - prevPoint[1]
                                  if dy1*dx0 < dy0*dx1:
                                      break
                                  hull.pop()
                                  prevPoint = p0
                              hull.append(point)
                          
                          return [hull[i+1][0] - hull[i][0] for i in range(0, len(hull)-1)]
                      
                      def pairwise(lst):
                          return zip(lst, lst[1:])
                      
                      def Matt_Pychoed(arr):
                          hull = [(0, 0)]
                          for x, y in enumerate(accumulate(arr), 1):
                              while len(hull) >= 2:
                                  (x0, y0), (x1, y1) = hull[-2:]
                                  dx0 = x1 - x0
                                  dy0 = y1 - y0
                                  dx1 = x - x1
                                  dy1 = y - y1
                                  if dy1*dx0 < dy0*dx1:
                                      break
                                  hull.pop()
                              hull.append((x, y))
                          return [q[0] - p[0] for p, q in pairwise(hull)]
                      
                      funcs = kc, kc_Pychoed_1, kc_Pychoed_2, Matt, Matt_Pychoed
                      stats = min, median, mean, max
                      tss = [[] for _ in funcs]
                      for r in range(1, 21):
                          print(f'After round {r}:')
                          arr = random.choices(range(1, 1001), k=100_000)
                          # arr = list(range(1000, 1, -1))
                          expect = None
                          print(*(f'{stat.__name__:^7}' for stat in stats))
                          for func, ts in zip(funcs, tss):
                              t0 = timer()
                              result = func(arr)
                              t1 = timer()
                              ts.append(t1 - t0)
                              if expect is None:
                                  expect = result
                              assert result == expect
                              print(*('%3d ms ' % (stat(ts) * 1e3) for stat in stats), func.__name__)
                          print()
                      
                      from itertools import accumulate, pairwise
                      
                      def Matt_Pychoed(arr):
                          hull = [(0, 0)]
                          for x, y in enumerate(accumulate(arr), 1):
                              while len(hull) >= 2:
                                  (x0, y0), (x1, y1) = hull[-2:]
                                  dx0 = x1 - x0
                                  dy0 = y1 - y0
                                  dx1 = x - x1
                                  dy1 = y - y1
                                  if dy1*dx0 < dy0*dx1:
                                      break
                                  hull.pop()
                              hull.append((x, y))
                          return [q[0] - p[0] for p, q in pairwise(hull)]
                      
                      from itertools import accumulate, count
                      from operator import truediv
                      
                      def kc_Pychoed_2(nums):
                          removals = []
                          while nums:
                              averages = map(truediv, accumulate(nums), count(1))
                              remove = max(zip(averages, count(1)))[1]
                              removals.append(remove)
                              nums = nums[remove:]
                          return removals
                      
                        min   median   mean     max  
                       65 ms  164 ms  159 ms  249 ms  kc
                       38 ms   98 ms   92 ms  146 ms  kc_Pychoed_1
                       58 ms  127 ms  120 ms  189 ms  kc_Pychoed_2
                      134 ms  137 ms  138 ms  157 ms  Matt
                      101 ms  102 ms  103 ms  111 ms  Matt_Pychoed
                      
                        min   median   mean     max  
                      102 ms  106 ms  107 ms  116 ms  kc
                       60 ms   61 ms   61 ms   62 ms  kc_Pychoed_1
                       76 ms   77 ms   77 ms   86 ms  kc_Pychoed_2
                        0 ms    1 ms    1 ms    1 ms  Matt
                        0 ms    0 ms    0 ms    0 ms  Matt_Pychoed
                      
                      from timeit import default_timer as timer
                      from statistics import mean, median
                      import random
                      from typing import List, Tuple
                      import math
                      from itertools import accumulate, count
                      from operator import truediv
                      
                      def kc(nums: List[int]) -> List[int]:
                          """Return list of lengths of max average prefix reductions."""
                      
                          def max_prefix_avg(arr: List[int]) -> Tuple[float, int]:
                              """Return value and length of max average prefix in arr"""
                              if len(arr) == 0:
                                  return (-math.inf, 0)
                              
                              best_length = 1
                              best_average = -math.inf
                              running_sum = 0.0
                      
                              for i, x in enumerate(arr, 1):
                                  running_sum += x
                                  new_average = running_sum / i
                                  
                                  if (new_average >= best_average
                                      or math.isclose(new_average, best_average)):
                                      
                                      best_average = new_average
                                      best_length = i
                      
                              return (best_average, best_length)
                      
                          removed_lengths = []
                          total_removed = 0
                      
                          while total_removed < len(nums):
                              _, new_removal = max_prefix_avg(nums[total_removed:])
                              removed_lengths.append(new_removal)
                              total_removed += new_removal
                      
                          return removed_lengths
                      
                      def kc_Pychoed_1(nums: List[int]) -> List[int]:
                          """Return list of lengths of max average prefix reductions."""
                      
                          def max_prefix_avg(arr: List[int]) -> Tuple[float, int]:
                              """Return value and length of max average prefix in arr"""
                              if len(arr) == 0:
                                  return (-math.inf, 0)
                              
                              best_length = 1
                              best_average = -math.inf
                              running_sum = 0
                      
                              for i, x in enumerate(arr, 1):
                                  running_sum += x
                                  new_average = running_sum / i
                                  
                                  if new_average >= best_average:
                                      
                                      best_average = new_average
                                      best_length = i
                      
                              return (best_average, best_length)
                      
                          removed_lengths = []
                          total_removed = 0
                      
                          while total_removed < len(nums):
                              _, new_removal = max_prefix_avg(nums[total_removed:])
                              removed_lengths.append(new_removal)
                              total_removed += new_removal
                      
                          return removed_lengths
                      
                      def kc_Pychoed_2(nums):
                          removals = []
                          while nums:
                              averages = map(truediv, accumulate(nums), count(1))
                              remove = max(zip(averages, count(1)))[1]
                              removals.append(remove)
                              nums = nums[remove:]
                          return removals
                      
                      # Lengths of the segments in the upper convex hull
                      # of the cumulative sum graph
                      def Matt(arr):
                          if len(arr) < 2:
                              if len(arr) < 1:
                                  return []
                              else:
                                  return [1]
                          
                          hull = [(0, 0),(1, arr[0])]
                          for x in range(2, len(arr)+1):
                              # this has x coordinate x-1
                              prevPoint = hull[len(hull) - 1]
                              # next point in cumulative sum
                              point = (x, prevPoint[1] + arr[x-1])
                              # remove points not on the convex hull
                              while len(hull) >= 2:
                                  p0 = hull[len(hull)-2]
                                  dx0 = prevPoint[0] - p0[0]
                                  dy0 = prevPoint[1] - p0[1]
                                  dx1 = x - prevPoint[0]
                                  dy1 = point[1] - prevPoint[1]
                                  if dy1*dx0 < dy0*dx1:
                                      break
                                  hull.pop()
                                  prevPoint = p0
                              hull.append(point)
                          
                          return [hull[i+1][0] - hull[i][0] for i in range(0, len(hull)-1)]
                      
                      def pairwise(lst):
                          return zip(lst, lst[1:])
                      
                      def Matt_Pychoed(arr):
                          hull = [(0, 0)]
                          for x, y in enumerate(accumulate(arr), 1):
                              while len(hull) >= 2:
                                  (x0, y0), (x1, y1) = hull[-2:]
                                  dx0 = x1 - x0
                                  dy0 = y1 - y0
                                  dx1 = x - x1
                                  dy1 = y - y1
                                  if dy1*dx0 < dy0*dx1:
                                      break
                                  hull.pop()
                              hull.append((x, y))
                          return [q[0] - p[0] for p, q in pairwise(hull)]
                      
                      funcs = kc, kc_Pychoed_1, kc_Pychoed_2, Matt, Matt_Pychoed
                      stats = min, median, mean, max
                      tss = [[] for _ in funcs]
                      for r in range(1, 21):
                          print(f'After round {r}:')
                          arr = random.choices(range(1, 1001), k=100_000)
                          # arr = list(range(1000, 1, -1))
                          expect = None
                          print(*(f'{stat.__name__:^7}' for stat in stats))
                          for func, ts in zip(funcs, tss):
                              t0 = timer()
                              result = func(arr)
                              t1 = timer()
                              ts.append(t1 - t0)
                              if expect is None:
                                  expect = result
                              assert result == expect
                              print(*('%3d ms ' % (stat(ts) * 1e3) for stat in stats), func.__name__)
                          print()
                      
                      from itertools import accumulate, pairwise
                      
                      def Matt_Pychoed(arr):
                          hull = [(0, 0)]
                          for x, y in enumerate(accumulate(arr), 1):
                              while len(hull) >= 2:
                                  (x0, y0), (x1, y1) = hull[-2:]
                                  dx0 = x1 - x0
                                  dy0 = y1 - y0
                                  dx1 = x - x1
                                  dy1 = y - y1
                                  if dy1*dx0 < dy0*dx1:
                                      break
                                  hull.pop()
                              hull.append((x, y))
                          return [q[0] - p[0] for p, q in pairwise(hull)]
                      
                      from itertools import accumulate, count
                      from operator import truediv
                      
                      def kc_Pychoed_2(nums):
                          removals = []
                          while nums:
                              averages = map(truediv, accumulate(nums), count(1))
                              remove = max(zip(averages, count(1)))[1]
                              removals.append(remove)
                              nums = nums[remove:]
                          return removals
                      
                        min   median   mean     max  
                       65 ms  164 ms  159 ms  249 ms  kc
                       38 ms   98 ms   92 ms  146 ms  kc_Pychoed_1
                       58 ms  127 ms  120 ms  189 ms  kc_Pychoed_2
                      134 ms  137 ms  138 ms  157 ms  Matt
                      101 ms  102 ms  103 ms  111 ms  Matt_Pychoed
                      
                        min   median   mean     max  
                      102 ms  106 ms  107 ms  116 ms  kc
                       60 ms   61 ms   61 ms   62 ms  kc_Pychoed_1
                       76 ms   77 ms   77 ms   86 ms  kc_Pychoed_2
                        0 ms    1 ms    1 ms    1 ms  Matt
                        0 ms    0 ms    0 ms    0 ms  Matt_Pychoed
                      
                      from timeit import default_timer as timer
                      from statistics import mean, median
                      import random
                      from typing import List, Tuple
                      import math
                      from itertools import accumulate, count
                      from operator import truediv
                      
                      def kc(nums: List[int]) -> List[int]:
                          """Return list of lengths of max average prefix reductions."""
                      
                          def max_prefix_avg(arr: List[int]) -> Tuple[float, int]:
                              """Return value and length of max average prefix in arr"""
                              if len(arr) == 0:
                                  return (-math.inf, 0)
                              
                              best_length = 1
                              best_average = -math.inf
                              running_sum = 0.0
                      
                              for i, x in enumerate(arr, 1):
                                  running_sum += x
                                  new_average = running_sum / i
                                  
                                  if (new_average >= best_average
                                      or math.isclose(new_average, best_average)):
                                      
                                      best_average = new_average
                                      best_length = i
                      
                              return (best_average, best_length)
                      
                          removed_lengths = []
                          total_removed = 0
                      
                          while total_removed < len(nums):
                              _, new_removal = max_prefix_avg(nums[total_removed:])
                              removed_lengths.append(new_removal)
                              total_removed += new_removal
                      
                          return removed_lengths
                      
                      def kc_Pychoed_1(nums: List[int]) -> List[int]:
                          """Return list of lengths of max average prefix reductions."""
                      
                          def max_prefix_avg(arr: List[int]) -> Tuple[float, int]:
                              """Return value and length of max average prefix in arr"""
                              if len(arr) == 0:
                                  return (-math.inf, 0)
                              
                              best_length = 1
                              best_average = -math.inf
                              running_sum = 0
                      
                              for i, x in enumerate(arr, 1):
                                  running_sum += x
                                  new_average = running_sum / i
                                  
                                  if new_average >= best_average:
                                      
                                      best_average = new_average
                                      best_length = i
                      
                              return (best_average, best_length)
                      
                          removed_lengths = []
                          total_removed = 0
                      
                          while total_removed < len(nums):
                              _, new_removal = max_prefix_avg(nums[total_removed:])
                              removed_lengths.append(new_removal)
                              total_removed += new_removal
                      
                          return removed_lengths
                      
                      def kc_Pychoed_2(nums):
                          removals = []
                          while nums:
                              averages = map(truediv, accumulate(nums), count(1))
                              remove = max(zip(averages, count(1)))[1]
                              removals.append(remove)
                              nums = nums[remove:]
                          return removals
                      
                      # Lengths of the segments in the upper convex hull
                      # of the cumulative sum graph
                      def Matt(arr):
                          if len(arr) < 2:
                              if len(arr) < 1:
                                  return []
                              else:
                                  return [1]
                          
                          hull = [(0, 0),(1, arr[0])]
                          for x in range(2, len(arr)+1):
                              # this has x coordinate x-1
                              prevPoint = hull[len(hull) - 1]
                              # next point in cumulative sum
                              point = (x, prevPoint[1] + arr[x-1])
                              # remove points not on the convex hull
                              while len(hull) >= 2:
                                  p0 = hull[len(hull)-2]
                                  dx0 = prevPoint[0] - p0[0]
                                  dy0 = prevPoint[1] - p0[1]
                                  dx1 = x - prevPoint[0]
                                  dy1 = point[1] - prevPoint[1]
                                  if dy1*dx0 < dy0*dx1:
                                      break
                                  hull.pop()
                                  prevPoint = p0
                              hull.append(point)
                          
                          return [hull[i+1][0] - hull[i][0] for i in range(0, len(hull)-1)]
                      
                      def pairwise(lst):
                          return zip(lst, lst[1:])
                      
                      def Matt_Pychoed(arr):
                          hull = [(0, 0)]
                          for x, y in enumerate(accumulate(arr), 1):
                              while len(hull) >= 2:
                                  (x0, y0), (x1, y1) = hull[-2:]
                                  dx0 = x1 - x0
                                  dy0 = y1 - y0
                                  dx1 = x - x1
                                  dy1 = y - y1
                                  if dy1*dx0 < dy0*dx1:
                                      break
                                  hull.pop()
                              hull.append((x, y))
                          return [q[0] - p[0] for p, q in pairwise(hull)]
                      
                      funcs = kc, kc_Pychoed_1, kc_Pychoed_2, Matt, Matt_Pychoed
                      stats = min, median, mean, max
                      tss = [[] for _ in funcs]
                      for r in range(1, 21):
                          print(f'After round {r}:')
                          arr = random.choices(range(1, 1001), k=100_000)
                          # arr = list(range(1000, 1, -1))
                          expect = None
                          print(*(f'{stat.__name__:^7}' for stat in stats))
                          for func, ts in zip(funcs, tss):
                              t0 = timer()
                              result = func(arr)
                              t1 = timer()
                              ts.append(t1 - t0)
                              if expect is None:
                                  expect = result
                              assert result == expect
                              print(*('%3d ms ' % (stat(ts) * 1e3) for stat in stats), func.__name__)
                          print()
                      
                      from itertools import accumulate, pairwise
                      
                      def Matt_Pychoed(arr):
                          hull = [(0, 0)]
                          for x, y in enumerate(accumulate(arr), 1):
                              while len(hull) >= 2:
                                  (x0, y0), (x1, y1) = hull[-2:]
                                  dx0 = x1 - x0
                                  dy0 = y1 - y0
                                  dx1 = x - x1
                                  dy1 = y - y1
                                  if dy1*dx0 < dy0*dx1:
                                      break
                                  hull.pop()
                              hull.append((x, y))
                          return [q[0] - p[0] for p, q in pairwise(hull)]
                      
                      from itertools import accumulate, count
                      from operator import truediv
                      
                      def kc_Pychoed_2(nums):
                          removals = []
                          while nums:
                              averages = map(truediv, accumulate(nums), count(1))
                              remove = max(zip(averages, count(1)))[1]
                              removals.append(remove)
                              nums = nums[remove:]
                          return removals
                      
                        min   median   mean     max  
                       65 ms  164 ms  159 ms  249 ms  kc
                       38 ms   98 ms   92 ms  146 ms  kc_Pychoed_1
                       58 ms  127 ms  120 ms  189 ms  kc_Pychoed_2
                      134 ms  137 ms  138 ms  157 ms  Matt
                      101 ms  102 ms  103 ms  111 ms  Matt_Pychoed
                      
                        min   median   mean     max  
                      102 ms  106 ms  107 ms  116 ms  kc
                       60 ms   61 ms   61 ms   62 ms  kc_Pychoed_1
                       76 ms   77 ms   77 ms   86 ms  kc_Pychoed_2
                        0 ms    1 ms    1 ms    1 ms  Matt
                        0 ms    0 ms    0 ms    0 ms  Matt_Pychoed
                      
                      from timeit import default_timer as timer
                      from statistics import mean, median
                      import random
                      from typing import List, Tuple
                      import math
                      from itertools import accumulate, count
                      from operator import truediv
                      
                      def kc(nums: List[int]) -> List[int]:
                          """Return list of lengths of max average prefix reductions."""
                      
                          def max_prefix_avg(arr: List[int]) -> Tuple[float, int]:
                              """Return value and length of max average prefix in arr"""
                              if len(arr) == 0:
                                  return (-math.inf, 0)
                              
                              best_length = 1
                              best_average = -math.inf
                              running_sum = 0.0
                      
                              for i, x in enumerate(arr, 1):
                                  running_sum += x
                                  new_average = running_sum / i
                                  
                                  if (new_average >= best_average
                                      or math.isclose(new_average, best_average)):
                                      
                                      best_average = new_average
                                      best_length = i
                      
                              return (best_average, best_length)
                      
                          removed_lengths = []
                          total_removed = 0
                      
                          while total_removed < len(nums):
                              _, new_removal = max_prefix_avg(nums[total_removed:])
                              removed_lengths.append(new_removal)
                              total_removed += new_removal
                      
                          return removed_lengths
                      
                      def kc_Pychoed_1(nums: List[int]) -> List[int]:
                          """Return list of lengths of max average prefix reductions."""
                      
                          def max_prefix_avg(arr: List[int]) -> Tuple[float, int]:
                              """Return value and length of max average prefix in arr"""
                              if len(arr) == 0:
                                  return (-math.inf, 0)
                              
                              best_length = 1
                              best_average = -math.inf
                              running_sum = 0
                      
                              for i, x in enumerate(arr, 1):
                                  running_sum += x
                                  new_average = running_sum / i
                                  
                                  if new_average >= best_average:
                                      
                                      best_average = new_average
                                      best_length = i
                      
                              return (best_average, best_length)
                      
                          removed_lengths = []
                          total_removed = 0
                      
                          while total_removed < len(nums):
                              _, new_removal = max_prefix_avg(nums[total_removed:])
                              removed_lengths.append(new_removal)
                              total_removed += new_removal
                      
                          return removed_lengths
                      
                      def kc_Pychoed_2(nums):
                          removals = []
                          while nums:
                              averages = map(truediv, accumulate(nums), count(1))
                              remove = max(zip(averages, count(1)))[1]
                              removals.append(remove)
                              nums = nums[remove:]
                          return removals
                      
                      # Lengths of the segments in the upper convex hull
                      # of the cumulative sum graph
                      def Matt(arr):
                          if len(arr) < 2:
                              if len(arr) < 1:
                                  return []
                              else:
                                  return [1]
                          
                          hull = [(0, 0),(1, arr[0])]
                          for x in range(2, len(arr)+1):
                              # this has x coordinate x-1
                              prevPoint = hull[len(hull) - 1]
                              # next point in cumulative sum
                              point = (x, prevPoint[1] + arr[x-1])
                              # remove points not on the convex hull
                              while len(hull) >= 2:
                                  p0 = hull[len(hull)-2]
                                  dx0 = prevPoint[0] - p0[0]
                                  dy0 = prevPoint[1] - p0[1]
                                  dx1 = x - prevPoint[0]
                                  dy1 = point[1] - prevPoint[1]
                                  if dy1*dx0 < dy0*dx1:
                                      break
                                  hull.pop()
                                  prevPoint = p0
                              hull.append(point)
                          
                          return [hull[i+1][0] - hull[i][0] for i in range(0, len(hull)-1)]
                      
                      def pairwise(lst):
                          return zip(lst, lst[1:])
                      
                      def Matt_Pychoed(arr):
                          hull = [(0, 0)]
                          for x, y in enumerate(accumulate(arr), 1):
                              while len(hull) >= 2:
                                  (x0, y0), (x1, y1) = hull[-2:]
                                  dx0 = x1 - x0
                                  dy0 = y1 - y0
                                  dx1 = x - x1
                                  dy1 = y - y1
                                  if dy1*dx0 < dy0*dx1:
                                      break
                                  hull.pop()
                              hull.append((x, y))
                          return [q[0] - p[0] for p, q in pairwise(hull)]
                      
                      funcs = kc, kc_Pychoed_1, kc_Pychoed_2, Matt, Matt_Pychoed
                      stats = min, median, mean, max
                      tss = [[] for _ in funcs]
                      for r in range(1, 21):
                          print(f'After round {r}:')
                          arr = random.choices(range(1, 1001), k=100_000)
                          # arr = list(range(1000, 1, -1))
                          expect = None
                          print(*(f'{stat.__name__:^7}' for stat in stats))
                          for func, ts in zip(funcs, tss):
                              t0 = timer()
                              result = func(arr)
                              t1 = timer()
                              ts.append(t1 - t0)
                              if expect is None:
                                  expect = result
                              assert result == expect
                              print(*('%3d ms ' % (stat(ts) * 1e3) for stat in stats), func.__name__)
                          print()
                      

                      How to apply one signature test to multiple positionals

                      copy iconCopydownload iconDownload
                      subset RealOrMeasure where Real | Measure;
                      multi infix:<+> ( RealOrMeasure:D $left, RealOrMeasure:D $right )  {
                          given $left, $right {
                             when Real,    Real    { nextsame }
                             when Real,    Measure { $right.clone.add-const($left)  }
                             when Measure, Real    {  $left.clone.add-const($right) }
                             when Measure, Measure { my ($result, $argument) = infix-prep $left, $right;
                                                     $result.add($argument)}}
                      
                      }
                      
                      class Foo { 
                          method Int { 110 };
                      } 
                      multi t( Int() $x ) { $x + 1 };
                      multi t( Real $x ) { $x.Int + 11 };
                      
                      say t( 0 );
                      say t( 0.1 );
                      say t( Foo.new );
                      

                      Replacing whole string is faster than replacing only its first character

                      copy iconCopydownload iconDownload
                      $ # .match only looks at the first position regardless
                      $ python -m timeit --setup "import re; p=re.compile('a'); string='x'*100000" "p.match(string)"
                      2000000 loops, best of 5: 155 nsec per loop
                      $ python -m timeit --setup "import re; p=re.compile('^a'); string='x'*100000" "p.match(string)"
                      2000000 loops, best of 5: 157 nsec per loop
                      $ # .search looks at every position, even if there is an anchor
                      $ python -m timeit --setup "import re; p=re.compile('a'); string='x'*100000" "p.search(string)"
                      10000 loops, best of 5: 22.4 usec per loop
                      $ # and the anchor only adds complexity to the matching process
                      $ python -m timeit --setup "import re; p=re.compile('^a'); string='x'*100000" "p.search(string)"
                      500 loops, best of 5: 746 usec per loop
                      
                          if (prefix_len == 1) {
                              /* pattern starts with a literal character */
                              SRE_CHAR c = (SRE_CHAR) prefix[0];
                      #if SIZEOF_SRE_CHAR < 4
                              if ((SRE_CODE) c != prefix[0])
                                  return 0; /* literal can't match: doesn't fit in char width */
                      #endif
                              end = (SRE_CHAR *)state->end;
                              state->must_advance = 0;
                              while (ptr < end) {
                                  while (*ptr != c) {
                                      if (++ptr >= end)
                                          return 0;
                                  }
                                  ...
                      
                      $ # .match only looks at the first position regardless
                      $ python -m timeit --setup "import re; p=re.compile('a'); string='x'*100000" "p.match(string)"
                      2000000 loops, best of 5: 155 nsec per loop
                      $ python -m timeit --setup "import re; p=re.compile('^a'); string='x'*100000" "p.match(string)"
                      2000000 loops, best of 5: 157 nsec per loop
                      $ # .search looks at every position, even if there is an anchor
                      $ python -m timeit --setup "import re; p=re.compile('a'); string='x'*100000" "p.search(string)"
                      10000 loops, best of 5: 22.4 usec per loop
                      $ # and the anchor only adds complexity to the matching process
                      $ python -m timeit --setup "import re; p=re.compile('^a'); string='x'*100000" "p.search(string)"
                      500 loops, best of 5: 746 usec per loop
                      
                          if (prefix_len == 1) {
                              /* pattern starts with a literal character */
                              SRE_CHAR c = (SRE_CHAR) prefix[0];
                      #if SIZEOF_SRE_CHAR < 4
                              if ((SRE_CODE) c != prefix[0])
                                  return 0; /* literal can't match: doesn't fit in char width */
                      #endif
                              end = (SRE_CHAR *)state->end;
                              state->must_advance = 0;
                              while (ptr < end) {
                                  while (*ptr != c) {
                                      if (++ptr >= end)
                                          return 0;
                                  }
                                  ...
                      

                      Why doesn't GHC recognize the function as linear?

                      copy iconCopydownload iconDownload
                      sendToPeer :: Peer Idle %1-> IO (Peer Idle)
                      sendToPeer c = pure c
                      
                      sendToPeer :: Peer Idle %1-> Int -> Peer Busy
                      sendToPeer (Peer d) n = Peer d
                      
                      sendToPeer :: Peer Idle %1-> IO (Peer Idle)
                      sendToPeer c = pure c
                      
                      sendToPeer :: Peer Idle %1-> Int -> Peer Busy
                      sendToPeer (Peer d) n = Peer d
                      
                      {-# LANGUAGE LinearTypes #-}
                      
                      module Lib where
                      
                      import Prelude.Linear
                      import Control.Functor.Linear as Control
                      import qualified Prelude as NonLinear
                      import qualified System.IO.Linear as Linear
                      
                      data Peer st = Peer String deriving Show
                      
                      data Idle
                      data Busy
                      
                      sendToPeer :: Peer Idle %1-> Int -> Linear.IO (Peer Busy)
                      sendToPeer (Peer d) n = Control.pure (Peer d)
                      

                      Why is SFINAE for one of the std::basic_string constructors so restrictive?

                      copy iconCopydownload iconDownload
                      __not_<is_convertible<const _Tp&, const _CharT*>>>::value
                      
                      constexpr basic_string( const CharT* s,
                                              const Allocator& alloc = Allocator() ); //(5)
                      
                      template< class T >
                      explicit basic_string( const T& t,
                                             const Allocator& alloc = Allocator() ); //(10)
                      
                      __not_<is_convertible<const _Tp&, const _CharT*>>>::value
                      
                      constexpr basic_string( const CharT* s,
                                              const Allocator& alloc = Allocator() ); //(5)
                      
                      template< class T >
                      explicit basic_string( const T& t,
                                             const Allocator& alloc = Allocator() ); //(10)
                      
                      class tstring : public std::string
                      {
                      public:
                        tstring() : std::string() {}
                        tstring(tstring&& s) : std::string(std::move(s)) {}
                      };
                      

                      How to combine and then branch in MonadPlus/Alternative

                      copy iconCopydownload iconDownload
                      do
                        let acts = do more actions
                        (do x <- m; acts; ...) <|> (do y <- n; acts; ...)
                      
                      data Coyoneda f a where       
                          Coyoneda :: (b -> a) -> f b -> Coyoneda f a  
                      
                      Alternative f => Alternative (Coyoneda f)
                      MonadPlus f => MonadPlus (Coyoneda f)
                      
                      sandwich :: (Foldable f, MonadPlus m, Monad m) 
                               => m x 
                               -> f (Coyoneda m (m a)) 
                               -> m a
                      sandwich more = join . lowerCoyoneda . hoistCoyoneda (<* more) . asum 
                      
                      sandwich more [Coyoneda m xCont, Coyoneda n yCont]
                      
                      data Coyoneda f a where       
                          Coyoneda :: (b -> a) -> f b -> Coyoneda f a  
                      
                      Alternative f => Alternative (Coyoneda f)
                      MonadPlus f => MonadPlus (Coyoneda f)
                      
                      sandwich :: (Foldable f, MonadPlus m, Monad m) 
                               => m x 
                               -> f (Coyoneda m (m a)) 
                               -> m a
                      sandwich more = join . lowerCoyoneda . hoistCoyoneda (<* more) . asum 
                      
                      sandwich more [Coyoneda m xCont, Coyoneda n yCont]
                      
                      data Coyoneda f a where       
                          Coyoneda :: (b -> a) -> f b -> Coyoneda f a  
                      
                      Alternative f => Alternative (Coyoneda f)
                      MonadPlus f => MonadPlus (Coyoneda f)
                      
                      sandwich :: (Foldable f, MonadPlus m, Monad m) 
                               => m x 
                               -> f (Coyoneda m (m a)) 
                               -> m a
                      sandwich more = join . lowerCoyoneda . hoistCoyoneda (<* more) . asum 
                      
                      sandwich more [Coyoneda m xCont, Coyoneda n yCont]
                      
                      data Coyoneda f a where       
                          Coyoneda :: (b -> a) -> f b -> Coyoneda f a  
                      
                      Alternative f => Alternative (Coyoneda f)
                      MonadPlus f => MonadPlus (Coyoneda f)
                      
                      sandwich :: (Foldable f, MonadPlus m, Monad m) 
                               => m x 
                               -> f (Coyoneda m (m a)) 
                               -> m a
                      sandwich more = join . lowerCoyoneda . hoistCoyoneda (<* more) . asum 
                      
                      sandwich more [Coyoneda m xCont, Coyoneda n yCont]
                      
                      do
                        e <- (Left <$> m) <|> (Right <$> n)
                        more actions
                        case e of
                          Left x -> fx x
                          Right y -> fy y
                      
                      do
                        e <- (fx <$> m) <|> (fy <$> n)
                        more actions
                        e
                      
                      do
                        e <- (Left <$> m) <|> (Right <$> n)
                        more actions
                        case e of
                          Left x -> fx x
                          Right y -> fy y
                      
                      do
                        e <- (fx <$> m) <|> (fy <$> n)
                        more actions
                        e
                      

                      Where to put formatMsgNoLookups in the Log4j XML configuration file

                      copy iconCopydownload iconDownload
                      log4j2.formatMsgNoLookups
                      
                      -Dlog4j2.formatMsgNoLookups=true
                      
                      java -Dlog4j2.formatMsgNoLookups=true -jar myapp.jar
                      
                      log4j2.formatMsgNoLookups
                      
                      -Dlog4j2.formatMsgNoLookups=true
                      
                      java -Dlog4j2.formatMsgNoLookups=true -jar myapp.jar
                      
                      log4j2.formatMsgNoLookups
                      
                      -Dlog4j2.formatMsgNoLookups=true
                      
                      java -Dlog4j2.formatMsgNoLookups=true -jar myapp.jar
                      
                      java -version
                      
                      find yourReleaseDir -type f -name log4j\*jar
                      
                       Log4jReleaseVersion: A.B.C
                      
                      lsof | grep log4j
                      
                      ps -ef | egrep "(java|jdk)"    #OR: | grep -v grep
                      
                      java ShowClassVersions.java app_server_dir |grep log4j
                      app_server_dir/somewebapp.war => WEB-INF/lib/log4j2-core.jar
                      
                      java -version
                      
                      find yourReleaseDir -type f -name log4j\*jar
                      
                       Log4jReleaseVersion: A.B.C
                      
                      lsof | grep log4j
                      
                      ps -ef | egrep "(java|jdk)"    #OR: | grep -v grep
                      
                      java ShowClassVersions.java app_server_dir |grep log4j
                      app_server_dir/somewebapp.war => WEB-INF/lib/log4j2-core.jar
                      
                      java -version
                      
                      find yourReleaseDir -type f -name log4j\*jar
                      
                       Log4jReleaseVersion: A.B.C
                      
                      lsof | grep log4j
                      
                      ps -ef | egrep "(java|jdk)"    #OR: | grep -v grep
                      
                      java ShowClassVersions.java app_server_dir |grep log4j
                      app_server_dir/somewebapp.war => WEB-INF/lib/log4j2-core.jar
                      
                      java -version
                      
                      find yourReleaseDir -type f -name log4j\*jar
                      
                       Log4jReleaseVersion: A.B.C
                      
                      lsof | grep log4j
                      
                      ps -ef | egrep "(java|jdk)"    #OR: | grep -v grep
                      
                      java ShowClassVersions.java app_server_dir |grep log4j
                      app_server_dir/somewebapp.war => WEB-INF/lib/log4j2-core.jar
                      
                      java -version
                      
                      find yourReleaseDir -type f -name log4j\*jar
                      
                       Log4jReleaseVersion: A.B.C
                      
                      lsof | grep log4j
                      
                      ps -ef | egrep "(java|jdk)"    #OR: | grep -v grep
                      
                      java ShowClassVersions.java app_server_dir |grep log4j
                      app_server_dir/somewebapp.war => WEB-INF/lib/log4j2-core.jar
                      
                      java -version
                      
                      find yourReleaseDir -type f -name log4j\*jar
                      
                       Log4jReleaseVersion: A.B.C
                      
                      lsof | grep log4j
                      
                      ps -ef | egrep "(java|jdk)"    #OR: | grep -v grep
                      
                      java ShowClassVersions.java app_server_dir |grep log4j
                      app_server_dir/somewebapp.war => WEB-INF/lib/log4j2-core.jar
                      
                      / **
                      * Converts a property name string into a list of tokens. This will strip a prefix of {@code log4j},
                      * {@code log4j2}, {@code Log4j}, or {@code org.apache.logging.log4j}, along with separators of
                      * dash {@code -}, dot {@code.}, underscore {@code _}, and slash {@code /}. Tokens can also be separated
                      * by camel case conventions without needing a separator character in between.
                      *
                      * @param value property name
                      * @return the property broken into lower case tokens
                      * /
                      
                      package org.apache.logging.log4j.core.pattern;
                      
                      import org.apache.logging.log4j.core.util.Constants;
                      import org.junit.Test;
                      
                      import static org.junit.Assert.assertTrue;
                      
                      / **
                       *
                       * /
                      
                      public class Log4jParameterTest {
                          static {
                              // Test Ok. All working
                      // System.setProperty ("log4j2.formatMsgNoLookups", "true");
                      // System.setProperty ("log4j.formatMsgNoLookups", "true");
                      // System.setProperty ("Log4j.formatMsgNoLookups", "true");
                      // System.setProperty ("org.apache.logging.log4j.formatMsgNoLookups", "true");
                      // System.setProperty ("log4j2-formatMsgNoLookups", "true");
                      // System.setProperty ("log4j2_formatMsgNoLookups", "true");
                              System.setProperty ("log4j2 / formatMsgNoLookups", "true");
                              // Test KO. All fail
                      // System.setProperty ("log5j2.formatMsgNoLookups", "true");
                      // System.setProperty ("log5j2-formatMsgNoLookups", "true");
                          }
                          @Test
                          public void testLookupEnabledByDefault () {
                              assertTrue ("Lookups deactivated", Constants.FORMAT_MESSAGES_PATTERN_DISABLE_LOOKUPS);
                      
                          }
                      }
                      
                      / **
                      * Converts a property name string into a list of tokens. This will strip a prefix of {@code log4j},
                      * {@code log4j2}, {@code Log4j}, or {@code org.apache.logging.log4j}, along with separators of
                      * dash {@code -}, dot {@code.}, underscore {@code _}, and slash {@code /}. Tokens can also be separated
                      * by camel case conventions without needing a separator character in between.
                      *
                      * @param value property name
                      * @return the property broken into lower case tokens
                      * /
                      
                      package org.apache.logging.log4j.core.pattern;
                      
                      import org.apache.logging.log4j.core.util.Constants;
                      import org.junit.Test;
                      
                      import static org.junit.Assert.assertTrue;
                      
                      / **
                       *
                       * /
                      
                      public class Log4jParameterTest {
                          static {
                              // Test Ok. All working
                      // System.setProperty ("log4j2.formatMsgNoLookups", "true");
                      // System.setProperty ("log4j.formatMsgNoLookups", "true");
                      // System.setProperty ("Log4j.formatMsgNoLookups", "true");
                      // System.setProperty ("org.apache.logging.log4j.formatMsgNoLookups", "true");
                      // System.setProperty ("log4j2-formatMsgNoLookups", "true");
                      // System.setProperty ("log4j2_formatMsgNoLookups", "true");
                              System.setProperty ("log4j2 / formatMsgNoLookups", "true");
                              // Test KO. All fail
                      // System.setProperty ("log5j2.formatMsgNoLookups", "true");
                      // System.setProperty ("log5j2-formatMsgNoLookups", "true");
                          }
                          @Test
                          public void testLookupEnabledByDefault () {
                              assertTrue ("Lookups deactivated", Constants.FORMAT_MESSAGES_PATTERN_DISABLE_LOOKUPS);
                      
                          }
                      }
                      

                      Repeating triangle pattern in Python

                      copy iconCopydownload iconDownload
                      n = int(input("n = "))
                      
                      rows = n ** 2
                      base = n * 2 - 1
                      
                      for row in range(rows):
                          triangle = row // n
                          level = row % n
                      
                          a_space = " " * (n - triangle - 1) * base
                          b_space = " " * (n - level - 1)
                      
                          line = (a_space + (b_space + "*" * (level * 2 + 1) + b_space)
                              * (triangle * 2 + 1)).rstrip()
                      
                          print(line)
                      
                      for row in range(rows):
                          triangle = row // n
                          level = row % n
                      
                          print(triangle, level)
                      
                      a_space = " " * (n - triangle - 1) * base
                      b_space = " " * (n - level - 1)
                      
                      a_space
                      
                      "*" * (level * 2 + 1)
                      
                      b_space + "*" * (level * 2 + 1) + b_space
                      
                      (b_space + "*" * (level * 2 + 1) + b_space) * (triangle * 2 + 1)
                      
                      line = (a_space + (b_space + "*" * (level * 2 + 1) + b_space)
                              * (triangle * 2 + 1)).rstrip()
                      
                      print(line)
                      
                      *
                      
                          *
                         ***
                       *  *  *
                      *********
                      
                                  *
                                 ***
                                *****
                             *    *    *
                            ***  ***  ***
                           ***************
                        *    *    *    *    *
                       ***  ***  ***  ***  ***
                      *************************
                      
                                              *
                                             ***
                                            *****
                                           *******
                                       *      *      *
                                      ***    ***    ***
                                     *****  *****  *****
                                    *********************
                                *      *      *      *      *
                               ***    ***    ***    ***    ***
                              *****  *****  *****  *****  *****
                             ***********************************
                         *      *      *      *      *      *      *
                        ***    ***    ***    ***    ***    ***    ***
                       *****  *****  *****  *****  *****  *****  *****
                      *************************************************
                      
                      n = int(input("n = "))
                      
                      rows = n ** 2
                      base = n * 2 - 1
                      
                      for row in range(rows):
                          triangle = row // n
                          level = row % n
                      
                          a_space = " " * (n - triangle - 1) * base
                          b_space = " " * (n - level - 1)
                      
                          line = (a_space + (b_space + "*" * (level * 2 + 1) + b_space)
                              * (triangle * 2 + 1)).rstrip()
                      
                          print(line)
                      
                      for row in range(rows):
                          triangle = row // n
                          level = row % n
                      
                          print(triangle, level)
                      
                      a_space = " " * (n - triangle - 1) * base
                      b_space = " " * (n - level - 1)
                      
                      a_space
                      
                      "*" * (level * 2 + 1)
                      
                      b_space + "*" * (level * 2 + 1) + b_space
                      
                      (b_space + "*" * (level * 2 + 1) + b_space) * (triangle * 2 + 1)
                      
                      line = (a_space + (b_space + "*" * (level * 2 + 1) + b_space)
                              * (triangle * 2 + 1)).rstrip()
                      
                      print(line)
                      
                      *
                      
                          *
                         ***
                       *  *  *
                      *********
                      
                                  *
                                 ***
                                *****
                             *    *    *
                            ***  ***  ***
                           ***************
                        *    *    *    *    *
                       ***  ***  ***  ***  ***
                      *************************
                      
                                              *
                                             ***
                                            *****
                                           *******
                                       *      *      *
                                      ***    ***    ***
                                     *****  *****  *****
                                    *********************
                                *      *      *      *      *
                               ***    ***    ***    ***    ***
                              *****  *****  *****  *****  *****
                             ***********************************
                         *      *      *      *      *      *      *
                        ***    ***    ***    ***    ***    ***    ***
                       *****  *****  *****  *****  *****  *****  *****
                      *************************************************
                      
                      n = int(input("n = "))
                      
                      rows = n ** 2
                      base = n * 2 - 1
                      
                      for row in range(rows):
                          triangle = row // n
                          level = row % n
                      
                          a_space = " " * (n - triangle - 1) * base
                          b_space = " " * (n - level - 1)
                      
                          line = (a_space + (b_space + "*" * (level * 2 + 1) + b_space)
                              * (triangle * 2 + 1)).rstrip()
                      
                          print(line)
                      
                      for row in range(rows):
                          triangle = row // n
                          level = row % n
                      
                          print(triangle, level)
                      
                      a_space = " " * (n - triangle - 1) * base
                      b_space = " " * (n - level - 1)
                      
                      a_space
                      
                      "*" * (level * 2 + 1)
                      
                      b_space + "*" * (level * 2 + 1) + b_space
                      
                      (b_space + "*" * (level * 2 + 1) + b_space) * (triangle * 2 + 1)
                      
                      line = (a_space + (b_space + "*" * (level * 2 + 1) + b_space)
                              * (triangle * 2 + 1)).rstrip()
                      
                      print(line)
                      
                      *
                      
                          *
                         ***
                       *  *  *
                      *********
                      
                                  *
                                 ***
                                *****
                             *    *    *
                            ***  ***  ***
                           ***************
                        *    *    *    *    *
                       ***  ***  ***  ***  ***
                      *************************
                      
                                              *
                                             ***
                                            *****
                                           *******
                                       *      *      *
                                      ***    ***    ***
                                     *****  *****  *****
                                    *********************
                                *      *      *      *      *
                               ***    ***    ***    ***    ***
                              *****  *****  *****  *****  *****
                             ***********************************
                         *      *      *      *      *      *      *
                        ***    ***    ***    ***    ***    ***    ***
                       *****  *****  *****  *****  *****  *****  *****
                      *************************************************
                      
                      n = int(input("n = "))
                      
                      rows = n ** 2
                      base = n * 2 - 1
                      
                      for row in range(rows):
                          triangle = row // n
                          level = row % n
                      
                          a_space = " " * (n - triangle - 1) * base
                          b_space = " " * (n - level - 1)
                      
                          line = (a_space + (b_space + "*" * (level * 2 + 1) + b_space)
                              * (triangle * 2 + 1)).rstrip()
                      
                          print(line)
                      
                      for row in range(rows):
                          triangle = row // n
                          level = row % n
                      
                          print(triangle, level)
                      
                      a_space = " " * (n - triangle - 1) * base
                      b_space = " " * (n - level - 1)
                      
                      a_space
                      
                      "*" * (level * 2 + 1)
                      
                      b_space + "*" * (level * 2 + 1) + b_space
                      
                      (b_space + "*" * (level * 2 + 1) + b_space) * (triangle * 2 + 1)
                      
                      line = (a_space + (b_space + "*" * (level * 2 + 1) + b_space)
                              * (triangle * 2 + 1)).rstrip()
                      
                      print(line)
                      
                      *
                      
                          *
                         ***
                       *  *  *
                      *********
                      
                                  *
                                 ***
                                *****
                             *    *    *
                            ***  ***  ***
                           ***************
                        *    *    *    *    *
                       ***  ***  ***  ***  ***
                      *************************
                      
                                              *
                                             ***
                                            *****
                                           *******
                                       *      *      *
                                      ***    ***    ***
                                     *****  *****  *****
                                    *********************
                                *      *      *      *      *
                               ***    ***    ***    ***    ***
                              *****  *****  *****  *****  *****
                             ***********************************
                         *      *      *      *      *      *      *
                        ***    ***    ***    ***    ***    ***    ***
                       *****  *****  *****  *****  *****  *****  *****
                      *************************************************
                      
                      n = int(input("n = "))
                      
                      rows = n ** 2
                      base = n * 2 - 1
                      
                      for row in range(rows):
                          triangle = row // n
                          level = row % n
                      
                          a_space = " " * (n - triangle - 1) * base
                          b_space = " " * (n - level - 1)
                      
                          line = (a_space + (b_space + "*" * (level * 2 + 1) + b_space)
                              * (triangle * 2 + 1)).rstrip()
                      
                          print(line)
                      
                      for row in range(rows):
                          triangle = row // n
                          level = row % n
                      
                          print(triangle, level)
                      
                      a_space = " " * (n - triangle - 1) * base
                      b_space = " " * (n - level - 1)
                      
                      a_space
                      
                      "*" * (level * 2 + 1)
                      
                      b_space + "*" * (level * 2 + 1) + b_space
                      
                      (b_space + "*" * (level * 2 + 1) + b_space) * (triangle * 2 + 1)
                      
                      line = (a_space + (b_space + "*" * (level * 2 + 1) + b_space)
                              * (triangle * 2 + 1)).rstrip()
                      
                      print(line)
                      
                      *
                      
                          *
                         ***
                       *  *  *
                      *********
                      
                                  *
                                 ***
                                *****
                             *    *    *
                            ***  ***  ***
                           ***************
                        *    *    *    *    *
                       ***  ***  ***  ***  ***
                      *************************
                      
                                              *
                                             ***
                                            *****
                                           *******
                                       *      *      *
                                      ***    ***    ***
                                     *****  *****  *****
                                    *********************
                                *      *      *      *      *
                               ***    ***    ***    ***    ***
                              *****  *****  *****  *****  *****
                             ***********************************
                         *      *      *      *      *      *      *
                        ***    ***    ***    ***    ***    ***    ***
                       *****  *****  *****  *****  *****  *****  *****
                      *************************************************
                      
                      n = int(input("n = "))
                      
                      rows = n ** 2
                      base = n * 2 - 1
                      
                      for row in range(rows):
                          triangle = row // n
                          level = row % n
                      
                          a_space = " " * (n - triangle - 1) * base
                          b_space = " " * (n - level - 1)
                      
                          line = (a_space + (b_space + "*" * (level * 2 + 1) + b_space)
                              * (triangle * 2 + 1)).rstrip()
                      
                          print(line)
                      
                      for row in range(rows):
                          triangle = row // n
                          level = row % n
                      
                          print(triangle, level)
                      
                      a_space = " " * (n - triangle - 1) * base
                      b_space = " " * (n - level - 1)
                      
                      a_space
                      
                      "*" * (level * 2 + 1)
                      
                      b_space + "*" * (level * 2 + 1) + b_space
                      
                      (b_space + "*" * (level * 2 + 1) + b_space) * (triangle * 2 + 1)
                      
                      line = (a_space + (b_space + "*" * (level * 2 + 1) + b_space)
                              * (triangle * 2 + 1)).rstrip()
                      
                      print(line)
                      
                      *
                      
                          *
                         ***
                       *  *  *
                      *********
                      
                                  *
                                 ***
                                *****
                             *    *    *
                            ***  ***  ***
                           ***************
                        *    *    *    *    *
                       ***  ***  ***  ***  ***
                      *************************
                      
                                              *
                                             ***
                                            *****
                                           *******
                                       *      *      *
                                      ***    ***    ***
                                     *****  *****  *****
                                    *********************
                                *      *      *      *      *
                               ***    ***    ***    ***    ***
                              *****  *****  *****  *****  *****
                             ***********************************
                         *      *      *      *      *      *      *
                        ***    ***    ***    ***    ***    ***    ***
                       *****  *****  *****  *****  *****  *****  *****
                      *************************************************
                      
                      n = int(input("n = "))
                      
                      rows = n ** 2
                      base = n * 2 - 1
                      
                      for row in range(rows):
                          triangle = row // n
                          level = row % n
                      
                          a_space = " " * (n - triangle - 1) * base
                          b_space = " " * (n - level - 1)
                      
                          line = (a_space + (b_space + "*" * (level * 2 + 1) + b_space)
                              * (triangle * 2 + 1)).rstrip()
                      
                          print(line)
                      
                      for row in range(rows):
                          triangle = row // n
                          level = row % n
                      
                          print(triangle, level)
                      
                      a_space = " " * (n - triangle - 1) * base
                      b_space = " " * (n - level - 1)
                      
                      a_space
                      
                      "*" * (level * 2 + 1)
                      
                      b_space + "*" * (level * 2 + 1) + b_space
                      
                      (b_space + "*" * (level * 2 + 1) + b_space) * (triangle * 2 + 1)
                      
                      line = (a_space + (b_space + "*" * (level * 2 + 1) + b_space)
                              * (triangle * 2 + 1)).rstrip()
                      
                      print(line)
                      
                      *
                      
                          *
                         ***
                       *  *  *
                      *********
                      
                                  *
                                 ***
                                *****
                             *    *    *
                            ***  ***  ***
                           ***************
                        *    *    *    *    *
                       ***  ***  ***  ***  ***
                      *************************
                      
                                              *
                                             ***
                                            *****
                                           *******
                                       *      *      *
                                      ***    ***    ***
                                     *****  *****  *****
                                    *********************
                                *      *      *      *      *
                               ***    ***    ***    ***    ***
                              *****  *****  *****  *****  *****
                             ***********************************
                         *      *      *      *      *      *      *
                        ***    ***    ***    ***    ***    ***    ***
                       *****  *****  *****  *****  *****  *****  *****
                      *************************************************
                      
                      n = int(input("n = "))
                      
                      rows = n ** 2
                      base = n * 2 - 1
                      
                      for row in range(rows):
                          triangle = row // n
                          level = row % n
                      
                          a_space = " " * (n - triangle - 1) * base
                          b_space = " " * (n - level - 1)
                      
                          line = (a_space + (b_space + "*" * (level * 2 + 1) + b_space)
                              * (triangle * 2 + 1)).rstrip()
                      
                          print(line)
                      
                      for row in range(rows):
                          triangle = row // n
                          level = row % n
                      
                          print(triangle, level)
                      
                      a_space = " " * (n - triangle - 1) * base
                      b_space = " " * (n - level - 1)
                      
                      a_space
                      
                      "*" * (level * 2 + 1)
                      
                      b_space + "*" * (level * 2 + 1) + b_space
                      
                      (b_space + "*" * (level * 2 + 1) + b_space) * (triangle * 2 + 1)
                      
                      line = (a_space + (b_space + "*" * (level * 2 + 1) + b_space)
                              * (triangle * 2 + 1)).rstrip()
                      
                      print(line)
                      
                      *
                      
                          *
                         ***
                       *  *  *
                      *********
                      
                                  *
                                 ***
                                *****
                             *    *    *
                            ***  ***  ***
                           ***************
                        *    *    *    *    *
                       ***  ***  ***  ***  ***
                      *************************
                      
                                              *
                                             ***
                                            *****
                                           *******
                                       *      *      *
                                      ***    ***    ***
                                     *****  *****  *****
                                    *********************
                                *      *      *      *      *
                               ***    ***    ***    ***    ***
                              *****  *****  *****  *****  *****
                             ***********************************
                         *      *      *      *      *      *      *
                        ***    ***    ***    ***    ***    ***    ***
                       *****  *****  *****  *****  *****  *****  *****
                      *************************************************
                      
                      n = int(input("n = "))
                      
                      rows = n ** 2
                      base = n * 2 - 1
                      
                      for row in range(rows):
                          triangle = row // n
                          level = row % n
                      
                          a_space = " " * (n - triangle - 1) * base
                          b_space = " " * (n - level - 1)
                      
                          line = (a_space + (b_space + "*" * (level * 2 + 1) + b_space)
                              * (triangle * 2 + 1)).rstrip()
                      
                          print(line)
                      
                      for row in range(rows):
                          triangle = row // n
                          level = row % n
                      
                          print(triangle, level)
                      
                      a_space = " " * (n - triangle - 1) * base
                      b_space = " " * (n - level - 1)
                      
                      a_space
                      
                      "*" * (level * 2 + 1)
                      
                      b_space + "*" * (level * 2 + 1) + b_space
                      
                      (b_space + "*" * (level * 2 + 1) + b_space) * (triangle * 2 + 1)
                      
                      line = (a_space + (b_space + "*" * (level * 2 + 1) + b_space)
                              * (triangle * 2 + 1)).rstrip()
                      
                      print(line)
                      
                      *
                      
                          *
                         ***
                       *  *  *
                      *********
                      
                                  *
                                 ***
                                *****
                             *    *    *
                            ***  ***  ***
                           ***************
                        *    *    *    *    *
                       ***  ***  ***  ***  ***
                      *************************
                      
                                              *
                                             ***
                                            *****
                                           *******
                                       *      *      *
                                      ***    ***    ***
                                     *****  *****  *****
                                    *********************
                                *      *      *      *      *
                               ***    ***    ***    ***    ***
                              *****  *****  *****  *****  *****
                             ***********************************
                         *      *      *      *      *      *      *
                        ***    ***    ***    ***    ***    ***    ***
                       *****  *****  *****  *****  *****  *****  *****
                      *************************************************
                      
                      n = int(input("n = "))
                      
                      rows = n ** 2
                      base = n * 2 - 1
                      
                      for row in range(rows):
                          triangle = row // n
                          level = row % n
                      
                          a_space = " " * (n - triangle - 1) * base
                          b_space = " " * (n - level - 1)
                      
                          line = (a_space + (b_space + "*" * (level * 2 + 1) + b_space)
                              * (triangle * 2 + 1)).rstrip()
                      
                          print(line)
                      
                      for row in range(rows):
                          triangle = row // n
                          level = row % n
                      
                          print(triangle, level)
                      
                      a_space = " " * (n - triangle - 1) * base
                      b_space = " " * (n - level - 1)
                      
                      a_space
                      
                      "*" * (level * 2 + 1)
                      
                      b_space + "*" * (level * 2 + 1) + b_space
                      
                      (b_space + "*" * (level * 2 + 1) + b_space) * (triangle * 2 + 1)
                      
                      line = (a_space + (b_space + "*" * (level * 2 + 1) + b_space)
                              * (triangle * 2 + 1)).rstrip()
                      
                      print(line)
                      
                      *
                      
                          *
                         ***
                       *  *  *
                      *********
                      
                                  *
                                 ***
                                *****
                             *    *    *
                            ***  ***  ***
                           ***************
                        *    *    *    *    *
                       ***  ***  ***  ***  ***
                      *************************
                      
                                              *
                                             ***
                                            *****
                                           *******
                                       *      *      *
                                      ***    ***    ***
                                     *****  *****  *****
                                    *********************
                                *      *      *      *      *
                               ***    ***    ***    ***    ***
                              *****  *****  *****  *****  *****
                             ***********************************
                         *      *      *      *      *      *      *
                        ***    ***    ***    ***    ***    ***    ***
                       *****  *****  *****  *****  *****  *****  *****
                      *************************************************
                      
                      n = int(input("n = "))
                      
                      rows = n ** 2
                      base = n * 2 - 1
                      
                      for row in range(rows):
                          triangle = row // n
                          level = row % n
                      
                          a_space = " " * (n - triangle - 1) * base
                          b_space = " " * (n - level - 1)
                      
                          line = (a_space + (b_space + "*" * (level * 2 + 1) + b_space)
                              * (triangle * 2 + 1)).rstrip()
                      
                          print(line)
                      
                      for row in range(rows):
                          triangle = row // n
                          level = row % n
                      
                          print(triangle, level)
                      
                      a_space = " " * (n - triangle - 1) * base
                      b_space = " " * (n - level - 1)
                      
                      a_space
                      
                      "*" * (level * 2 + 1)
                      
                      b_space + "*" * (level * 2 + 1) + b_space
                      
                      (b_space + "*" * (level * 2 + 1) + b_space) * (triangle * 2 + 1)
                      
                      line = (a_space + (b_space + "*" * (level * 2 + 1) + b_space)
                              * (triangle * 2 + 1)).rstrip()
                      
                      print(line)
                      
                      *
                      
                          *
                         ***
                       *  *  *
                      *********
                      
                                  *
                                 ***
                                *****
                             *    *    *
                            ***  ***  ***
                           ***************
                        *    *    *    *    *
                       ***  ***  ***  ***  ***
                      *************************
                      
                                              *
                                             ***
                                            *****
                                           *******
                                       *      *      *
                                      ***    ***    ***
                                     *****  *****  *****
                                    *********************
                                *      *      *      *      *
                               ***    ***    ***    ***    ***
                              *****  *****  *****  *****  *****
                             ***********************************
                         *      *      *      *      *      *      *
                        ***    ***    ***    ***    ***    ***    ***
                       *****  *****  *****  *****  *****  *****  *****
                      *************************************************
                      
                      n = int(input("n = "))
                      
                      rows = n ** 2
                      base = n * 2 - 1
                      
                      for row in range(rows):
                          triangle = row // n
                          level = row % n
                      
                          a_space = " " * (n - triangle - 1) * base
                          b_space = " " * (n - level - 1)
                      
                          line = (a_space + (b_space + "*" * (level * 2 + 1) + b_space)
                              * (triangle * 2 + 1)).rstrip()
                      
                          print(line)
                      
                      for row in range(rows):
                          triangle = row // n
                          level = row % n
                      
                          print(triangle, level)
                      
                      a_space = " " * (n - triangle - 1) * base
                      b_space = " " * (n - level - 1)
                      
                      a_space
                      
                      "*" * (level * 2 + 1)
                      
                      b_space + "*" * (level * 2 + 1) + b_space
                      
                      (b_space + "*" * (level * 2 + 1) + b_space) * (triangle * 2 + 1)
                      
                      line = (a_space + (b_space + "*" * (level * 2 + 1) + b_space)
                              * (triangle * 2 + 1)).rstrip()
                      
                      print(line)
                      
                      *
                      
                          *
                         ***
                       *  *  *
                      *********
                      
                                  *
                                 ***
                                *****
                             *    *    *
                            ***  ***  ***
                           ***************
                        *    *    *    *    *
                       ***  ***  ***  ***  ***
                      *************************
                      
                                              *
                                             ***
                                            *****
                                           *******
                                       *      *      *
                                      ***    ***    ***
                                     *****  *****  *****
                                    *********************
                                *      *      *      *      *
                               ***    ***    ***    ***    ***
                              *****  *****  *****  *****  *****
                             ***********************************
                         *      *      *      *      *      *      *
                        ***    ***    ***    ***    ***    ***    ***
                       *****  *****  *****  *****  *****  *****  *****
                      *************************************************
                      
                      def tri(n):
                         r = [(s:=(' '*(((2*n-1)-(2*i-1))//2)))+('*'*(2*i-1))+s for i in range(1, n+1)]
                         return r
                      
                      def triangle(n):
                         v = [''.join(j) for i in range(n+1) for j in zip(*[tri(n) for _ in range(2*i-1)])]
                         return '\n'.join((s:=' '*((len(v[-1]) - len(i))//2))+i+s for i in v) 
                      
                      for i in range(1, 4):
                         print(triangle(i))
                         print('-'*25)
                      
                      *
                      -------------------------
                          *    
                         ***   
                       *  *  * 
                      *********
                      -------------------------
                                  *            
                                 ***           
                                *****          
                             *    *    *       
                            ***  ***  ***      
                           ***************     
                        *    *    *    *    *  
                       ***  ***  ***  ***  *** 
                      *************************
                      -------------------------
                      
                      def tri(n):
                         r = [(s:=(' '*(((2*n-1)-(2*i-1))//2)))+('*'*(2*i-1))+s for i in range(1, n+1)]
                         return r
                      
                      def triangle(n):
                         v = [''.join(j) for i in range(n+1) for j in zip(*[tri(n) for _ in range(2*i-1)])]
                         return '\n'.join((s:=' '*((len(v[-1]) - len(i))//2))+i+s for i in v) 
                      
                      for i in range(1, 4):
                         print(triangle(i))
                         print('-'*25)
                      
                      *
                      -------------------------
                          *    
                         ***   
                       *  *  * 
                      *********
                      -------------------------
                                  *            
                                 ***           
                                *****          
                             *    *    *       
                            ***  ***  ***      
                           ***************     
                        *    *    *    *    *  
                       ***  ***  ***  ***  *** 
                      *************************
                      -------------------------
                      
                      def tri(n):
                         r = [(s:=(' '*(((2*n-1)-(2*i-1))//2)))+('*'*(2*i-1))+s for i in range(1, n+1)]
                         return r
                      
                      def triangle(n):
                         v = [''.join(j) for i in range(n+1) for j in zip(*[tri(n) for _ in range(2*i-1)])]
                         return '\n'.join((s:=' '*((len(v[-1]) - len(i))//2))+i+s for i in v) 
                      
                      for i in range(1, 4):
                         print(triangle(i))
                         print('-'*25)
                      
                      *
                      -------------------------
                          *    
                         ***   
                       *  *  * 
                      *********
                      -------------------------
                                  *            
                                 ***           
                                *****          
                             *    *    *       
                            ***  ***  ***      
                           ***************     
                        *    *    *    *    *  
                       ***  ***  ***  ***  *** 
                      *************************
                      -------------------------
                      
                      import sys
                      
                      n = int(sys.argv[1])
                      
                      def drawtriangle(num_lines):
                          # prepares the inner triagle in a list and return it together with its width (size).
                          size = (2*num_lines)-1
                          triangle = []
                          for i in range(num_lines):
                              white_side = num_lines - i - 1
                              asterisks = 2*i + 1
                              triangle.append(" "*white_side + "*"*asterisks + " "*white_side)
                          return triangle, size
                      
                      def main(num_lines):
                          tr, tr_size = drawtriangle(num_lines)
                      
                          for j in range(num_lines):
                              for line in tr:
                                  white_triangles = n - j - 1
                                  white_size = tr_size * white_triangles
                                  line_repeat = (2*j) + 1
                                  print(" "*white_size + line*line_repeat + " "*white_size)
                      
                      main(n)
                      
                      *
                      
                          *
                         ***
                       *  *  *
                      *********
                      
                                  *
                                 ***
                                *****
                             *    *    *
                            ***  ***  ***
                           ***************
                        *    *    *    *    *
                       ***  ***  ***  ***  ***
                      *************************
                      
                                              *
                                             ***
                                            *****
                                           *******
                                       *      *      *
                                      ***    ***    ***
                                     *****  *****  *****
                                    *********************
                                *      *      *      *      *
                               ***    ***    ***    ***    ***
                              *****  *****  *****  *****  *****
                             ***********************************
                         *      *      *      *      *      *      *
                        ***    ***    ***    ***    ***    ***    ***
                       *****  *****  *****  *****  *****  *****  *****
                      *************************************************
                      
                      import sys
                      
                      n = int(sys.argv[1])
                      
                      def drawtriangle(num_lines):
                          # prepares the inner triagle in a list and return it together with its width (size).
                          size = (2*num_lines)-1
                          triangle = []
                          for i in range(num_lines):
                              white_side = num_lines - i - 1
                              asterisks = 2*i + 1
                              triangle.append(" "*white_side + "*"*asterisks + " "*white_side)
                          return triangle, size
                      
                      def main(num_lines):
                          tr, tr_size = drawtriangle(num_lines)
                      
                          for j in range(num_lines):
                              for line in tr:
                                  white_triangles = n - j - 1
                                  white_size = tr_size * white_triangles
                                  line_repeat = (2*j) + 1
                                  print(" "*white_size + line*line_repeat + " "*white_size)
                      
                      main(n)
                      
                      *
                      
                          *
                         ***
                       *  *  *
                      *********
                      
                                  *
                                 ***
                                *****
                             *    *    *
                            ***  ***  ***
                           ***************
                        *    *    *    *    *
                       ***  ***  ***  ***  ***
                      *************************
                      
                                              *
                                             ***
                                            *****
                                           *******
                                       *      *      *
                                      ***    ***    ***
                                     *****  *****  *****
                                    *********************
                                *      *      *      *      *
                               ***    ***    ***    ***    ***
                              *****  *****  *****  *****  *****
                             ***********************************
                         *      *      *      *      *      *      *
                        ***    ***    ***    ***    ***    ***    ***
                       *****  *****  *****  *****  *****  *****  *****
                      *************************************************
                      
                      import sys
                      
                      n = int(sys.argv[1])
                      
                      def drawtriangle(num_lines):
                          # prepares the inner triagle in a list and return it together with its width (size).
                          size = (2*num_lines)-1
                          triangle = []
                          for i in range(num_lines):
                              white_side = num_lines - i - 1
                              asterisks = 2*i + 1
                              triangle.append(" "*white_side + "*"*asterisks + " "*white_side)
                          return triangle, size
                      
                      def main(num_lines):
                          tr, tr_size = drawtriangle(num_lines)
                      
                          for j in range(num_lines):
                              for line in tr:
                                  white_triangles = n - j - 1
                                  white_size = tr_size * white_triangles
                                  line_repeat = (2*j) + 1
                                  print(" "*white_size + line*line_repeat + " "*white_size)
                      
                      main(n)
                      
                      *
                      
                          *
                         ***
                       *  *  *
                      *********
                      
                                  *
                                 ***
                                *****
                             *    *    *
                            ***  ***  ***
                           ***************
                        *    *    *    *    *
                       ***  ***  ***  ***  ***
                      *************************
                      
                                              *
                                             ***
                                            *****
                                           *******
                                       *      *      *
                                      ***    ***    ***
                                     *****  *****  *****
                                    *********************
                                *      *      *      *      *
                               ***    ***    ***    ***    ***
                              *****  *****  *****  *****  *****
                             ***********************************
                         *      *      *      *      *      *      *
                        ***    ***    ***    ***    ***    ***    ***
                       *****  *****  *****  *****  *****  *****  *****
                      *************************************************
                      
                      import sys
                      
                      n = int(sys.argv[1])
                      
                      def drawtriangle(num_lines):
                          # prepares the inner triagle in a list and return it together with its width (size).
                          size = (2*num_lines)-1
                          triangle = []
                          for i in range(num_lines):
                              white_side = num_lines - i - 1
                              asterisks = 2*i + 1
                              triangle.append(" "*white_side + "*"*asterisks + " "*white_side)
                          return triangle, size
                      
                      def main(num_lines):
                          tr, tr_size = drawtriangle(num_lines)
                      
                          for j in range(num_lines):
                              for line in tr:
                                  white_triangles = n - j - 1
                                  white_size = tr_size * white_triangles
                                  line_repeat = (2*j) + 1
                                  print(" "*white_size + line*line_repeat + " "*white_size)
                      
                      main(n)
                      
                      *
                      
                          *
                         ***
                       *  *  *
                      *********
                      
                                  *
                                 ***
                                *****
                             *    *    *
                            ***  ***  ***
                           ***************
                        *    *    *    *    *
                       ***  ***  ***  ***  ***
                      *************************
                      
                                              *
                                             ***
                                            *****
                                           *******
                                       *      *      *
                                      ***    ***    ***
                                     *****  *****  *****
                                    *********************
                                *      *      *      *      *
                               ***    ***    ***    ***    ***
                              *****  *****  *****  *****  *****
                             ***********************************
                         *      *      *      *      *      *      *
                        ***    ***    ***    ***    ***    ***    ***
                       *****  *****  *****  *****  *****  *****  *****
                      *************************************************
                      
                      import sys
                      
                      n = int(sys.argv[1])
                      
                      def drawtriangle(num_lines):
                          # prepares the inner triagle in a list and return it together with its width (size).
                          size = (2*num_lines)-1
                          triangle = []
                          for i in range(num_lines):
                              white_side = num_lines - i - 1
                              asterisks = 2*i + 1
                              triangle.append(" "*white_side + "*"*asterisks + " "*white_side)
                          return triangle, size
                      
                      def main(num_lines):
                          tr, tr_size = drawtriangle(num_lines)
                      
                          for j in range(num_lines):
                              for line in tr:
                                  white_triangles = n - j - 1
                                  white_size = tr_size * white_triangles
                                  line_repeat = (2*j) + 1
                                  print(" "*white_size + line*line_repeat + " "*white_size)
                      
                      main(n)
                      
                      *
                      
                          *
                         ***
                       *  *  *
                      *********
                      
                                  *
                                 ***
                                *****
                             *    *    *
                            ***  ***  ***
                           ***************
                        *    *    *    *    *
                       ***  ***  ***  ***  ***
                      *************************
                      
                                              *
                                             ***
                                            *****
                                           *******
                                       *      *      *
                                      ***    ***    ***
                                     *****  *****  *****
                                    *********************
                                *      *      *      *      *
                               ***    ***    ***    ***    ***
                              *****  *****  *****  *****  *****
                             ***********************************
                         *      *      *      *      *      *      *
                        ***    ***    ***    ***    ***    ***    ***
                       *****  *****  *****  *****  *****  *****  *****
                      *************************************************
                      
                      rows = int(input())
                      p = 2 * rows *(rows - 1)  # Variable to print the left most spaces
                      x = " "
                      for i in range(rows):  # For every row
                          space = 2 * (rows - 1)  # Space variable to print spaces after an asterisk when needed
                          for j in range(rows):  # For every row inside the row
                              print(p * x, end="")  # print the left most spaces
                              for k in range(2*(i + 1) - 1): 
                                  print((2*(j + 1) - 1) * "*", end = "")  # Print the asterisk(s) based on the row number
                                  print(space * x, end = "")  # Print spaces(s) after the asterisk(s)
                              space -= 2  # Decrement the number of spaces to be printed after an asterisk for every row
                              p -= 1  # Every row has one lesser space on the left
                              print()  # Print a new line after every row
                          p -= (rows - 1)  # Update the number of spaces to be printed on the left most side for every outer row
                      
                                              *      
                                             ***    
                                            *****  
                                           *******
                                       *      *      *      
                                      ***    ***    ***    
                                     *****  *****  *****  
                                    *********************
                                *      *      *      *      *      
                               ***    ***    ***    ***    ***    
                              *****  *****  *****  *****  *****  
                             ***********************************
                         *      *      *      *      *      *      *      
                        ***    ***    ***    ***    ***    ***    ***    
                       *****  *****  *****  *****  *****  *****  *****  
                      *************************************************
                      
                                                              *        
                                                             ***      
                                                            *****    
                                                           *******  
                                                          *********
                                                     *        *        *        
                                                    ***      ***      ***      
                                                   *****    *****    *****    
                                                  *******  *******  *******  
                                                 ***************************
                                            *        *        *        *        *        
                                           ***      ***      ***      ***      ***
                                          *****    *****    *****    *****    *****
                                         *******  *******  *******  *******  *******
                                        *********************************************
                                   *        *        *        *        *        *        *
                                  ***      ***      ***      ***      ***      ***      ***
                                 *****    *****    *****    *****    *****    *****    *****
                                *******  *******  *******  *******  *******  *******  *******
                               ***************************************************************
                          *        *        *        *        *        *        *        *        *
                         ***      ***      ***      ***      ***      ***      ***      ***      ***
                        *****    *****    *****    *****    *****    *****    *****    *****    *****
                       *******  *******  *******  *******  *******  *******  *******  *******  *******
                      *********************************************************************************
                      
                      rows = int(input())
                      p = 2 * rows *(rows - 1)  # Variable to print the left most spaces
                      x = " "
                      for i in range(rows):  # For every row
                          space = 2 * (rows - 1)  # Space variable to print spaces after an asterisk when needed
                          for j in range(rows):  # For every row inside the row
                              print(p * x, end="")  # print the left most spaces
                              for k in range(2*(i + 1) - 1): 
                                  print((2*(j + 1) - 1) * "*", end = "")  # Print the asterisk(s) based on the row number
                                  print(space * x, end = "")  # Print spaces(s) after the asterisk(s)
                              space -= 2  # Decrement the number of spaces to be printed after an asterisk for every row
                              p -= 1  # Every row has one lesser space on the left
                              print()  # Print a new line after every row
                          p -= (rows - 1)  # Update the number of spaces to be printed on the left most side for every outer row
                      
                                              *      
                                             ***    
                                            *****  
                                           *******
                                       *      *      *      
                                      ***    ***    ***    
                                     *****  *****  *****  
                                    *********************
                                *      *      *      *      *      
                               ***    ***    ***    ***    ***    
                              *****  *****  *****  *****  *****  
                             ***********************************
                         *      *      *      *      *      *      *      
                        ***    ***    ***    ***    ***    ***    ***    
                       *****  *****  *****  *****  *****  *****  *****  
                      *************************************************
                      
                                                              *        
                                                             ***      
                                                            *****    
                                                           *******  
                                                          *********
                                                     *        *        *        
                                                    ***      ***      ***      
                                                   *****    *****    *****    
                                                  *******  *******  *******  
                                                 ***************************
                                            *        *        *        *        *        
                                           ***      ***      ***      ***      ***
                                          *****    *****    *****    *****    *****
                                         *******  *******  *******  *******  *******
                                        *********************************************
                                   *        *        *        *        *        *        *
                                  ***      ***      ***      ***      ***      ***      ***
                                 *****    *****    *****    *****    *****    *****    *****
                                *******  *******  *******  *******  *******  *******  *******
                               ***************************************************************
                          *        *        *        *        *        *        *        *        *
                         ***      ***      ***      ***      ***      ***      ***      ***      ***
                        *****    *****    *****    *****    *****    *****    *****    *****    *****
                       *******  *******  *******  *******  *******  *******  *******  *******  *******
                      *********************************************************************************
                      
                      rows = int(input())
                      p = 2 * rows *(rows - 1)  # Variable to print the left most spaces
                      x = " "
                      for i in range(rows):  # For every row
                          space = 2 * (rows - 1)  # Space variable to print spaces after an asterisk when needed
                          for j in range(rows):  # For every row inside the row
                              print(p * x, end="")  # print the left most spaces
                              for k in range(2*(i + 1) - 1): 
                                  print((2*(j + 1) - 1) * "*", end = "")  # Print the asterisk(s) based on the row number
                                  print(space * x, end = "")  # Print spaces(s) after the asterisk(s)
                              space -= 2  # Decrement the number of spaces to be printed after an asterisk for every row
                              p -= 1  # Every row has one lesser space on the left
                              print()  # Print a new line after every row
                          p -= (rows - 1)  # Update the number of spaces to be printed on the left most side for every outer row
                      
                                              *      
                                             ***    
                                            *****  
                                           *******
                                       *      *      *      
                                      ***    ***    ***    
                                     *****  *****  *****  
                                    *********************
                                *      *      *      *      *      
                               ***    ***    ***    ***    ***    
                              *****  *****  *****  *****  *****  
                             ***********************************
                         *      *      *      *      *      *      *      
                        ***    ***    ***    ***    ***    ***    ***    
                       *****  *****  *****  *****  *****  *****  *****  
                      *************************************************
                      
                                                              *        
                                                             ***      
                                                            *****    
                                                           *******  
                                                          *********
                                                     *        *        *        
                                                    ***      ***      ***      
                                                   *****    *****    *****    
                                                  *******  *******  *******  
                                                 ***************************
                                            *        *        *        *        *        
                                           ***      ***      ***      ***      ***
                                          *****    *****    *****    *****    *****
                                         *******  *******  *******  *******  *******
                                        *********************************************
                                   *        *        *        *        *        *        *
                                  ***      ***      ***      ***      ***      ***      ***
                                 *****    *****    *****    *****    *****    *****    *****
                                *******  *******  *******  *******  *******  *******  *******
                               ***************************************************************
                          *        *        *        *        *        *        *        *        *
                         ***      ***      ***      ***      ***      ***      ***      ***      ***
                        *****    *****    *****    *****    *****    *****    *****    *****    *****
                       *******  *******  *******  *******  *******  *******  *******  *******  *******
                      *********************************************************************************
                      
                      size = int(input())
                      
                      for i in range(size):
                          for j in range(i, size):
                              print(" ", end = "")
                          for j in range(i):
                              print("*", end = "")
                          for j in range(i + 1):
                              print("*", end = "")
                          print()
                      
                      def triangle(size):
                          rows = []
                          for i in range(size):
                              row = []
                              for j in range(i + 1, size):
                                  row.append(" ")
                              for j in range(2 * i + 1):    # i + (i+1) = 2*i+1.
                                  row.append("*")
                              for j in range(i + 1, size):  # Let's add spaces at the end, too.
                                  row.append(" ")           # It'll make sense in a moment!
                              rows.append("".join(row))
                          return rows
                      
                      for row in triangle(5):
                          print(row)
                      
                      #     *
                      #    ***
                      #   *****
                      #  *******
                      # *********
                      
                      def triangle(size, block):
                          rows = []
                          for i in range(size):
                              strip = [[] for _ in block]
                              for j in range(i + 1, size):
                                  for s, b in zip(strip, block):
                                      s.append(" " * len(b))     # Space as wide as the building block
                              for j in range(2 * i + 1):
                                  for s, b in zip(strip, block):
                                      s.append(b)
                              for j in range(i + 1, size):
                                  for s, b in zip(strip, block):
                                      s.append(" " * len(b))
                              for s in strip:
                                  rows.append("".join(s))
                          return rows
                      
                      
                      # Make a triangle out of ["abc",
                      #                         "def"]:
                      
                      for row in triangle(3, ["abc", "def"]):
                          print(row)
                      
                      #       abc
                      #       def
                      #    abcabcabc
                      #    defdefdef
                      # abcabcabcabcabc
                      # defdefdefdefdef
                      
                      fractal = triangle(4, triangle(4, ["*"]))
                      
                      for row in fractal:
                          print(row)
                      
                      #                         *
                      #                        ***
                      #                       *****
                      #                      *******
                      #                  *      *      *
                      #                 ***    ***    ***
                      #                *****  *****  *****
                      #               *********************
                      #           *      *      *      *      *
                      #          ***    ***    ***    ***    ***
                      #         *****  *****  *****  *****  *****
                      #        ***********************************
                      #    *      *      *      *      *      *      *
                      #   ***    ***    ***    ***    ***    ***    ***
                      #  *****  *****  *****  *****  *****  *****  *****
                      # *************************************************
                      
                      for row in triangle(2, triangle(2, triangle(2, ["()"]))):
                          print(row)
                      
                      #                           ()
                      #                         ()()()
                      #                     ()    ()    ()
                      #                   ()()()()()()()()()
                      #         ()                ()                ()
                      #       ()()()            ()()()            ()()()
                      #   ()    ()    ()    ()    ()    ()    ()    ()    ()
                      # ()()()()()()()()()()()()()()()()()()()()()()()()()()()
                      
                      size = int(input())
                      
                      for i in range(size):
                          for j in range(i, size):
                              print(" ", end = "")
                          for j in range(i):
                              print("*", end = "")
                          for j in range(i + 1):
                              print("*", end = "")
                          print()
                      
                      def triangle(size):
                          rows = []
                          for i in range(size):
                              row = []
                              for j in range(i + 1, size):
                                  row.append(" ")
                              for j in range(2 * i + 1):    # i + (i+1) = 2*i+1.
                                  row.append("*")
                              for j in range(i + 1, size):  # Let's add spaces at the end, too.
                                  row.append(" ")           # It'll make sense in a moment!
                              rows.append("".join(row))
                          return rows
                      
                      for row in triangle(5):
                          print(row)
                      
                      #     *
                      #    ***
                      #   *****
                      #  *******
                      # *********
                      
                      def triangle(size, block):
                          rows = []
                          for i in range(size):
                              strip = [[] for _ in block]
                              for j in range(i + 1, size):
                                  for s, b in zip(strip, block):
                                      s.append(" " * len(b))     # Space as wide as the building block
                              for j in range(2 * i + 1):
                                  for s, b in zip(strip, block):
                                      s.append(b)
                              for j in range(i + 1, size):
                                  for s, b in zip(strip, block):
                                      s.append(" " * len(b))
                              for s in strip:
                                  rows.append("".join(s))
                          return rows
                      
                      
                      # Make a triangle out of ["abc",
                      #                         "def"]:
                      
                      for row in triangle(3, ["abc", "def"]):
                          print(row)
                      
                      #       abc
                      #       def
                      #    abcabcabc
                      #    defdefdef
                      # abcabcabcabcabc
                      # defdefdefdefdef
                      
                      fractal = triangle(4, triangle(4, ["*"]))
                      
                      for row in fractal:
                          print(row)
                      
                      #                         *
                      #                        ***
                      #                       *****
                      #                      *******
                      #                  *      *      *
                      #                 ***    ***    ***
                      #                *****  *****  *****
                      #               *********************
                      #           *      *      *      *      *
                      #          ***    ***    ***    ***    ***
                      #         *****  *****  *****  *****  *****
                      #        ***********************************
                      #    *      *      *      *      *      *      *
                      #   ***    ***    ***    ***    ***    ***    ***
                      #  *****  *****  *****  *****  *****  *****  *****
                      # *************************************************
                      
                      for row in triangle(2, triangle(2, triangle(2, ["()"]))):
                          print(row)
                      
                      #                           ()
                      #                         ()()()
                      #                     ()    ()    ()
                      #                   ()()()()()()()()()
                      #         ()                ()                ()
                      #       ()()()            ()()()            ()()()
                      #   ()    ()    ()    ()    ()    ()    ()    ()    ()
                      # ()()()()()()()()()()()()()()()()()()()()()()()()()()()
                      
                      size = int(input())
                      
                      for i in range(size):
                          for j in range(i, size):
                              print(" ", end = "")
                          for j in range(i):
                              print("*", end = "")
                          for j in range(i + 1):
                              print("*", end = "")
                          print()
                      
                      def triangle(size):
                          rows = []
                          for i in range(size):
                              row = []
                              for j in range(i + 1, size):
                                  row.append(" ")
                              for j in range(2 * i + 1):    # i + (i+1) = 2*i+1.
                                  row.append("*")
                              for j in range(i + 1, size):  # Let's add spaces at the end, too.
                                  row.append(" ")           # It'll make sense in a moment!
                              rows.append("".join(row))
                          return rows
                      
                      for row in triangle(5):
                          print(row)
                      
                      #     *
                      #    ***
                      #   *****
                      #  *******
                      # *********
                      
                      def triangle(size, block):
                          rows = []
                          for i in range(size):
                              strip = [[] for _ in block]
                              for j in range(i + 1, size):
                                  for s, b in zip(strip, block):
                                      s.append(" " * len(b))     # Space as wide as the building block
                              for j in range(2 * i + 1):
                                  for s, b in zip(strip, block):
                                      s.append(b)
                              for j in range(i + 1, size):
                                  for s, b in zip(strip, block):
                                      s.append(" " * len(b))
                              for s in strip:
                                  rows.append("".join(s))
                          return rows
                      
                      
                      # Make a triangle out of ["abc",
                      #                         "def"]:
                      
                      for row in triangle(3, ["abc", "def"]):
                          print(row)
                      
                      #       abc
                      #       def
                      #    abcabcabc
                      #    defdefdef
                      # abcabcabcabcabc
                      # defdefdefdefdef
                      
                      fractal = triangle(4, triangle(4, ["*"]))
                      
                      for row in fractal:
                          print(row)
                      
                      #                         *
                      #                        ***
                      #                       *****
                      #                      *******
                      #                  *      *      *
                      #                 ***    ***    ***
                      #                *****  *****  *****
                      #               *********************
                      #           *      *      *      *      *
                      #          ***    ***    ***    ***    ***
                      #         *****  *****  *****  *****  *****
                      #        ***********************************
                      #    *      *      *      *      *      *      *
                      #   ***    ***    ***    ***    ***    ***    ***
                      #  *****  *****  *****  *****  *****  *****  *****
                      # *************************************************
                      
                      for row in triangle(2, triangle(2, triangle(2, ["()"]))):
                          print(row)
                      
                      #                           ()
                      #                         ()()()
                      #                     ()    ()    ()
                      #                   ()()()()()()()()()
                      #         ()                ()                ()
                      #       ()()()            ()()()            ()()()
                      #   ()    ()    ()    ()    ()    ()    ()    ()    ()
                      # ()()()()()()()()()()()()()()()()()()()()()()()()()()()
                      
                      size = int(input())
                      
                      for i in range(size):
                          for j in range(i, size):
                              print(" ", end = "")
                          for j in range(i):
                              print("*", end = "")
                          for j in range(i + 1):
                              print("*", end = "")
                          print()
                      
                      def triangle(size):
                          rows = []
                          for i in range(size):
                              row = []
                              for j in range(i + 1, size):
                                  row.append(" ")
                              for j in range(2 * i + 1):    # i + (i+1) = 2*i+1.
                                  row.append("*")
                              for j in range(i + 1, size):  # Let's add spaces at the end, too.
                                  row.append(" ")           # It'll make sense in a moment!
                              rows.append("".join(row))
                          return rows
                      
                      for row in triangle(5):
                          print(row)
                      
                      #     *
                      #    ***
                      #   *****
                      #  *******
                      # *********
                      
                      def triangle(size, block):
                          rows = []
                          for i in range(size):
                              strip = [[] for _ in block]
                              for j in range(i + 1, size):
                                  for s, b in zip(strip, block):
                                      s.append(" " * len(b))     # Space as wide as the building block
                              for j in range(2 * i + 1):
                                  for s, b in zip(strip, block):
                                      s.append(b)
                              for j in range(i + 1, size):
                                  for s, b in zip(strip, block):
                                      s.append(" " * len(b))
                              for s in strip:
                                  rows.append("".join(s))
                          return rows
                      
                      
                      # Make a triangle out of ["abc",
                      #                         "def"]:
                      
                      for row in triangle(3, ["abc", "def"]):
                          print(row)
                      
                      #       abc
                      #       def
                      #    abcabcabc
                      #    defdefdef
                      # abcabcabcabcabc
                      # defdefdefdefdef
                      
                      fractal = triangle(4, triangle(4, ["*"]))
                      
                      for row in fractal:
                          print(row)
                      
                      #                         *
                      #                        ***
                      #                       *****
                      #                      *******
                      #                  *      *      *
                      #                 ***    ***    ***
                      #                *****  *****  *****
                      #               *********************
                      #           *      *      *      *      *
                      #          ***    ***    ***    ***    ***
                      #         *****  *****  *****  *****  *****
                      #        ***********************************
                      #    *      *      *      *      *      *      *
                      #   ***    ***    ***    ***    ***    ***    ***
                      #  *****  *****  *****  *****  *****  *****  *****
                      # *************************************************
                      
                      for row in triangle(2, triangle(2, triangle(2, ["()"]))):
                          print(row)
                      
                      #                           ()
                      #                         ()()()
                      #                     ()    ()    ()
                      #                   ()()()()()()()()()
                      #         ()                ()                ()
                      #       ()()()            ()()()            ()()()
                      #   ()    ()    ()    ()    ()    ()    ()    ()    ()
                      # ()()()()()()()()()()()()()()()()()()()()()()()()()()()
                      
                      size = int(input())
                      
                      for i in range(size):
                          for j in range(i, size):
                              print(" ", end = "")
                          for j in range(i):
                              print("*", end = "")
                          for j in range(i + 1):
                              print("*", end = "")
                          print()
                      
                      def triangle(size):
                          rows = []
                          for i in range(size):
                              row = []
                              for j in range(i + 1, size):
                                  row.append(" ")
                              for j in range(2 * i + 1):    # i + (i+1) = 2*i+1.
                                  row.append("*")
                              for j in range(i + 1, size):  # Let's add spaces at the end, too.
                                  row.append(" ")           # It'll make sense in a moment!
                              rows.append("".join(row))
                          return rows
                      
                      for row in triangle(5):
                          print(row)
                      
                      #     *
                      #    ***
                      #   *****
                      #  *******
                      # *********
                      
                      def triangle(size, block):
                          rows = []
                          for i in range(size):
                              strip = [[] for _ in block]
                              for j in range(i + 1, size):
                                  for s, b in zip(strip, block):
                                      s.append(" " * len(b))     # Space as wide as the building block
                              for j in range(2 * i + 1):
                                  for s, b in zip(strip, block):
                                      s.append(b)
                              for j in range(i + 1, size):
                                  for s, b in zip(strip, block):
                                      s.append(" " * len(b))
                              for s in strip:
                                  rows.append("".join(s))
                          return rows
                      
                      
                      # Make a triangle out of ["abc",
                      #                         "def"]:
                      
                      for row in triangle(3, ["abc", "def"]):
                          print(row)
                      
                      #       abc
                      #       def
                      #    abcabcabc
                      #    defdefdef
                      # abcabcabcabcabc
                      # defdefdefdefdef
                      
                      fractal = triangle(4, triangle(4, ["*"]))
                      
                      for row in fractal:
                          print(row)
                      
                      #                         *
                      #                        ***
                      #                       *****
                      #                      *******
                      #                  *      *      *
                      #                 ***    ***    ***
                      #                *****  *****  *****
                      #               *********************
                      #           *      *      *      *      *
                      #          ***    ***    ***    ***    ***
                      #         *****  *****  *****  *****  *****
                      #        ***********************************
                      #    *      *      *      *      *      *      *
                      #   ***    ***    ***    ***    ***    ***    ***
                      #  *****  *****  *****  *****  *****  *****  *****
                      # *************************************************
                      
                      for row in triangle(2, triangle(2, triangle(2, ["()"]))):
                          print(row)
                      
                      #                           ()
                      #                         ()()()
                      #                     ()    ()    ()
                      #                   ()()()()()()()()()
                      #         ()                ()                ()
                      #       ()()()            ()()()            ()()()
                      #   ()    ()    ()    ()    ()    ()    ()    ()    ()
                      # ()()()()()()()()()()()()()()()()()()()()()()()()()()()
                      
                      def print_fractal(n, char='*'):
                          # Width of single triangle
                          base = 2*n - 1
                          
                          # Width of overall figure
                          width = base**2
                          
                          # Lines containing single triangle padded to rectangle of width `base`
                          lines = [f'{(2*line + 1)*char:^{base}}' for line in range(n)]
                          
                          for row in range(n):
                              # Print (2*row + 1) triangle blocks next to each other
                              for line in lines:
                                  print(f'{(2*row + 1)*line:^{width}}')
                      
                      >>> print_fractal(3)
                                  *            
                                 ***           
                                *****          
                             *    *    *       
                            ***  ***  ***      
                           ***************     
                        *    *    *    *    *  
                       ***  ***  ***  ***  *** 
                      *************************
                      
                      def make_fractal(n, depth, block=['*']):
                          if not depth:
                              return block
                          
                          width = (2*n - 1)*max(map(len, block))
                          
                          lines = []
                          
                          for row in range(n):
                              for line in block:
                                  lines.append(f'{(2*row + 1)*line:^{width}}')
                          
                          return make_fractal(n, depth - 1, lines)
                      
                      >>> for line in make_fractal(3, 2): print(line)
                                  *            
                                 ***           
                                *****          
                             *    *    *       
                            ***  ***  ***      
                           ***************     
                        *    *    *    *    *  
                       ***  ***  ***  ***  *** 
                      *************************
                      >>> for line in make_fractal(2, 3): print(line)
                                   *             
                                  ***            
                                *  *  *          
                               *********         
                          *        *        *    
                         ***      ***      ***   
                       *  *  *  *  *  *  *  *  * 
                      ***************************
                      >>> for line in make_fractal(2, 2, [' . ', '---']): print(line)
                                   .             
                                  ---            
                                .  .  .          
                               ---------         
                          .        .        .    
                         ---      ---      ---   
                       .  .  .  .  .  .  .  .  . 
                      ---------------------------
                      
                      def print_fractal(n, char='*'):
                          # Width of single triangle
                          base = 2*n - 1
                          
                          # Width of overall figure
                          width = base**2
                          
                          # Lines containing single triangle padded to rectangle of width `base`
                          lines = [f'{(2*line + 1)*char:^{base}}' for line in range(n)]
                          
                          for row in range(n):
                              # Print (2*row + 1) triangle blocks next to each other
                              for line in lines:
                                  print(f'{(2*row + 1)*line:^{width}}')
                      
                      >>> print_fractal(3)
                                  *            
                                 ***           
                                *****          
                             *    *    *       
                            ***  ***  ***      
                           ***************     
                        *    *    *    *    *  
                       ***  ***  ***  ***  *** 
                      *************************
                      
                      def make_fractal(n, depth, block=['*']):
                          if not depth:
                              return block
                          
                          width = (2*n - 1)*max(map(len, block))
                          
                          lines = []
                          
                          for row in range(n):
                              for line in block:
                                  lines.append(f'{(2*row + 1)*line:^{width}}')
                          
                          return make_fractal(n, depth - 1, lines)
                      
                      >>> for line in make_fractal(3, 2): print(line)
                                  *            
                                 ***           
                                *****          
                             *    *    *       
                            ***  ***  ***      
                           ***************     
                        *    *    *    *    *  
                       ***  ***  ***  ***  *** 
                      *************************
                      >>> for line in make_fractal(2, 3): print(line)
                                   *             
                                  ***            
                                *  *  *          
                               *********         
                          *        *        *    
                         ***      ***      ***   
                       *  *  *  *  *  *  *  *  * 
                      ***************************
                      >>> for line in make_fractal(2, 2, [' . ', '---']): print(line)
                                   .             
                                  ---            
                                .  .  .          
                               ---------         
                          .        .        .    
                         ---      ---      ---   
                       .  .  .  .  .  .  .  .  . 
                      ---------------------------
                      
                      def print_fractal(n, char='*'):
                          # Width of single triangle
                          base = 2*n - 1
                          
                          # Width of overall figure
                          width = base**2
                          
                          # Lines containing single triangle padded to rectangle of width `base`
                          lines = [f'{(2*line + 1)*char:^{base}}' for line in range(n)]
                          
                          for row in range(n):
                              # Print (2*row + 1) triangle blocks next to each other
                              for line in lines:
                                  print(f'{(2*row + 1)*line:^{width}}')
                      
                      >>> print_fractal(3)
                                  *            
                                 ***           
                                *****          
                             *    *    *       
                            ***  ***  ***      
                           ***************     
                        *    *    *    *    *  
                       ***  ***  ***  ***  *** 
                      *************************
                      
                      def make_fractal(n, depth, block=['*']):
                          if not depth:
                              return block
                          
                          width = (2*n - 1)*max(map(len, block))
                          
                          lines = []
                          
                          for row in range(n):
                              for line in block:
                                  lines.append(f'{(2*row + 1)*line:^{width}}')
                          
                          return make_fractal(n, depth - 1, lines)
                      
                      >>> for line in make_fractal(3, 2): print(line)
                                  *            
                                 ***           
                                *****          
                             *    *    *       
                            ***  ***  ***      
                           ***************     
                        *    *    *    *    *  
                       ***  ***  ***  ***  *** 
                      *************************
                      >>> for line in make_fractal(2, 3): print(line)
                                   *             
                                  ***            
                                *  *  *          
                               *********         
                          *        *        *    
                         ***      ***      ***   
                       *  *  *  *  *  *  *  *  * 
                      ***************************
                      >>> for line in make_fractal(2, 2, [' . ', '---']): print(line)
                                   .             
                                  ---            
                                .  .  .          
                               ---------         
                          .        .        .    
                         ---      ---      ---   
                       .  .  .  .  .  .  .  .  . 
                      ---------------------------
                      
                      def print_fractal(n, char='*'):
                          # Width of single triangle
                          base = 2*n - 1
                          
                          # Width of overall figure
                          width = base**2
                          
                          # Lines containing single triangle padded to rectangle of width `base`
                          lines = [f'{(2*line + 1)*char:^{base}}' for line in range(n)]
                          
                          for row in range(n):
                              # Print (2*row + 1) triangle blocks next to each other
                              for line in lines:
                                  print(f'{(2*row + 1)*line:^{width}}')
                      
                      >>> print_fractal(3)
                                  *            
                                 ***           
                                *****          
                             *    *    *       
                            ***  ***  ***      
                           ***************     
                        *    *    *    *    *  
                       ***  ***  ***  ***  *** 
                      *************************
                      
                      def make_fractal(n, depth, block=['*']):
                          if not depth:
                              return block
                          
                          width = (2*n - 1)*max(map(len, block))
                          
                          lines = []
                          
                          for row in range(n):
                              for line in block:
                                  lines.append(f'{(2*row + 1)*line:^{width}}')
                          
                          return make_fractal(n, depth - 1, lines)
                      
                      >>> for line in make_fractal(3, 2): print(line)
                                  *            
                                 ***           
                                *****          
                             *    *    *       
                            ***  ***  ***      
                           ***************     
                        *    *    *    *    *  
                       ***  ***  ***  ***  *** 
                      *************************
                      >>> for line in make_fractal(2, 3): print(line)
                                   *             
                                  ***            
                                *  *  *          
                               *********         
                          *        *        *    
                         ***      ***      ***   
                       *  *  *  *  *  *  *  *  * 
                      ***************************
                      >>> for line in make_fractal(2, 2, [' . ', '---']): print(line)
                                   .             
                                  ---            
                                .  .  .          
                               ---------         
                          .        .        .    
                         ---      ---      ---   
                       .  .  .  .  .  .  .  .  . 
                      ---------------------------
                      

                      Typescript Inheritance: Expanding base class object property

                      copy iconCopydownload iconDownload
                      class Wizard extends Human {
                        manaLevel: number
                        declare options: WizardOptions; // <-- declare
                        constructor() {
                          super()
                          this.manaLevel = 100
                          this.options.hat = "pointy" // <-- no problem now
                        }
                      }
                      
                      class Wizard extends Human {
                          manaLevel;
                          options; // <-- this will be here in JavaScript
                          constructor() {
                              super();
                              this.manaLevel = 100;
                              this.options.hat = "pointy";
                          }
                      }
                      
                      console.log(new Wizard()); // runtime error!
                      // this.options is undefined
                      
                      class Wizard extends Human {
                        manaLevel: number
                        declare options: WizardOptions; // <-- declare
                        constructor() {
                          super()
                          this.manaLevel = 100
                          this.options.hat = "pointy" // <-- no problem now
                        }
                      }
                      
                      class Wizard extends Human {
                          manaLevel;
                          options; // <-- this will be here in JavaScript
                          constructor() {
                              super();
                              this.manaLevel = 100;
                              this.options.hat = "pointy";
                          }
                      }
                      
                      console.log(new Wizard()); // runtime error!
                      // this.options is undefined
                      
                      class Wizard extends Human {
                        manaLevel: number
                        declare options: WizardOptions; // <-- declare
                        constructor() {
                          super()
                          this.manaLevel = 100
                          this.options.hat = "pointy" // <-- no problem now
                        }
                      }
                      
                      class Wizard extends Human {
                          manaLevel;
                          options; // <-- this will be here in JavaScript
                          constructor() {
                              super();
                              this.manaLevel = 100;
                              this.options.hat = "pointy";
                          }
                      }
                      
                      console.log(new Wizard()); // runtime error!
                      // this.options is undefined
                      
                      type HumanOptions = {
                        alive: boolean
                        age: number
                      }
                      
                      class Human<Options extends HumanOptions> {
                        id: string
                        options: Options
                      
                        constructor() {
                          this.id = '_' + Math.random()
                      
                          this.options = {
                            alive: true,
                            age: 25,
                          } as Options
                        }
                      }
                      
                      type WizardOptions = {
                        hat: string
                      } & HumanOptions
                      
                      class Wizard extends Human<WizardOptions> {
                        manaLevel: number
                      
                        constructor() {
                          super()
                          this.manaLevel = 100
                          this.options.hat = "pointy"
                        }
                      }
                      

                      Python 3.10 pattern matching (PEP 634) - wildcard in string

                      copy iconCopydownload iconDownload
                      for event in data:
                          match event:
                              case {'id': x} if x.startswith("matchme"): # guard
                                  print(event["message"])
                              case {'id':'anotherid'}:
                                  print(event["message"])
                      
                      match point:
                           case Point(x, y) if x == y:
                               print(f"The point is located on the diagonal Y=X at {x}.")
                           case Point(x, y):
                               print(f"Point is not on the diagonal.")
                      
                      for event in data:
                          match event:
                              case {'id': x} if x.startswith("matchme"): # guard
                                  print(event["message"])
                              case {'id':'anotherid'}:
                                  print(event["message"])
                      
                      match point:
                           case Point(x, y) if x == y:
                               print(f"The point is located on the diagonal Y=X at {x}.")
                           case Point(x, y):
                               print(f"Point is not on the diagonal.")
                      

                      See all related Code Snippets

                      Community Discussions

                      Trending Discussions on pattern
                      • ESlint - Error: Must use import to load ES Module
                      • Match ergonomics and &amp; pattern
                      • Repeatedly removing the maximum average subarray
                      • How to apply one signature test to multiple positionals
                      • Replacing whole string is faster than replacing only its first character
                      • Why doesn't GHC recognize the function as linear?
                      • Why is SFINAE for one of the std::basic_string constructors so restrictive?
                      • How to combine and then branch in MonadPlus/Alternative
                      • Where to put formatMsgNoLookups in the Log4j XML configuration file
                      • Repeating triangle pattern in Python
                      Trending Discussions on pattern

                      QUESTION

                      ESlint - Error: Must use import to load ES Module

                      Asked 2022-Mar-17 at 12:13

                      I am currently setting up a boilerplate with React, Typescript, styled components, webpack etc. and I am getting an error when trying to run eslint:

                      Error: Must use import to load ES Module

                      Here is a more verbose version of the error:

                      /Users/ben/Desktop/development projects/react-boilerplate-styled-context/src/api/api.ts
                        0:0  error  Parsing error: Must use import to load ES Module: /Users/ben/Desktop/development projects/react-boilerplate-styled-context/node_modules/eslint/node_modules/eslint-scope/lib/definition.js
                      require() of ES modules is not supported.
                      require() of /Users/ben/Desktop/development projects/react-boilerplate-styled-context/node_modules/eslint/node_modules/eslint-scope/lib/definition.js from /Users/ben/Desktop/development projects/react-boilerplate-styled-context/node_modules/babel-eslint/lib/require-from-eslint.js is an ES module file as it is a .js file whose nearest parent package.json contains "type": "module" which defines all .js files in that package scope as ES modules.
                      Instead rename definition.js to end in .cjs, change the requiring code to use import(), or remove "type": "module" from /Users/ben/Desktop/development projects/react-boilerplate-styled-context/node_modules/eslint/node_modules/eslint-scope/package.json
                      

                      The error occurs in every single one of my .js and .ts/ .tsx files where I only use import or the file doesn't even have an import at all. I understand what the error is saying but I have no idea why it is being thrown when in fact I only use imports or even no imports at all in some files.

                      Here is my package.json where I trigger the linter from using npm run lint:eslint:quiet:

                      {
                        "name": "my-react-boilerplate",
                        "version": "1.0.0",
                        "description": "",
                        "main": "index.tsx",
                        "directories": {
                          "test": "test"
                        },
                        "engines": {
                          "node": ">=14.0.0"
                        },
                        "type": "module",
                        "scripts": {
                          "build": "webpack --config webpack.prod.js",
                          "dev": "webpack serve --config webpack.dev.js",
                          "lint": "npm run typecheck && npm run lint:css && npm run lint:eslint:quiet",
                          "lint:css": "stylelint './src/**/*.{js,ts,tsx}'",
                          "lint:eslint:quiet": "eslint --ext .ts,.tsx,.js,.jsx  ./src --no-error-on-unmatched-pattern --quiet",
                          "lint:eslint": "eslint --ext .ts,.tsx,.js,.jsx  ./src --no-error-on-unmatched-pattern",
                          "lint:eslint:fix": "eslint --ext .ts,.tsx,.js,.jsx  ./src --no-error-on-unmatched-pattern --quiet --fix",
                          "test": "cross-env NODE_ENV=test jest --coverage",
                          "test:watch": "cross-env NODE_ENV=test jest --watchAll",
                          "typecheck": "tsc --noEmit",
                          "precommit": "npm run lint"
                        },
                        "lint-staged": {
                          "*.{ts,tsx,js,jsx}": [
                            "npm run lint:eslint:fix",
                            "git add --force"
                          ],
                          "*.{md,json}": [
                            "prettier --write",
                            "git add --force"
                          ]
                        },
                        "husky": {
                          "hooks": {
                            "pre-commit": "npx lint-staged && npm run typecheck"
                          }
                        },
                        "resolutions": {
                          "styled-components": "^5"
                        },
                        "author": "",
                        "license": "ISC",
                        "devDependencies": {
                          "@babel/core": "^7.5.4",
                          "@babel/plugin-proposal-class-properties": "^7.5.0",
                          "@babel/preset-env": "^7.5.4",
                          "@babel/preset-react": "^7.0.0",
                          "@types/history": "^4.7.6",
                          "@types/react": "^17.0.29",
                          "@types/react-dom": "^17.0.9",
                          "@types/react-router": "^5.1.17",
                          "@types/react-router-dom": "^5.1.5",
                          "@types/styled-components": "^5.1.15",
                          "@typescript-eslint/eslint-plugin": "^5.0.0",
                          "babel-cli": "^6.26.0",
                          "babel-eslint": "^10.0.2",
                          "babel-loader": "^8.0.0-beta.6",
                          "babel-polyfill": "^6.26.0",
                          "babel-preset-env": "^1.7.0",
                          "babel-preset-react": "^6.24.1",
                          "babel-preset-stage-2": "^6.24.1",
                          "clean-webpack-plugin": "^4.0.0",
                          "dotenv-webpack": "^7.0.3",
                          "error-overlay-webpack-plugin": "^1.0.0",
                          "eslint": "^8.0.0",
                          "eslint-config-airbnb": "^18.2.0",
                          "eslint-config-prettier": "^8.3.0",
                          "eslint-config-with-prettier": "^6.0.0",
                          "eslint-plugin-compat": "^3.3.0",
                          "eslint-plugin-import": "^2.25.2",
                          "eslint-plugin-jsx-a11y": "^6.2.3",
                          "eslint-plugin-prettier": "^4.0.0",
                          "eslint-plugin-react": "^7.14.2",
                          "eslint-plugin-react-hooks": "^4.2.0",
                          "extract-text-webpack-plugin": "^3.0.2",
                          "file-loader": "^6.2.0",
                          "html-webpack-plugin": "^5.3.2",
                          "husky": "^7.0.2",
                          "prettier": "^2.4.1",
                          "raw-loader": "^4.0.2",
                          "style-loader": "^3.3.0",
                          "stylelint": "^13.13.1",
                          "stylelint-config-recommended": "^5.0.0",
                          "stylelint-config-styled-components": "^0.1.1",
                          "stylelint-processor-styled-components": "^1.10.0",
                          "ts-loader": "^9.2.6",
                          "tslint": "^6.1.3",
                          "typescript": "^4.4.4",
                          "url-loader": "^4.1.1",
                          "webpack": "^5.58.2",
                          "webpack-cli": "^4.2.0",
                          "webpack-dev-server": "^4.3.1",
                          "webpack-merge": "^5.3.0"
                        },
                        "dependencies": {
                          "history": "^4.10.0",
                          "process": "^0.11.10",
                          "react": "^17.0.1",
                          "react-dom": "^17.0.1",
                          "react-router-dom": "^5.2.0",
                          "styled-components": "^5.2.1"
                        }
                      }
                      

                      Here is my .eslintrc file:

                      {
                        "extends": ["airbnb", "prettier"],
                        "parser": "babel-eslint",
                        "plugins": ["prettier", "@typescript-eslint"],
                        "parserOptions": {
                          "ecmaVersion": 8,
                          "ecmaFeatures": {
                            "experimentalObjectRestSpread": true,
                            "impliedStrict": true,
                            "classes": true
                          }
                        },
                        "env": {
                          "browser": true,
                          "node": true,
                          "jest": true
                        },
                        "rules": {
                          "arrow-body-style": ["error", "as-needed"],
                          "class-methods-use-this": 0,
                          "react/jsx-filename-extension": 0,
                          "global-require": 0,
                          "react/destructuring-assignment": 0,
                          "import/named": 2,
                          "linebreak-style": 0,
                          "import/no-dynamic-require": 0,
                          "import/no-named-as-default": 0,
                          "import/no-unresolved": 2,
                          "import/prefer-default-export": 0,
                          "semi": [2, "always"],
                          "max-len": [
                            "error",
                            {
                              "code": 80,
                              "ignoreUrls": true,
                              "ignoreComments": true,
                              "ignoreStrings": true,
                              "ignoreTemplateLiterals": true
                            }
                          ],
                          "new-cap": [
                            2,
                            {
                              "capIsNew": false,
                              "newIsCap": true
                            }
                          ],
                          "no-param-reassign": 0,
                          "no-shadow": 0,
                          "no-tabs": 2,
                          "no-underscore-dangle": 0,
                          "react/forbid-prop-types": [
                            "error",
                            {
                              "forbid": ["any"]
                            }
                          ],
                          "import/no-extraneous-dependencies": ["error", { "devDependencies": true }],
                          "react/jsx-no-bind": [
                            "error",
                            {
                              "ignoreRefs": true,
                              "allowArrowFunctions": true,
                              "allowBind": false
                            }
                          ],
                          "react/no-unknown-property": [
                            2,
                            {
                              "ignore": ["itemscope", "itemtype", "itemprop"]
                            }
                          ]
                        }
                      }
                      

                      And i'm not sure if relevant but also my tsconfig.eslint.json file:

                      {
                        "extends": "./tsconfig.json",
                        "include": ["./src/**/*.ts", "./src/**/*.tsx", "./src/**/*.js"],
                        "exclude": ["node_modules/**", "build/**", "coverage/**"]
                      }
                      

                      Not sure if anyone has come across this before? Googling the error does not present any useful forums or raised bugs, most of them just state not to use require in your files which I am not.

                      ANSWER

                      Answered 2022-Mar-15 at 16:08

                      I think the problem is that you are trying to use the deprecated babel-eslint parser, last updated a year ago, which looks like it doesn't support ES6 modules. Updating to the latest parser seems to work, at least for simple linting.

                      So, do this:

                      • In package.json, update the line "babel-eslint": "^10.0.2", to "@babel/eslint-parser": "^7.5.4",. This works with the code above but it may be better to use the latest version, which at the time of writing is 7.16.3.
                      • Run npm i from a terminal/command prompt in the folder
                      • In .eslintrc, update the parser line "parser": "babel-eslint", to "parser": "@babel/eslint-parser",
                      • In .eslintrc, add "requireConfigFile": false, to the parserOptions section (underneath "ecmaVersion": 8,) (I needed this or babel was looking for config files I don't have)
                      • Run the command to lint a file

                      Then, for me with just your two configuration files, the error goes away and I get appropriate linting errors.

                      Source https://stackoverflow.com/questions/69554485

                      Community Discussions, Code Snippets contain sources that include Stack Exchange Network

                      Vulnerabilities

                      No vulnerabilities reported

                      Install pattern

                      You can download it from GitHub.
                      You can use pattern like any standard Java library. Please include the the jar files in your classpath. You can also use any IDE and you can run and debug the pattern component as you would do with any other Java program. Best practice is to use a build tool that supports dependency management such as Maven or Gradle. For Maven installation, please refer maven.apache.org. For Gradle installation, please refer gradle.org .

                      Support

                      The best way to report an issue is to add a new test to SimplePMMLPlatformTest along with the expected result set and submit a pull request on GitHub. Failing that, feel free to open an issue on the Cascading/Pattern project site or mail the mailing list.

                      DOWNLOAD this Library from

                      Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from
                      over 430 million Knowledge Items
                      Find more libraries
                      Reuse Solution Kits and Libraries Curated by Popular Use Cases
                      Explore Kits

                      Save this library and start creating your kit

                      Share this Page

                      share link
                      Consider Popular Machine Learning Libraries
                      Try Top Libraries by Cascading
                      Compare Machine Learning Libraries with Highest Support
                      Compare Machine Learning Libraries with Highest Quality
                      Compare Machine Learning Libraries with Highest Security
                      Compare Machine Learning Libraries with Permissive License
                      Compare Machine Learning Libraries with Highest Reuse
                      Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from
                      over 430 million Knowledge Items
                      Find more libraries
                      Reuse Solution Kits and Libraries Curated by Popular Use Cases
                      Explore Kits

                      Save this library and start creating your kit

                      • © 2022 Open Weaver Inc.