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 | 415 Views, 24855 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 | 415 Views, 24855 Search Bots | 94 Words Subscribe to Feed Burner

Related Articles

  1. Detect Linked List Cycle
  2. Algorithm Interview: Maximum Path Sum in Binary Tree
  3. A trick for getting good at coding interviews FASTER
  4. First and Last Indices of an Element in a Sorted Array
  5. Daily Interview Problem: Maximum Profit From Stocks
  6. [Daily Problem] Longest Palindromic Substring
  7. Daily Interview Problem: Contiguous Subarray with Maximum Sum
  8. New Vulnerabilities (CVE-2016-4581) have been detected in CentOS/RHEL/CloudLinux 7
  9. Binary Tree Level with Minimum Sum
  10. CVE-2015-8874 - cPanel EasyApache Vulnerabilities

Comments (0)

    Be the first one to comment this page !


Page Edited: May 11 2024 14:36:49 | RSS Subscription
How to Cook a Perfect Steak? | <meta name="robots" content="noindex, follow" />