Java, 1574 2643 1934 characters
Compressed 1934 characters:
public static void main(String[] args){int[][][]num={{{1,1,1},{1,0,1},{1,0,1},{1,0,1},{1,1,1}},{{0,0,1},{0,0,1},{0,0,1},{0,0,1},{0,0,1}},{{1,1,1},{0,0,1},{1,1,1},{1,0,0},{1,1,1}},{{1,1,1},{0,0,1},{1,1,1},{0,0,1},{1,1,1}},{{1,0,1},{1,0,1},{1,1,1},{0,0,1},{0,0,1}},{{1,1,1},{1,0,0},{1,1,1},{0,0,1},{1,1,1}},{{1,1,1},{1,0,0},{1,1,1},{1,0,1},{1,1,1}},{{1,1,1},{0,0,1},{0,0,1},{0,0,1},{0,0,1}},{{1,1,1},{1,0,1},{1,1,1},{1,0,1},{1,1,1}},{{1,1,1},{1,0,1},{1,1,1},{0,0,1},{0,0,1}},{{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,1}}};BufferedImage image=new BufferedImage(103,5,BufferedImage.TYPE_3BYTE_BGR);for(int q=0;q<103;q++){for(int w=0;w<5;w++){image.setRGB(q,w,0xFFFFFF);}}int loc = 0;String g=String.valueOf(pi(20));for(int w=0;w<g.length()-1;w++){Integer n=0;if(g.charAt(w)=='.'){n=10;}else{n=Integer.parseInt(String.valueOf(g.charAt(w)));}for(int t=0;t<5;t++){for(int q=0;q<3;q++){int c=num[n][t][q]==1?0x000000:0xFFFFFF;image.setRGB(loc+q,t,c);}}loc+=5;}try{BufferedImage bi=image;File f=new File("o.png");ImageIO.write(bi,"png",f);}catch(IOException e){}}public static BigDecimal pi(final int SCALE){BigDecimal a=BigDecimal.ONE;BigDecimal b=BigDecimal.ONE.divide(sqrt(new BigDecimal(2),SCALE),SCALE,BigDecimal.ROUND_HALF_UP);BigDecimal t=new BigDecimal(0.25);BigDecimal x=BigDecimal.ONE;BigDecimal y;while(!a.equals(b)){y=a;a=a.add(b).divide(new BigDecimal(2),SCALE,BigDecimal.ROUND_HALF_UP);b=sqrt(b.multiply(y),SCALE);t=t.subtract(x.multiply(y.subtract(a).multiply(y.subtract(a))));x=x.multiply(new BigDecimal(2));}return a.add(b).multiply(a.add(b)).divide(t.multiply(new BigDecimal(4)),SCALE,BigDecimal.ROUND_HALF_UP);}public static BigDecimal sqrt(BigDecimal A,final int SCALE){BigDecimal x0=new BigDecimal("0");BigDecimal x1=new BigDecimal(Math.sqrt(A.doubleValue()));while(!x0.equals(x1)){x0=x1;x1=A.divide(x0,SCALE,BigDecimal.ROUND_HALF_UP);x1=x1.add(x0);x1=x1.divide(new BigDecimal(2),SCALE,BigDecimal.ROUND_HALF_UP);}return x1;}}
Expanded 2643 characters:
public static void main(String[] args) {
int[][][] num = { { { 1, 1, 1 }, { 1, 0, 1 }, { 1, 0, 1 }, { 1, 0, 1 }, { 1, 1, 1 } },
{ { 0, 0, 1 }, { 0, 0, 1 }, { 0, 0, 1 }, { 0, 0, 1 }, { 0, 0, 1 } },
{ { 1, 1, 1 }, { 0, 0, 1 }, { 1, 1, 1 }, { 1, 0, 0 }, { 1, 1, 1 } },
{ { 1, 1, 1 }, { 0, 0, 1 }, { 1, 1, 1 }, { 0, 0, 1 }, { 1, 1, 1 } },
{ { 1, 0, 1 }, { 1, 0, 1 }, { 1, 1, 1 }, { 0, 0, 1 }, { 0, 0, 1 } },
{ { 1, 1, 1 }, { 1, 0, 0 }, { 1, 1, 1 }, { 0, 0, 1 }, { 1, 1, 1 } },
{ { 1, 1, 1 }, { 1, 0, 0 }, { 1, 1, 1 }, { 1, 0, 1 }, { 1, 1, 1 } },
{ { 1, 1, 1 }, { 0, 0, 1 }, { 0, 0, 1 }, { 0, 0, 1 }, { 0, 0, 1 } },
{ { 1, 1, 1 }, { 1, 0, 1 }, { 1, 1, 1 }, { 1, 0, 1 }, { 1, 1, 1 } },
{ { 1, 1, 1 }, { 1, 0, 1 }, { 1, 1, 1 }, { 0, 0, 1 }, { 0, 0, 1 } },
{ { 0, 0, 0 }, { 0, 0, 0 }, { 0, 0, 0 }, { 0, 0, 0 }, { 0, 0, 1 } } };
BufferedImage image = new BufferedImage(103, 5, BufferedImage.TYPE_3BYTE_BGR);
for (int q = 0; q < 103; q++) {
for (int w = 0; w < 5; w++) {
image.setRGB(q, w, 0xFFFFFF);
}
}
int loc = 0;
String g = String.valueOf(pi(20));
for (int w = 0; w < g.length()-1; w++) {
Integer n = 0;
if (g.charAt(w) == '.') {
n = 10;
} else {
n = Integer.parseInt(String.valueOf(g.charAt(w)));
}
for (int t = 0; t < 5; t++) {
for (int q = 0; q < 3; q++) {
int c = num[n][t][q] == 1 ? 0x000000 : 0xFFFFFF;
image.setRGB(loc + q, t, c);
}
}
loc += 5;
}
try {
BufferedImage bi = image;
File outputfile = new File("out2.png");
ImageIO.write(bi, "png", outputfile);
} catch (IOException e) {
}
}
public static BigDecimal pi(final int SCALE) {
BigDecimal a = BigDecimal.ONE;
BigDecimal b = BigDecimal.ONE.divide(sqrt(new BigDecimal(2), SCALE), SCALE, BigDecimal.ROUND_HALF_UP);
BigDecimal t = new BigDecimal(0.25);
BigDecimal x = BigDecimal.ONE;
BigDecimal y;
while (!a.equals(b)) {
y = a;
a = a.add(b).divide(new BigDecimal(2), SCALE, BigDecimal.ROUND_HALF_UP);
b = sqrt(b.multiply(y), SCALE);
t = t.subtract(x.multiply(y.subtract(a).multiply(y.subtract(a))));
x = x.multiply(new BigDecimal(2));
}
return a.add(b).multiply(a.add(b)).divide(t.multiply(new BigDecimal(4)), SCALE, BigDecimal.ROUND_HALF_UP);
}
public static BigDecimal sqrt(BigDecimal A, final int SCALE) {
BigDecimal x0 = new BigDecimal("0");
BigDecimal x1 = new BigDecimal(Math.sqrt(A.doubleValue()));
while (!x0.equals(x1)) {
x0 = x1;
x1 = A.divide(x0, SCALE, BigDecimal.ROUND_HALF_UP);
x1 = x1.add(x0);
x1 = x1.divide(new BigDecimal(2), SCALE, BigDecimal.ROUND_HALF_UP);
}
return x1;
}
Pi method gathered from: https://stackoverflow.com/questions/8343977/calculate-pi-on-an-android-phone?rq=1
I like the challenge, but technically wouldn't such a system also be incapable of displaying source code? Except for Piet, of course. – ApproachingDarknessFish – 2014-01-18T21:40:25.703
2@ValekHalfHeart you can load the source code from a different machine – John Dvorak – 2014-01-18T21:41:14.470
@ValekHalfHeart I thought about doing a quine, but I didn't want to check them. – hildred – 2014-01-18T21:44:36.373
How legible does the text have to be? There's nothing in the rules to prevent extremely small fonts (such as 2x2 bitmap glyphs, which would be unreadable to any human). – Kendall Frey – 2014-01-18T22:00:38.617
@KendallFrey magnifying glasses are ok, but you should use a font that is human readable. (besides 2x2=4<11 and you need all ten digits and a decimal point.) Small fonts may assume a low resolution display. Vectors are also acceptable. – hildred – 2014-01-18T22:06:18.207
1And how do you define human readable? For example, my handwriting is readable to some humans (at least one) and not to others. (By the way, 2^(2x2)=16, enough glyphs for all 11 digits. ;) ) – Kendall Frey – 2014-01-18T22:19:05.270
@KendallFrey more readable than your handwriting. Specifically that each character resembles the numeral it represents and is distinct from the other characters in the font and that the numeral system be decimal. I think this can be done in a 3x5 with 1 px between chars. – hildred – 2014-01-18T22:25:44.653
What math functions can be used? – Gelatin – 2014-01-18T22:28:16.887
I still don't think that's specific enough. "resembles" is subjective. – Kendall Frey – 2014-01-18T22:32:14.437
@Gelatin all but PI(). – hildred – 2014-01-18T22:37:58.770
@KendallFrey you don't have to be able to tell between a 6 and a b but you should be able to tell the difference between a 2 and a 3. – hildred – 2014-01-18T22:45:13.960
Is ASCII art ok? – Gelatin – 2014-01-18T22:49:10.077
@Gelatin, why not. – hildred – 2014-01-18T23:28:51.847
4I don't understand the title at all, I don't understand how ASCII art can be ok when we cannot use text display, and the question very much needs a definition of "calculate PI". – Peter Taylor – 2014-01-19T09:07:27.593
2What does "calculate pi" really mean? Could I hard-code a bitmap of the first 20 decimals? (Doesn't make use of any built-in PI constant or similar) – FireFly – 2014-01-19T18:40:18.017
@PeterTaylor FireFly, et. al.: I think it's safe to assume that any hard-coding or use of built-in definitions of Pi are out. However, inclusion of ASCII art while built-in font/text display functions are outlawed is... odd. Unless the permission was granted with the presumption that one would write their own such functions and then print ASCII art. That could be a valid solution, but I have doubts that it is competitive in terms of length. – Iszi – 2014-01-20T07:51:41.453
@Iszi, using built-in definitions of pi is ruled out, but using
4*atan(1)
seems to be explicitly permitted, which seems bizarre. It's not calculation in any meaningful sense of the word and it's no more interesting than using a built-in constant. And the calculation of pi isn't the interesting part of the challenge anyway (or it would be a duplicate). – Peter Taylor – 2014-01-20T08:36:52.700“Animated” ? Where ? – Nicolas Barbulesco – 2014-03-03T22:26:29.633