Skip to main content
20 digits instead of 20 characters
Source Link
Victor Stafusa
  • 8.8k
  • 5
  • 42
  • 63
import java.math.BigDecimal;class H{public static void main(String[]h)throws Exception{int[]t={31599,4681,31183,29647,5101,29671,31719,4687,31727,29679,8192};BigDecimal y=v(-3);for(int n=1;n<99;n++)y=y.add(v(n).multiply(v(2).pow(n)).multiply(f(n).pow(2)).divide(f(2*n),4042,0));for(int z=0;z<5;z++){for(char c:y.toPlainString().substring(0,2021).toCharArray()){if(c<48)c=58;int a=(t[c-48]>>>z*3)&7;e(a/4);e(a/2&1);e(a&1);e(0);e(0);}e(10);}}static void e(int c){System.out.print((char)(c<2?c*3+32:c));}static BigDecimal v(int k){return BigDecimal.valueOf(k);}static BigDecimal f(int k){return k<2?v(1):f(k-1).multiply(v(k));}} 
import java.math.BigDecimal; class H { public static void main(String[] h) throws Exception { // Each block corresponds to a line. Each char has 5 lines with a 3-char width. int[] t = { 0b111_101_101_101_111, 0b001_001_001_001_001, 0b111_100_111_001_111, 0b111_001_111_001_111, 0b001_001_111_101_101, 0b111_001_111_100_111, 0b111_101_111_100_111, 0b001_001_001_001_111, 0b111_101_111_101_111, 0b111_001_111_101_111, 0b010_000_000_000_000 }; // Calculate PI using the Simon Plouffe formula, 1996. BigDecimal y = v(-3); for (int n = 1; n < 99; n++) y = y.add(v(n).multiply(v(2).pow(n)).multiply(f(n).pow(2)).divide(f(2 * n), 4042, 0)); for (int z = 0; z < 5; z++) { for (char c : y.toPlainString().substring(0, 2021).toCharArray()) { if (c < 48) c = 58; int a = (t[c - 48] >>> z * 3) & 7; e(a / 4); e(a / 2 & 2); e(a & 1); e(0); e(0); // Not needed, but makes a better art with the cost of 5 chars. } e(10); } } static void e(int c) { System.out.print((char) (c < 2 ? c * 3 + 32 : c)); } static BigDecimal v(int k) { return BigDecimal.valueOf(k); } static BigDecimal f(int k) { return k < 2 ? v(1) : f(k - 1).multiply(v(k)); } } 
### # # # # ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### # #  # # # # # # # # # # # # # # # # # # # # # # # # #  # #  ### # ### # ### ### ### ### ### ### ### ### ### # ### ### ### ### ### ### # # # # # # # # # # # # # # # # # # # # # #  #  ### # # # # ### ### ### ### ### ### ### ### ### # ### ### ### ### ### # 
import java.math.BigDecimal;class H{public static void main(String[]h)throws Exception{int[]t={31599,4681,31183,29647,5101,29671,31719,4687,31727,29679,8192};BigDecimal y=v(-3);for(int n=1;n<99;n++)y=y.add(v(n).multiply(v(2).pow(n)).multiply(f(n).pow(2)).divide(f(2*n),40,0));for(int z=0;z<5;z++){for(char c:y.toPlainString().substring(0,20).toCharArray()){if(c<48)c=58;int a=(t[c-48]>>>z*3)&7;e(a/4);e(a/2&1);e(a&1);e(0);e(0);}e(10);}}static void e(int c){System.out.print((char)(c<2?c*3+32:c));}static BigDecimal v(int k){return BigDecimal.valueOf(k);}static BigDecimal f(int k){return k<2?v(1):f(k-1).multiply(v(k));}} 
import java.math.BigDecimal; class H { public static void main(String[] h) throws Exception { // Each block corresponds to a line. Each char has 5 lines with a 3-char width. int[] t = { 0b111_101_101_101_111, 0b001_001_001_001_001, 0b111_100_111_001_111, 0b111_001_111_001_111, 0b001_001_111_101_101, 0b111_001_111_100_111, 0b111_101_111_100_111, 0b001_001_001_001_111, 0b111_101_111_101_111, 0b111_001_111_101_111, 0b010_000_000_000_000 }; // Calculate PI using the Simon Plouffe formula, 1996. BigDecimal y = v(-3); for (int n = 1; n < 99; n++) y = y.add(v(n).multiply(v(2).pow(n)).multiply(f(n).pow(2)).divide(f(2 * n), 40, 0)); for (int z = 0; z < 5; z++) { for (char c : y.toPlainString().substring(0, 20).toCharArray()) { if (c < 48) c = 58; int a = (t[c - 48] >>> z * 3) & 7; e(a / 4); e(a / 2 & 2); e(a & 1); e(0); e(0); // Not needed, but makes a better art with the cost of 5 chars. } e(10); } } static void e(int c) { System.out.print((char) (c < 2 ? c * 3 + 32 : c)); } static BigDecimal v(int k) { return BigDecimal.valueOf(k); } static BigDecimal f(int k) { return k < 2 ? v(1) : f(k - 1).multiply(v(k)); } } 
### # # # # ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### # # # # # # # # # # # # # # # # # # # # # # # # # ### # ### # ### ### ### ### ### ### ### ### ### # ### ### ### ### ### # # # # # # # # # # # # # # # # # # # # # # ### # # # # ### ### ### ### ### ### ### ### ### # ### ### ### ### ### 
import java.math.BigDecimal;class H{public static void main(String[]h)throws Exception{int[]t={31599,4681,31183,29647,5101,29671,31719,4687,31727,29679,8192};BigDecimal y=v(-3);for(int n=1;n<99;n++)y=y.add(v(n).multiply(v(2).pow(n)).multiply(f(n).pow(2)).divide(f(2*n),42,0));for(int z=0;z<5;z++){for(char c:y.toPlainString().substring(0,21).toCharArray()){if(c<48)c=58;int a=(t[c-48]>>>z*3)&7;e(a/4);e(a/2&1);e(a&1);e(0);e(0);}e(10);}}static void e(int c){System.out.print((char)(c<2?c*3+32:c));}static BigDecimal v(int k){return BigDecimal.valueOf(k);}static BigDecimal f(int k){return k<2?v(1):f(k-1).multiply(v(k));}} 
import java.math.BigDecimal; class H { public static void main(String[] h) throws Exception { // Each block corresponds to a line. Each char has 5 lines with a 3-char width. int[] t = { 0b111_101_101_101_111, 0b001_001_001_001_001, 0b111_100_111_001_111, 0b111_001_111_001_111, 0b001_001_111_101_101, 0b111_001_111_100_111, 0b111_101_111_100_111, 0b001_001_001_001_111, 0b111_101_111_101_111, 0b111_001_111_101_111, 0b010_000_000_000_000 }; // Calculate PI using the Simon Plouffe formula, 1996. BigDecimal y = v(-3); for (int n = 1; n < 99; n++) y = y.add(v(n).multiply(v(2).pow(n)).multiply(f(n).pow(2)).divide(f(2 * n), 42, 0)); for (int z = 0; z < 5; z++) { for (char c : y.toPlainString().substring(0, 21).toCharArray()) { if (c < 48) c = 58; int a = (t[c - 48] >>> z * 3) & 7; e(a / 4); e(a / 2 & 2); e(a & 1); e(0); e(0); // Not needed, but makes a better art with the cost of 5 chars. } e(10); } } static void e(int c) { System.out.print((char) (c < 2 ? c * 3 + 32 : c)); } static BigDecimal v(int k) { return BigDecimal.valueOf(k); } static BigDecimal f(int k) { return k < 2 ? v(1) : f(k - 1).multiply(v(k)); } } 
### # # # # ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### # #  # # # # # # # # # # # # # # # # # # # # # # # # #  # #  ### # ### # ### ### ### ### ### ### ### ### ### # ### ### ### ### ### ### # # # # # # # # # # # # # # # # # # # # # #  #  ### # # # # ### ### ### ### ### ### ### ### ### # ### ### ### ### ### # 
Adding the output
Source Link
Victor Stafusa
  • 8.8k
  • 5
  • 42
  • 63

Output:

### # # # # ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### # # # # # # # # # # # # # # # # # # # # # # # # # ### # ### # ### ### ### ### ### ### ### ### ### # ### ### ### ### ### # # # # # # # # # # # # # # # # # # # # # # ### # # # # ### ### ### ### ### ### ### ### ### # ### ### ### ### ### 

Output:

### # # # # ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### # # # # # # # # # # # # # # # # # # # # # # # # # ### # ### # ### ### ### ### ### ### ### ### ### # ### ### ### ### ### # # # # # # # # # # # # # # # # # # # # # # ### # # # # ### ### ### ### ### ### ### ### ### # ### ### ### ### ### 
Shaving 20 chars
Source Link
Victor Stafusa
  • 8.8k
  • 5
  • 42
  • 63

Java - 642642 622 characters

import java.math.BigDecimal;class H{public static void main(String[]h)throws Exception{int[]t={31599,4681,31183,29647,5101,29671,31719,4687,31727,29679,8192};BigDecimal y=v(-3);for(int n=1;n<99;n++)y=y.add(v(n).multiply(v(2).pow(n)).multiply(f(n).pow(2)).divide(f(2*n),40,0));for(int z=0;z<5;z++){for(char c:y.toPlainString().substring(0,20).toCharArray()){if(c<48)c=58;int a=(t[c-48]>>>z*3)&7;e((a&4)!=0?35:32a/4);e((a&2)!=0?35:32a/2&1);e((a&1)!=0?35:32);e(320);e(320);}e(10);}}static void e(int c){System.out.print((char)(c<2?c*3+32:c));}static BigDecimal v(int k){return BigDecimal.valueOf(k);}static BigDecimal f(int k){return k<2?v(1):f(k-1).multiply(v(k));}} 
import java.math.BigDecimal; class H { public static void main(String[] h) throws Exception { // Each block corresponds to a line. Each char has 5 lines with a 3-char width. int[] t = { 0b111_101_101_101_111, 0b001_001_001_001_001, 0b111_100_111_001_111, 0b111_001_111_001_111, 0b001_001_111_101_101, 0b111_001_111_100_111, 0b111_101_111_100_111, 0b001_001_001_001_111, 0b111_101_111_101_111, 0b111_001_111_101_111, 0b010_000_000_000_000 }; // Calculate PI using the Simon Plouffe formula, 1996. BigDecimal y = v(-3); for (int n = 1; n < 99; n++) y = y.add(v(n).multiply(v(2).pow(n)).multiply(f(n).pow(2)).divide(f(2 * n), 40, 0)); for (int z = 0; z < 5; z++) { for (char c : y.toPlainString().substring(0, 20).toCharArray()) { if (c < 48) c = 58; int a = (t[c - 48] >>> z * 3) & 7; e((a &/ 4) != 0 ? 35 : 32); e((a &/ 2) != 0 ? 35 :& 322); e((a & 1) != 0 ? 35 : 32); e(320); e(320); // Not needed, but makes a better art with the cost of 65 chars. } e(10); } } static void e(int c) { System.out.print((char) (c < 2 ? c * 3 + 32 : c)); } static BigDecimal v(int k) { return BigDecimal.valueOf(k); } static BigDecimal f(int k) { return k < 2 ? v(1) : f(k - 1).multiply(v(k)); } } 

Java - 642 characters

import java.math.BigDecimal;class H{public static void main(String[]h)throws Exception{int[]t={31599,4681,31183,29647,5101,29671,31719,4687,31727,29679,8192};BigDecimal y=v(-3);for(int n=1;n<99;n++)y=y.add(v(n).multiply(v(2).pow(n)).multiply(f(n).pow(2)).divide(f(2*n),40,0));for(int z=0;z<5;z++){for(char c:y.toPlainString().substring(0,20).toCharArray()){if(c<48)c=58;int a=(t[c-48]>>>z*3)&7;e((a&4)!=0?35:32);e((a&2)!=0?35:32);e((a&1)!=0?35:32);e(32);e(32);}e(10);}}static void e(int c){System.out.print((char)c);}static BigDecimal v(int k){return BigDecimal.valueOf(k);}static BigDecimal f(int k){return k<2?v(1):f(k-1).multiply(v(k));}} 
import java.math.BigDecimal; class H { public static void main(String[] h) throws Exception { // Each block corresponds to a line. Each char has 5 lines with a 3-char width. int[] t = { 0b111_101_101_101_111, 0b001_001_001_001_001, 0b111_100_111_001_111, 0b111_001_111_001_111, 0b001_001_111_101_101, 0b111_001_111_100_111, 0b111_101_111_100_111, 0b001_001_001_001_111, 0b111_101_111_101_111, 0b111_001_111_101_111, 0b010_000_000_000_000 }; // Calculate PI using the Simon Plouffe formula, 1996. BigDecimal y = v(-3); for (int n = 1; n < 99; n++) y = y.add(v(n).multiply(v(2).pow(n)).multiply(f(n).pow(2)).divide(f(2 * n), 40, 0)); for (int z = 0; z < 5; z++) { for (char c : y.toPlainString().substring(0, 20).toCharArray()) { if (c < 48) c = 58; int a = (t[c - 48] >>> z * 3) & 7; e((a & 4) != 0 ? 35 : 32); e((a & 2) != 0 ? 35 : 32); e((a & 1) != 0 ? 35 : 32); e(32); e(32); // Not needed, but makes a better art with the cost of 6 chars. } e(10); } } static void e(int c) { System.out.print((char) c); } static BigDecimal v(int k) { return BigDecimal.valueOf(k); } static BigDecimal f(int k) { return k < 2 ? v(1) : f(k - 1).multiply(v(k)); } } 

Java - 642 622 characters

import java.math.BigDecimal;class H{public static void main(String[]h)throws Exception{int[]t={31599,4681,31183,29647,5101,29671,31719,4687,31727,29679,8192};BigDecimal y=v(-3);for(int n=1;n<99;n++)y=y.add(v(n).multiply(v(2).pow(n)).multiply(f(n).pow(2)).divide(f(2*n),40,0));for(int z=0;z<5;z++){for(char c:y.toPlainString().substring(0,20).toCharArray()){if(c<48)c=58;int a=(t[c-48]>>>z*3)&7;e(a/4);e(a/2&1);e(a&1);e(0);e(0);}e(10);}}static void e(int c){System.out.print((char)(c<2?c*3+32:c));}static BigDecimal v(int k){return BigDecimal.valueOf(k);}static BigDecimal f(int k){return k<2?v(1):f(k-1).multiply(v(k));}} 
import java.math.BigDecimal; class H { public static void main(String[] h) throws Exception { // Each block corresponds to a line. Each char has 5 lines with a 3-char width. int[] t = { 0b111_101_101_101_111, 0b001_001_001_001_001, 0b111_100_111_001_111, 0b111_001_111_001_111, 0b001_001_111_101_101, 0b111_001_111_100_111, 0b111_101_111_100_111, 0b001_001_001_001_111, 0b111_101_111_101_111, 0b111_001_111_101_111, 0b010_000_000_000_000 }; // Calculate PI using the Simon Plouffe formula, 1996. BigDecimal y = v(-3); for (int n = 1; n < 99; n++) y = y.add(v(n).multiply(v(2).pow(n)).multiply(f(n).pow(2)).divide(f(2 * n), 40, 0)); for (int z = 0; z < 5; z++) { for (char c : y.toPlainString().substring(0, 20).toCharArray()) { if (c < 48) c = 58; int a = (t[c - 48] >>> z * 3) & 7; e(a / 4); e(a / 2 & 2); e(a & 1); e(0); e(0); // Not needed, but makes a better art with the cost of 5 chars. } e(10); } } static void e(int c) { System.out.print((char) (c < 2 ? c * 3 + 32 : c)); } static BigDecimal v(int k) { return BigDecimal.valueOf(k); } static BigDecimal f(int k) { return k < 2 ? v(1) : f(k - 1).multiply(v(k)); } } 
Source Link
Victor Stafusa
  • 8.8k
  • 5
  • 42
  • 63
Loading