Senter for Marxistiske og Matematiske Studium, Enschede (SMMSE)

16 juli 2008

 

Ein quine til

Som til skilnad frå dei to fyrste er uavhengig av teiknsett.

public class Q2 {
static char[] c = {'p','u','b','l','i','c','a','s','Q','2',
'{','t','h','r','[',']','=','}',';','n',
'v','o','d','m','(','S','g',')','0',',',
'3','8','f','j','<','.','e','+','"','\'',
'\\','|','?',':','y','!','-','1','%','6',
'5','>','k'};

static int[] i = {1,2,3,4,5,6,-1,6,4,7,8,8,-1,9,10,
-1,11,0,-4,8,12,7,12,5,6,-1,6,13,7,14,
15,16,-1,6,-1,17,-1,11,18,19,0,0,-4,8,12,
7,12,5,6,-1,5,20,12,15,16,-1,5,-1,17,-2,
11,18,19,0,0,-4,1,2,3,4,5,6,-1,8,12,
7,12,5,6,-1,21,22,5,23,-1,24,7,5,20,25,
26,12,14,5,20,27,15,16,-1,7,14,27,8,28,-1,
11,0,-8,1,25,29,30,31,32,28,19,0,-8,33,22,
14,-1,25,5,20,12,-1,34,17,29,19,34,35,6,36,
4,37,20,27,12,13,19,34,38,38,28,-1,11,0,-12,
26,12,14,5,20,27,-1,12,-1,17,-1,39,40,39,-1,
38,-1,25,6,15,34,16,17,17,40,41,40,40,-1,42,
42,-1,6,15,34,16,17,17,40,41,41,40,-1,43,-1,
39,41,41,39,-1,44,-1,39,39,28,-1,38,-1,6,15,
34,16,-1,38,-1,39,40,39,19,0,-12,26,45,8,12,
37,24,36,22,2,12,36,1,14,5,20,12,25,12,28,
19,0,-12,5,33,-1,25,34,46,17,6,36,4,37,20,
27,12,13,47,48,28,-1,26,45,8,12,37,24,36,22,
2,12,36,1,14,5,20,12,25,39,30,39,28,19,0,
-12,5,33,-1,25,25,34,38,48,28,49,48,29,17,17,
29,28,-1,26,45,8,12,37,24,36,22,2,12,36,1,
14,5,20,12,25,39,41,20,-23,39,28,19,0,-8,18,
0,-8,1,25,31,32,30,50,48,28,19,0,-8,33,22,
14,-1,25,5,20,12,-1,34,17,29,19,34,35,5,36,
4,37,20,27,12,13,19,34,38,38,28,-1,11,0,-12,
26,45,8,12,37,24,36,22,2,12,36,1,14,5,20,
12,25,5,15,34,16,28,19,0,-12,5,33,-1,25,34,
46,17,5,36,4,37,20,27,12,13,47,48,28,-1,26,
45,8,12,37,24,36,22,2,12,36,1,14,5,20,12,
25,39,30,39,28,19,0,-12,5,33,-1,25,25,34,38,
48,28,49,48,51,17,17,29,28,-1,26,45,8,12,37,
24,36,22,2,12,36,1,14,5,20,12,25,39,41,20,
-23,39,28,19,0,-8,18,0,-8,1,25,50,48,30,5,
36,4,37,20,27,12,13,28,19,0,-4,18,0,0,-4,
1,14,5,21,7,12,37,-1,8,12,7,12,5,6,-1,
21,22,5,23,-1,1,25,5,20,12,-1,20,30,5,20,
12,-1,24,28,-1,11,0,-8,33,22,14,-1,25,5,20,
12,-1,34,17,20,19,34,35,24,19,34,38,38,28,-1,
11,0,-12,5,33,-1,25,5,15,34,16,52,29,28,-1,
26,45,8,12,37,24,36,22,2,12,36,1,14,5,20,
12,25,6,15,5,15,34,16,47,48,16,28,19,0,-12,
37,4,8,37,-1,5,33,-1,25,5,15,34,16,17,17,
29,28,-1,26,45,8,12,37,24,36,22,2,12,36,1,
14,5,20,12,25,39,41,20,39,28,19,0,-12,37,4,
8,37,-1,33,22,14,-1,25,5,20,12,-1,53,17,29,
19,53,52,5,15,34,16,19,53,47,47,28,-1,26,45,
8,12,37,24,36,22,2,12,36,1,14,5,20,12,25,
39,-1,39,28,19,0,-8,18,0,-4,18,0,18};

public static void main(String[] args) {
p(0,38);
for (int j=0;j<c.length;j++) {
String t = "'" + (c[j]=='\'' || c[j]=='\\' ? "\\" : "") + c[j] + "'";
System.out.print(t);
if (j!=c.length-1) System.out.print(",");
if ((j+1)%10==0) System.out.print("\n ");
}
p(38,61);
for (int j=0;j<i.length;j++) {
System.out.print(i[j]);
if (j!=i.length-1) System.out.print(",");
if ((j+1)%15==0) System.out.print("\n ");
}
p(61,i.length);
}

private static void p(int n,int m) {
for (int j=n;j<m;j++) {
if (i[j]>0) System.out.print(c[i[j]-1]);
else if (i[j]==0) System.out.print("\n");
else for (int k=0;k>i[j];k--) System.out.print(" ");
}
}
}

15 juli 2008

 

To quines

Berre for moro skuld. To quines skrivne i Java.

public class Quine {
public static void main(String[] args) {
String s = "public class Quine {%n public static void main(String[] args) {%n String s = %2$c%1$s%2$c;%n System.out.printf(s, s, 34);%n }%n}";
System.out.printf(s, s, 34);
}
}


public class Q {
static byte[] c = {112,117,98,108,105,99,32,99,108,97,115,115,32,81,32,123,
10,32,32,32,32,115,116,97,116,105,99,32,98,121,116,101,
91,93,32,99,32,61,32,123,125,59,10,10,32,32,32,32,
112,117,98,108,105,99,32,115,116,97,116,105,99,32,118,111,
105,100,32,109,97,105,110,40,83,116,114,105,110,103,91,93,
32,97,114,103,115,41,32,123,10,32,32,32,32,32,32,32,
32,102,111,114,32,40,105,110,116,32,105,61,48,59,105,60,
52,48,59,105,43,43,41,32,83,121,115,116,101,109,46,111,
117,116,46,112,114,105,110,116,40,40,99,104,97,114,41,32,
99,91,105,93,41,59,10,32,32,32,32,32,32,32,32,102,
111,114,32,40,105,110,116,32,105,61,48,59,105,60,99,46,
108,101,110,103,116,104,59,105,43,43,41,32,123,10,32,32,
32,32,32,32,32,32,32,32,32,32,83,121,115,116,101,109,
46,111,117,116,46,112,114,105,110,116,40,99,91,105,93,41,
59,10,32,32,32,32,32,32,32,32,32,32,32,32,105,102,
32,40,105,33,61,99,46,108,101,110,103,116,104,45,49,41,
32,83,121,115,116,101,109,46,111,117,116,46,112,114,105,110,
116,40,34,44,34,41,59,10,32,32,32,32,32,32,32,32,
32,32,32,32,105,102,32,40,40,105,43,49,41,37,49,54,
61,61,48,41,32,83,121,115,116,101,109,46,111,117,116,46,
112,114,105,110,116,40,34,92,110,32,32,32,32,32,32,32,
32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,
34,41,59,10,32,32,32,32,32,32,32,32,125,10,32,32,
32,32,32,32,32,32,102,111,114,32,40,105,110,116,32,105,
61,52,48,59,105,60,99,46,108,101,110,103,116,104,59,105,
43,43,41,32,83,121,115,116,101,109,46,111,117,116,46,112,
114,105,110,116,40,40,99,104,97,114,41,32,99,91,105,93,
41,59,10,32,32,32,32,125,10,125};

public static void main(String[] args) {
for (int i=0;i<40;i++) System.out.print((char) c[i]);
for (int i=0;i<c.length;i++) {
System.out.print(c[i]);
if (i!=c.length-1) System.out.print(",");
if ((i+1)%16==0) System.out.print("\n ");
}
for (int i=40;i<c.length;i++) System.out.print((char) c[i]);
}
}

Tidlegare tekstar

Ein quine til
To quines
Brev frå Schickard til Kepler
Rapport: Hjelper valkamp?
Prosjektskildring: Hjelper valkamp?
Operativsystemrevolusjonen
Perspektiv på fri/open programvare
Om ... misforståingar knytt til datateknologi II
Om misoppfatninga at fri/open programvare er kommu...
Til glede for nye brukarar

Arkiv

november 2005   desember 2005   februar 2006   april 2006   november 2006   desember 2006   januar 2007   februar 2007   mars 2007   august 2007   desember 2007   januar 2008   juli 2008  

This page is powered by Blogger. Isn't yours?