Skip to content

A simple way to generate dynamic pyramid without PHP looping functions (for, foreach, while) via CLI.

License

Notifications You must be signed in to change notification settings

trisna-ashari/php-dynamic-pyramid

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 

Repository files navigation

PHP Dynamic Pyramid

Challenge yout self?

Can you write only 5 lines of php code to make output like this?

  • 5 lines of code
  • without for, forach, & while
  • dynamic level
*******************
 *****************
  ***************
   *************
    ***********
     *********
      *******
       *****
        ***
         *
        ***
       *****
      *******
     *********
    ***********
   *************
  ***************
 *****************
*******************

Given Up?

You can run it via terminal or command line:

Set your working directory to ./php-dynamic-pyramid
type php php-dynamic-pyraid.php then enter

or open it via browser.

The Goal

To simulate of using native php recursive function without using for, foreach, & while.

Sample output:

*******************
 *****************
  ***************
   *************
    ***********
     *********
      *******
       *****
        ***
         *
        ***
       *****
      *******
     *********
    ***********
   *************
  ***************
 *****************
*******************

0.0052859783172607

One-side-up pyramid:

         *
        ***
       *****
      *******
     *********
    ***********
   *************
  ***************
 *****************
*******************

0.0028870105743408

One-side-bottom pyramid:

*******************
 *****************
  ***************
   *************
    ***********
     *********
      *******
       *****
        ***
         *

0.0045459270477295

About

A simple way to generate dynamic pyramid without PHP looping functions (for, foreach, while) via CLI.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages