Coder Social home page Coder Social logo

magic-square's Introduction

magic-square

Create a magic square of order three in your terminal.

"Magic square" is the name given to a square array of numbers if the sums of the numbers in each row, each column, and both main diagonals are the same; the number that each sum gives is called the "magic constant". "Order" is the number of integers along one side. (Wikipedia)

Setup

To use magic-square, you need to download the executable (.exe) file in the Releases page and use it via the command-line.

Usage

$ magic-square A B C [--style STYLE]

where

  • A is a positive integer: A > 0;
  • B is an integer greater than A and not equal to the double of A: B > A && B /= 2 * A;
  • C is an integer greater than B plus A: C > B + A;
  • STYLE prints the magic square with the chosen style (--styles-list shows available styles).

Examples

$ magic-square 1 5 9
 4 | 15 |  8
------------
13 |  9 |  5
------------
10 |  3 | 14

$ magic-square 1 3 5 -sMinimal
2 9 4
7 5 3
6 1 8

$ magic-square 1 4 7 -sPlus
 3 + 12 +  6
++++++++++++
10 +  7 +  4
++++++++++++
 8 +  2 + 11

$ magic-square 2 3 8 -sBox
 5 || 13 ||  6
##############
 9 ||  8 ||  7
##############
10 ||  3 || 11

$ magic-square 1 6 9 -sArray
[[ 3, 16,  8],
 [14,  9,  4],
 [10,  2, 15]]

magic-square's People

Contributors

erickcan avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.