Permutation Scoreboard
Rank Username Score
1 primo 1000 (53 B)
2 milieu 768 (69 B)
3 JWvdVeer 768 (69 B)
4 Wim 768 (69 B)
5 Steinigtmich 768 (69 B)
6 ToastyX 768 (69 B)
7 vgadge 768 (69 B)
8 henrik 768 (69 B)
9 six 757 (70 B)
10 lheurt 757 (70 B)
11 Electron 757 (70 B)
12 sl1m 757 (70 B)
13 nubs 757 (70 B)
14 spicausis 746 (71 B)
15 luci 746 (71 B)
16 eremit 746 (71 B)
17 ralf 746 (71 B)
18 geli 736 (72 B)
19 jared 736 (72 B)
20 helge 716 (74 B)
Recent Activity
Username Bytes Time ago Result
primo 53 December 04 2011, 19:22:51
primo 53 December 04 2011, 19:20:50
primo 53 December 04 2011, 19:19:53
primo 53 December 04 2011, 19:18:21
primo 53 December 04 2011, 19:17:26
primo 53 December 04 2011, 19:16:40
primo 53 December 04 2011, 19:15:40
primo 53 December 04 2011, 19:14:27
primo 53 December 04 2011, 19:13:33
primo 53 December 04 2011, 19:12:26
primo 53 December 04 2011, 19:11:18
primo 53 December 04 2011, 19:09:15
primo 53 December 04 2011, 19:05:42
primo 53 December 04 2011, 19:04:24
primo 53 December 04 2011, 19:02:45

Challenge: Permutation

Challenge information

Challenge Type Public
Challenge Status Open
Constant name WORD
Trim method Full trim
Rating [ up ] [ down ]

Instructions

There will be one trimmed random word in the constant.

No word will be longer then 6 characters.

Output the word in the constant with the total permutations as possible.

Separate each word with a newline.

The output must be in alphabetical order.

Example

Show/hide Input
asdf
Show/hide Output
adfs
adsf
afds
afsd
asdf
asfd
dafs
dasf
dfas
dfsa
dsaf
dsfa
fads
fasd
fdas
fdsa
fsad
fsda
sadf
safd
sdaf
sdfa
sfad
sfda

Comments

Show/hide comments (4)
lheurt December 20 2011, 00:12:15
Wow this 53 chars is brilliant! Doesn't it break with a 'z' though ?
primo December 20 2011, 07:31:01
It does, so it is a slight cheat. The other option would be Q^$w++, which would break whenever there's an 'a'. All of the 69s break when the input length is larger than 4 as well, though: they each output a maximum of 99 permutations, where an input length of 5 would require 5! == 120.
mit March 03 2012, 15:02:45
primo, i cant run your code, how is it working?

PHP Notice: Use of undefined constant J - assumed 'J' in test.php on line 5

thank you.
primo March 10 2012, 13:06:36
A notice shouldn't affect the execution of the code. The code does, however, assume a pre-defined constant called 'WORD', as the problem describes.

A sample test script might look something like this:

<?php

  define
('WORD''abcd');

  include(
'permutation.php');

?>

assuming the code is saved in a file called 'permutation.php' in the same directory as the test script.

Submissions

