6 replaced http://cs.stackexchange.com/ with https://cs.stackexchange.com/
source | link

This was inspired by a now removed CS.SE questionnow removed CS.SE question.

Task

Given two non-empty input strings A and B, output the smallest distance from A to a palindrome that contains B as a substring. Distance is defined by the number of character replacements (Hamming distance).

Restrictions

  • Sensible input: a palindrome exists. This means |A| ≥ |B|.
  • A and B contain only lower ASCII characters, lowercase and uppercase are distinct (as are all other characters).
  • If your language cannot deal with ASCII characters, you may use integers (or some other reasonable data type) as well, and you may choose to limit the range to 128 elements.
  • You may take input from stdin, function arguments, command line arguments, etc.
  • You may give the result on stdout, return value, etc.
  • You do not need to give a working palindrome, the smallest distance to one is sufficient.

Examples

A                   B            Output
thilloaoyreot       hello        4 (thelloaolleht)
benjonson           stack        9 (stackcats)
neversaynever!      odd          9 (neveroddoreven)
ppcggcpp            gg           0 (ppcggcpp)
stars               tat          1 (stats)

Scoring

This is code golf, shortest code in bytes wins.

This was inspired by a now removed CS.SE question.

Task

Given two non-empty input strings A and B, output the smallest distance from A to a palindrome that contains B as a substring. Distance is defined by the number of character replacements (Hamming distance).

Restrictions

  • Sensible input: a palindrome exists. This means |A| ≥ |B|.
  • A and B contain only lower ASCII characters, lowercase and uppercase are distinct (as are all other characters).
  • If your language cannot deal with ASCII characters, you may use integers (or some other reasonable data type) as well, and you may choose to limit the range to 128 elements.
  • You may take input from stdin, function arguments, command line arguments, etc.
  • You may give the result on stdout, return value, etc.
  • You do not need to give a working palindrome, the smallest distance to one is sufficient.

Examples

A                   B            Output
thilloaoyreot       hello        4 (thelloaolleht)
benjonson           stack        9 (stackcats)
neversaynever!      odd          9 (neveroddoreven)
ppcggcpp            gg           0 (ppcggcpp)
stars               tat          1 (stats)

Scoring

This is code golf, shortest code in bytes wins.

This was inspired by a now removed CS.SE question.

Task

Given two non-empty input strings A and B, output the smallest distance from A to a palindrome that contains B as a substring. Distance is defined by the number of character replacements (Hamming distance).

Restrictions

  • Sensible input: a palindrome exists. This means |A| ≥ |B|.
  • A and B contain only lower ASCII characters, lowercase and uppercase are distinct (as are all other characters).
  • If your language cannot deal with ASCII characters, you may use integers (or some other reasonable data type) as well, and you may choose to limit the range to 128 elements.
  • You may take input from stdin, function arguments, command line arguments, etc.
  • You may give the result on stdout, return value, etc.
  • You do not need to give a working palindrome, the smallest distance to one is sufficient.

Examples

A                   B            Output
thilloaoyreot       hello        4 (thelloaolleht)
benjonson           stack        9 (stackcats)
neversaynever!      odd          9 (neveroddoreven)
ppcggcpp            gg           0 (ppcggcpp)
stars               tat          1 (stats)

Scoring

This is code golf, shortest code in bytes wins.

5 added 48 characters in body
source | link

This was inspired by a now removed CS.SE question.

Task

Given two non-empty input strings A and B, output the smallest distance from A to a palindrome that contains B as a substring. Distance is defined by the number of character replacements (Hamming distance).

Restrictions

  • Sensible input: a palindrome exists. This means |A| ≥ |B|.
  • A and B contain only lower ASCII characters, lowercase and uppercase are distinct (as are all other characters).
  • If your language cannot deal with ASCII characters, you may use integers (or some other reasonable data type) as well, and you may choose to limit the range to 128 elements.
  • You may take input from stdin, function arguments, command line arguments, etc.
  • You may give the result on stdout, return value, etc.
  • You do not need to give a working palindrome, the smallest distance to one is sufficient.

Examples

A                   B            Output
thilloaoyreot       hello        4 (thelloaolleht)
benjonson           stack        9 (stackcats)
neversaynever!      odd          9 (neveroddoreven)
ppcggcpp            gg           0 (ppcggcpp)
stars               tat          1 (stats)

Scoring

This is code golf, shortest code in bytes wins.

This was inspired by a now removed CS.SE question.

Task

Given two non-empty input strings A and B, output the smallest distance from A to a palindrome that contains B as a substring. Distance is defined by the number of character replacements (Hamming distance).

