Google Labs Aptitude Test Partially Answered

博客包含多个Google相关的问题及解答,如密码方程求解、预测搜索流量季节性方法、序列规律、迷宫路径、图形着色等,还涉及数学公式语义搜索等技术内容,部分问题给出Mathematica代码求解,部分留作读者思考。

1. Solve this cryptic equation, realizing of course that values for M and E could be interchanged. No leading zeros are allowed.

WWWDOT - GOOGLE = DOTCOM

This can be solved through systematic application of logic.  For example, O cannot be equal to 0, since O + O +[1 or  0] = W.  That would make W1, but D + GW, which is not possible.

Here is a slow brute-force method of solution that takes a few minutes on a relatively fast machine:

Off[General :: "spell1"] chars = Characters/@ToLowerCase/@{"WWWDOT", "GOOGLE", "DOTCOM"} ; uchars = Union[Flatten[chars]] ;

eqn = First[#] - Plus @@ Rest[#] &[FromDigits[#, 10] &/@chars] == 0 ; Timing[soln = Select[Permutations[Range[0, 9]], eqn/.Thread[ucharsMost[#]] &]]

{359.3 Second, {​{4, 5, 3, 1, 0, 6, 8, 9, 7, 2}, {4, 5, 6, 1, 0, 3, 8, 9, 7, 2}}}

Thread[ucharsMost[#]] &/@soln

{​{c4, d5, e3, g1, l0, m6, o8, t ... , d5, e6, g1, l0, m3, o8, t9, w7}}

This gives the two solutions

777589 - 188106 == 589483
777589 - 188103 == 589486

Here is another solution using Mathematica's Reduce command:

eqn = "wwwdot" - "google""dotcom"/.s_StringFromD ... eqs&&#, vars, Integers] &/@eqs, (Unequal @@ vars/.ToRules[#]) =!= False&]//Timing

{96.98 Second, c4&&d5&&e3&&g1&& ... p;&l0&&m3&&o8&&t9&&w7}

A faster (but slightly more obscure) piece of code is the following:

cf = Compile[Evaluate[{#, _Integer} &/@{c, d, e, g, l, m, o, t, w, x}], Module[ {& ...  {d, o, t, c, o} . S ; A - B - mC + e&&A - B - eC + m] ] ;

Transpose[{​{c, d, e, g, l, m, o, t, w}, Most[#]}] &/@Module[{perms = Developer`ToPackedArray/@Take[Permutations[Range[0, 9]], All]}, Select[perms, cf @@ #1&]]//Timing

{49.89 Second, {​{​{c, 4}, {d, 5}, {e, 3}, {g, 1}, {l, 0}, {m, 6}, {o, 8}, {t, 9}, {w, 7}}, {​{c, 4}, {d, 5}, {e, 6}, {g, 1}, {l, 0}, {m, 3}, {o, 8}, {t, 9}, {w, 7}}}}

Faster still using the same approach (and requiring ~300 MB of memory):

Transpose[{​{c, d, e, g, l, m, o, t, w}, Most[#]}] &/@Compile[{}, Module[{perms = Take[Perm ... d, o, t, c, o} . S ; A - B - mC + e&&A - B - eC + m]]]]][]//Timing

{14.65 Second, {​{​{c, 4}, {d, 5}, {e, 3}, {g, 1}, {l, 0}, {m, 6}, {o, 8}, {t, 9}, {w, 7}}, {​{c, 4}, {d, 5}, {e, 6}, {g, 1}, {l, 0}, {m, 3}, {o, 8}, {t, 9}, {w, 7}}}}

Even faster using the same approach (that does not exclude leading zeros in the solution, but that can easily be weeded out at the end):

eq = Simplify["wwwdot" - "google" - "dotcom"/.s_StringFr ... ers[s]], 10]] ; Join[CoefficientList[eq, #][[2]] &/@Union[Cases[eq, _Symbol, Infinity]], {0}]

{-100, -99900, -1, -100100, -10, -1, -21000, -999, 111000, 0}

Transpose[{​{c, d, e, g, l, m, o, t, w}, Most[#]}] &/@Compile[{}, Select[Permutations[Range ... , 9]], {-100, -99900, -1, -100100, -10, -1, -21000, -999, 111000, 0} . #0&]][]//Timing

{6.44 Second, {​{​{c, 4}, {d, 5}, {e, 3}, {g, 1}, {l, 0}, {m, 6}, {o, 8}, {t, 9}, {w, 7}}, {​{c, 4}, {d, 5}, {e, 6}, {g, 1}, {l, 0}, {m, 3}, {o, 8}, {t, 9}, {w, 7}}}}

Here is an independent solution method that uses branch-and-prune techniques:

wwwdot = {w, w, w, d, o, t} ; google = {g, o, o, g, l, e} ; dotcom = {d, o, t, c, o, m} ; vars ... en[{eqn, vareqns, zeroOneConstraints, noLeadingZeros, mustSumToOneConstraints, distinctDigits}] ;

Developer`SetSystemOptions["LinearProgrammingOptions" {"InteriorPointSize"1, "Preprocessing"True}] ;

Off[General :: "spell1"]

wwwdotgoogledotcom[constraints_, vars_, zeroOneVars_] := Module[{allvars = Join[vars, zeroOneV ...  zeroOneVars[[badpos]] 1], stack} ;] ;] ; Sort/@Map[Reverse, solns, {2}] ]

wwwdotgoogledotcom[allInfo, vars, Flatten[newvars]]//Timing

{72.89 Second, {​{​{c, 4}, {d, 5}, {e, 3}, {g, 1}, {l, 0}, {m, 6}, {o, 8}, {t, 9}, {w, 7}}, {​{c, 4}, {d, 5}, {e, 6}, {g, 1}, {l, 0}, {m, 3}, {o, 8}, {t, 9}, {w, 7}}}}

And the winner for overall fastest:

enforceUniqueDigits[l_, k_] := If[Length[Union[Take[l, -k]]] =!= k, Sequence @@ {}, l] <br />  ...  &/@Select[dgclotem, dotcom[#, 6] + google[#, 6] wwwdot[#, 6] &])//Timing

{2.58 Second, {​{c4, d5, e6, g1, l0, m3, oɳ ...  d5, e3, g1, l0, m6, o8, t9, w7}}}

2. Write a haiku describing possible methods for predicting search traffic seasonality.

MathWorld's search engine
seemed slowed this May. Undergrads
prepping for finals.

3.       1
         1 1
         2 1
      1 2 1 1
   1 1 1 2 2 1

What's the next line?  

312211.  This is the "look and say" sequence in which each term after the first describes the previous term: one 1 (11); two 1s (21); one 2 and one 1 (1211); one 1, one 2, and two 1's (111221); and so on.  See the look and say sequence entry on MathWorld for a complete write-up and the algebraic form of a fascinating related quantity known as Conway's constant.

RunLengthEncode[x_List] := (Through[{First, Length}[#1]] &)/@Split[x] LookAndSay[n_, d_:1] := NestList[Flatten[Reverse/@RunLengthEncode[#]] &, {d}, n - 1]

FromDigits/@LookAndSay[6]

{1, 11, 21, 1211, 111221, 312211}

4. You are in a maze of twisty little passages, all alike.  There is a dusty laptop here with a weak wireless connection.  There are dull, lifeless gnomes strolling around.  What dost thou do?

    A) Wander aimlessly, bumping into obstacles until you are eaten by a grue.
    B) Use the laptop as a digging device to tunnel to the next level.
    C) Play MPoRPG until the battery dies along with your hopes.
    D) Use the computer to map the nodes of the maze and discover an exit path.
    E) Email your resume to Google, tell the lead gnome you quit and find yourself in whole different world [sic].

In general, make a state diagram.  However, this method would not work in certain pathological cases such as, say, a fractal maze.  For an example of this and commentary, see Ed Pegg's column about state diagrams and mazes.

5. What's broken with Unix?

Their reproductive capabilities.

How would you fix it?

[This exercise is left to the reader.]

6. On your first day at Google, you discover that your cubicle mate wrote the textbook you used as a primary resource in your first year of graduate school. Do you:

    A) Fawn obsequiously and ask if you can have an autograph.
    B) Sit perfectly still and use only soft keystrokes to avoid disturbing her concentration
    C) Leave her daily offerings of granola and English toffee from the food bins.
    D) Quote your favorite formula from the textbook and explain how it's now your mantra.
    E) Show her how example 17b could have been solved with 34 fewer lines of code.

[This exercise is left to the reader.]

7. Which of the following expresses Google's over-arching philosophy?

    A) "I'm feeling lucky"
    B) "Don't be evil"
    C) "Oh, I already fixed that"
    D) "You should never be more than 50 feet from food"
    E) All of the above

[This exercise is left to the reader.]

8. How many different ways can you color an icosahedron with one of three colors on each face?

For an asymmetric 20-sided solid, there are 3^20 possible 3-colorings.  For a symmetric 20-sided object, the Pólya enumeration theorem can be used to obtain the number of distinct colorings.  Here is a concise Mathematica implementation:

Off[General :: "shdw", General :: "spell1"] <<DiscreteMath`Combinato ...  GroupFaces = KSubsetGroup[GroupI, Sort/@f] ; Polya[GroupFaces, colors] ]

ColorMySolid[Icosahedron, colors]

(2 colors^4)/5 + colors^8/3 + colors^10/4 + colors^20/60

%/.colors 3

58130055

What colors would you choose?

[This exercise is left to the reader.]

9. This space left intentionally blank.  Please fill it with something that improves upon emptiness.

For nearly 10,000 images of mathematical functions, see The Wolfram Functions Site visualization gallery.

10. On an infinite, two-dimensional, rectangular lattice of 1-ohm resistors, what is the resistance between two nodes that are a knight's move away?

R[m_, n_] := 1/(2π) Integrate[1/t (1 - ((t - I)/(t + I))^(m + n) ((t - 1)/(t + 1))^Abs[m - n]), {t, 0, ∞}]

R[1, 2]

(8 - π)/(2 π)

This problem is discussed in J. Cserti's 1999 arXiv preprint.  It is also discussed in The Mathematica GuideBook for Symbolics, the forthcoming fourth volume in Michael Trott's GuideBook series, the first two of which were published just last week by Springer-Verlag.  The contents for all four GuideBooks, including the two not yet published, are available on the DVD distributed with the first two GuideBooks.

11. It's 2PM on a sunny Sunday afternoon in the Bay Area.  You're minutes from the Pacific Ocean, redwood forest hiking trails and world class cultural attractions.  What do you do?

[This exercise is left to the reader.]

12. In your opinion, what is the most beautiful math equation ever derived?

There are obviously many candidates.  The following list gives ten of the authors' favorites:

1. Archimedes' recurrence formula: a_ (2 n) = (2 a_n b_n)/(a_n + b_n), b_ (2 n) = (a_ (2 n) b_n)^(1/2), a_n>π>b_n, a_∞ = b_∞
2. Euler formula: ^( π) + 10
3. Euler-Mascheroni constant: Underscript[lim, k∞]   (Underoverscript[∑, n = 1, arg3] 1/n - log(k)) 
4. Riemann hypothesis: ζ (α + β ) 0 and β≠0 implies α1/2
5. Gaussian integral:   ∫_ (-∞)^∞^(-x^2) xπ^(1/2)
6. Ramanujan's prime product formula: Underoverscript[∏, k = 1, arg3] (p_k^2 + 1)/(p_k^2 - 1) 5/2
7. Zeta-regularized product: Underoverscript[∏, k = 1, arg3] k (2 π)^(1/2)
8. Mandelbrot set recursion: z_ (n + 1) z_n^2 + C
9. BBP formula: πUnderoverscript[∑, n = 0, arg3] (-2/(8 n + 4) - 1/(8 n + 5) - 1/(8 n + 6) + 4/(8 n + 1)) (1/16)^n
10. Cauchy integral formula: f(z_0) 1/(2 π ) ∮f(z)/(z - z_0) z

An excellent paper discussing the most beautiful equations in physics is Daniel Z. Freedman's "Some beautiful equations of mathematical physics."  Note that the physics view on beauty in equations is less uniform than the mathematical one.  To quote the not-necessarily-standard view of theoretical physicist P.A.M. Dirac, "It is more important to have beauty in one's equations than to have them fit experiment."

13. Which of the following is NOT an actual interest group formed by Google employees?

    A. Women's basketball
    B. Buffy fans
    C. Cricketeers
    D. Nobel winners
    E. Wine club

[This exercise is left to the reader.]

14. What will be the next great improvement in search technology?

Semantic searching of mathematical formulas.  See http://functions.wolfram.com/About/ourvision.html for work currently underway at Wolfram Research that will be made available in the near future.

15. What is the optimal size of a project team, above which additional members do not contribute productivity equivalent to the percentage increase in the staff size?

    A) 1
    B) 3
    C) 5
    D) 11
    E) 24

[This exercise is left to the reader.]

16. Given a triangle ABC, how would you use only a compass and straight edge to find a point P such that triangles ABP, ACP and BCP have equal perimeters?  (Assume that ABC is constructed so that a solution does exist.)

This is the isoperimetric point, which is at the center of the larger Soddy circle. It is related to Apollonius' problem. The three tangent circles are easy to construct: The circle around C has diameter a + b - c, which gives the other two circles.  A summary of compass and straightedge constructions for the outer Soddy circle can be found in "Apollonius' Problem: A Study of Solutions and Their Connections" by David Gisch and Jason M. Ribando.

17. Consider a function which, for a given whole number n, returns the number of ones required when writing out all numbers between 0 and n.  For example, f(13)=6.  Notice that f(1)=1.  What is the next largest n such that f(n)=n?

The following Mathematica code computes the difference between [the cumulative number of 1s in the positive integers up to n] and [the value of n itself] as n ranges from 1 to 500,000:

data = MapIndexed[#1 - #2[[1]] &, Rest[FoldList[Plus, 0, Table[DigitCount[n, 10, 1], {n, 500000}]]]] ;

<<Graphics`Colors` ListPlot[Take[MapIndexed[{#2[[1]], #1} &, data], {1, -1, 1000}], PlotStyleRed] ;

[Graphics:HTMLFiles/AptitudeTest_58.gif]

The solution to the problem is then the first position greater than the first at which data equals 0:

Position[data, 0]//Flatten

{1, 199981, 199982, 199983, 199984, 199985, 199986, 199987, 199988, 199989, 199990, 200000, 200001}

which are the first few terms of sequence A014778 in the On-Line Encyclopedia of Integer Sequences.

Checking by hand confirms that the numbers from 1 to 199981 contain a total of 199981 1s:

IntegerDigits/@Range[199981]//Flatten//Count[#, 1] &

199981

18.  What is the coolest hack you've ever written?

While there is no "correct" answer, a nice hack for solving the first problem in the SIAM hundred-dollar, hundred-digit challenge can be achieved by converting the limit into the strongly divergent series:

Sum[(-1)^k (2k)^(2k - 1), {k, ∞}]

and then using Mathematica's numerical function SequenceLimit to trivially get the correct answer (to six digits),

Off[SequenceLimit :: "seqlim"] SequenceLimit[FoldList[Plus, 0, N[#, 1000] & @ Table[-(-1)^k (2k)^(2k - 1), {k, 300}]], WynnDegree20]

0.323368

You must tweak parameters a bit or write your own sequence limit to get all 10 digits.

[Other hacks are left to the reader.]

19. 'Tis known in refined company, that choosing K things out of N can be done in ways as many as choosing N minus K from N: I pick K, you the remaining.

This simply states the binomial coefficient identity (N)  (N    )   K            N - K.  

Find though a cooler bijection, where you show a knack uncanny, of making your choices contain all K of mine.  Oh, for pedantry: let K be no more than half N.

'Tis more problematic to disentangle semantic meaning precise from the this paragraph of verbiage peculiar.

20. What number comes next in the sequence: 10, 9, 60, 90, 70, 66, ?

    A) 96
    B) 1000000000000000000000000000000000/
         0000000000000000000000000000000000/
         000000000000000000000000000000000
    C) Either of the above
    D) None of the above

This can be looked up and found to be sequence A052196 in the On-Line Encyclopedia of Integer Sequences, which gives the largest positive integer whose English name has n letters.  For example, the first few terms are ten, nine, sixty, ninety, seventy, sixty-six, ninety-six, ….  A more correct sequence might be ten, nine, sixty, googol, seventy, sixty-six, ninety-six, googolplex.  And also note, incidentally, that the correct spelling of the mathematical term "googol" differs from the name of the company that made up this aptitude test.

The first few can be computed using the NumberName function in Eric Weisstein's MathWorld packages:

<<MathWorld`IntegerSequences`

pairs = Last/@Split[Sort[{StringLength[StringReplace[NumberName[#], {" "->"", "-"->""}]], #} &/@Range[100]], #1[[1]] == #2[[1]] &]

{​{3, 10}, {4, 9}, {5, 60}, {6, 90}, {7, 70}, {8, 66}, {9, 96}, {10, 100}, {11, 98}, {12, 78}}

Last/@Take[pairs, 7]

{10, 9, 60, 90, 70, 66, 96}

A mathematical solution could also be found by fitting a Lagrange interpolating polynomial to the six known terms and extrapolating:

pts = {10, 9, 60, 90, 70, 66} ;

newpts = Function[x, Evaluate[InterpolatingPolynomial[pts, x]]]/@Range[7]

{10, 9, 60, 90, 70, 66, 290}

Plot[Evaluate[InterpolatingPolynomial[pts, x]], {x, 0, 7}, PlotStyleRed, Epilog {Red, PointSize[.02], Point/@Transpose[{Range[7], newpts}]}] ;

[Graphics:HTMLFiles/AptitudeTest_76.gif]

21. In 29 words or fewer, describe what you would strive to accomplish if you worked at Google Labs.

内容概要:本文提出了一种基于神经网络的数据驱动迭代学习控制(ILC)算法,专门用于解决具有未知动态模型和重复任务特征的非线性单输入单输出(SISO)离散时间系统在无人车路径跟踪中的应用问题,并通过Matlab代码实现了算法的仿真验证。该方法充分利用神经网络强大的非线性逼近能力和自适应学习特性,结合迭代学习控制在周期性任务中逐步优化控制输入的优势,即使在缺乏精确系统数学模型的前提下,也能有效提升无人车在复杂环境下的路径跟踪精度与系统稳定性。算法的核心在于通过多次运行过程中不断修正控制律,实现对期望轨迹的渐近跟踪。; 适合人群:具备一定现代控制理论基础知识、熟悉迭代学习控制基本概念,并拥有Matlab编程与仿真实践经验的研究生、科研人员及自动化、机器人领域的相关工程师。; 使用场景及目标:① 解决无人车在模型未知或难以精确建模的复杂动态环境中的高精度路径跟踪控制问题;② 为一类具有重复运行特性的非线性系统提供一种不依赖精确模型的先进控制策略;③ 推动数据驱动与人工智能方法在自动化控制领域的工程应用与学术研究发展。; 阅读建议:读者应重点理解神经网络在控制律中的设计与集成方式、迭代学习机制的具体实现流程,以及两者融合的创新点。务必结合所提供的Matlab代码进行详细的阅读、调试与仿真分析,通过改变参数和工况来观察控制效果,以深化对算法内在机理和性能特点的掌握。
内容概要:本文档是一份面向参与大学生创新创业训练计划(大创项目)的在校学生的系统性指导资源,全面覆盖国家级与省级项目的申报、执行、中期检查、结题全流程。内容包括大创项目的政策解读、分类与级别说明、申报流程与时间节点、评审标准解析,并提供创新训练、创业训练、创业实践三类项目的申报书撰写指南与范文。文档重点围绕物联网、数据分析、Web应用三大技术方向,提供可运行的完整项目实现案例,如基于ESP32的智慧农场系统、基于Python与Tableau的公交数据可视化平台、基于Spring Boot的校园协作平台,涵盖技术架构、代码实现、系统部署等细节。此外,还包括答辩PPT制作技巧、中期检查与结题报告的撰写模板,以及各类工具与学习资源推荐,助力学生从项目构思到成果落地的全过程。; 适合人群:参与大创项目的在校本科生,尤其是计算机、数据科学、物联网等相关专业,具备一定编程基础和科研兴趣的学生。; 使用场景及目标:①指导学生高效撰写符合评审要求的申报书、答辩材料、中期报告与结题报告;②提供三大主流技术方向的完整项目范例,帮助学生快速搭建原型系统,提升技术实践能力;③辅助团队进行项目规划、进度管理与成果总结,确保项目顺利立项与结题。; 阅读建议:建议根据项目所处阶段选择性阅读对应章节,申报阶段重点学习第1-4章,执行阶段参考第5-9章的技术实现案例,结题阶段使用第6章模板。应结合自身项目特点灵活应用范文与代码,避免照搬,注重原创性与可行性,并积极与指导教师沟通完善方案。
内容概要:本文围绕基于超局部模型的无模型预测电流控制(MFPCC)与自抗扰扩张状态观测器(ESO)相结合的改进型模型预测控制策略展开研究,提出了一种摆脱传统依赖精确电机数学模型限制的高性能控制方法。该方法通过构建超局部模型简化永磁同步电机(PMSM)的动态特性描述,并引入ESO实时估计系统内部参数扰动及外部负载干扰,实现对扰动的前馈补偿,从而显著提升控制系统的鲁棒性和动态性能。研究详细阐述了MFPCC的预测机制、ESO的设计原理及其在电流环中的集成方案,并借助Simulink搭建完整的仿真模型,对所提控制策略在动态响应速度、抗负载扰动能力及稳态控制精度等方面进行了全面的仿真验证,结果表明其相较于传统方法具有更优的综合性能。; 适合人群:具备自动控制理论基础、熟悉永磁同步电机驱动系统原理及Simulink/MATLAB仿真实践的电气工程、自动化、机电一体化等领域的研究生、科研人员和工程技术人员。; 使用场景及目标:①应用于对鲁棒性要求高的永磁同步电机高性能驱动系统设计;②为无模型控制、自抗扰控制(ADRC)等先进控制理论的教学与科研提供一个完整的、可复现的案例参考;③解决实际工程中因电机参数摄动、温度变化、负载突变等因素导致的模型失配与控制性能下降问题。; 阅读建议:读者应结合提供的Simulink仿真模型,深入剖析MFPCC与ESO协同工作的内在机理,重点关注ESO带宽整定、预测步长选择等关键参数对系统性能的影响,并通过对比不同工况下的仿真结果,深刻理解该先进控制策略的设计思想与实际应用技巧。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值