Skip to main content
Golfed 10 bytes
Source Link
AdmBorkBork
  • 43.5k
  • 5
  • 103
  • 284

PowerShell, 108 100 9595 85 Bytes

$i,$z=$args;$b,$s=[char[]]$z;($b+$z=$args;($z[0]+($i-split'[^\d.-]+'-ne'')-join$sjoin$z[1])+' }) >]'[($b$z[0]-32)%6]).Trim()

A slight variation(see revision history for previous versions)

Golfed another 15 bytes by removing $b and $s variables and changing parens on the below, thanks to TessellatingHecklerinner string. 

This takes the two arguments as input toas two strings and stores them into $i and $z, then casts $z aswe construct a char-array and pulls the two arguments out intonew output string. The inner parens $b-split ands $s$i. We with a regex to select only numeric digits, then concatenate $b-joins back together with $i having been split on digits and negativesthe requested delimiter. We concatenate that existwith the first character of the delimiter input (i.e.g., -ne''[). That gets -joined and close it with the same indexing, into a string based on the ASCII value of the first character and finallysome formulation trickery. The outer .Trim() to removeremoves any leading/trailing or trailing spaces.


###Old:

param($a,$b)($b[0]+(-split($a-replace"[\[\]{}()<>;,]",' ')-join$b[1])+' }) >]'[($b[0]-32)%6]).Trim()

Pretty similar to the other answers, just with PowerShell's verbose unique syntax.

###Explained:

  • Takes input as two strings via param($a,$b), then builds the output string via everything inside the parens ().
  • We first use the first character of $b with $b[0], add that to another parens-separated dynamically built string, and then add that to the closing character.
  • The closing character is selected by indexing into a string based on a formula of ($b[0]-32)%6 - thanks to Danko Durbić for golfing 8 bytes here).
  • The inner-parens string is constructed by simply getting rid of any input junk with a regex and -replaceing it with a space, -splitting that on spaces to create an array, and -joining that array together with the second character of $b.
  • Finally, the trailing .Trim() removes any remaining leading or trailing spaces.

PowerShell, 108 100 95 Bytes

$i,$z=$args;$b,$s=[char[]]$z;($b+(($i-split'[^\d.-]+'-ne'')-join$s)+' }) >]'[($b-32)%6]).Trim()

A slight variation on the below, thanks to TessellatingHeckler. This takes the two arguments as input to $i and $z, then casts $z as a char-array and pulls the two arguments out into $b and $s. We then concatenate $b with $i having been split on digits and negatives that exist (i.e., -ne''). That gets -joined with the same indexing, and finally .Trim() to remove leading/trailing spaces.


###Old:

param($a,$b)($b[0]+(-split($a-replace"[\[\]{}()<>;,]",' ')-join$b[1])+' }) >]'[($b[0]-32)%6]).Trim()

Pretty similar to the other answers, just with PowerShell's verbose unique syntax.

###Explained:

  • Takes input as two strings via param($a,$b), then builds the output string via everything inside the parens ().
  • We first use the first character of $b with $b[0], add that to another parens-separated dynamically built string, and then add that to the closing character.
  • The closing character is selected by indexing into a string based on a formula of ($b[0]-32)%6 - thanks to Danko Durbić for golfing 8 bytes here).
  • The inner-parens string is constructed by simply getting rid of any input junk with a regex and -replaceing it with a space, -splitting that on spaces to create an array, and -joining that array together with the second character of $b.
  • Finally, the trailing .Trim() removes any remaining leading or trailing spaces.

PowerShell, 108 100 95 85 Bytes

$i,$z=$args;($z[0]+($i-split'[^\d.-]+'-ne''-join$z[1])+' }) >]'[($z[0]-32)%6]).Trim()

(see revision history for previous versions)

Golfed another 15 bytes by removing $b and $s variables and changing parens on the inner string. 

