Advertisement
Spocoman

Draw Fort

Oct 11th, 2023 (edited)
540
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function drawFort(input) {
  2.     let n = Number(input[0]);
  3.  
  4.     let x = n > 4 ? n * 2 - (n / 2 + 2) * 2 : 0;
  5.  
  6.     console.log(`/${'^'.repeat(n / 2)}\\${'_'.repeat(x)}/${'^'.repeat(n / 2)}\\`);
  7.  
  8.     for (let i = 0; i < n - 3; i++) {
  9.         console.log(`|${' '.repeat(n * 2 - 2)}|`);
  10.     }
  11.  
  12.     console.log(`|${' '.repeat((n * 2 - (x + 2)) / 2)}${'_'.repeat(x)}${' '.repeat((n * 2 - (x + 2)) / 2)}|`,);
  13.  
  14.     console.log(`\\${'_'.repeat(n / 2)}/${' '.repeat(x)}\\${'_'.repeat(n / 2)}/`);
  15.  
  16.     return;
  17. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement