Skip to main content
deleted 130 characters in body
Source Link
miles
  • 17.3k
  • 2
  • 31
  • 95

Jelly, 44 5 bytes

Ṣm0wṢm0ẇ@ 

Try it online!Try it online!

Returns the indexOriginally was (1-based) of the first match in the concatenation of the sorted and reverse sorted, otherwise returns 0. In Jelly, zero is considered falsey and non-zero is truthyṢm0w at four bytes.

Explanation

Ṣm0wṢm0ẇ@ Input: string S Ṣ  Sort S m0  Concatenate sort(S) with reverse(sort(S)) wẇ@ FindSublist theexists? firstCheck indexif thatS containsis S,contained elsein 0the previous result 

Jelly, 4 bytes

Ṣm0w 

Try it online!

Returns the index (1-based) of the first match in the concatenation of the sorted and reverse sorted, otherwise returns 0. In Jelly, zero is considered falsey and non-zero is truthy.

Explanation

Ṣm0w Input: string S Ṣ Sort S m0 Concatenate sort(S) with reverse(sort(S)) w Find the first index that contains S, else 0 

Jelly, 4 5 bytes

Ṣm0ẇ@ 

Try it online!

Originally was Ṣm0w at four bytes.

Explanation

Ṣm0ẇ@ Input: string S Ṣ  Sort S m0  Concatenate sort(S) with reverse(sort(S)) ẇ@ Sublist exists? Check if S is contained in the previous result 
Source Link
miles
  • 17.3k
  • 2
  • 31
  • 95

Jelly, 4 bytes

Ṣm0w 

Try it online!

Returns the index (1-based) of the first match in the concatenation of the sorted and reverse sorted, otherwise returns 0. In Jelly, zero is considered falsey and non-zero is truthy.

Explanation

Ṣm0w Input: string S Ṣ Sort S m0 Concatenate sort(S) with reverse(sort(S)) w Find the first index that contains S, else 0