Skip to main content
We’ve updated our Terms of Service. A new AI Addendum clarifies how Stack Overflow utilizes AI interactions.
Code Golf

Return to Answer

added 299 characters in body
Source Link
Neil
  • 184.4k
  • 12
  • 76
  • 290

Retina 0.8.2, (削除) 42 (削除ここまで) 34 bytes

r`(?<-1>.)+(?<=(\w\w)+),
,
D`\w
,$

Try it online! Link includes test cases. Explanation:

r`(?<-1>.)+(?<=(\w\w)+),
,

Delete 1 character for every pairThe r modifier causes the regex to be processed from right to left, so that the , is matched first, before the lookbehind then matches as many pairs of letters as possible. .NET captures each matching pair into a stack of values for capture group 1. The balancing group then matches once for each value in the stack, starting atthus deleting 1 character from the end of eachthe row and working backwardsfor every pair of letters.

D`\w

Remove all duplicate letters.

,$

Check that no letters of S remain.

Retina 0.8.2, (削除) 42 (削除ここまで) 34 bytes

r`(?<-1>.)+(?<=(\w\w)+),
,
D`\w
,$

Try it online! Link includes test cases. Explanation:

r`(?<-1>.)+(?<=(\w\w)+),
,

Delete 1 character for every pair of letters, starting at the end of each row and working backwards.

D`\w

Remove all duplicate letters.

,$

Check that no letters of S remain.

Retina 0.8.2, (削除) 42 (削除ここまで) 34 bytes

r`(?<-1>.)+(?<=(\w\w)+),
,
D`\w
,$

Try it online! Link includes test cases. Explanation:

r`(?<-1>.)+(?<=(\w\w)+),
,

The r modifier causes the regex to be processed from right to left, so that the , is matched first, before the lookbehind then matches as many pairs of letters as possible. .NET captures each matching pair into a stack of values for capture group 1. The balancing group then matches once for each value in the stack, thus deleting 1 character from the end of the row for every pair of letters.

D`\w

Remove all duplicate letters.

,$

Check that no letters of S remain.

added 582 characters in body
Source Link
Neil
  • 184.4k
  • 12
  • 76
  • 290

Retina Retina 0.8.2, 42(削除) 42 (削除ここまで) 34 bytes

~(r`(?<-1>.)+(?<=(\w\w)+),
,
\w+$
]+$
^D`\w
,[$

Try it online! Try it online! Link includes test cases. Explanation:

r`(?<-1>.)+(?<=(\w\w)+),
,

Delete 1 character for every pair of letters, starting at the end of each row and working backwards.

\w+$
]+$
^
,[D`\w

Remove the string S and wrap the halved keyboard in ,[ and ]+$all duplicate letters.

~(`,$

Evaluate the result as a regex and applyCheck that to the original inputno letters of S remain.

Retina, 42 bytes

~(r`(?<-1>.)+(?<=(\w\w)+),
,
\w+$
]+$
^
,[

Try it online! Link includes test cases. Explanation:

r`(?<-1>.)+(?<=(\w\w)+),
,

Delete 1 character for every pair of letters, starting at the end of each row and working backwards.

\w+$
]+$
^
,[

Remove the string S and wrap the halved keyboard in ,[ and ]+$.

~(`

Evaluate the result as a regex and apply that to the original input.

Retina 0.8.2, (削除) 42 (削除ここまで) 34 bytes

r`(?<-1>.)+(?<=(\w\w)+),
,
D`\w
,$

Try it online! Link includes test cases. Explanation:

r`(?<-1>.)+(?<=(\w\w)+),
,

Delete 1 character for every pair of letters, starting at the end of each row and working backwards.

D`\w

Remove all duplicate letters.

,$

Check that no letters of S remain.

Source Link
Neil
  • 184.4k
  • 12
  • 76
  • 290

Retina, 42 bytes

~(r`(?<-1>.)+(?<=(\w\w)+),
,
\w+$
]+$
^
,[

Try it online! Link includes test cases. Explanation:

r`(?<-1>.)+(?<=(\w\w)+),
,

Delete 1 character for every pair of letters, starting at the end of each row and working backwards.

\w+$
]+$
^
,[

Remove the string S and wrap the halved keyboard in ,[ and ]+$.

~(`

Evaluate the result as a regex and apply that to the original input.

AltStyle によって変換されたページ (->オリジナル) /