| about | help | code help+videos | done | prefs |
In Chess, a Queen can move any number of spaces in a straight line: horizontally, vertically, or diagonally. Write the function queens_attack(n, Q1, Q2), which should return if queen Q1 attacks queen Q2 (that is, Q1 can move to Q2's position). The paramater n is an integer saying the size of the board; for a regular chess board it will be 8, indicating an 8 x 8 board. Both Q1 and Q2 will be specified in the form of a pair, [c, r], indicating the column and row number (going from 0 to n-1). queens_attack(8, [1, 1], [7, 7]) → True queens_attack(8, [1, 1], [2, 3]) → False queens_attack(8, [1, 1], [2, 0]) → True ...Save, Compile, Run (ctrl-enter) |
Progress graphs:
Your progress graph for this problem
Random user progress graph for this problem
Random Epic Progress Graph
Copyright Nick Parlante 2017 - privacy