To the Top
File:  root - text - article - 2020 - 02 - staying-on-a-chess-board.txt
Tags: 每日算法题, 算法, 数据结构, 面试题, Daily Interview Problem, Data Structures and Algorithms, Computer Programming, Python, | English | Home Page | Category: Computing | 331 Views, 22043 Search Bots | 94 Words

Subscribe to Feed Burner | Browse | Archive
Hi, here's your problem today. This problem was recently asked by Google:

A chess board is an 8x8 grid. Given a knight at any position (x, y) and a number of moves k, we want to figure out after k random moves by a knight, the probability that the knight will still be on the chessboard. Once the knight leaves the board it cannot move again and will be considered off the board.

Here's some starter code:

def is_knight_on_board(x, y, k, cache={}):
# Fill this in.

print is_knight_on_board(0, 0, 1)
# 0.25
Tags: 每日算法题, 算法, 数据结构, 面试题, Daily Interview Problem, Data Structures and Algorithms, Computer Programming, Python, | English | Home Page | Cateogry: Computing | 331 Views, 22043 Search Bots | 94 Words Subscribe to Feed Burner

Related Articles

  1. Patterns for breaking down questions you haven
  2. Daily Interview Problem: Min Range Needed to Sort
  3. [Daily Problem] Course Prerequisites
  4. Fix Brackets
  5. [Daily Problem] Validate Balanced Parentheses
  6. Daily Interview Problem: Word Ordering in a Different Alphabetical Order
  7. Non-decreasing Array with Single Modification
  8. Daily Interview Problem: Product of Array Except Self
  9. Spectrum Master
  10. Daily Interview Problem: Count Number of Unival Subtrees

Comments (0)

Your Email (Domain Part Not Exposed):

Your Comments:

Privately By Mail Colors More Smileys S x y @

Verification (Click Image 2 Refresh):

    Be the first one to comment this page !


Page Edited: October 30 2020 14:21:09 | RSS Subscription
How to Cook a Perfect Steak? | <meta name="robots" content="noindex, follow" />