This is a pipe. (Something dear to me.)
blog.200nipples.com
blog.200nipples.com
Just shoot me an email at wade |at| 200nipples |dot| com.
The conduct you call a pipe in english is a "tuyau" in french.
Conductor or conduit?
The pipe character is used to indicate that the output of process A is piped to process B. I guess it's a pun. My apologies for horribly overexplaining.
Have to say this is 1) a brilliant tshirt, 2) a brilliant business model. Just placed an order. :-)
Not sure why that popped into my head whilst reading seven paragraphs about his t-shirt with a vertical bar...
(It's python, and I'm very new to programming. Criticism is welcome.)
a,b = 1,1
while a <= 100:
a = a + 1
b = b + a
print(b)One way of computing it in Python, using a loop approach like you did, is like so:
sum = 0
for p in xrange(101):
sum += p
print (sum)
This uses better variable names, and a simpler looping construct. The reason for the 101 is because it starts at 0.I knew of the shortcut to increment a variable, but I had no idea you didn't have to declare one for a loop. I also didn't not know of xrange, I will have to look that one up.
print ((n-1)*n)/2(fold the sequence in half, which gives you 100 + 1 on one end and 50 + 51 on the other.)
I took the 'n' to be the 100, not the 101. A little too quick on the submit there, I should have run it :)
But anyway, that seems to be a damn sight faster than to run a loop to add a bunch of numbers in a fixed interval.
Especially for large 'n'.
print sum([x for x in xrange(101)])
although the n(n+1)/2 is probably the best, I'd just like to point that out because I wish someone would have pointed out list comprehensions to me earlier :)
You could easily verify the answer by hand for small numbers of shirts, then run your debugged code to compute the answer for 100 shirts.