Вы находитесь на странице: 1из 8

8/31/2019 OMNIDRONE - Test 13

OMNIDRONE

Coding Test
Instructions
1. For each problem, copy the code to your IDE

2. Use your IDE to implement the classes, execute as console application, test and debug

3. When you’re done or run out of time, zip all your code files and submit them here.

Picture Composition
Bob has a collection of pictures. He wants to create the most stylish composition with them, so he tries to
arrange them in different orders, by adding and removing pictures to the left or the right of his current
composition.

For example: he starts his collection with picture 1, then he adds picture 2 to the left. His collection now will
look like {2, 1}. Now he can add picture 3 to the right, and will end up with {2, 1, 3}.

Implement this functionality completing the class below.

https://sites.google.com/omnidrone.net/coding-test/test-13 1/8
8/31/2019 OMNIDRONE - Test 13

using System;
OMNIDRONE
public class PictureComposition
{
public void AttachPictureFromLeft(int pictureId)
{
throw new NotImplementedException("Not implemented yet.");
}

public void AttachPictureFromRight(int pictureId)


{
throw new NotImplementedException("Not implemented yet.");
}

public int DetachPictureFromLeft()


{
throw new NotImplementedException("Not implemented yet.");
}

public int DetachPictureFromRight()


{
throw new NotImplementedException("Not implemented yet.");
}

#if !OMNIDRONE_TEST // Please don't remove.


public static void Main(string[] args)
{
PictureComposition pc = new PictureComposition();
pc.AttachPictureFromLeft(1);
pc.AttachPictureFromLeft(2);
pc.AttachPictureFromRight(3);
Console.WriteLine(pc.DetachPictureFromLeft()); // 2
Console.WriteLine(pc.DetachPictureFromLeft()); // 1
Console.WriteLine(pc.DetachPictureFromLeft()); // 3
}
#endif
}

https://sites.google.com/omnidrone.net/coding-test/test-13 2/8
8/31/2019 OMNIDRONE - Test 13

Grid Blocks
OMNIDRONE
We have a Tetris-like grid, with some blocks falling due to gravity. Whenever a cell is empty, the block will fall
down. If a cell is occupied by a block, the blocks above will pile-up.

The state of the grid is represented with a list of strings, where "." represents an empty space and "#"
represents a block.

For example, given the initial status:

{"##",
"#.",
".."}

The function should return:

{"..",
"#.",
"##"}

The two blocks on the left will fall down and pile up in the first column. The only block in the right column will
fall down to the bottom.

using System;

public class GridBlocks


{
public GridBlocks(string[] rows)
{
throw new NotImplementedException("Waiting to be imple
}

public string[] GetStateAfterFall()


{
throw new NotImplementedException("Waiting to be imple
}

if

https://sites.google.com/omnidrone.net/coding-test/test-13 3/8
8/31/2019 OMNIDRONE - Test 13

OMNIDRONE
Step Distance

Joe navigates a map, and moves one step at a time. He's using a compass to decide in which of the 8 direction
he goes: North, NorthEast, East, SouthEast, South, SouthWest, West or NorthWest. For every move i he makes, he
chooses a direction d[i] and a number of steps s[i].

We need to find out the distance to its original position.

For example, if he moves 1 step North, he'll be exactly 1.0 steps away from where he started.

If he moves 2 steps North, then 1 step East, he'll be approximately at 2.2360679774997898 steps from the
beginning.

https://sites.google.com/omnidrone.net/coding-test/test-13 4/8
8/31/2019 OMNIDRONE - Test 13

OMNIDRONE

https://sites.google.com/omnidrone.net/coding-test/test-13 5/8
8/31/2019 OMNIDRONE - Test 13

using System;
OMNIDRONE
public enum Direction
{
North,
NorthEast,
East,
SouthEast,
South,
SouthWest,
West,
NorthWest
}

public class StepDistance


{
public StepDistance(int[] distances, Direction[] direction
{
throw new NotImplementedException("Waiting to be imple

https://sites.google.com/omnidrone.net/coding-test/test-13 6/8
8/31/2019 OMNIDRONE - Test 13

Path
OMNIDRONE
Write a function that provides change directory (cd) function for an abstract file system.

For example:

Path path = new Path("/x/y/z");


path.Cd("../a");
Console.WriteLine(path.CurrentPath);

should display “/x/y/a”.

Root path is '/'

Path separator is '/'

Parent directory is addressable as ".."

Directory names consist only of English alphabet letters (A-Z and a-z)

The function should support both relative and absolute paths

The function will not be passed any invalid paths

Do not use built-in path-related functions

https://sites.google.com/omnidrone.net/coding-test/test-13 7/8
8/31/2019 OMNIDRONE - Test 13

using System;
OMNIDRONE
public class Path
{
public string CurrentPath { get; private set; }

public Path(string path)


{
this.CurrentPath = path;
}

public void Cd(string newPath)


{
throw new NotImplementedException("Waiting to be imple
}

#if !OMNIDRONE_TEST // Please don't remove.


public static void Main(string[] args)
{
Path path = new Path("/x/y/z");
path.Cd("../a");
Console.WriteLine(path.CurrentPath); // "/x/y/a"
}

SUBMIT YOUR ZIP FILE

Submit your answers. You can submit more than once as long as there's time left.

Submit Answer

*Will open another window

https://sites.google.com/omnidrone.net/coding-test/test-13 8/8

Вам также может понравиться