Desafío JS-272: Convertir números romanos a enteros

Desafío diario de JavaScript: convierte números romanos a enteros (1-3999) usando suma y resta con I V X L C D M, aplicando las reglas sustractivas IV/IX/XC/CD/CM y validación de repeticiones.

7 sept 2025 • 2 min read • Q2BSTUDIO Team

Inteligencia-Artificial-

Desafío diario de JavaScript Convertir números romanos a enteros

Dificultad Media. Tema Manipulación de cadenas

Descripción Crea una función que transforme una cadena con numeración romana en su equivalente entero. La función debe manejar valores del 1 al 3999 y considerar los símbolos I V X L C D M y las reglas sustractivas habituales como IV IX XL XC CD CM

Objetivo Dada una cadena como XIV o MCMXCIV devuelve el entero correspondiente 14 o 1994 asegurando que el resultado sea correcto para todo el rango válido

Enfoque recomendado Recorre la cadena de izquierda a derecha usando un mapa de valores. Si el valor actual es menor que el siguiente réstalo del total en caso contrario súmalo. Controla repeticiones inválidas y evita secuencias no permitidas

Ejemplos rápidos III 3 IV 4 IX 9 LVIII 58 MCMXCIV 1994

Pasos para participar 1 haz un fork del reto 2 implementa tu solución 3 pruébala con casos de prueba representativos 4 comparte tu enfoque y aprendizajes en los comentarios

En Q2BSTUDIO impulsamos el talento técnico con desafíos prácticos y con soluciones reales para empresas. Somos una empresa de desarrollo de software con foco en aplicaciones a medida y software a medida, donde combinamos buenas prácticas de ingeniería con metodologías ágiles. Si tu organización necesita un producto robusto y escalable, te acompañamos en todo el ciclo de vida desde la idea al despliegue. Conoce más sobre cómo creamos soluciones multiplataforma en desarrollo de aplicaciones y software a medida

Nuestro equipo también es especialista en inteligencia artificial y en la creación de agentes IA para automatizar tareas, enriquecer experiencias de usuario y potenciar la toma de decisiones. Descubre cómo aplicamos ia para empresas con casos de uso reales, desde clasificación y búsqueda semántica hasta copilotos y chatbots corporativos, en servicios de inteligencia artificial

Además, reforzamos tu seguridad y cumplimiento con servicios de ciberseguridad y pentesting, habilitamos arquitecturas modernas con servicios cloud aws y azure, y potenciamos la analítica con servicios inteligencia de negocio y power bi. Si buscas eficiencia operativa, también te ayudamos con automatización de procesos de extremo a extremo

Para debatir Cómo estructuraste el mapa y la lógica de suma y resta Qué casos borde te sorprendieron por ejemplo entradas con repeticiones no válidas o combinaciones sustractivas no permitidas Qué aprendiste sobre validación y diseño de pruebas

Forma parte de nuestra serie diaria de retos JavaScript. Comparte tu solución, aprende de la comunidad y mejora tus habilidades cada día

Palabras clave aplicaciones a medida software a medida inteligencia artificial ciberseguridad servicios cloud aws y azure servicios inteligencia de negocio ia para empresas agentes IA power bi

A BREAK?

Play for a moment before you go

OUR SERVICES

How we can help you

Artificial intelligence

AI agents, chatbots, and intelligent assistants that automate tasks and serve your customers 24/7 to improve the efficiency of your business.

More info

Software Development

Web, mobile, and desktop applications, intranets, e-commerce, SaaS, and management platforms designed for your company's specific needs.

More info

Cloud services

Migration, infrastructure, managed hosting, high availability, and security on Microsoft Azure and Amazon Web Services to help your business scale without limits.

More info

Cybersecurity and pentesting

Security audits, penetration testing and protection of applications, data and infrastructure on-premise and cloud, with ethical hacking and regulatory compliance.

More info

Business Intelligence

Dashboards and data analysis with Power BI: we integrate your sources, design dashboards and KPIs and turn your data into decisions.

More info

Process automation

We automate repetitive tasks and connect your applications with n8n, Power Automate, Make, and RPA, eliminating manual work and increasing productivity.

More info

Training for Companies

We train your teams in technology with criteria: web development, databases, Git, best practices and security, automation with n8n, artificial intelligence for companies and creation of AI solutions with Azure AI Foundry.

More info

Code Auditing

We audit the code that you, your team or an AI create: we tell you what is good and what to improve, we secure it and make it ready for production, web or app.

More info

AI Image Generation

We create for you the images that your business needs with artificial intelligence: product, networks, advertising, illustration and avatars. You tell us what you want and we deliver it ready to use.

More info

AI Video Generation

We create videos with artificial intelligence for you: promotional, networking, virtual presenters, dubbing and animations. You tell us the idea and we will deliver it assembled and ready to publish.

More info

AI Conversational Avatars

We create conversational avatars with AI – digital humans with a face and voice – that serve your customers and teams with the knowledge of your company, on your website, interactive monitors, WhatsApp or Teams.

More info

Online Marketing and AI

Google Ads, Meta Ads, LinkedIn Ads and AI Engine Positioning (GEO/AEO): we attract customers and make your brand appear where they search for you, also on ChatGPT, Gemini and Perplexity.

More info

Do you have a project in mind?

Tell us your vision and we'll turn it into a software solution. Whatever the scope, we make your idea real.