john-halbert / permy

Generates permutations of a string in PHP

Home Page:http://johnhalbert.com/permy

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Permy

Requirements

Write a program which prints all the permutations of a string in alphabetical order. We consider that digits < upper case letters < lower case letters. The sorting should be performed in ascending order

INPUT SAMPLE:

Your program should accept a file as its first argument. The file contains input strings, one per line.

For example: hat abc Zu6

OUTPUT SAMPLE:

Print to stdout the permutations of the string separated by comma, in alphabetical order. For example:

aht,ath,hat,hta,tah,tha

abc,acb,bac,bca,cab,cba

6Zu,6uZ,Z6u,Zu6,u6Z,uZ6

Running from CLI

  • php src/index-cli.php dictionary.txt

Running from Web

Tests

  • Install PHPUnit
  • phpunit --bootstrap src/PermuteTest.class.php tests/PermuteTest.php

About

Generates permutations of a string in PHP

http://johnhalbert.com/permy


Languages

Language:PHP 41.7%Language:CSS 37.4%Language:HTML 11.4%Language:JavaScript 9.5%