DEV Community

loading...
Cover image for Code to generate the Map of India using Node.js

Code to generate the Map of India using Node.js

vinitshahdeo profile image Vinit Shahdeo ・1 min read

Hello 👋

I am Vinit Shahdeo, a Software Engineer from India. Yesterday on 15th August, India celebrated its 74th Independence Day. At midnight, I got an idea to write a code in JavaScript(Node.js) to generate the Map Of India. I've already seen code snippets in C/C++ which do the same but found nothing using JavaScript so far. With this spirit, I opened VSCode and started smashing my keys and finally ended up having a Node.js script to generate the Map of India.

In this article, I'm trying to explain the obfuscated code which does the magic.

const MAGIC_STRING = "TFy!QJu ROo TNn(ROo)SLq SLq ULo+UHs UJq TNn*RPn/QPbEWS_JSWQAIJO^NBELPeHBFHT}TnALVlBLOFAkHFOuFETpHCStHAUFAgcEAelclcn^r^r\\tZvYxXyT|S~Pn SPm SOn TNn ULo0ULo#ULo-WHq!WFs XDt!"
Enter fullscreen mode Exit fullscreen mode

The above encoded string is basically a binary sequence converted to ASCII in which alternating characters stores how many times to draw space and how many times to draw an exclamation mark(!).

Map Of India using Node.js

Here's the link to the GitHub repository.

GitHub logo vinitshahdeo / Map-of-India

A Node.js script to generate the Map of India in terminal

Map of India

A Node.js script to generate the Map of India in terminal

Quick Start 🚀

Open your terminal and run npm start

Setup ⚙️

npm install && npm start
Enter fullscreen mode Exit fullscreen mode

Commands 🔥

  • npm run draw: Prints Map of India 🇮🇳 in the terminal

  • npm run wish: Prints a Happy Independence Day message in the terminal

Explained 🏗️

cd src && cat index.js
Enter fullscreen mode Exit fullscreen mode

Navigate to src/ folder and check out index.js.

         .--,_
        ['    '\
         \       `''|
         |         ,]
          `._      ].
            |     \
          _/       -'\
         ,'          ,'
       _/'          \                     ,..-''L_
  |--''              '-;__        |\     /      .,'
   \                      `--.__,'_ '----     ,-'
   `\                             \`-'\__    ,|
,--;/                             /     .| ,/
\__                               '|    /  / 
  ./  _-,                         _|   S@yaN
  \__/ /                        ,/        "
       |                      _/
       |                    ,/
       \                   /
        |              /.-'
         \           _/                   :
          |
…
Enter fullscreen mode Exit fullscreen mode

Say Hi on Twitter(@Vinit_Shahdeo)!

Thanks :)

Discussion (2)

pic
Editor guide
Collapse
not4ro profile image
Matteo Notaro

This is with or without Kashmir?