Difference between revisions of "Talk:1685: Patch"

Explain xkcd: It's 'cause you're dumb.
Jump to: navigation, search
Line 20: Line 20:
  
 
I don't really know anything about programming, but it looks like it's checking for factors of n from 2 to sqrt(n)+1. Why would it need to check any number larger than sqrt(n) though? If i>sqrt(n), then ij=n implies that j<sqrt(n), and j should already have been found. So the largest integer you need to check is floor( sqrt(n) ), which is in the range from 2 to sqrt(n). Checking ceiling( sqrt(n) ) for a non-square number seems redundant. [[Special:Contributions/108.162.237.250|108.162.237.250]] 15:25, 25 May 2016 (UTC)
 
I don't really know anything about programming, but it looks like it's checking for factors of n from 2 to sqrt(n)+1. Why would it need to check any number larger than sqrt(n) though? If i>sqrt(n), then ij=n implies that j<sqrt(n), and j should already have been found. So the largest integer you need to check is floor( sqrt(n) ), which is in the range from 2 to sqrt(n). Checking ceiling( sqrt(n) ) for a non-square number seems redundant. [[Special:Contributions/108.162.237.250|108.162.237.250]] 15:25, 25 May 2016 (UTC)
 +
:It's because <code>range(a, b)</code> in Python means the interval [a, b) (excluding b). [[Special:Contributions/108.162.222.29|108.162.222.29]] 15:41, 25 May 2016 (UTC)

Revision as of 15:41, 25 May 2016

Hey, I'm first! Guessing the Bot only JUST created this, it was mere minutes after midnight EST when I landed on this page. Unfortunately this is a comic I'm less capable of explaining. From the looks of it, his Photoshop Patch turned what looks like C code into gobbledegook by filling in several of the spaces (and I think even changing some of the characters, possible with characters which fill more of the space). - NiceGuy1 108.162.218.77 04:24, 25 May 2016 (UTC)

This appears to be Python code. Note the "def" keyword, how "for i in [garbled]:" is used rather than C's for syntax, and how there are no semicolons or braces. --Sherlock9 (talk) 05:03, 25 May 2016 (UTC)

Photoshop has a 'patch' tool but it has a very different function from a software patch.

An explanation of Photoshop's patch tool might be helpful in identifying patterns in what pixels were changed by it, perhaps facilitating the identification of some likely characters. Dansiman (talk) 05:56, 25 May 2016 (UTC)

The first function looks like "isPrime" and seems to check if a number is prime. The last function looks like "quicksort". Both are common functions you create when learning programming. Not sure about the second one, but it looks like it uses regular expressions. -- 198.41.242.242 06:44, 25 May 2016 (UTC)

I think the second one is "isPrimeRegex". *cringe* 141.101.104.25 08:55, 25 May 2016 (UTC)

Second function looks like a function to check if number is a prime using Regex (described here http://www.noulakaz.net/2007/03/18/a-regular-expression-to-check-for-prime-numbers/). I don't know if it deserves some special mention, but at least to me (non-programmer) it looks like one of the most arcane things you can do in programming 141.101.80.79 07:22, 25 May 2016 (UTC)

That indeed looks very much like it. I think this is worth mentioning. --198.41.242.240 11:22, 25 May 2016 (UTC)
Note that mathematically speaking, that regular expression is NOT regular expression - use of backreference in match is one of originally perl extension which makes it much more powerful (and much slower in some cases). It's just that both python and ruby already copied most of perl extensions of regular expressions. -- Hkmaly (talk) 12:39, 25 May 2016 (UTC)

Do you think the use of pi is a reference to one of the other comics(I forgot which one...)?Transuranium (talk) 10:35, 25 May 2016 (UTC)Transuranium

I rather guess it is short for pivot. See quicksort for what the pivot does. --198.41.242.240 11:22, 25 May 2016 (UTC)

You know, it's theoretically possible for Photoshop to create compilable code in the esoteric programming language "Piet". But unless there's a way to turn off the Patch tool's antialiasing, it'll be practically impossible for patches larger than a single pixel. 108.162.237.220 14:15, 25 May 2016 (UTC)

I don't really know anything about programming, but it looks like it's checking for factors of n from 2 to sqrt(n)+1. Why would it need to check any number larger than sqrt(n) though? If i>sqrt(n), then ij=n implies that j<sqrt(n), and j should already have been found. So the largest integer you need to check is floor( sqrt(n) ), which is in the range from 2 to sqrt(n). Checking ceiling( sqrt(n) ) for a non-square number seems redundant. 108.162.237.250 15:25, 25 May 2016 (UTC)

It's because range(a, b) in Python means the interval [a, b) (excluding b). 108.162.222.29 15:41, 25 May 2016 (UTC)