Giter VIP home page Giter VIP logo

tarea1-programming2's Introduction

T01 0822 Robot

Un robot se desplaza horizontalmente por el eje X. Recibe las instrucciones de movimiento en un string, que contiene "I" para moverse una posición a la izquierda y "D" para moverse una posición a la derecha. Parte de una posición dada. Mostrar cuántos puntos diferentes visita el robot cuando se ejecutaron todos los comandos. Un punto se considera visitado si coincide con la posición del robot antes o después de ejecutar algún comando.

Input Format

Lee la secuencia de comandos y luego la posición inicial.

Constraints

La secuencia tiene como máximo 100 comandos y como mínimo 1 comando. Los comandos son "I" o "D". La posición inicial es un entero entre -10000 y 10000, ambos inclusive. Asumir datos válidos.

Output Format

Imprimir la cantidad de puntos diferentes alcanzados.

Sample Input 0

II
0
Sample Output 0

3

Explanation 0

Parte de la posición 0. Con el primer movimiento a la izquierda, queda en la posición -1, con el segundo movimiento a la izquierda, queda en la posición -2. En total, visitó 3 posiciones diferentes.

Sample Input 1

DDIIII
-10
Sample Output 1

5

Explanation 1

Parte de la posición -10, se desplaza a la derecha (llega a la -9), luego a la derecha (llega a la -8), luego a la izquierda (visita la -9 nuevamente), luego a la izquierda (llega a la -10 nuevamente), luego a la izquierda (llega a la -11) y finalmente a la izquierda (llega a la -12). Total de posiciones diferentes: 5.

Sample Input 2

I
10000
Sample Output 2

2

tarea1-programming2's People

Contributors

noeliabentancor avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.