Algorithm


Problem Name: beecrowd | H

Problem Link: https://www.beecrowd.com.br/judge/en/problems/view/2987

Balloon of Honor

 

By Roger Eliodoro Condras, UFSC-ARA BR Brazil

Timelimit: 1

Given a letter of the alphabet, state its position.

 

Input

 

A single character L, an uppercase letter ('A' - 'Z') of the alphabet.

 

Output

 

A single integer, which represents the position of the letter in the alphabet.

 

 

 

Input Sample Output Sample

C

3

 

Code Examples

#2 Code Example with Javascript Programming

Code - Javascript Programming


const { readFileSync } = require("fs")
const [letter] = readFileSync("/dev/stdin", "ascii")

const letters = ["", "A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z"]

console.log(letters.indexOf(letter))
Copy The Code & Try With Live Editor

Input

x
+
cmd
C

Output

x
+
cmd
3

#3 Code Example with Javascript Programming

Code - Javascript Programming


var input = require('fs').readFileSync('/dev/stdin', 'utf8');
var lines = input.split('\n');
const letter = lines.shift().trim().toLocaleLowerCase();
const alphabet = "abcdefghijklmnopqrstuvwxyz";

for(let i = 0; i  < = alphabet.length; i++){
    if(letter == alphabet[i]){
        console.log(i + 1);
    }
}
Copy The Code & Try With Live Editor

Input

x
+
cmd
C

Output

x
+
cmd
3
Advertisements

Demonstration


Previous
#1983 Beecrowd Online Judge Solution 1983 The Chosen Solution in C++, Java, Js and Python
Next
#3039 Beecrowd Online Judge Solution 3039 Santa's Toys Solution in C, C++, Java, Js and Python