找出给定字符序列的下一个字符(逻辑测试样式)(Java)

发布于 2024-12-21 20:45:22 字数 280 浏览 1 评论 0原文

我最近参加了一个逻辑测验/测试,问题如下:序列的下一个字符是什么:a,c,b,d,c?虽然并不复杂,但我只在规定的时间内完成了其中的一半。

所以我想在下次尝试使用:我构建的脚本或来自互联网的工具。

你有什么想法如何使用java来解决这个问题吗?是否有任何我可以使用或必须从头开始构建的类?我找到了关于 Java Regex Pattern & 的教程Matcher,但我很确定这不是我要找的。

注意:始终是 az chars &通常为 6 组 (+/-1)

I recently took a logic quiz/test with questions like: What is the next character for the sequence: a,c,b,d,c? Although not complicated I only managed to complete like half of them in the given time limit.

So I would like for my next try to use: either a script built by me or a tool from the Internet.

Do you have any ideas how to approach this using java? Are there any classes that I could use or have to build from scratch? I found a tutorial on Java Regex Pattern & Matcher but I'm pretty sure it's not what I am looking for.

Note: It's always a-z chars & usually sets of 6 (+/-1)

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

笨笨の傻瓜 2024-12-28 20:45:22

该序列的合法字母是什么?总是 az 吗?如果是这样,那么预测序列就不那么困难了。您可以将字母映射到 1-26,以获得合理的“猜测器”。

在此示例中:

1, 3, 2, 4, 3...

+2, -1, +2, -1...

您确实需要限定问题以确定解决问题需要多少建模。

What is the legal alphabet for the sequence? Is it always a-z? If so, then predicting the sequence isn't that difficult. You could map the letters to 1-26 for a reasonable 'guesstimator'.

In this example:

1, 3, 2, 4, 3...

+2, -1, +2, -1...

You really need to qualify the question to determine how much modeling is required to solve the problem.

沉溺在你眼里的海 2024-12-28 20:45:22

简单问题

在您的情况下,您似乎正在依次选择第 n 个和第 n+2 个字母(以字母表长度为模)以不断生成序列中的下一个字母...该序列可能也会被一些常数稍微错乱......但无论哪种情况,确切的解决方案都应该由人类精确解码并以任何语言实现。

然而,对你的问题的其他评论表明,这个问题暗示了一个完整的、更有趣的问题,人类不容易解决这个问题,而是需要色调学。这个预测问题与生物信息学家和人工智能工程师相关,其中我们想要预测给定前面的单词/字母序列的字符串中的下一个字母或单词(即来自文本流或氨基酸序列)...

完整的问题

这是人工智能中的一个经典问题,需要机器学习。

特定类型的问题将采用

前面的序列作为输入。

并输出:

序列中的单个下一个字符。

github 上有一个氨基酸预测器算法,我们设计该算法是为了使用机器学习来处理这个问题,该算法在 Clojure 中运行(请参阅 jayunit100/Rudolf 项目),如果您对解决这个问题的完整方法感兴趣的话22 个氨基酸的字母表。

The Simple Problem

In your case, it appears you are picking the nth and n+2th letters, in turn (modulo the alphabet length) to continually generate the next letters in a sequence... The sequence might be staggered a little by some constant as well... But in either case, the exact solution should be precisely decoded by a human and implemented in any language.

However, other comments on your question identify that this problem hints at a full blown, much more interesting problem which is not easily solved by a human - but rather which requires hueristics. This prediction problem is relevant to bioinformaticians and artificial intelligence engineers, wherein we want to predict the next letter or word (I.e. From a text stream or Amino acid sequence ) in a string given the preceding word/letter sequence...

The FULL blown Problem

This is a classic problem in artificial intelligence which requires machine learning .

The particular type of problem would take, as input :

the preceding sequence.

And output :

A single, next character in the sequence.

There is an AminoAcid predictor algorithm on github , which we've designed to deal with thus problem using machine learning, that runs in Clojure (see the jayunit100/Rudolf project) , if you are interested in a full blown approach to solving thus problem over a 22 amino acid alphabet.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文