PHP从字符串生成数字ID

时间:2019-07-03 21:33:18

标签: php

我做了一些在线编程测试,如果我在这里问,抱歉。如果我错了,我只想让你纠正我。 就是这种情况:

    The ID of every products in a factory has length 11 and fits the pattern "8xxxxxxxxxx", 
where each "x" is replaced by a digit. For example, "81234567891" and "80000000000" are IDs, 
while "8012345678" is not because less than 11 length and "79000000000" is not because
the first digit not equal to 8. The program has string input called `Pool`. 
    Find out the maximum number of IDs that can be formed from this `Pool` of digits 
simultaneously. If at least one ID can be made from these string, for example, 
given a string of digits = 8012345678981234567899, there are 22 digits available. 
It is possible to make 2 IDs simultaneously from this many digits. Two examples are 
80723456789 and 87234567899. 
They use all digits in the string one time. 
    Program must return an integer that represents the total number of IDs that can be generated 
from string of digits. numOflds has the following parameter(s): pool: a string of n digits 

Constraints
1 <= length of pool <= 100

这是我的代码: enter image description here

也许我的代码还不够好,但是除了$pool = 0011223344556677889788之外,它都可以在每个测试中工作。据我所知,结果应该是0,但是在线编辑说应该是2。因此,我的分数很差。 根据案件的问题和要求,我认为我的观点是正确的。我不怪任何党派/团体。我只想知道我是否错。

谢谢

0 个答案:

没有答案