Skip to main content
deleted 9 characters in body; deleted 6 characters in body
Source Link
dana
  • 2.7k
  • 1
  • 15
  • 11

C# (Visual C# Interactive Compiler), 120115 bytes

s=>s[0]==s[^1]&s=>!s[..^1]s.Where((c,i)=>i<s=>i<1?c!=s[^1]:i>s.IndexOfLastIndexOf(s.Max())?c>=s[i+1]c>=s[i-1]:i<si>s.LastIndexOfIndexOf(s.Max())?s.Max()!=c:c<=s[i+1]c<=s[i-1]).Any()

Try it online!Try it online!

Here is an overview of how this works...

  1. Input is in the form of a string
  2. Find the largest digit
  3. Ensure the first and last digits are the same
  4. Ensure digits after the last occurrence of the largest digit are decreasing
  5. Ensure digits between the first and last occurrence of the largest digit are equal to the largest digit
  6. Ensure digits before the first occurrence of the largest digit are increasing

C# (Visual C# Interactive Compiler), 120 bytes

s=>s[0]==s[^1]&!s[..^1].Where((c,i)=>i<s.IndexOf(s.Max())?c>=s[i+1]:i<s.LastIndexOf(s.Max())?s.Max()!=c:c<=s[i+1]).Any()

Try it online!

Here is an overview of how this works...

  1. Input is in the form of a string
  2. Find the largest digit
  3. Ensure the first and last digits are the same
  4. Ensure digits after the last occurrence of the largest digit are decreasing
  5. Ensure digits between the first and last occurrence of the largest digit are equal to the largest digit
  6. Ensure digits before the first occurrence of the largest digit are increasing

C# (Visual C# Interactive Compiler), 115 bytes

s=>!s.Where((c,i)=>i<1?c!=s[^1]:i>s.LastIndexOf(s.Max())?c>=s[i-1]:i>s.IndexOf(s.Max())?s.Max()!=c:c<=s[i-1]).Any()

Try it online!

Here is an overview of how this works...

  1. Input is in the form of a string
  2. Find the largest digit
  3. Ensure the first and last digits are the same
  4. Ensure digits after the last occurrence of the largest digit are decreasing
  5. Ensure digits between the first and last occurrence of the largest digit are equal to the largest digit
  6. Ensure digits before the first occurrence of the largest digit are increasing
deleted 35 characters in body; deleted 2 characters in body
Source Link
dana
  • 2.7k
  • 1
  • 15
  • 11

C# (Visual C# Interactive Compiler), 137120 bytes

s=>s[0]==s[^1]&Enumerables=>s[0]==s[^1]&!s[.Range(1,s.Length-1)^1].AllWhere(i=>i>s(c,i)=>i<s.LastIndexOfIndexOf(s.Max())?s[i-1]>s[i]c>=s[i+1]:i>si<s.IndexOfLastIndexOf(s.Max())?s.Max()==s[i]!=c:s[i-1]<s[i]c<=s[i+1]).Any()

Try it online!Try it online!

Here is an overview of how this works...

  1. Input is in the form of a string
  2. Find the largest digit
  3. Ensure the first and last digits are the same
  4. Ensure digits after the last occurrence of the largest digit are decreasing
  5. Ensure digits between the first and last occurrence of the largest digit are equal to the largest digit
  6. Ensure digits before the first occurrence of the largest digit are increasing

C# (Visual C# Interactive Compiler), 137 bytes

s=>s[0]==s[^1]&Enumerable.Range(1,s.Length-1).All(i=>i>s.LastIndexOf(s.Max())?s[i-1]>s[i]:i>s.IndexOf(s.Max())?s.Max()==s[i]:s[i-1]<s[i])

Try it online!

Here is an overview of how this works...

  1. Input is in the form of a string
  2. Find the largest digit
  3. Ensure the first and last digits are the same
  4. Ensure digits after the last occurrence of the largest digit are decreasing
  5. Ensure digits between the first and last occurrence of the largest digit are equal to the largest digit
  6. Ensure digits before the first occurrence of the largest digit are increasing

C# (Visual C# Interactive Compiler), 120 bytes

s=>s[0]==s[^1]&!s[..^1].Where((c,i)=>i<s.IndexOf(s.Max())?c>=s[i+1]:i<s.LastIndexOf(s.Max())?s.Max()!=c:c<=s[i+1]).Any()

Try it online!

Here is an overview of how this works...

  1. Input is in the form of a string
  2. Find the largest digit
  3. Ensure the first and last digits are the same
  4. Ensure digits after the last occurrence of the largest digit are decreasing
  5. Ensure digits between the first and last occurrence of the largest digit are equal to the largest digit
  6. Ensure digits before the first occurrence of the largest digit are increasing
deleted 59 characters in body
Source Link
dana
  • 2.7k
  • 1
  • 15
  • 11

C# (Visual C# Interactive Compiler), 161137 bytes

s=>{var m=s.OrderBy(c=>c).Last();return s[0]==s.Last()&Enumerables=>s[0]==s[^1]&Enumerable.Range(1,s.Length-1).All(i=>i>s.LastIndexOf(ms.Max())?s[i-1]>s[i]:i>s.IndexOf(ms.Max())?m==s[i]s.Max()==s[i]:s[i-1]<s[i]);}

Try it online!Try it online!

Here is an overview of how this works...

  1. Input is in the form of a string
  2. Find the largest digit
  3. Ensure the first and last digits are the same
  4. Ensure digits after the last occurrence of the largest digit are decreasing
  5. Ensure digits between the first and last occurrence of the largest digit are equal to the largest digit
  6. Ensure digits before the first occurrence of the largest digit are increasing

C# (Visual C# Interactive Compiler), 161 bytes

s=>{var m=s.OrderBy(c=>c).Last();return s[0]==s.Last()&Enumerable.Range(1,s.Length-1).All(i=>i>s.LastIndexOf(m)?s[i-1]>s[i]:i>s.IndexOf(m)?m==s[i]:s[i-1]<s[i]);}

Try it online!

Here is an overview of how this works...

  1. Input is in the form of a string
  2. Find the largest digit
  3. Ensure the first and last digits are the same
  4. Ensure digits after the last occurrence of the largest digit are decreasing
  5. Ensure digits between the first and last occurrence of the largest digit are equal to the largest digit
  6. Ensure digits before the first occurrence of the largest digit are increasing

C# (Visual C# Interactive Compiler), 137 bytes

s=>s[0]==s[^1]&Enumerable.Range(1,s.Length-1).All(i=>i>s.LastIndexOf(s.Max())?s[i-1]>s[i]:i>s.IndexOf(s.Max())?s.Max()==s[i]:s[i-1]<s[i])

Try it online!

Here is an overview of how this works...

  1. Input is in the form of a string
  2. Find the largest digit
  3. Ensure the first and last digits are the same
  4. Ensure digits after the last occurrence of the largest digit are decreasing
  5. Ensure digits between the first and last occurrence of the largest digit are equal to the largest digit
  6. Ensure digits before the first occurrence of the largest digit are increasing
deleted 16 characters in body
Source Link
dana
  • 2.7k
  • 1
  • 15
  • 11
Loading
added 15 characters in body
Source Link
dana
  • 2.7k
  • 1
  • 15
  • 11
Loading
Source Link
dana
  • 2.7k
  • 1
  • 15
  • 11
Loading