How to resolve the algorithm A+B step by step in the Clojure programming language
Published on 12 May 2024 09:40 PM
How to resolve the algorithm A+B step by step in the Clojure programming language
Table of Contents
Problem Statement
A+B ─── a classic problem in programming contests, it's given so contestants can gain familiarity with the online judging system being used.
Given two integers, A and B. Their sum needs to be calculated.
Two integers are written in the input stream, separated by space(s):
The required output is one integer: the sum of A and B.
Let's start with the solution:
Step by Step solution about How to resolve the algorithm A+B step by step in the Clojure programming language
Source code in the clojure programming language
(println (+ (Integer/parseInt (read-line)) (Integer/parseInt (read-line))))
3
4
=>7
(eval (read-string (str "(+ " (read-line) " )") ))
3 3
6
(println (+ (read) (read)))
3 4
7
(let [ints (map #(Integer/parseInt %) (clojure.string/split (read-line) #"\s") )]
(println (reduce + ints)))
3 4
=>7
(println (reduce + (map #(Integer/parseInt %) (clojure.string/split (read-line) #"\s") )))
3 4
=>7
You may also check:How to resolve the algorithm Hello world/Newline omission step by step in the Uxntal programming language
You may also check:How to resolve the algorithm Trigonometric functions step by step in the Autolisp programming language
You may also check:How to resolve the algorithm Parsing/RPN calculator algorithm step by step in the jq programming language
You may also check:How to resolve the algorithm Function definition step by step in the HicEst programming language
You may also check:How to resolve the algorithm Increment a numerical string step by step in the Retro programming language