This takes input as two strings and stores them into $i and $z, then we construct a new output string. The inner parens -splits $i with a regex to select only numeric digits, then -joins back together with the requested delimiter. We concatenate that with the first character of the delimiter input (e.g., [) and close it with indexing into a string based on the ASCII value of the first character and some formulation trickery. The outer .Trim() removes any leading or trailing spaces.

Thanks to TessellatingHeckler for golf
Source Link
AdmBorkBork
  • 43.5k
  • 5
  • 103
  • 284

PowerShell, 108 100100 95 Bytes

$i,$z=$args;$b,$s=[char[]]$z;($b+(($i-split'[^\d.-]+'-ne'')-join$s)+' }) >]'[($b-32)%6]).Trim()

A slight variation on the below, thanks to TessellatingHeckler. This takes the two arguments as input to $i and $z, then casts $z as a char-array and pulls the two arguments out into $b and $s. We then concatenate $b with $i having been split on digits and negatives that exist (i.e., -ne''). That gets -joined with the same indexing, and finally .Trim() to remove leading/trailing spaces.


###Old:

param($a,$b)($b[0]+(-split($a-replace"[\[\]{}()<>;,]",' ')-join$b[1])+' }) >]'[($b[0]-32)%6]).Trim()

Pretty similar to the other answers, just with PowerShell's verbose unique syntax.

###Explained:

  • Takes input as two strings via param($a,$b), then builds the output string via everything inside the parens ().
  • We first use the first character of $b with $b[0], add that to another parens-separated dynamically built string, and then add that to the closing character.
  • The closing character is selected by indexing into a string based on a formula of ($b[0]-32)%6 - thanks to Danko Durbić for golfing 8 bytes here).
  • The inner-parens string is constructed by simply getting rid of any input junk with a regex and -replaceing it with a space, -splitting that on spaces to create an array, and -joining that array together with the second character of $b.
  • Finally, the trailing .Trim() removes any remaining leading or trailing spaces.

PowerShell, 108 100 Bytes

param($a,$b)($b[0]+(-split($a-replace"[\[\]{}()<>;,]",' ')-join$b[1])+' }) >]'[($b[0]-32)%6]).Trim()

Pretty similar to the other answers, just with PowerShell's verbose unique syntax.

###Explained:

  • Takes input as two strings via param($a,$b), then builds the output string via everything inside the parens ().
  • We first use the first character of $b with $b[0], add that to another parens-separated dynamically built string, and then add that to the closing character.
  • The closing character is selected by indexing into a string based on a formula of ($b[0]-32)%6 - thanks to Danko Durbić for golfing 8 bytes here).
  • The inner-parens string is constructed by simply getting rid of any input junk with a regex and -replaceing it with a space, -splitting that on spaces to create an array, and -joining that array together with the second character of $b.
  • Finally, the trailing .Trim() removes any remaining leading or trailing spaces.

PowerShell, 108 100 95 Bytes

$i,$z=$args;$b,$s=[char[]]$z;($b+(($i-split'[^\d.-]+'-ne'')-join$s)+' }) >]'[($b-32)%6]).Trim()

A slight variation on the below, thanks to TessellatingHeckler. This takes the two arguments as input to $i and $z, then casts $z as a char-array and pulls the two arguments out into $b and $s. We then concatenate $b with $i having been split on digits and negatives that exist (i.e., -ne''). That gets -joined with the same indexing, and finally .Trim() to remove leading/trailing spaces.


###Old:

param($a,$b)($b[0]+(-split($a-replace"[\[\]{}()<>;,]",' ')-join$b[1])+' }) >]'[($b[0]-32)%6]).Trim()

Pretty similar to the other answers, just with PowerShell's verbose unique syntax.

