Skip to content

Instantly share code, notes, and snippets.

View codeperfectplus's full-sized avatar
🟢
Online

Deepak Raj codeperfectplus

🟢
Online
View GitHub Profile
/*
* Complete the vowelsAndConsonants function.
* Print your output using 'console.log()'.
*/
function vowelsAndConsonants(s) {
let vowels = ['a','e','i','o','u'];
for(let v of s) {
if(vowels.includes(v))
console.log(v);
def is_armstrong_number(number):
num = str(number)
exp = len(num)
return number == sum([int(i)**exp for i in num])
def is_armstrong_number(number, exp=3):
""" Checks if a number is an Armstrong number.
An Armstrong number is a number that is the sum of its own digits each raised to the
power of the number of digits.
Args:
number (int): The number to check.
exp (int): The exponent to raise the digits to.
/* c++ function to check if the number is armstrong number or not */
#include <iostream>
#include <cmath>
using namespace std;
int main() {
int n, num, digit, sum = 0;
cout << "Enter a positive integer: ";
cin >> num;
def largestPalindrome(bot, top):
z = 0
for i in range(top, bot, -1):
for j in range(top, bot, -1):
if isPalindrome(i*j):
if i * j > z:
z = i * j
return z
def isPalindrome(num):
from math import gcd
def lcm(a, b):
"Calculate the lowest common multiple of two integers a and b"
return a * b // gcd(a, b)
from functools import reduce
result = reduce(lcm, range(1, 11))
print(result)
#include <bits/stdc++.h>
using namespace std;
// Complete the solve function below.
void solve(double meal_cost, int tip_percent, int tax_percent) {
int total_cost;
total_cost = meal_cost + meal_cost * tip_percent/100 + meal_cost * tax_percent/100;
// Complete the solve function below.
function solve(meal_cost, tip_percent, tax_percent) {
let total_cost;
total_cost = meal_cost + meal_cost * tip_percent/100 + meal_cost * tax_percent/100;
console.log(Math.round(total_cost));
}
function main() {
const meal_cost = parseFloat(readLine());
import math
import os
import random
import re
import sys
# Complete the solve function below.
def solve(meal_cost, tip_percent, tax_percent):
total_cost = meal_cost + meal_cost * tip_percent/100 + meal_cost * tax_percent/100
# Read a full line of input from stdin and save it to our dynamically typed variable, input_string.
input_string = input()
# Print a string literal saying "Hello, World." to stdout.
print('Hello, World.')
# TODO: Write a line of code here that prints the contents of input_string to stdout.
print(input_string)