Facebook Interview Report
- 1of 1 vote
AnswersWrite a recursive procedure, called laceStringsRecur(s1, s2), which also laces together two strings. Your procedure should not use any explicit loop mechanism, such as a for or while loop. We have provided a template of the code; your job is to insert a single line of code in each of the indicated places.
- nishakothari62 November 03, 2012 in United Statesdef laceStringsRecur(s1, s2): """ s1 and s2 are strings. Returns a new str with elements of s1 and s2 interlaced, beginning with s1. If strings are not of same length, then the extra elements should appear at the end. """ def helpLaceStrings(s1, s2, out): if s1 == '': #PLACE A LINE OF CODE HERE if s2 == '': #PLACE A LINE OF CODE HERE else: #PLACE A LINE OF CODE HERE return helpLaceStrings(s1, s2, '')
| Report Duplicate | Flag | PURGE
Facebook Developer Program Engineer Python - 2of 2 votes
AnswersMcDonald’s sells Chicken McNuggets in packages of 6, 9 or 20 McNuggets. Thus, it is possible, for example, to buy exactly 15 McNuggets (with one package of 6 and a second package of 9), but it is not possible to buy exactly 16 McNuggets, since no non- negative integer combination of 6's, 9's and 20's add up to 16. To determine if it is possible to buy exactly n McNuggets, one has to find non-negative integer values of a, b, and c such that
- nishakothari62 November 03, 2012 in United States
6a+9b+20c=n
Write a function, called McNuggets that takes one argument, n, and returns True if it is possible to buy a combination of 6, 9 and 20 pack units such that the total number of McNuggets equals n, and otherwise returns False. Hint: use a guess and check approach.| Report Duplicate | Flag | PURGE
Facebook Developer Program Engineer Python