Restrictions

  • Sensible input: a palindrome exists. This means |A| ≥ |B|.
  • A and B contain only lower ASCII characters, lowercase and uppercase are distinct (as are all other characters).
  • If your language cannot deal with ASCII characters, you may use integers (or some other reasonable data type) as well, and you may choose to limit the range to 128 elements.
  • You may take input from stdin, function arguments, command line arguments, etc.
  • You may give the result on stdout, return value, etc.
  • You do not need to give a working palindrome, the smallest distance to one is sufficient.

Examples

A                   B            Output
thilloaoyreot       hello        4 (thelloaolleht)
benjonson           stack        9 (stackcats)
neversaynever!      odd          9 (neveroddoreven)
ppcggcpp            gg           0 (ppcggcpp)

Scoring

This is code golf, shortest code in bytes wins.

This was inspired by a now removed CS.SE question.

Task

Given two non-empty input strings A and B, output the smallest distance from A to a palindrome that contains B as a substring. Distance is defined by the number of character replacements (Hamming distance).

Restrictions

  • Sensible input: a palindrome exists. This means |A| ≥ |B|.
  • A and B contain only lower ASCII characters, lowercase and uppercase are distinct (as are all other characters).
  • If your language cannot deal with ASCII characters, you may use integers (or some other reasonable data type) as well, and you may choose to limit the range to 128 elements.
  • You may take input from stdin, function arguments, command line arguments, etc.
  • You may give the result on stdout, return value, etc.
  • You do not need to give a working palindrome, the smallest distance to one is sufficient.

Examples

A                   B            Output
thilloaoyreot       hello        4 (thelloaolleht)
benjonson           stack        9 (stackcats)
neversaynever!      odd          9 (neveroddoreven)
ppcggcpp            gg           0 (ppcggcpp)
stars               tat          1 (stats)

Scoring

This is code golf, shortest code in bytes wins.

    Tweeted twitter.com/StackCodeGolf/status/783546901236944896
4 added 177 characters in body
source | link

This was inspired by a now removed CS.SE question.

Task

Given two non-empty input strings A and B, output the smallest distance from A to a palindrome that contains B as a substring. Distance is defined by the number of character replacements (Hamming distance).

Restrictions

  • Sensible input: a palindrome exists. This means |A| ≥ |B|.
  • A and B contain only lower ASCII characters, lowercase and uppercase are distinct (as are all other characters).
  • If your language cannot deal with ASCII characters, you may use integers (or some other reasonable data type) as well, and you may choose to limit the range to 128 elements.
  • You may take input from stdin, function arguments, command line arguments, etc.
  • You may give the result on stdout, return value, etc.
  • You do not need to give a working palindrome, the smallest distance to one is sufficient.

Examples

A                   B            Output
thilloaoyreot       hello        4 (thelloaolleht)
benjonson           stack        9 (stackcats)
neversaynever!      odd          9 (neveroddoreven)
ppcggcpp            gg           0 (ppcggcpp)

Scoring

This is code golf, shortest code in bytes wins.

This was inspired by a now removed CS.SE question.

Task

Given two non-empty input strings A and B, output the smallest distance from A to a palindrome that contains B as a substring. Distance is defined by the number of character replacements (Hamming distance).

Restrictions

  • Sensible input: a palindrome exists. This means |A| ≥ |B|.
  • A and B contain only lower ASCII characters, lowercase and uppercase are distinct (as are all other characters).
  • You may take input from stdin, function arguments, command line arguments, etc.
  • You may give the result on stdout, return value, etc.
  • You do not need to give a working palindrome, the smallest distance to one is sufficient.

Examples

A                   B            Output
thilloaoyreot       hello        4 (thelloaolleht)
benjonson           stack        9 (stackcats)
neversaynever!      odd          9 (neveroddoreven)
ppcggcpp            gg           0 (ppcggcpp)

Scoring

This is code golf, shortest code in bytes wins.

This was inspired by a now removed CS.SE question.

Task

Given two non-empty input strings A and B, output the smallest distance from A to a palindrome that contains B as a substring. Distance is defined by the number of character replacements (Hamming distance).

Restrictions

  • Sensible input: a palindrome exists. This means |A| ≥ |B|.
  • A and B contain only lower ASCII characters, lowercase and uppercase are distinct (as are all other characters).
  • If your language cannot deal with ASCII characters, you may use integers (or some other reasonable data type) as well, and you may choose to limit the range to 128 elements.
  • You may take input from stdin, function arguments, command line arguments, etc.
  • You may give the result on stdout, return value, etc.
  • You do not need to give a working palindrome, the smallest distance to one is sufficient.

Examples

A                   B            Output
thilloaoyreot       hello        4 (thelloaolleht)
benjonson           stack        9 (stackcats)
neversaynever!      odd          9 (neveroddoreven)
ppcggcpp            gg           0 (ppcggcpp)

Scoring

This is code golf, shortest code in bytes wins.

3 added 51 characters in body; edited title
source | link
2 added 69 characters in body
source | link
1
source | link