###Explained:

  • Takes input as two strings via param($a,$b), then builds the output string via everything inside the parens ().
  • We first use the first character of $b with $b[0], add that to another parens-separated dynamically built string, and then add that to the closing character.
  • The closing character is selected by indexing into a string based on a formula of ($b[0]-32)%6 - thanks to Danko Durbić for golfing 8 bytes here).
  • The inner-parens string is constructed by simply getting rid of any input junk with a regex and -replaceing it with a space, -splitting that on spaces to create an array, and -joining that array together with the second character of $b.
  • Finally, the trailing .Trim() removes any remaining leading or trailing spaces.
Golfed 8 bytes thanks to Danko Durbić
Source Link
AdmBorkBork
  • 43.5k
  • 5
  • 103
  • 284

PowerShell, 108108 100 Bytes

param($a,$b)($b[0]+(-split($a-replace"[\[\]{}()<>;,]",' ')-join$b[1])+"]+' })>"["[{(< ".IndexOf>]'[($b[0]-32)]%6]).Trim()

Pretty similar to the other answers, just with PowerShell's verbose unique syntax.

###Explained:

  • Takes input as two strings via param($a,$b), then builds the output string via everything inside the parens ().
  • We first use the first character of $b with $b[0], add that to another parens-separated dynamically built string, and then add that to the closing character (which.
  • The closing character is selected by indexing into a string based on the index of $b[0] into another string).
  • We exploit the fact that strings can be indexed like an array, but without triggering "Array index outa formula of bounds" exceptions, so that the .IndexOf($b[0]-32)%6 doesn't return -1 if the "bracket" character is a space. That's why the "closing brackets" string is length-4, while the "indexing" string is length-5 thanks to Danko Durbić for golfing 8 bytes here).
  • The inner-parens string is constructed by simply getting rid of any input junk with a regex and -replaceing it with a space, -splitting that on spaces to create an array, and -joining that array together with the second character of $b.
  • Finally, the trailing .Trim() removes any remaining leading or trailing spaces.

PowerShell, 108 Bytes

param($a,$b)($b[0]+(-split($a-replace"[\[\]{}()<>;,]",' ')-join$b[1])+"]})>"["[{(< ".IndexOf($b[0])]).Trim()

Pretty similar to the other answers, just with PowerShell's verbose unique syntax.

###Explained:

  • Takes input as two strings via param($a,$b), then builds the output string via everything inside the parens ().
  • We first use the first character of $b with $b[0], add that to another parens-separated dynamically built string, and then add that to the closing character (which is selected by indexing into a string based on the index of $b[0] into another string).
  • We exploit the fact that strings can be indexed like an array, but without triggering "Array index out of bounds" exceptions, so that the .IndexOf() doesn't return -1 if the "bracket" character is a space. That's why the "closing brackets" string is length-4, while the "indexing" string is length-5.
  • The inner-parens string is constructed by simply getting rid of any input junk with a regex and -replaceing it with a space, -splitting that on spaces to create an array, and -joining that array together with the second character of $b.
  • Finally, the trailing .Trim() removes any remaining leading or trailing spaces.

PowerShell, 108 100 Bytes

param($a,$b)($b[0]+(-split($a-replace"[\[\]{}()<>;,]",' ')-join$b[1])+' }) >]'[($b[0]-32)%6]).Trim()

Pretty similar to the other answers, just with PowerShell's verbose unique syntax.

###Explained:

  • Takes input as two strings via param($a,$b), then builds the output string via everything inside the parens ().
  • We first use the first character of $b with $b[0], add that to another parens-separated dynamically built string, and then add that to the closing character.
  • The closing character is selected by indexing into a string based on a formula of ($b[0]-32)%6 - thanks to Danko Durbić for golfing 8 bytes here).
  • The inner-parens string is constructed by simply getting rid of any input junk with a regex and -replaceing it with a space, -splitting that on spaces to create an array, and -joining that array together with the second character of $b.
  • Finally, the trailing .Trim() removes any remaining leading or trailing spaces.
Source Link
AdmBorkBork
  • 43.5k
  • 5
  • 103
  • 284
Loading