53 bytes (ver. 31) by primo Show / Hide
<?for($w=a;J^$w++||!$f;)trim(WORD,$w)?:$f=print$w.~;
69 bytes (ver. 3) by henrik Show / Hide
<?for(;$i++<99;$a[$b=str_shuffle(WORD)]=$b);sort($a)?><?=join($a,~);
69 bytes (ver. 4) by Steinigtmich Show / Hide
<?for(;$i++<99;$a[$o=str_shuffle(WORD)]=$o);sort($a)?><?=join(~,$a);
69 bytes (ver. 5) by milieu Show / Hide
<?for(;$i++<99;)$a[$c=str_shuffle(WORD)]=$c;sort($a)?><?=join(~,$a);
69 bytes (ver. 2) by ToastyX Show / Hide
<?for(;++$x<99;)$a[$b=str_shuffle(WORD)]=$b.~;sort($a)?><?=join($a);
69 bytes (ver. 26) by JWvdVeer Show / Hide
<?for(;++$a<99;$b[$c=str_shuffle(WORD)]=$c);sort($b)?><?=join(~,$b);
69 bytes (ver. 27) by JWvdVeer Show / Hide
<?for(;++$a<99;$b[$c=str_shuffle(WORD)]=$c);sort($b)?><?=join(~,$b);
69 bytes (ver. 29) by JWvdVeer Show / Hide
<?for(;++$a<99;$b[$c=str_shuffle(WORD)]=$c);sort($b)?><?=join(~,$b);
69 bytes (ver. 30) by JWvdVeer Show / Hide
<?for(;++$a<99;$b[$c=str_shuffle(WORD)]=$c);sort($b)?><?=join(~,$b);
69 bytes (ver. 2) by milieu Show / Hide
<?for(;$i++<99;)$a[$c=str_shuffle(WORD)]=$c;sort($a)?><?=join(~,$a);
69 bytes (ver. 3) by milieu Show / Hide
<?for(;$i++<99;)$a[$c=str_shuffle(WORD)]=$c;sort($a)?><?=join(~,$a);
69 bytes (ver. 21) by Wim Show / Hide
<?for(;$i++<99;$w[$d=str_shuffle(WORD)]="$d
"
);sort($w)?><?=join($w);
69 bytes (ver. 22) by Wim Show / Hide
<?for(;$i++<99;$w[$d=str_shuffle(WORD)]="$d
"
);sort($w)?><?=join($w);
69 bytes (ver. 11) by vgadge Show / Hide
<?for(;$i++<99;$k[$s=str_shuffle(WORD)]=$s);sort($k)?><?=join(~,$k);
70 bytes (ver. 2) by Electron Show / Hide
<?for(;1E6>$j++;)$x[$i=str_shuffle(WORD)]="$i
"
;sort($x)?><?=join($x);
70 bytes (ver. 2) by henrik Show / Hide
<?for(;$i++<1e3;ksort($a))$a[$b=str_shuffle(WORD)]=$b?><?=join($a,~);
70 bytes (ver. 2) by Steinigtmich Show / Hide
<?for(;$i++<99;$a[$o=str_shuffle(WORD)]=$o);sort($a)?><?=join("
"
,$a);
70 bytes (ver. 11) by sl1m Show / Hide
<?for(;++$j<99;$c[$p=str_shuffle(WORD)]=$p)@asort($c)?><?=join(~,$c);
70 bytes (ver. 3) by Steinigtmich Show / Hide
<?for(;$i++<99;$a[$o=str_shuffle(WORD)]=$o);sort($a)?><?=join("
"
,$a);
70 bytes (ver. 5) by Steinigtmich Show / Hide
<?for(;$i++<999;$a[$o=str_shuffle(WORD)]=$o);sort($a)?><?=join(~,$a);
70 bytes (ver. 6) by Steinigtmich Show / Hide
<?for(;$i++<999;$a[$o=str_shuffle(WORD)]=$o);sort($a)?><?=join(~,$a);
70 bytes (ver. 7) by Steinigtmich Show / Hide
<?for(;$i++<9e3;$a[$o=str_shuffle(WORD)]=$o);sort($a)?><?=join(~,$a);
70 bytes (ver. 3) by primo Show / Hide
<?for(;$i++<1e4;)$a[$c=str_shuffle(WORD)]=$c;sort($a)?><?=join(~,$a);
70 bytes (ver. 21) by JWvdVeer Show / Hide
<?for(;++$a<99;$b[$c=str_shuffle(WORD)]=$c);sort($b);echo join(~,$b);
70 bytes (ver. 22) by JWvdVeer Show / Hide
<?for(;++$a<99;$b[$c=str_shuffle(WORD)]=$c);sort($b);echo join(~,$b);
70 bytes (ver. 6) by milieu Show / Hide
<?for(;$i++<1e4;)$a[$c=str_shuffle(WORD)]=$c;sort($a)?><?=join(~,$a);
70 bytes (ver. 23) by JWvdVeer Show / Hide
<?for(;++$a<99;$b[$c=str_shuffle(WORD)]=$c);sort($b);echo join(~,$b);
70 bytes (ver. 1) by ToastyX Show / Hide
<?for(;++$x<3e3;)$a[$b=str_shuffle(WORD)]=$b.~;sort($a)?><?=join($a);
70 bytes (ver. 1) by nubs Show / Hide
<?for(;$i++<9e3;)$b[$a=str_shuffle(WORD)]=$a;sort($b)?><?=join(~,$b);
70 bytes (ver. 25) by JWvdVeer Show / Hide
<?for(;++$a<9e3;$b[$c=str_shuffle(WORD)]=$c);sort($b)?><?=join(~,$b);
70 bytes (ver. 13) by Wim Show / Hide
<?for(;$i++<1e4;ksort($w))$w[$d=str_shuffle(WORD)]="$d
"
?><?=join($w);
70 bytes (ver. 4) by six Show / Hide
<?while($i++<1e4)$a[$z]=$z=str_shuffle(WORD).~;sort($a)?><?=join($a);
70 bytes (ver. 6) by lheurt Show / Hide
<?for(;$i++<1e6;$a[$j=str_shuffle(WORD)]="$j
"
);sort($a)?><?=join($a);
70 bytes (ver. 14) by Wim Show / Hide
<?for(;$i++<1e4;)$w[$d=str_shuffle(WORD)]="$d
"
;sort($w)?><?=join($w);
70 bytes (ver. 32) by JWvdVeer Show / Hide
<?for(;++$a<9e4;$b[$c=str_shuffle(WORD)]=$c);sort($b)?><?=join(~,$b);
70 bytes (ver. 33) by JWvdVeer Show / Hide
<?for(;++$a<5e4;$b[$c=str_shuffle(WORD)]=$c);sort($b)?><?=join(~,$b);
70 bytes (ver. 34) by JWvdVeer Show / Hide
<?for(;++$a<1e4;$b[$c=str_shuffle(WORD)]=$c);sort($b)?><?=join(~,$b);
70 bytes (ver. 35) by JWvdVeer Show / Hide
<?for(;++$a<2e5;$b[$c=str_shuffle(WORD)]=$c);sort($b)?><?=join(~,$b);
70 bytes (ver. 10) by vgadge Show / Hide
<?for(;$i++<1e3;$k[$s=str_shuffle(WORD)]=$s);sort($k)?><?=join(~,$k);
70 bytes (ver. 36) by JWvdVeer Show / Hide
<?for(;++$a<5e5;$b[$c=str_shuffle(WORD)]=$c);sort($b)?><?=join(~,$b);
71 bytes (ver. 1) by Electron Show / Hide
<?for(;1E6>$j++;)$x[$i=str_shuffle(WORD)]=$i;sort($x)?><?=join("
"
,$x);
71 bytes (ver. 7) by eremit Show / Hide
<?while(++$j<1e3)$r[$i=str_shuffle(WORD)]=$i;sort($r)?><?=join("
"
,$r);
71 bytes (ver. 5) by lheurt Show / Hide
<?for(;$i++<1e6;$a[$j=str_shuffle(WORD)]=$j);sort($a)?><?=join("
"
,$a);
71 bytes (ver. 24) by JWvdVeer Show / Hide
<?for(;++$a<9e3;$b[$c=str_shuffle(WORD)]=$c);sort($b);echo join(~,$b);
71 bytes (ver. 11) by Wim Show / Hide
<?for(;$i++<1e4;$w[$d=str_shuffle(WORD)]="
$d",ksort($w))?><?=join($w);
71 bytes (ver. 12) by Wim Show / Hide
<?for(;$i++<1e4;$w[$d=str_shuffle(WORD)]="$d
"
,ksort($w))?><?=join($w);
71 bytes (ver. 11) by spicausis Show / Hide
<?for(;++$i<999;$o[$n=str_shuffle(WORD)]="$n
"
);sort($o);die(join($o));
71 bytes (ver. 1) by luci Show / Hide
<?for(;++$i<4E5;)$a[$x=str_shuffle(WORD)]=$x;sort($a)?><?=join("
"
,$a);
71 bytes (ver. 1) by ralf Show / Hide
<?for(;$x++<1E6;$a[$s=str_shuffle(WORD)]=$s.~);sort($a);echo join($a);
72 bytes (ver. 5) by sl1m Show / Hide
<?for(;++$j<99;$c[$p=str_shuffle(WORD)]=$p)@asort($c)?><?=join("
"
,$c);