3v4l.org

run code in 300+ PHP versions simultaneously
<?php /** * Riddle: Bit Play #1 * ------------------- * This riddle may move, add, remove, compair, and evaluate bit values. It is * suggested that you brush up on your binary and bitwise operators before * starting. */ $answer = 0; // put your answer here and run to check if you are right // The Setup function luhn($number) { settype($number, 'string'); $sumTable = array( array(0,1,2,3,4,5,6,7,8,9), array(0,2,4,6,8,1,3,5,7,9)); $sum = 0; $flip = 0; for ($i = strlen($number) - 1; $i >= 0; $i--) { $sum += $sumTable[$flip++ & 0x1][$number[$i]]; } return $sum % 10 === 0; } settype($answer, 'integer'); $s = (string) $a = &$answer; $ns = (string) $n = (isset($s[1])) ? ($a >> 1)+$s[1] : ($a >> 1)+$s[0]; $f = ((int) $ns[0] ^ (int) $s[1]); // The Riddle function riddle($a, $n, $s, $f, $ns) { if ( ($a != 0 && luhn($a)) && (!$f) && (($n | $a) == 63) && (!isset($s[2])) ) { return TRUE; } return FALSE; } // The Result if (riddle($a, $n, $s, $f, $ns)) { echo "You got the correct answer! ($a)"; } else { echo "Sorry, wrong answer. ($a)"; }

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.0140.00717.00
8.3.50.0120.00622.91
8.3.40.0110.00418.80
8.3.30.0110.00419.25
8.3.20.0050.00320.41
8.3.10.0040.00423.57
8.3.00.0080.00017.63
8.2.180.0070.00716.75
8.2.170.0120.00322.96
8.2.160.0100.00720.43
8.2.150.0030.00524.18
8.2.140.0040.00424.66
8.2.130.0040.00426.16
8.2.120.0040.00420.96
8.2.110.0000.00819.38
8.2.100.0090.00317.89
8.2.90.0000.00819.21
8.2.80.0040.00417.97
8.2.70.0040.00417.72
8.2.60.0060.00317.80
8.2.50.0090.00018.16
8.2.40.0000.00720.59
8.2.30.0000.00719.34
8.2.20.0000.00817.80
8.2.10.0050.00218.22
8.2.00.0040.00417.85
8.1.280.0150.00625.92
8.1.270.0000.00823.91
8.1.260.0050.00226.35
8.1.250.0040.00428.09
8.1.240.0030.00622.36
8.1.230.0110.00017.82
8.1.220.0050.00317.74
8.1.210.0040.00418.77
8.1.200.0030.00617.35
8.1.190.0030.00617.25
8.1.180.0050.00318.10
8.1.170.0050.00318.59
8.1.160.0040.00418.93
8.1.150.0070.00020.14
8.1.140.0040.00417.51
8.1.130.0030.00317.80
8.1.120.0070.00017.46
8.1.110.0040.00417.35
8.1.100.0000.00717.43
8.1.90.0070.00017.47
8.1.80.0040.00417.41
8.1.70.0080.00017.52
8.1.60.0080.00017.60
8.1.50.0080.00017.61
8.1.40.0040.00417.54
8.1.30.0050.00317.56
8.1.20.0080.00017.67
8.1.10.0030.00517.56
8.1.00.0000.00817.54
8.0.300.0060.00318.77
8.0.290.0000.00816.75
8.0.280.0000.00718.36
8.0.270.0050.00217.35
8.0.260.0000.00817.22
8.0.250.0040.00416.98
8.0.240.0000.00716.96
8.0.230.0000.00816.95
8.0.220.0020.00517.04
8.0.210.0020.00516.99
8.0.200.0050.00317.02
8.0.190.0000.00816.95
8.0.180.0030.00316.94
8.0.170.0040.00416.92
8.0.160.0030.00517.05
8.0.150.0040.00416.89
8.0.140.0040.00716.99
8.0.130.0050.00013.42
8.0.120.0000.00816.99
8.0.110.0050.00216.95
8.0.100.0040.00416.87
8.0.90.0040.00417.06
8.0.80.0100.00717.04
8.0.70.0050.00216.85
8.0.60.0000.00916.80
8.0.50.0070.00017.05
8.0.30.0130.00617.17
8.0.20.0100.01017.40
8.0.10.0080.00016.97
8.0.00.0110.00616.74
7.4.330.0050.00015.00
7.4.320.0070.00016.56
7.4.300.0050.00216.52
7.4.290.0050.00216.48
7.4.280.0000.00716.55
7.4.270.0030.00316.61
7.4.260.0030.00616.55
7.4.250.0050.00216.59
7.4.240.0030.00516.56
7.4.230.0030.00316.54
7.4.220.0090.01016.68
7.4.210.0050.00816.73
7.4.200.0060.00316.51
7.4.160.0130.00316.54
7.4.150.0100.01017.40
7.4.140.0140.00317.86
7.4.130.0080.00916.65
7.4.120.0100.00716.62
7.4.110.0170.00016.39
7.4.100.0060.01016.63
7.4.90.0310.03416.64
7.4.80.0090.00919.39
7.4.70.0070.01116.44
7.4.60.0070.01016.46
7.4.50.0040.00416.61
7.4.40.0130.01016.42
7.4.30.0090.00616.60
7.4.00.0050.00815.03
7.3.330.0000.00513.47
7.3.320.0070.00013.36
7.3.310.0080.00016.41
7.3.300.0050.00216.42
7.3.290.0150.00616.41
7.3.280.0060.00916.43
7.3.270.0100.01017.40
7.3.260.0070.01016.28
7.3.250.0090.00816.47
7.3.240.0140.00316.39
7.3.230.0090.00916.47
7.3.210.0190.00016.66
7.3.200.0110.00519.39
7.3.190.0120.00916.52
7.3.180.0100.00616.44
7.3.170.0040.01616.56
7.3.160.0160.00016.48
7.3.120.0060.01214.66
7.3.110.0090.00314.82
7.3.100.0030.01214.91
7.3.90.0070.01114.86
7.3.80.0000.01514.87
7.3.70.0060.00615.00
7.3.60.0050.00514.72
7.3.50.0040.01114.94
7.3.40.0030.00814.80
7.3.30.0070.01014.90
7.3.20.0040.00716.66
7.3.10.0060.00616.80
7.3.00.0050.01016.73
7.2.330.0130.00716.79
7.2.320.0160.00016.64
7.2.310.0120.00916.79
7.2.300.0130.00316.52
7.2.290.0140.00316.79
7.2.250.0090.00915.16
7.2.240.0100.01015.02
7.2.230.0090.00915.05
7.2.220.0090.01015.28
7.2.210.0030.01315.12
7.2.200.0070.00715.04
7.2.190.0040.01115.12
7.2.180.0030.01315.12
7.2.170.0100.00315.17
7.2.130.0080.00417.01
7.2.120.0060.00916.84
7.2.110.0120.00316.64
7.2.100.0000.00916.73
7.2.90.0070.00716.82
7.2.80.0030.01216.85
7.2.70.0030.01316.82
7.2.60.0020.01416.91
7.2.50.0040.01116.96
7.2.40.0060.01216.96
7.2.30.0070.00717.09
7.2.20.0080.00616.84
7.2.10.0000.01516.97
7.2.00.0090.00617.10
7.1.330.0030.01015.68
7.1.320.0120.00615.94
7.1.310.0130.00315.64
7.1.300.0040.00715.79
7.1.290.0040.01215.75
7.1.280.0000.00915.66
7.1.270.0030.00915.81
7.1.260.0100.00315.84
7.1.250.0100.00315.64
7.1.240.0000.00915.79
7.1.230.0070.00415.55
7.1.220.0070.00715.91
7.1.210.0000.01415.62
7.1.200.0100.00515.82
7.1.190.0030.00915.81
7.1.180.0090.00615.98
7.1.170.0070.00415.95
7.1.160.0060.00915.84
7.1.150.0000.01315.86
7.1.140.0070.00415.86
7.1.130.0070.01115.48
7.1.120.0060.00316.02
7.1.110.0090.00615.70
7.1.100.0070.00716.68
7.1.90.0070.00415.79
7.1.80.0040.00815.85
7.1.70.0030.00816.59
7.1.60.0090.01017.67
7.1.50.0080.01116.27
7.1.40.0030.00615.75
7.1.30.0040.00415.68
7.1.20.0090.00315.80
7.1.10.0030.00715.61
7.1.00.0080.03719.22
7.0.330.0130.00015.33
7.0.320.0000.01115.53
7.0.310.0030.00915.45
7.0.300.0000.01415.39
7.0.290.0070.01015.11
7.0.280.0030.00915.43
7.0.270.0100.00315.38
7.0.260.0060.00615.49
7.0.250.0030.00615.36
7.0.240.0070.00715.55
7.0.230.0030.01015.47
7.0.220.0040.00815.23
7.0.210.0080.00415.54
7.0.200.0050.00615.82
7.0.190.0040.01415.19
7.0.180.0060.00615.31
7.0.170.0060.00615.29
7.0.160.0060.00915.29
7.0.150.0090.00315.43
7.0.140.0050.04218.69
7.0.130.0070.00715.54
7.0.120.0110.00415.51
7.0.110.0000.01415.39
7.0.100.0070.00715.37
7.0.90.0030.01015.39
7.0.80.0070.00415.37
7.0.70.0030.00815.39
7.0.60.0080.04317.65
7.0.50.0070.01916.82
7.0.40.0040.02916.77
7.0.30.0200.03916.76
7.0.20.0130.02516.96
7.0.10.0070.04416.65
7.0.00.0090.04716.92
5.6.380.0100.00314.30
5.6.370.0070.00714.41
5.6.360.0060.00914.44
5.6.350.0050.00514.57
5.6.340.0000.00914.09
5.6.330.0130.00014.41
5.6.320.0110.00314.52
5.6.310.0110.00014.11
5.6.300.0100.00614.21
5.6.290.0040.01114.61
5.6.280.0050.04017.62
5.6.270.0030.00614.27
5.6.260.0000.01114.61
5.6.250.0070.00714.32
5.6.240.0070.00314.27
5.6.230.0060.01014.56
5.6.220.0060.00614.13
5.6.210.0070.04217.45
5.6.200.0050.04716.38
5.6.190.0090.04617.50
5.6.180.2020.03017.34
5.6.170.0100.04517.54
5.6.160.0050.02517.30
5.6.150.0070.02216.43
5.6.140.0100.04016.40
5.6.130.0050.03616.43
5.6.120.0020.03017.71
5.6.110.0120.04017.72
5.6.100.0080.04317.77
5.6.90.0020.04417.73
5.6.80.0050.03917.26
5.6.70.0100.00314.21
5.6.60.0140.00014.20
5.6.50.0070.00714.13
5.6.40.0030.01014.41
5.6.30.0030.00914.06
5.6.20.0080.00414.21
5.6.10.0060.00614.45
5.6.00.0060.00913.87
5.5.380.0040.00710.95
5.5.370.0030.01010.98
5.5.360.0030.00611.02
5.5.350.0130.03815.71
5.5.340.0060.02814.44
5.5.330.0030.02515.84
5.5.320.0150.02215.71
5.5.310.0180.04015.80
5.5.300.0020.02514.57
5.5.290.0030.04814.72
5.5.280.0080.02315.90
5.5.270.0120.04016.05
5.5.260.0050.04715.89
5.5.250.0030.03115.79
5.5.240.0020.04215.55
5.5.230.0040.00811.03
5.5.220.0030.00711.13
5.5.210.0070.00311.11
5.5.200.0000.00811.18
5.5.190.0000.00810.90
5.5.180.0030.00911.10
5.5.170.0070.00311.10
5.5.160.0030.00711.24
5.5.150.0000.00911.02
5.5.140.0070.00711.26
5.5.130.0000.01110.90
5.5.120.0030.00311.17
5.5.110.0030.00911.12
5.5.100.0050.00511.17
5.5.90.0000.01110.94
5.5.80.0000.01210.99
5.5.70.0000.00910.90
5.5.60.0000.00910.90
5.5.50.0030.00510.90
5.5.40.0030.00610.90
5.5.30.0040.00411.10
5.5.20.0070.00311.02
5.5.10.0030.00611.28
5.5.00.0040.00710.93
5.4.450.0290.03615.33
5.4.440.0130.02815.43
5.4.430.0070.03615.15
5.4.420.0150.02615.10
5.4.410.0060.03815.05
5.4.400.0230.03014.90
5.4.390.0220.03814.74
5.4.380.0080.02814.88
5.4.370.0080.02014.79
5.4.360.0050.02314.76
5.4.350.0050.02011.50
5.4.340.0070.02311.50
5.4.330.0070.00710.90
5.4.320.0030.02211.81
5.4.310.0030.02111.70
5.4.300.0050.01811.70
5.4.290.0060.02411.85
5.4.280.0040.02311.79
5.4.270.0050.02811.65
5.4.260.0040.02611.65
5.4.250.0050.02011.82
5.4.240.0030.02311.66
5.4.230.0020.02911.70
5.4.220.0020.02511.65
5.4.210.0060.01811.65
5.4.200.0060.02011.66
5.4.190.0040.02211.64
5.4.180.0030.02211.64
5.4.170.0060.02611.72
5.4.160.0040.02311.72
5.4.150.0070.02211.64
5.4.140.0030.02311.53
5.4.130.0080.01711.56
5.4.120.0020.02211.46
5.4.110.0030.02111.54
5.4.100.0040.02111.58
5.4.90.0050.02411.46
5.4.80.0050.02011.56
5.4.70.0060.02011.46
5.4.60.0020.02211.45
5.4.50.0070.01911.47
5.4.40.0020.02111.59
5.4.30.0080.02111.45
5.4.20.0060.01811.64
5.4.10.0050.02611.47
5.4.00.0060.02111.32
5.3.290.0070.02311.85
5.3.280.0060.02011.80
5.3.270.0070.02211.81
5.3.260.0070.01911.81
5.3.250.0040.02211.81
5.3.240.0050.02011.81
5.3.230.0030.02311.80
5.3.220.0070.02111.79
5.3.210.0020.02411.79
5.3.200.0070.02011.79
5.3.190.0060.02111.79
5.3.180.0030.02311.79
5.3.170.0080.02211.78
5.3.160.0050.02011.79
5.3.150.0050.02311.79
5.3.140.0040.02111.78
5.3.130.0060.02011.78
5.3.120.0060.02111.78
5.3.110.0040.02411.78
5.3.100.0020.02211.51
5.3.90.0040.02811.50
5.3.80.0060.02211.50
5.3.70.0030.02311.50
5.3.60.0050.02311.49
5.3.50.0050.02111.46
5.3.40.0050.02211.46
5.3.30.0040.02211.45
5.3.20.0040.02211.34
5.3.10.0050.02211.32
5.3.00.0040.02211.31
5.2.170.0050.01610.06
5.2.160.0040.01910.06
5.2.150.0020.01710.06
5.2.140.0070.01610.06
5.2.130.0040.01610.04
5.2.120.0040.01910.04
5.2.110.0030.01810.04
5.2.100.0030.01610.04
5.2.90.0050.01410.04
5.2.80.0060.01910.04
5.2.70.0050.01710.04
5.2.60.0090.01810.02
5.2.50.0040.02210.01
5.2.40.0030.0189.99
5.2.30.0020.0189.98
5.2.20.0040.0159.97
5.2.10.0060.0149.93
5.2.00.0050.0179.86
5.1.60.0050.0139.50
5.1.50.0040.0139.50
5.1.40.0040.0149.49
5.1.30.0050.0169.66
5.1.20.0040.0169.67
5.1.10.0020.0179.54
5.1.00.0050.0179.54
5.0.50.0020.0148.78
5.0.40.0050.0108.71
5.0.30.0040.0168.62
5.0.20.0020.0138.60
5.0.10.0020.0128.59
5.0.00.0020.0198.59
4.4.90.0030.0087.84
4.4.80.0020.0117.83
4.4.70.0040.0127.83
4.4.60.0050.0077.82
4.4.50.0030.0117.84
4.4.40.0020.0167.80
4.4.30.0010.0147.83
4.4.20.0020.0107.87
4.4.10.0020.0137.88
4.4.00.0040.0167.83
4.3.110.0020.0107.78
4.3.100.0020.0097.78
4.3.90.0020.0097.77
4.3.80.0030.0147.74
4.3.70.0040.0087.76
4.3.60.0010.0117.76
4.3.50.0050.0077.76
4.3.40.0030.0137.72
4.3.30.0020.0107.11
4.3.20.0020.0107.10
4.3.10.0030.0107.08
4.3.00.0070.0169.10

preferences:
40.83 ms | 401 KiB | 5 Q