Martian Robots For iOS With Swift

Overview

Martian Robots

The Problem

The surface of Mars can be modelled by a rectangular grid around which robots are able to move according to instructions provided from Earth. You are to write a program that determines each sequence of robot positions and reports the final position of the robot. A robot position consists of a grid coordinate (a pair of integers: x-coordinate followed by y-coordinate) and an orientation (N, S, E, W for north, south, east, and west). A robot instruction is a string of the letters “L”, “R”, and “F” which represent, respectively, the instructions: * Left : the robot turns left 90 degrees and remains on the current grid point. * Right : the robot turns right 90 degrees and remains on the current grid point. * Forward : the robot moves forward one grid point in the direction of the current orientation and maintains the same orientation.

The direction North corresponds to the direction from grid point (x, y) to grid point (x, y+1). There is also a possibility that additional command types may be required in the future and provision should be made for this.

Since the grid is rectangular and bounded (. . . yes Mars is a strange planet), a robot that moves “off” an edge of the grid is lost forever. However, lost robots leave a robot “scent” that prohibits future robots from dropping off the world at the same grid point. The scent is left at the last grid position the robot occupied before disappearing over the edge. An instruction to move “off” the world from a grid point from which a robot has been previously lost is simply ignored by the current robot.

The Input

The first line of input is the upper-right coordinates of the rectangular world, the lower-left coordinates are assumed to be 0, 0. The remaining input consists of a sequence of robot positions and instructions (two lines per robot). A position consists of two integers specifying the initial coordinates of the robot and an orientation (N, S, E, W), all separated by whitespace on one line. A robot instruction is a string of the letters “L”, “R”, and “F” on one line. Each robot is processed sequentially, i.e., finishes executing the robot instructions before the next robot begins execution. The maximum value for any coordinate is 50. All instruction strings will be less than 100 characters in length.

The Output

For each robot position/instruction in the input, the output should indicate the final grid position and orientation of the robot. If a robot falls off the edge of the grid the word “LOST” should be printed after the position and orientation.

Sample Input

The input is a text file that

5 3 1 1 E RFRFRFRF

3 2 N FRRFLLFFRRFLL

0 3 W LLFFFLFLFL

Sample Output

1 1 E 3 3 N LOST 2 3 S

Initial Build Setup for iOS App

  • Clone the repo.
  • Xcode 13 or above installed.
  • Change the input.txt file as you want.
  • Build & Run.
  • See the outcomes in your Xcode's terminal.

Examples

Happy Path

happyPath

Creating mars requires x and y need to be Int values Error

marsXYIntValues

Creating mars requires x and y need to be less or equal to 50

marsXYlessOrEqualTo50

Creating robot's coordinate requires x and y need to be less or equal to 50

robotXYlessOrEqualTo50

Orientation should be one of these: N, S, E, W

robotOrientation

Robot's instructions accepted are L, R, F

robotInstructions

Robot's instruction strings need to be less than 100 characters in length

robotInstructionLenght

You might also like...
contoh pembuatan framework untuk ios swift

circularContohFramework Example To run the example project, clone the repo, and run pod install from the Example directory first. Requirements Install

A corresponding package to RxKotlin Plus, but for Swift and iOS

A corresponding package to RxKotlin Plus, but for Swift and iOS

IOS Swift Application using VIPER Architecture

IOS Swift Application using VIPER Architecture. This is a simple design application for E-Commerce using VIPER architecture and CoreData, I prefer using Delegate Protocols rather than Third Party Library such as Rx but at this project I make it as an example on how to using VIPER.The application also support localization.

A sample app demonstrates how to use Atlantis on Swift Playground (iOS/macOS)
A sample app demonstrates how to use Atlantis on Swift Playground (iOS/macOS)

Atlantis with Swift Playground A sample app demonstrates how to use Atlantis on

FrolovSowingo - IOS DEV Interview With Swift
FrolovSowingo - IOS DEV Interview With Swift

Sowingo Technical Interview How to Install? 1) Before downloading the project pl

