-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
40 lines (27 loc) · 1.02 KB
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
// this file contains the execution of given example
const { executeCommands } = require('./src/pragyan.functions');
// Define the commands array.
const commands = ['f', 'r', 'u', 'b', 'l'];
// Define the initial position of the spacecraft.
const initialPosition = {
x: 0,
y: 0,
z: 0,
direction: 'N',
priorDirections: [],
};
// Calculate the final state of the spacecraft after executing the commands.
const finalState = executeCommands(commands, initialPosition);
// print the required input/output
console.log('\n**Commands**');
console.log(commands);
console.log('\n**Starting Position**');
console.log(`(${initialPosition.x}, ${initialPosition.y}, ${initialPosition.z})`);
console.log('\n**Initial Direction**');
console.log(initialPosition.direction);
console.log('\n**Final Position**');
console.log(`(${finalState.x}, ${finalState.y}, ${finalState.z})`);
console.log('\n**Final Direction**');
console.log(finalState.direction);
console.log('\n**Prior Directions');
console.log(finalState.priorDirections);