Fibonacci program lengths
Python 2, 160 bytes
s='s=%s;c=s;l=len(s%%c)+4;a,b=1,1\nwhile b<l:a,b=b,a+b\nc+="1"*(b-l-1);print s%%`c`;a=1'
c=s
l=len(s%c)+4
a,b=1,1
while b<l:a,b=b,a+b
c+="1"*(b-l-1)
print s%`c`
This is a true quasi-quine; it doesn't read its own source, but it generates it. First output (has trailing newline):
s='s=%s;c=s;l=len(s%%c)+4;a,b=1,1\nwhile b<l:a,b=b,a+b\nc+="1"*(b-l-1);print s%%`c`;a=111111111111111111111111111111111111111111111111111111111111111111111';c=s;l=len(s%c)+4;a,b=1,1
while b<l:a,b=b,a+b
c+="1"*(b-l-1);print s%`c`;a=1
Second:
s='s=%s;c=s;l=len(s%%c)+4;a,b=1,1\nwhile b<l:a,b=b,a+b\nc+="1"*(b-l-1);print s%%`c`;a=1111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111';c=s;l=len(s%c)+4;a,b=1,1
while b<l:a,b=b,a+b
c+="1"*(b-l-1);print s%`c`;a=111111111111111111111111111111111111111111111111111111111111111111111
Edit: Oops. Forgot to change the string when I changed from ;
s to 1
s, so the second output was outputting extra semicolons (which Python doesn't support). Fixed
CJam, 41 31 bytes
{1$+S@]_1=4+1$`,-S*"2$~"}21D2$~
Try it online.
Output
$ cjam <(echo '{1$+S@]_1=4+1$`,-S*"2$~"}21D2$~'); echo
{1$+S@]_1=4+1$`,-S*"2$~"}34 21 2$~
$ cjam <(echo '{1$+S@]_1=4+1$`,-S*"2$~"}21D2$~') | wc -c
34
$ cjam <(cjam <(echo '{1$+S@]_1=4+1$`,-S*"2$~"}21D2$~')); echo
{1$+S@]_1=4+1$`,-S*"2$~"}55 34 2$~
$ cjam <(cjam <(echo '{1$+S@]_1=4+1$`,-S*"2$~"}21D2$~')) | wc -c
55
$ cjam (cjam <(cjam <(echo '{1$+S@]_1=4+1$`,-S*"2$~"}21D2$~'))); echo
bash: syntax error near unexpected token `cjam'
$ cjam <(cjam <(cjam <(echo '{1$+S@]_1=4+1$`,-S*"2$~"}21D2$~'))); echo
{1$+S@]_1=4+1$`,-S*"2$~"}89 55 2$~
$ cjam <(cjam <(cjam <(echo '{1$+S@]_1=4+1$`,-S*"2$~"}21D2$~'))) | wc -c
89
How it works
{ " {…} 21 13 ";
1$+ " Duplicate the higher number and add. {…} 21 34 ";
S@ " Push a space and rotate the lower number on top. {…} 34 ' ' 21 ";
] " Wrap the stack into an array. [ {…} 34 ' ' 21 ] ";
_1= " Push the second element of the array. [ {…} 34 ' ' 21 ] 34 ";
4+ " Add 4 to it. [ {…} 34 ' ' 21 ] 38 ";
1$`, " Push the length of the stringified array. [ {…} 34 ' ' 21 ] 38 37 ";
-S* " Subtract and push that many spaces. [ {…} 34 ' ' 21 ] ' ' ";
"2$~" " Push the string '2$~'. [ {…} 34 ' ' 21 ] ' ' '2$~' ";
} " {…} ";
21D " Push 21 and 13. {…} 21 13 ";
2$~ " Copy the code block an evaluate. [ {…} 34 ' ' 21 ] ' ' '2$~' ";
Python - 89
g="%(s,b,a+b);print o.ljust(b-1)";s,a,b="s,a,b=%r,%i,%i;o=s%"+g,89,144;exec("o=s"+g)#####
My perfect character count is gone. ;_; Thanks to TheRare for pointing out the newline thing and Quincunx for suggesting I use Python 2, shaving off 2 chars.
EDIT: Now just uses more #
s instead of 1
s; 12 chars shorter.
EDIT 2: 94 chars! Eliminated some repetition. >:3
EDIT 3: Shorter repr alternative for Python 2.
EDIT 4: Output is a character shorter now.
EDIT 5: The use of %r
to shorten it was taken from an answer on another question by @primo.
EDIT 6: Shorter. :D
Here's a Python 3 version:
g="%(s,b,a+b);print(o.ljust(b-1))";s,a,b="s,a,b=%r,%i,%i;o=s%"+g,89,144;exec("o=s"+g)####
This answer is similar to the one by @Quincunx.