Advertisement
caucow

The Maths behind Cabbiton's Ceiling

Oct 16th, 2016
56
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.52 KB | None | 0 0
  1. public static void main(String[] args) {
  2. try {
  3. double num = Math.PI / 2.0 / 68.0;
  4. int[][] feelsgood = new int[69][69];
  5. for (int i = 0; i < 69; i++) {
  6. for (int j = 0; j < 69; j++) {
  7. double dist = Math.sqrt(i * i + j * j);
  8. int rnd = (int) Math.round(dist);
  9. if (rnd <= 68) {
  10. feelsgood[i][j] = (int) Math.round(20 * Math.sin(Math.PI * 0.5 + rnd * num));
  11. } else {
  12. feelsgood[i][j] = -1;
  13. }
  14. }
  15. }
  16. String bigblock = String.format("%69s", "").replace(" ", "+--") + "+";
  17. for (int i = 0; i < 69; i++) {
  18. System.out.println(bigblock);
  19. for (int j = 0; j < 69; j++) {
  20. if (i == j) {
  21. System.out.print("|##");
  22. } else if (feelsgood[i][j] != -1 && (i % 4 == 0 || j % 4 == 0)) {
  23. if (feelsgood[i][j] % 2 == 1) {
  24. System.out.print("|--");
  25. } else {
  26. System.out.printf("|%2d", feelsgood[i][j]);
  27. }
  28. } else {
  29. System.out.print("| ");
  30. }
  31. }
  32. System.out.println("|");
  33. }
  34. System.out.println(bigblock);
  35. } catch (Exception e) {
  36. }
  37. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement