Coder Social home page Coder Social logo

trianglecalculator's Introduction

Triangle Grid Calculator

This project solves the problems posed in this pdf.

https://drive.google.com/open?id=1PX4U_6829m6dR_fBjSpygfGNISqMi2ZI

I solved the problems in two ways. First way was to create triangle objects in a list with their coordinates and labels then use LINQ to query the list. This method throws exceptions if the parameters are out of range or invalid. Second way uses math and regular expressions to figure out the row, column, and position (upper / lower) of the triangle based on the provided parameters. This way can calculate for infinite columns and 26 (alphabet restricted) rows.

1. Sample Requests (using LINQ).

First way using LINQ entities.

Using LINQ - Get all Triangles

https://localhost:44384/api/values/AllTriangles

Using LINQ - Get a triangle by label (task 1A)

https://localhost:44384/api/values/GetByLabel?label=C6

Using LINQ - Get a triangle by coordinates (task 1B)

https://localhost:44384/api/values/GetByCoordinates?aX=30&aY=50&bX=30&bY=60&cX=40&cY=60

2. Sample Requests (not using LINQ).

Second way using math and a regular expression.

Caclulate coordinates by label (task 1A)

https://localhost:44384/api/values/GetByLabelInference?label=A2

Calculate label by coordinates (task 1B)

https://localhost:44384/api/values/GetByInferenceCoordinates?aX=40&aY=30&bX=40&bY=40&cX=50&cY=40

The following request examples show how we can go beyond the grid in the sample and get any row (A-Z) and column.

https://localhost:44384/api/values/GetByInferenceCoordinates?aX=2050&aY=60&bX=2050&bY=70&cX=2060&cY=70

https://localhost:44384/api/values/GetByLabelInference?label=S448

trianglecalculator's People

Contributors

ajfleming1 avatar

Watchers

James Cloos avatar  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.