From f040c492d180218c48700a4b35c3a6186c5373f1 Mon Sep 17 00:00:00 2001
From: Johannes Schindelin
+
+ Problem: what is the shortest way of defining a variable consisting of N
+ spaces? I.e. for N=80 the result will look something like
+
+ Table of contents:
+
- Older posts
+ Older posts
Tuesday, 27th of January, Anno Domini MMIX, at the hour of the Tiger
+
+ Fun with calculus after midnight
+
+
+
+
+
+
+
+
+
+
+
+
+
+s=' '
+s="$s$s$s$s$s$s$s$s$s$s$s$s$s$s$s$s$s$s$s$s"
+
+
+ Let's see. Let the minimal number of characters needed be A(N). For + simplicity, let's say that we only use one variable. Then, certainly, A(N) + cannot be larger than 5+N, as we could define a variable using 1 character + for the name, 1 for the equal sign, 2 for the quotes, and one for the semicolon + or newline character (whichever). +
+ Now, let's assume N is a product K*L. Then certainly, A(N) cannot + be larger than A(K)+5+2*L, as we could first define a variable that has + exactly K spaces and then use that to define the end result (in the example + above, K=5 and L=20). +
+ So, for which N=K*L is it better to use two definitions instead of one? +
+ Simple calculus says that 5+K*L>5+K+5+2*L must hold true, or (after some + scribbling): L>1+7/(K-2). Which means that it makes no sense to define + a variable with 1 or 2 spaces first, which is kinda obvious (writing '$s' + alone would use two characters, so we could write the spaces right away). +
+ But what for the other values? For K=3, L must be at least 9 to make + sense (in other words, N must be at least 27). For K=4, L needs + to be greater or equal to 5 (N>=20), the next pairs are (5,4), + (6,3), (7,3), (8,3), (9,3) and starting with K=10, any + L>1 makes sense. +
+ The second definition can also contain spaces at the end, however, so for any + N=K*L+M, A(N) cannot be larger than A(K)+5+2*L+M. +
+ Not surprisingly, this leads to exactly the same L>1+7/(K-2) (as we can + append the M spaces in the last definition, no matter if we use 1 or + 2 definitions). +
+ However, that means that as soon as N>=18, we should use two definitions, + prior to that, it makes no sense. +
+ So for N<18, A(N)=5+N. +
+ But what K should one choose, i.e. how many spaces in the first definition? + In other words, what is A(N) given that we use two definitions? +
+ That will have to wait for another midnight. Just a teaser: A(80)=36. Oh, + and with 80 characters, you can define a string of 9900 spaces... +
Which is good, because if they were not that funny, they would be pretty sad.
--
- The fun part about a blog is that you can talk about less technical stuff. - For example, Sverre's hat. -
- Let me start a bit earlier, so that you get the context. -
- Last year, at the GitTogether, - we had an unconference style - conference, which basically meant that it was our job to decide what - we want to talk about. -
- It turned out to be pretty hard, because there was so much we wanted to - discuss, and because we wanted to get to know each other, and we wanted to - do some hacking. -
- So to help us decide what subjects, and in which order we wanted to have - scheduled, Shawn opened a series on - Google Moderator, a nifty, yet simple application which allows a group - to agree quickly on an agenda. -
- It worked quite well; However, that little saboteur displayed his sense of - humor so overtly that some entertaining Gitter put the question "Should Sverre - wear a hat?" on the agenda. -
- Sure enough, the subject got voted up, and eventually, we got Sverre a hat: -
-
- By the way, another thing I like about this blog engine is that there are no - comments... Nothing is more annoying than leaving a comment on a blog, - forgetting about it for a few months, and then finding somebody answered - ages ago. -
- Update: Sverre says it was dsymonds idea. -