How to resolve the algorithm Roman numerals/Decode step by step in the BQN programming language

Published on 12 May 2024 09:40 PM

How to resolve the algorithm Roman numerals/Decode step by step in the BQN programming language

Table of Contents

Problem Statement

Create a function that takes a Roman numeral as its argument and returns its value as a numeric decimal integer. You don't need to validate the form of the Roman numeral. Modern Roman numerals are written by expressing each decimal digit of the number to be encoded separately, starting with the leftmost decimal digit and skipping any 0s   (zeroes). 1990 is rendered as   MCMXC     (1000 = M,   900 = CM,   90 = XC)     and 2008 is rendered as   MMVIII       (2000 = MM,   8 = VIII). The Roman numeral for 1666,   MDCLXVI,   uses each letter in descending order.

Let's start with the solution:

Step by Step solution about How to resolve the algorithm Roman numerals/Decode step by step in the BQN programming language

Source code in the bqn programming language

ToArabicA  {
  c  "IVXLCDM"         # Characters
  v   (104) × 15  # Their values
  A  +´(ׯ1<«) v ˜ c  
}


   ToArabic¨ "MCMXC""MDCLXVI""MMVII""MMXXI"
 1990 1666 2007 2021 


  

You may also check:How to resolve the algorithm Feigenbaum constant calculation step by step in the Phix programming language
You may also check:How to resolve the algorithm Matrix multiplication step by step in the zkl programming language
You may also check:How to resolve the algorithm O'Halloran numbers step by step in the Julia programming language
You may also check:How to resolve the algorithm Associative array/Iteration step by step in the Clojure programming language
You may also check:How to resolve the algorithm Identity matrix step by step in the TypeScript programming language