3v4l.org

run code in 300+ PHP versions simultaneously
<?php // Returns the total number of $count-length strings generatable from $letters. function getPermCount($letters, $count) { $result = 1; // k characters from a set of n has n!/(n-k)! possible combinations for($i = strlen($letters) - $count + 1; $i <= strlen($letters); $i++) { $result *= $i; } return $result; } // Decodes $index to a $count-length string from $letters, no repeat chars. function getPerm($letters, $count, $index) { $result = ''; for($i = 0; $i < $count; $i++) { $pos = $index % strlen($letters); $result .= $letters[$pos]; $index = ($index-$pos)/strlen($letters); $letters = substr($letters, 0, $pos) . substr($letters, $pos+1); } return $result; } $letters = 'abcd'; echo '2 letters from 4:<br>'; for($i = 0; $i < getPermCount($letters, 2); $i++) echo getPerm($letters, 2, $i).'<br>'; echo '<br>3 letters from 4:<br>'; for($i = 0; $i < getPermCount($letters, 3); $i++) echo getPerm($letters, 3, $i). " ";

Here you find the average performance (time & memory) of each version. A grayed out version indicates it didn't complete successfully (based on exit-code).

VersionSystem time (s)User time (s)Memory (MiB)
8.3.60.0090.00618.55
8.3.50.0150.00522.05
8.3.40.0110.00418.98
8.3.30.0070.00720.34
8.3.20.0040.00418.79
8.3.10.0000.00820.84
8.3.00.0050.00319.81
8.2.180.0130.00316.63
8.2.170.0070.00722.96
8.2.160.0070.00721.00
8.2.150.0050.00324.18
8.2.140.0000.00824.66
8.2.130.0040.00426.16
8.2.120.0040.00419.76
8.2.110.0090.00022.25
8.2.100.0080.00317.91
8.2.90.0050.00319.11
8.2.80.0000.00719.16
8.2.70.0040.00417.63
8.2.60.0040.00417.93
8.2.50.0030.00818.07
8.2.40.0070.00018.34
8.2.30.0050.00221.20
8.2.20.0000.00717.64
8.2.10.0000.00817.84
8.2.00.0080.00417.63
8.1.280.0040.01125.92
8.1.270.0040.00423.99
8.1.260.0090.00026.35
8.1.250.0110.00328.09
8.1.240.0080.00323.86
8.1.230.0110.00020.90
8.1.220.0060.00318.77
8.1.210.0040.00418.97
8.1.200.0140.00017.13
8.1.190.0000.00817.53
8.1.180.0000.00818.10
8.1.170.0000.00818.49
8.1.160.0050.00218.81
8.1.150.0000.00818.66
8.1.140.0000.00717.53
8.1.130.0000.00717.71
8.1.120.0050.00517.54
8.1.110.0000.00717.35
8.1.100.0040.00417.47
8.1.90.0040.00417.47
8.1.80.0000.00817.41
8.1.70.0030.00317.46
8.1.60.0050.00417.53
8.1.50.0050.00317.43
8.1.40.0040.00417.43
8.1.30.0060.00317.72
8.1.20.0040.00417.56
8.1.10.0000.00717.50
8.1.00.0110.00017.52
8.0.300.0050.00319.83
8.0.290.0000.00717.05
8.0.280.0040.00418.39
8.0.270.0040.00417.20
8.0.260.0040.00416.79
8.0.250.0070.00017.04
8.0.240.0080.00016.96
8.0.230.0080.00016.90
8.0.220.0000.00716.79
8.0.210.0030.00616.95
8.0.200.0080.00016.86
8.0.190.0000.00717.04
8.0.180.0040.00416.89
8.0.170.0030.00316.91
8.0.160.0040.00416.98
8.0.150.0060.00316.79
8.0.140.0070.00016.92
8.0.130.0000.01013.29
8.0.120.0000.00816.89
8.0.110.0000.00716.79
8.0.100.0040.00416.84
8.0.90.0040.00416.94
8.0.80.0070.01116.96
8.0.70.0030.00516.97
8.0.60.0000.00816.80
8.0.50.0030.00516.77
8.0.30.0090.01216.90
8.0.20.0150.00517.40
8.0.10.0000.00716.99
8.0.00.0130.00516.69
7.4.330.0000.00516.74
7.4.320.0040.00416.61
7.4.300.0060.00316.53
7.4.290.0030.00316.53
7.4.280.0030.00316.66
7.4.270.0040.00416.54
7.4.260.0000.00513.32
7.4.250.0040.00416.42
7.4.240.0060.00316.61
7.4.230.0030.00316.66
7.4.220.0070.01016.58
7.4.210.0090.00616.62
7.4.200.0070.00016.73
7.4.190.0070.00016.59
7.4.160.0090.00916.64
7.4.150.0060.01317.40
7.4.140.0100.01017.86
7.4.130.0110.00716.45
7.4.120.0060.01216.53
7.4.110.0110.00716.45
7.4.100.0120.00616.45
7.4.90.0060.01216.38
7.4.80.0140.00819.39
7.4.70.0140.00316.48
7.4.60.0120.00316.54
7.4.50.0000.00916.43
7.4.40.0030.01022.77
7.4.30.0150.00316.54
7.4.10.0070.00714.85
7.4.00.0060.00914.85
7.3.330.0050.00013.23
7.3.320.0030.00313.32
7.3.310.0000.00816.22
7.3.300.0000.00616.38
7.3.290.0030.01716.36
7.3.280.0070.01316.37
7.3.270.0180.00017.40
7.3.260.0090.01018.24
7.3.250.0090.00916.40
7.3.240.0100.00716.49
7.3.230.0130.00316.46
7.3.210.0070.01016.68
7.3.200.0180.01219.39
7.3.190.0120.00916.52
7.3.180.0120.00416.30
7.3.170.0070.01016.36
7.3.160.0120.00316.62
7.3.130.0160.00314.88
7.3.120.0080.00914.95
7.3.110.0040.01414.82
7.3.100.0040.01515.03
7.3.90.0040.01114.56
7.3.80.0040.00714.88
7.3.70.0070.00715.00
7.3.60.0030.00714.96
7.3.50.0000.01414.81
7.3.40.0060.00614.80
7.3.30.0000.01614.59
7.3.20.0040.01416.86
7.3.10.0020.01016.71
7.3.00.0080.00716.68
7.2.330.0080.01016.50
7.2.320.0030.01316.80
7.2.310.0140.00516.84
7.2.300.0090.00916.83
7.2.290.0060.01016.57
7.2.260.0090.00615.03
7.2.250.0080.00815.35
7.2.240.0060.00915.25
7.2.230.0040.01215.34
7.2.220.0030.01214.98
7.2.210.0030.01314.95
7.2.200.0100.00615.13
7.2.190.0060.00915.11
7.2.180.0040.00714.81
7.2.170.0000.01415.19
7.2.160.0060.00915.16
7.2.150.0030.01017.11
7.2.140.0040.01216.91
7.2.130.0100.00416.87
7.2.120.0030.01016.81
7.2.110.0290.00316.73
7.2.100.0060.01016.92
7.2.90.0100.00716.99
7.2.80.0090.00316.94
7.2.70.0070.01017.06
7.2.60.0060.00716.70
7.2.50.0100.00616.81
7.2.40.0080.00616.85
7.2.30.0050.01016.66
7.2.20.0050.01116.77
7.2.10.0060.00616.71
7.2.00.0090.00617.73
7.1.330.0030.01015.57
7.1.320.0040.00815.96
7.1.310.0070.00715.54
7.1.300.0030.00915.89
7.1.290.0030.01015.44
7.1.280.0080.00615.84
7.1.270.0040.01415.95
7.1.260.0060.00615.54
7.1.250.0040.01115.82
7.1.240.0030.00715.84
7.1.230.0070.00715.93
7.1.220.0060.01215.68
7.1.210.0070.00715.60
7.1.200.0040.00715.59
7.1.190.0040.01115.93
7.1.180.0090.00615.73
7.1.170.0040.00815.82
7.1.160.0060.00616.00
7.1.150.0000.00915.97
7.1.140.0030.01015.92
7.1.130.0040.01116.00
7.1.120.0000.01115.91
7.1.110.0090.00615.70
7.1.100.0050.00916.98
7.1.90.0060.00615.98
7.1.80.0090.00316.02
7.1.70.0050.00716.35
7.1.60.0060.01317.49
7.1.50.0060.01116.39
7.1.40.0110.00715.86
7.1.30.0070.01015.82
7.1.20.0030.01015.56
7.1.10.0070.00715.78
7.1.00.0020.02418.99
7.0.330.0000.01215.51
7.0.320.0000.01915.11
7.0.310.0090.00615.41
7.0.300.0000.01015.39
7.0.290.0070.00415.32
7.0.280.0030.00615.40
7.0.270.0060.00815.33
7.0.260.0000.01415.23
7.0.250.0060.00615.23
7.0.240.0060.00615.54
7.0.230.0000.01615.58
7.0.220.0040.01115.26
7.0.210.0090.00615.52
7.0.200.0060.00516.12
7.0.190.0070.00715.33
7.0.180.0040.01115.11
7.0.170.0070.01115.55
7.0.160.0030.00915.59
7.0.150.0070.00715.52
7.0.140.0100.03518.64
7.0.130.0030.01115.57
7.0.120.0070.00315.73
7.0.110.0000.00915.29
7.0.100.0070.04717.63
7.0.90.0080.02517.74
7.0.80.0020.02717.69
7.0.70.0050.02617.79
7.0.60.0140.03217.66
7.0.50.0120.03717.97
7.0.40.0070.03516.82
7.0.30.0010.04616.82
7.0.20.0050.04716.77
7.0.10.0100.03616.91
7.0.00.0100.04016.75
5.6.400.0000.01514.70
5.6.390.0070.00714.71
5.6.380.0040.01414.28
5.6.370.0070.00714.70
5.6.360.0000.00914.30
5.6.350.0060.00914.52
5.6.340.0110.00414.29
5.6.330.0000.01814.47
5.6.320.0030.01314.38
5.6.310.0030.01014.55
5.6.300.0090.00614.48
5.6.290.0070.01014.32
5.6.280.0000.04117.75
5.6.270.0040.00814.62
5.6.260.0000.01514.57
5.6.250.0080.03617.54
5.6.240.0050.03317.70
5.6.230.0100.03317.41
5.6.220.0040.02417.44
5.6.210.0120.03217.51
5.6.200.0060.03617.67
5.6.190.0050.02317.87
5.6.180.0050.02017.67
5.6.170.0060.03617.60
5.6.160.0050.02517.74
5.6.150.0060.04417.66
5.6.140.0020.03917.79
5.6.130.0080.02117.79
5.6.120.0060.04517.75
5.6.110.0130.04017.70
5.6.100.0080.03217.61
5.6.90.0080.02017.52
5.6.80.0050.03117.44
5.6.70.0050.03217.28
5.6.60.0070.04117.24
5.6.50.0120.03517.40
5.6.40.0060.02817.49
5.6.30.0050.02717.45
5.6.20.0050.03717.37
5.6.10.0080.04317.34
5.6.00.0040.03517.29
5.5.380.0110.02017.52
5.5.370.0100.04317.40
5.5.360.0020.04817.23
5.5.350.0030.02717.35
5.5.340.0100.01817.54
5.5.330.0070.02517.83
5.5.320.0100.04017.66
5.5.310.0030.04917.79
5.5.300.0050.04317.53
5.5.290.0100.03917.60
5.5.280.0100.01917.59
5.5.270.0030.04817.61
5.5.260.0080.03017.52
5.5.250.0030.02717.35
5.5.240.0120.01817.33
5.5.230.0050.04617.23
5.5.220.0080.04517.36
5.5.210.0050.04317.13
5.5.200.0050.03917.32
5.5.190.0110.02917.34
5.5.180.0020.02717.08
5.5.170.0130.00314.35
5.5.160.0120.04017.34
5.5.150.0060.03117.11
5.5.140.0030.03317.22
5.5.130.0050.02117.35
5.5.120.0090.02717.14
5.5.110.0110.03117.17
5.5.100.0080.04317.21
5.5.90.0030.02117.26
5.5.80.0070.03917.14
5.5.70.0050.02417.06
5.5.60.0050.02017.21
5.5.50.0060.02417.30
5.5.40.0090.03617.23
5.5.30.0100.01417.31
5.5.20.0080.01817.32
5.5.10.0050.02117.25
5.5.00.0070.02717.23
5.4.450.0050.04915.08
5.4.440.0030.02215.33
5.4.430.0050.02315.30
5.4.420.0110.03715.18
5.4.410.0100.02815.27
5.4.400.0030.02415.25
5.4.390.0050.04315.13
5.4.380.0020.04214.89
5.4.370.0100.03815.18
5.4.360.0060.01815.15
5.4.350.0020.03215.18
5.4.340.0030.02414.93
5.4.330.0040.00711.34
5.4.320.0050.02214.99
5.4.310.0030.04514.96
5.4.300.0120.02915.20
5.4.290.0080.04015.19
5.4.280.0030.02715.08
5.4.270.0100.02115.11
5.4.260.0060.03614.99
5.4.250.0030.03615.14
5.4.240.0060.01814.96
5.4.230.0030.02414.89
5.4.220.0030.04115.06
5.4.210.0090.01715.20
5.4.200.0000.02415.07
5.4.190.0090.01615.23
5.4.180.0080.01614.97
5.4.170.0060.02815.15
5.4.160.0000.02515.06
5.4.150.0070.01915.04
5.4.140.0030.02113.86
5.4.130.0030.02213.83
5.4.120.0050.03713.81
5.4.110.0100.02313.77
5.4.100.0070.01813.85
5.4.90.0050.03313.75
5.4.80.0030.02013.65
5.4.70.0020.02313.83
5.4.60.0030.03013.87
5.4.50.0050.02913.78
5.4.40.0070.01813.63
5.4.30.0020.01913.76
5.4.20.0080.03813.63
5.4.10.0030.03513.72
5.4.00.0070.01313.57
5.3.290.0060.02312.68
5.3.280.0030.02312.50
5.3.270.0070.01812.63
5.3.260.0120.01812.69
5.3.250.0040.02212.66
5.3.240.0050.03912.53
5.3.230.0100.03512.63
5.3.220.0030.03612.56
5.3.210.0030.02112.56
5.3.200.0030.02312.53
5.3.190.0040.02412.61
5.3.180.0030.02112.55
5.3.170.0030.02312.54
5.3.160.0030.02112.60
5.3.150.0030.01812.62
5.3.140.0050.01912.50
5.3.130.0080.01712.49
5.3.120.0040.01912.56
5.3.110.0050.03712.67
5.3.100.0070.01512.20
5.3.90.0050.01712.40
5.3.80.0020.02412.38
5.3.70.0030.04012.33
5.3.60.0030.02012.12
5.3.50.0020.02512.26
5.3.40.0030.02312.26
5.3.30.0110.00812.34
5.3.20.0020.02212.10
5.3.10.0030.02012.05
5.3.00.0050.02012.04
5.2.170.0000.03011.57
5.2.160.0000.02711.57
5.2.150.0000.03311.57
5.2.140.0000.03311.57
5.2.130.0000.03311.57
5.2.120.0000.02711.57
5.2.110.0000.03011.57
5.2.100.0030.02711.57
5.2.90.0030.02711.57
5.2.80.0000.02711.57
5.2.70.0030.03011.57
5.2.60.0030.02311.57
5.2.50.0030.02711.57
5.2.40.0000.03311.57
5.2.30.0030.02711.57
5.2.20.0070.02011.57
5.2.10.0000.03011.57
5.2.00.0030.02711.57
5.1.60.0030.02311.57
5.1.50.0000.03311.57
5.1.40.0000.02711.57
5.1.30.0100.02711.57
5.1.20.0030.02311.57
5.1.10.0000.02311.57
5.1.00.0100.02011.57
5.0.50.0000.02011.57
5.0.40.0000.02311.57
5.0.30.0000.03011.57
5.0.20.0000.02011.57
5.0.10.0000.02011.57
5.0.00.0000.03011.57
4.4.90.0030.01311.57
4.4.80.0000.01311.57
4.4.70.0000.01311.57
4.4.60.0000.01711.57
4.4.50.0000.03311.57
4.4.40.0030.01711.57
4.4.30.0000.01711.57
4.4.20.0000.01711.57
4.4.10.0030.03711.57
4.4.00.0030.02311.57
4.3.110.0030.01011.57
4.3.100.0070.01011.57
4.3.90.0000.01311.57
4.3.80.0000.02011.57
4.3.70.0000.01711.57
4.3.60.0000.01711.57
4.3.50.0030.01311.57
4.3.40.0000.04011.57
4.3.30.0000.01311.57
4.3.20.0000.01711.57
4.3.10.0000.01711.57
4.3.00.0000.02011.57

preferences:
42.32 ms | 401 KiB | 5 Q