11167 views|7 replies

183

Posts

12

Resources
The OP
 

The number series problem from "Bible Code" and the python solution [Copy link]

These days, in my child’s extracurricular math study group, the teacher no longer sends geometry, combinatorics, number theory, or application questions, but instead sends series questions every day.

The teacher turned the good learning atmosphere into a brain teaser, and I dare not say anything, so I can only complain here. Of course, it is a technical complaint.

Today's number sequence problem is to find out what the next number is after 2, 2, 0, 7, 9, 9.

We hide the standard answers and ideas. Please read them after you finish reading this article:

游客,如果您要查看本帖隐藏内容请回复

Many years ago, there was a book that was popular for a while. The title of the book was "The Bible Code". The content roughly said that after observing one by one, it was found that many events were predicted in the Bible. The form was on a certain page of the Bible. Through vertical, diagonal, jumping, and individual letters counted in order by some unknown rules, they were put together in order, which were the names of people and places of certain historical events. If you are interested, you can check out the "Basic Overview of the Bible Code" of OSGeo China Center (https://www.osgeo.cn/post/11250). I won't go into details here. But one thing is clear - a random sequence of sufficient length is very likely to get a shorter sequence you want (this will depend on how Gdel ruins mathematics, so I won't go into details).

So, I am going to find a "simple rule" that can generate a random number sequence to "guess" the next item of any brain teaser sequence. The most handy language at hand is the scripting language python.
First, I calculated the first 12 digits of the trigonometric function tan value from 1 to 1000, and counted the numbers 0 to 9 on each digit, and found that the probability of occurrence is basically the same, which basically meets the distribution requirements.
Then I need a tool that can detect whether the sequence meets the requirements, so I use a state machine to implement it. _state ostensibly counts the length of the existing sequence that meets the overall sequence. In fact, when the value is equal to the standard sequence length, it means that a sequence has been found.
If you are testing genes and other sequences, you should consider issues such as simultaneous detection, but I just want to find a result, so I can tolerate simplifying it.
In the end, the python class was written like this:

class sq_auto_m():
 _seq=[]
 _full_flag= 0
 _stat =0
 _count=0
 _success=[]
 def __init__(self, seq):
  self._seq=seq[::]
  self.clean()
 
 def init(self,seq):
  self.__init__()
 
 def show_seq(self):
  print self._seq
 
 def show_cnt(self):
  print self._count
 
 def show_suc(self):
  return self._success
 
 def clean(self):
  self._full_flag= len(self._seq)
  self._stat =0
  self._count=0
  self._success=[]
 
 def push(self,val):
  self._count=self._count+1
  if self._seq[self._stat]==val:
   self._stat=self._stat+1
   if self._stat==self._full_flag:
    self._success.append(self._count)
    self._stat =0
    return True
  else:
   self._stat =0
   if self._seq[self._stat]==val:
    self._stat=self._stat+1
    #print self._stat
    if self._stat==self._full_flag:
     self._success.append(self._count)
     self._stat =0
     return True
  
  return False

When executing, call it like this:

r=range(12)
qc=[ sq_auto_m([2,2,0,7,9,9]) for x in r]
i=1
while i< (1<<20):
 print i
 s=repr(abs(math.tan(i))).replace('.','')
 _=[ qc[x].push(int(s[x:x+1])) for x in r]
 i=i+1

for x in r:
 print x,qc[x].show_suc()

2 to the power of 20 is more than one million. I looked at the output and got impatient after 121516. I forced the termination by pressing Ctrl+C and found that two results had been thrown.

0 []
1 []
2 []
3 []
4 [115141]
5 []
6 [46758]
7 []
8 []
9 []
10 []
11 []

The 6th one was discovered relatively early, appearing at more than 40,000. Print it out and take a look:

>>> for x in range(46753,46759+1):
...     repr(abs(math.tan(x)))[:15]
...
'0.1839028578233'
'1.0677023796878'
'3.9603504373298'
'0.3352375585022'
'0.8029491564140'
'9.4218595015405'
'0.5017617686735'

The sixth digit (not counting the decimal point) is 2, 2, 0, 7, 9, 9, 1, so the answer is 1?
This is obviously different from the correct answer, but it also fully illustrates that there is no real environment to test the number series problem, it is just a brain teaser.


This content is originally created by nemon , a user of EEWORLD forum. If you want to reprint or use it for commercial purposes, you need to obtain the author's consent and indicate the source

This post is from Creative Market

Latest reply

step   Details Published on 2021-3-19 16:15
 
 

1w

Posts

204

Resources
2
 

This is quite interesting~Thanks for sharing~~

This post is from Creative Market
Add and join groups EEWorld service account EEWorld subscription account Automotive development circle
Personal signature

玩板看这里:

https://bbs.eeworld.com.cn/elecplay.html

EEWorld测评频道众多好板等你来玩,还可以来频道许愿树许愿说说你想要玩的板子,我们都在努力为大家实现!

 
 
 

976

Posts

0

Resources
3
 

Headache

This post is from Creative Market
Personal signature

没有特别的幸运,就要特别的努力

 
 
 

109

Posts

2

Resources
4
 

See what the answer is

This post is from Creative Market
 
 
 

74

Posts

0

Resources
5
 

This is quite interesting, thanks for sharing.

This post is from Creative Market
 
 
 

40

Posts

0

Resources
6
 

You have to reply to see it, which aroused my curiosity to see it

This post is from Creative Market
 
 
 

1582

Posts

0

Resources
7
 

You have to reply to see it, which aroused my curiosity to see it

This post is from Creative Market
 
 
 

1643

Posts

0

Resources
8
 

step

This post is from Creative Market
 
 
 

Just looking around
Find a datasheet?

EEWorld Datasheet Technical Support

EEWorld
subscription
account

EEWorld
service
account

Automotive
development
circle

Copyright © 2005-2024 EEWORLD.com.cn, Inc. All rights reserved 京B2-20211791 京ICP备10001474号-1 电信业务审批[2006]字第258号函 京公网安备 11010802033920号
快速回复 返回顶部 Return list