Editing 1685: Patch
Warning: You are not logged in. Your IP address will be publicly visible if you make any edits. If you log in or create an account, your edits will be attributed to your username, along with other benefits.
The edit can be undone.
Please check the comparison below to verify that this is what you want to do, and then save the changes below to finish undoing the edit.
Latest revision | Your text | ||
Line 10: | Line 10: | ||
{{w|Adobe Photoshop}} is a commonly used application for image manipulation. One of its features is the Patch tool, which allows the user to overwrite parts of the image, replacing them with a copy of another area of the same image. It is often used for “patching up” photographs by overwriting scratches or other visible damage to the photo. Another of Photoshop’s features is “content-aware fill”, which could also be described as “content-aware inpainting”. It works similarly to the Patch tool, but automatically generates a replacement texture from the area surrounding the deleted part instead of copying a user-specified area exactly. | {{w|Adobe Photoshop}} is a commonly used application for image manipulation. One of its features is the Patch tool, which allows the user to overwrite parts of the image, replacing them with a copy of another area of the same image. It is often used for “patching up” photographs by overwriting scratches or other visible damage to the photo. Another of Photoshop’s features is “content-aware fill”, which could also be described as “content-aware inpainting”. It works similarly to the Patch tool, but automatically generates a replacement texture from the area surrounding the deleted part instead of copying a user-specified area exactly. | ||
− | {{w|GNU}} {{w|Patch (Unix)|patch}} is a program that replaces only parts of code with an updated version, without requiring the user to download the entire source code. Here, it appears the author was told to “patch” the code but used Photoshop to do this instead of GNU patch, with devastating results. | + | {{w|GNU}} {{w|Patch (Unix)|patch}} is a program that replaces only parts of code with an updated version, without requiring the user to download the entire source code. Here, it appears the author was told to “patch” the code, but used Photoshop to do this instead of GNU patch, with devastating results. Although the title text suggests that if you did this enough times the code would eventually compile, this would never happen. In fact, Photoshop could only edit an image of the text and not the text itself. |
− | The comic blurs the difference between {{w|text_file|text}} (in which letters and symbols represent discrete values, such as 65 being the number for the letter A in the ASCII encoding standard, and it's relatively easy for a program compiler to interpret combinations of these values as keywords and other programming constructs) and {{w|Raster_graphics|graphics}} (where the letters and symbols in the comic are actually represented by | + | The comic blurs the difference between {{w|text_file|text}} (in which letters and symbols represent discrete values, such as 65 being the number for the letter A in the ASCII encoding standard, and it's relatively easy for a program compiler to interpret combinations of these values as keywords and other programming constructs) and {{w|Raster_graphics|graphics}} (where the letters and symbols in the comic are actually represented by pattern of colored dots). There are common and straightforward processes for converting text information to images, such as printing, which can convert text to a graphics format very faithfully. The reverse, however, requires the use of {{w|optical character recognition}} (OCR), which attempts to figure out which letter or symbol certain patterns of dots "look like". OCR could be effective in converting some of the image in the comic back to usable text, however it would fail on some of those patterns that have been mangled and don't look like any existing characters or symbols. A compiler can only operate on text data, so converting the graphic back into text would be a requirement to even begin to attempt to compile it, a step omitted in the title text. |
− | The code appears to be written in {{w|Python_(programming_language)|Python}}, a programming language often referred to in xkcd | + | The code appears to be written in {{w|Python_(programming_language)|Python}}, a programming language often referred to in xkcd. A few of the function names that can be recognized are "isPrime" and "quicksort", both elementary programming algorithms. It was also apparently originally edited using a Python-aware programming text editor, which is able to use different colors for different programming elements. For example, it appears to use red for keywords, blue for variables, and black for other elements, however because of the mangling from the use of the wrong patching program, that doesn't appear to be consistent. Since the patching replaced graphical elements rather than whole characters, there are examples of symbols that are combination of two different characters, and when the original two characters were rendered in different colors the resulting non-character could be in two colors, or the resulting "word" might be rendered in multiple colors. |
− | + | The title text also explains that patch used the content-aware inpainting to fill in all the wasted whitespace in the code. In most programming languages, whitespace is necessary to separate words, so this would combine words that shouldn’t be combined and create invalid code. Since the code in the image is Python, the code will be messed up even more, because Python uses whitespace as a part of its programming syntax. For example, statements are separated by new lines instead of by semicolons (;), and indentation is used instead of brackets to determine the scope of each section of code. | |
− | |||
− | The title text also explains that | ||
The original code was likely as follows: | The original code was likely as follows: | ||
Line 44: | Line 42: | ||
isPrime and quicksort are standard python implementations of simple algorithms (although you would not generally write a sorting algorithm in python as there are built-in algorithms available). isPrimeRegex uses the [https://docs.python.org/library/re.html re module] to detect if a number is prime by seeing if a string containing that many 1s can be matched to 2 or more copies of some string containing at least 2 1s. | isPrime and quicksort are standard python implementations of simple algorithms (although you would not generally write a sorting algorithm in python as there are built-in algorithms available). isPrimeRegex uses the [https://docs.python.org/library/re.html re module] to detect if a number is prime by seeing if a string containing that many 1s can be matched to 2 or more copies of some string containing at least 2 1s. | ||
− | |||
− | |||
− | |||
− | |||
==Transcript== | ==Transcript== | ||
− | :[The panel displays part of a code, in five different colors (red, purple, light blue, blue | + | :[The panel displays part of a code, in five different colors (red, purple, light blue, blue and green) as well as normal black text, which due to image editing is difficult to read. The first and last line are partly obscured by the frame of the panel. Here below is an attempt to transcribe the code, using the sign "¤" for anything not easily transcribed. Feel free to add other signs instead of these that looks more like the one in the image (and also improve the attempted transcription if possible).] |
− | <font color="red"> | + | <font color="red">impo¤l </font><font color="purple">me</font> |
− | <font color="red">doo</font><font color="purple"> | + | <font color="red">doo</font><font color="purple">PisPޤme</font>(n): |
− | <font color="red"> | + | <font color="red">r</font>(<font color="purple">¤</font>n<font color="red"><</font>n,<font color="#44A1FF">1</font>: |
− | <font color="red"> | + | <font color="red">retern</font> <font color="#44A1FF">F</font>(<font color="#44A1FF">ise</font> |
− | <font color="red">for</font> i <font color="red">ir</font><font color="#44A1FF"> | + | <font color="red">for</font> i <font color="red">ir</font><font color="#44A1FF">ararre</font>(<font color="#44A1FF">2</font>, <font color="#44A1FF">nint</font> <font color="red">*</font>n<font color="red">**</font>n<font color="red">+</font><font color="#44A1FF">5</font>)<font color="red">+</font><font color="#44A1FF">5</font>): |
<font color="red">if</font> n i<font color="red">==</font><font color="#44A1FF">0</font> | <font color="red">if</font> n i<font color="red">==</font><font color="#44A1FF">0</font> | ||
− | <font color="red"> | + | <font color="red">ret¤¤nrs</font><font color="#44A1FF">elsel</font>: |
− | <font color="red"> | + | <font color="red">re¤ irn </font><font color="#44A1FF">True</font> |
− | <font color="red">defe</font><font color="purple"> | + | <font color="red">defe</font><font color="purple">sisPrimcieg ¤x</font>(c<font color="purple">x</font> |
− | <font color="red">if</font> <font color="purple">g</font> | + | <font color="red">if</font> <font color="purple">g</font>e<font color="purple">¤i</font>natc<font color="purple">x</font>(<font color="red">r</font>'<font color="#44A1FF">^</font><font color="blue">(1</font><font color="red">?| ?.</font><font color="blue">1</font><font color="red">+?</font><font color="blue">)</font><font color="lime">\+</font><font color="blue">)</font><font color="#44A1FF">$</font>'<font color="red">*</font>n <font color="blue">)1'</font><font color="red">*</font>n): |
− | <font color="red"> | + | <font color="red">rerjrn </font><font color="#44A1FF">Fa</font><font color="blue">(</font><font color="#44A1FF"> e</font> |
− | <font color="red"> | + | <font color="red">Letyl</font><font color="purple">nr</font><font color="#44A1FF">Trl</font> |
− | <font color="red">dq</font><font color="purple"> | + | <font color="red">dq</font><font color="purple">l qlsorsor</font><font color="#44A1FF">n</font>(a : |
− | <font color="red">if </font><font color="#44A1FF">¤n</font>(a | + | <font color="red">if </font><font color="#44A1FF">¤n</font>(a <font color="red">< </font><font color="#44A1FF">2</font>: |
<font color="red">eteturn </font>a | <font color="red">eteturn </font>a | ||
− | pi<font color="red">= | + | pi<font color="red">= =r f</font>a[<font color="#44A1FF">0</font>] |
− | l<font color="red">=</font>pi<font color="red">=for</font> j <font color="red"> | + | l<font color="red">=</font>pi<font color="red">=for</font> j <font color="red">ln</font> a i<font color="red"><</font> i<font color="red"><</font>pi<font color="red"><</font>(t]<small>(</small>) |
− | r<font color="red">=</font>[ | + | r<font color="red">=</font>[l<font color="red">=for f in</font> a) <font color="red">r</font> i<font color="red">></font>viviv]<small>(</small>vo) |
− | mid<font color="red">=</font>[pi[<font color="red">*</font>t]<font color="red">*</font>(<font color="#44A1FF">l</font><font color="red">*</font>t<font color="#44A1FF"> | + | mid<font color="red">=</font>[pi[<font color="red">*</font>t]<font color="red">*</font>(<font color="#44A1FF">l</font><font color="red">*</font>t<font color="#44A1FF">,</font>(a)<font color="red">-</font>(<font color="#44A1FF">len</font>pi<font color="#44A1FF">enlen</font>(c))) |
− | <font color="red">r¤lrurrr</font> | + | <font color="red">r¤lrurrr</font>iklcksckt(l) <font color="red">+</font> r ¤ ¤quickrort(r) |
:[Caption below the panel:] | :[Caption below the panel:] | ||
Line 76: | Line 70: | ||
{{comic discussion}} | {{comic discussion}} | ||
+ | |||
[[Category:Comics with color]] | [[Category:Comics with color]] | ||
[[Category:Protip]] | [[Category:Protip]] | ||
[[Category:Programming]] | [[Category:Programming]] | ||
− |