Skip to content

Instantly share code, notes, and snippets.

View codeperfectplus's full-sized avatar
🟢
Online

Deepak Raj codeperfectplus

🟢
Online
View GitHub Profile
from fractions import Fraction
from functools import reduce
def product(fracs):
t = reduce(lambda x, y : x * y, fracs)
return t.numerator, t.denominator
if __name__ == '__main__':
fracs = []
for _ in range(int(input())):
function processData(input) {
//Enter your code here
input = input.split('\n')
for(let i=1;i<input.length;i++){
var splitWord = input[i].split('');
var even = '';
var odd = '';
function sides(literals, ...expressions) {
const [a,p] = expressions;
const root = Math.sqrt((p*p)-(16*a));
const s1 = (p+root)/4;
const s2 = (p-root)/4;
return ([s2,s1]);
}
class Rectangle {
constructor(w, h) {
this.w = w;
this.h = h;
}
}
Rectangle.prototype.area = function () {
return this.w * this.h;
}
function modifyArray(nums) {
// iterate through the array
for(let i=0;i<nums.length;i++) {
// all even elements are doubled
if(nums[i] % 2 == 0){
nums[i]*=2;
// all odd elements are tripled
}else{
nums[i]*=3;
}
/*
* Complete the Rectangle function
*/
function Rectangle(a, b) {
this.length = a;
this.width = b;
this.perimeter = 2 * (this.length + this.width);
this.area = this.length * this.width;
}
const rec = new Rectangle(4,5);
function getCount(objects) {
for (let p in objects) {
return objects.filter(item => item.x == item.y).length;
}
}
'use strict'
class Polygon{
constructor(sides){
this.sides = sides;
this.perimeter = this.perimeter;
}
perimeter() {
let sum = 0;
for(let i =0;i<this.sides.length;i++) {
sum = sum + this.sides[i];
function reverseString(s) {
try {
console.log(s.split("").reverse().join(""))
} catch (e) {
console.log(e.message);
console.log(s);
}
}
function isPositive(a) {
if (a == 0) {
throw new Error("Zero Error");
}
if (a < 0) {
throw new Error("Negative Error");
}
return 'YES';
}
console.log(isPositive(-10))