【问题标题】:How to check whether a string is substring of another in WhiteSpace?如何检查一个字符串是否是 WhiteSpace 中另一个字符串的子字符串?
【发布时间】:2014-10-23 05:22:52
【问题描述】:

当我看到这个SBStr1 时,我正在处理 SPOJ 的问题。我学了一点 WhiteSpace 语言,但我只能达到循环。
谁能帮我检查一个字符串是否有另一个字符串作为 WhiteSpace 中的子字符串?

【问题讨论】:

  • 0 到 4 包括 ??你能解释一下它是如何工作的吗?我知道位移位(这可能是正确的解释),请在答案部分写下,谢谢^_^

标签: string substring whitespace-language


【解决方案1】:

我不打算为您编写空白代码,但您可以采用一种可以轻松转换为空白的方法:

24 times:
    read 10 bit number into A
    skip space
    read 5 bit number into B
    skip newline

    if (A>>0)%32 == B or (A>>1)%32 == B or ... or (A>>5)%32:
        print 1
    else:
        print 0
    print newline

您可以通过重复除以 2 来实现位移。

【讨论】: