Skip to content

esilvajr/linio-challenge

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Build Status Code Climate

Linio Challenge

Challenge

Write a program that prints all the numbers from 1 to 100. However, for multiples of 3, instead of the number, print "Linio". For multiples of 5 print "IT". For numbers which are multiples of both 3 and 5, print "Linianos".

But here's the catch: you can use only one if. No multiple branches, ternary operators or else.

Requisites

  • 1 if
  • You can't use 'else', 'else if' or ternary
  • Unit tests
  • You can write the challenge in any language you want. Here at Linio we are big fans of PHP, Kotlin and TypeScript

Submission

You can create a public repository on your GitHub account and send the link to us.

Environment

Requirements

Installation

  1. Download or clone the repository
  2. Execute the composer command in project root:
    composer install
  1. Run challenge php script in project root:
    php sample.php

Unit test

To run the PHPUnit tests execute the follow command in Terminal from project root:

    cd vendor/bin
    phpunit ../../tests/MultipleTest
    phpunit ../../tests/ResponsibilityTest

or, only if you've phpunit in environment, in project root:

    phpunit -c ./tests/phpunit.xml

Usage

<?php
    require_once 'vendor/autoload.php';
    
    /*
     * Linio Client: uses chain of responsibility pattern
     */
    $linioClient = new \Linio\Client();
    $linioClient->getResult()->toPrintConsole();
    
    /*
     * Linio Lookup: uses recursion and lookup table
     */
    $linioLookup = new \Linio\Lookup();
    $linioLookup->getResult()->toPrintConsole();
    
    /*
     * The method getResult():
     *
     * getResult()->toJson() : strings
     * getResult()->toArray() : array
     * getResult()->toPrintConsole() : void
     * getResult()->toPrintHtml() : void
     */

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages