Skip to content

Instantly share code, notes, and snippets.

View nderwin's full-sized avatar
🚂

Nathan Erwin nderwin

🚂
  • USA
  • 22:22 (UTC -04:00)
View GitHub Profile
@nderwin
nderwin / tree.jsh
Created December 13, 2021 17:38
Make an ASCII Christmas Tree with a jshell script
import java.nio.*;
String num = Files.readString(Path.of("merry-christmas.txt"));
int x = 25;
try { x = Integer.parseInt(num.trim()); } catch (NumberFormatException ex) {}
StringBuilder sb = new StringBuilder("");
for (int i = 1; i <= x; i++) { sb.append(" ".repeat(x-i)).append("*".repeat(i+(i-1))).append("\n"); }