KnockToReact is an iOS library written in Swift and Objective-C that brings an exclusive feature to interact with users just by receiving and recognizing "knocks" in the device.

KnockToReact is an iOS library written in Swift and Objective-C that brings an exclusive feature to interact with users just by receiving and recognizing "knocks" in the device.

An IPFS client/api Swift Package, with the ability to add and pin any data on iOS/iPadOS/macOS

An IPFS client/api Swift Package, with the ability to add and pin any data on iOS/iPadOS/macOS. Originally bundled with GraniteUI, pulled out for independant use by any party.

Project Based IOS/Swift study_fast campus lecture
Project Based IOS/Swift study_fast campus lecture

Project Based IOS/Swift study_fast campus lecture

XCSnippetsApp - macOS application to explore code snippets from the Swift and iOS community, view and edit the snippets before adding them conveniently to Xcode
XCSnippetsApp - macOS application to explore code snippets from the Swift and iOS community, view and edit the snippets before adding them conveniently to Xcode

XCSnippetsApp macOS application to explore code snippets from the Swift and iOS community, view and edit the snippets before adding them conveniently

Owner
Marlon
Marlon
Project 03 I created for "iOS & Swift - The Complete iOS App Development Bootcamp"

Dicee This is the third project I created for "iOS & Swift - The Complete iOS App Development Bootcamp" Our Goal The objective of this tutorial is to

Lukas Goodfellow 0 Dec 23, 2021
iOS's Stocks App clone written in React Native for demo purpose (available both iOS and Android).

FinanceReactNative iOS's Stocks App clone written in React Native for demo purpose (available both iOS and Android). Data is pulled from Yahoo Finance

kf 2k Dec 29, 2022
IOS-Prework - CodePath intro to iOS prework.

Hello World App Submitted by: Emmanuel Assumang Time spent: 1.5 hours spent in total App Description This is a simple mobile app programmed in Swift t

null 0 Dec 31, 2021
Home Assistant Native iOS Application built with SwiftUI for iOS 15+

Home Assistant - Native iOS SwiftUI Application Screenshots Disclaimer - Please read This application is mostly a not-working mockup written in SwiftU

Alessio Santoru 34 Dec 13, 2022
Google-Blogger-iOS-App - Using Google Blogger API to build an iOS app like Medium

Google Blogger iOS App Using Google Blogger API to build an iOS app like Medium!

Ricky Chuang 9 Dec 13, 2022
Ios jetpack - A codabase for iOS projects foundations

iOSJetpack A codabase for iOS projects foundations Neworking Data Reusable Proto

MonsterTechStudio 1 Jan 24, 2022
A native iOS UI widget for adding Spokestack to any iOS app.

A native iOS library for adding Spokestack to any iOS app. Installation Edit Podfile CocoaPods is a dependency manager for Cocoa projects. For usage a

Spokestack 6 Jun 8, 2021
Learning iOS Frontend: Aplikasi iOS Pemesanan Makanan dengan SwiftUI, WidgetKit, Google Fonts, dan Assets dari Figma

Foody Aplikasi Foody adalah Aplikasi iOS Pemesanan Makanan dengan SwiftUI, WidgetKit, Google Fonts, dan Assets dari Figma untuk Mempelajari Ilmu Front

DK 10 Aug 20, 2022
FunIOS - 玩Android IOS Swift 版本

FunIOS - 玩Android IOS Swift 版本 介绍 我一直都是做Android开发的,一直以来在断断续续的学习IOS,学了Object-C,可以看懂,写就不太习惯,后来直接上手了swift,突然觉得太舒服了,跟kotlin,dart差不多,本项目是纯代目撸布局。使用SnapKit 拘

redli 17 Aug 18, 2022
This repository hosts the PushwooshGeozones iOS SDK as an XCFramework based Swift Package.

This repository hosts the PushwooshGeozones iOS SDK as an XCFramework based Swift Package. Use this repository's Swift Package in Xcode 12+

Pushwoosh 2 Nov 23, 2021