DEV Community

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

Posted on

22 9

Code to generate the Map of India using Node.js

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.

For the binary version of the map, please checkout republic day/index.js.

cd republic\ day
node index.js
Enter fullscreen mode Exit fullscreen mode
         .--,_
        ['    '\
         \       `''|
         |         ,]
          `._      ].
            |     \
          _/       -'\
         ,'          ,'
       _/'          \                     ,..-''L_
  |--''              '-;__        |\     /      .,'
   \                      `--.__,'_ '----     ,-'
   `\                             \`-'\__    ,|
,--;/                             /     .| ,/
\__                               '|    /  / 
โ€ฆ
Enter fullscreen mode Exit fullscreen mode

Say Hi on Twitter(@Vinit_Shahdeo)!

Thanks :)

Image of Datadog

How to Diagram Your Cloud Architecture

Cloud architecture diagrams provide critical visibility into the resources in your environment and how theyโ€™re connected. In our latest eBook, AWS Solution Architects Jason Mimick and James Wenzel walk through best practices on how to build effective and professional diagrams.

Download the Free eBook

Top comments (1)

Collapse
 
not4ro profile image
Matteo Notaro โ€ข

This is with or without Kashmir?

Billboard image

The Next Generation Developer Platform

Coherence is the first Platform-as-a-Service you can control. Unlike "black-box" platforms that are opinionated about the infra you can deploy, Coherence is powered by CNC, the open-source IaC framework, which offers limitless customization.

Learn more

๐Ÿ‘‹ Kindness is contagious

Please leave a โค๏ธ or a friendly comment on this post if you found it helpful!

Okay