亚洲国产日韩欧美在线a乱码,国产精品路线1路线2路线,亚洲视频一区,精品国产自,www狠狠,国产情侣激情在线视频免费看,亚洲成年网站在线观看

google挑戰(zhàn)賽的練習(xí)題

時(shí)間:2020-11-10 18:54:51 筆試題目 我要投稿

google挑戰(zhàn)賽的練習(xí)題

  發(fā)信人: cynosure (UrsaminoR), 信區(qū): AI


標(biāo) 題: google挑戰(zhàn)賽的練習(xí)題
發(fā)信站: 天大求實(shí)BBS (Mon Dec 12 21:48:54 2005), 本站(bbs.tju.edu.cn)



Problem Statement

A simple line drawing program uses a blank 20 x 20 pixel canvas and a directional cursor that starts at the upper left corner pointing straight down. The upper left corner of the canvas is at (0, 0) and the lower right corner is at (19, 19). You are given a String[], commands, each element of which contains one of two possible commands. A command of the form "FORWARD x" means that the cursor should move forward by x pixels. Each pixel on its path, including the start and end points, is painted black. The only other command is "LEFT", which means that the cursor should change its direction by 90 degrees counterclockwise. So, if the cursor is initially pointing straight down and it receives a single "LEFT" command, it will end up pointing straight to the right. Execute all the commands in order and return the resulting 20 x 20 pixel canvas as a String[] where character j of element i represents the pixel at (i, j). Black pixels should be represented as uppercase 'X' characters and blank pixels should be represented as '.' characters.
Definition

Class:
DrawLines
Method:
execute
Parameters:
String[]
Returns:
String[]
Method signature:
String[] execute(String[] commands)
(be sure your method is public)
????
Notes
-
The cursor only paints the canvas if it moves (see example 1).
Constraints
-
commands will contain between 1 and 50 elements, inclusive.
-
Each element of commands will be formatted as either "LEFT" or "FORWARD x" (quotes for clarity only), where x is an integer between 1 and 19, inclusive, with no extra leading zeros.
-
When executing the commands in order, the cursor will never leave the 20 x 20 pixel canvas.
Examples
0)
????
{"FORWARD 19", "LEFT", "FORWARD 19", "LEFT", "FORWARD 19", "LEFT", "FORWARD 19"}
Returns:
{"XXXXXXXXXXXXXXXXXXXX",
"X..................X",
"X..................X",
"X..................X",
"X..................X",
"X..................X",
"X..................X",
"X..................X",
"X..................X",
"X..................X",
"X..................X",
"X..................X",
"X..................X",
"X..................X",
"X..................X",
"X..................X",
"X..................X",
"X..................X",
"X..................X",
"XXXXXXXXXXXXXXXXXXXX" }
This sequence of commands draws a 20 x 20 outline of a square. The cursor is initially at (0, 0) pointing straight down. It then travels to (0, 19) after the first FORWARD command, painting each pixel along its path with a '*'. It then rotates 90 degrees left, travels to (19, 19), rotates 90 degrees left, travels to (19, 0), rotates 90 degrees left, and finally travels back to (0, 0).
1)
????

{"LEFT", "LEFT", "LEFT", "LEFT", "LEFT", "LEFT", "LEFT", "LEFT"}

【google挑戰(zhàn)賽的練習(xí)題】相關(guān)文章:

針對(duì)Google的網(wǎng)站優(yōu)化方法08-08

2017年Google的面試流程09-17

分享Google筆試題目06-20

Google產(chǎn)品經(jīng)理筆試題分享08-15

Google技術(shù)崗位筆試題目08-13

怎么用Google Adwords來(lái)賺錢(qián)06-29

Google副總裁信奉的42條職場(chǎng)法則10-16

國(guó)際象棋挑戰(zhàn)賽規(guī)則03-02

Google15個(gè)面試題以及答案11-18

國(guó)學(xué)達(dá)人挑戰(zhàn)賽試題及答案08-08