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

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

Required fields*

Required fields*

Error-correct text

Correct a single-letter typo in a fixed text.

Input: The paragraph below but with exactly one typo, where a single letter a-zA-Z is replaced by a different letter a-zA-Z. To be clear, the letter isn't replaced everywhere it appears, but just in that one place. For example, the first word "In" might become "IZ". Non-letter characters like spaces or punctuation cannot be affected.

Output: The paragraph exactly as below, without the typo. A trailing newline is OK.

In information theory and coding theory with applications in computer science and telecommunication, error detection and correction or error control are techniques that enable reliable delivery of digital data over unreliable communication channels. Many communication channels are subject to channel noise, and thus errors may be introduced during transmission from the source to a receiver. Error detection techniques allow detecting such errors, while error correction enables reconstruction of the original data in many cases.

TIO with text

The text is taken from the Wikipedia article Error detection and correction. But, your code may not fetch the text from Wikipedia or elsewhere, as per the standard loophole.

Any site-default string I/O is acceptable. Fewest bytes wins. Please check that your solution works for all 23001 possible inputs, if you're able to run that much.

Answer*

Draft saved
Draft discarded
Cancel
5
  • \$\begingroup\$ 198: y=23;f(char*s){char*R="\x17|h0\"k5&j4\x10zm7\x7f""4sM6~0=a[z@z4zp4y j,-#3#mu7q030円dd",n=y,k,t,u,r,c,x;for(;n--;r?x=r,t=n:0){r=R[n];c=R[n+y];for(k=y;k--;r^=s[y*n+k])c^=s[y*k+n];c?u=n:0;}s[y*t+u]^=x;} \$\endgroup\$ Commented Mar 9, 2020 at 6:37
  • \$\begingroup\$ @Bubbler Thank you! That's clever golfing -- especially starting at R[n] and R[n+23] and aiming at 0, instead of starting at 0 and aiming at R[n] and R[n+23]. \$\endgroup\$ Commented Mar 9, 2020 at 7:10
  • \$\begingroup\$ @ceilingcat Thank you -- it looks like it's actually 185 bytes now. I'm kind of surprised that it works with R declared as an int * (implicitly) instead of as a char *. \$\endgroup\$ Commented Mar 11, 2020 at 4:50
  • \$\begingroup\$ There is a bug in the way TIO counts bytes in C files. Change the language into "bash" and see how long it is. \$\endgroup\$ Commented Mar 11, 2020 at 6:43
  • \$\begingroup\$ Strange. I’ve mostly used TIO for bash. \$\endgroup\$ Commented Mar 11, 2020 at 6:47

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