π―
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def fun(): | |
return "Hello" | |
fun() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def fun(): | |
return "Hemmo" | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function reverseString(s) { | |
try{ | |
console.log(s.split('').reverse().join('')); | |
} | |
catch(e){ | |
console.log(e.message); | |
console.log(s); | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function factorial(n){ | |
if(n===0){ | |
return 1; | |
} | |
else{ | |
return n* factorial(n-1); | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function main() { | |
// Write your code here. Read input using 'readLine()' and print output using 'console.log()'. | |
const PI = Math.PI; | |
var s = readLine(); | |
// Print the area of the circle: | |
console.log(PI*parseFloat(s)*parseFloat(s)); | |
// Print the perimeter of the circle: | |
console.log(2*PI*parseFloat(s)); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function getSecondLargest(arr) { | |
let max = -Infinity, result = -Infinity; | |
for (const value of arr) { | |
const next_ele = Number(value) | |
if (next_ele > max) { | |
[result, max] = [max, next_ele] // save previous max | |
} | |
else if (next_ele < max && next_ele > result) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Use rectangle class to find the area of Square. | |
class Rectangle { | |
constructor(w, h) { | |
this.w = w; | |
this.h = h; | |
} | |
} | |
// Rectangle class Method to find the area. | |
Rectangle.prototype.area = function() { | |
return(this.w*this.h); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* Implement a Polygon class with the following properties: | |
* 1. A constructor that takes an array of integer side lengths. | |
* 2. A 'perimeter' method that returns the sum of the Polygon's side lengths. | |
*/ | |
class Polygon { | |
constructor(sides) { | |
this.sides = sides; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Bubble sort | |
def bubble_sort(arr, itr): | |
lgth = len(arr) | |
for i in range(lgth): | |
for j in range(lgth-i-1): | |
if arr[j]>arr[j+1]: | |
arr[j],arr[j+1] = arr[j+1],arr[j] | |
print("Iteration:",i,arr) | |
itr+=1 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Insertion sort | |
def Insertion_sort(arr, itr): | |
lgth = len(arr) | |
for i in range(1,lgth): | |
x,j = arr[i],i-1 | |
while j>=0 and arr[j]>x: | |
arr[j+1] = arr[j] | |
j-=1 | |
arr[j+1] = x | |
print("Iteration:",i,arr) |
OlderNewer