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 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
Output
#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
Output