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
number = int(input()) | |
counter =0 | |
while number > 0: | |
number = number//10 | |
print(number) | |
counter +=1 | |
print("number of digits :",counter) |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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
getDiscountPercentageValue(products: Product[]): number { | |
let discountValue = 0; | |
if (products.length === 1) { | |
return 0; | |
} | |
let allProductsQuantity = products.reduce((sum, product) => sum + product.quantity, 0); | |
if (allProductsQuantity > 10 && allProductsQuantity <= 50) { | |
discountValue += 10; |
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 remove_instance(nums, val): | |
""" | |
Given an array nums, and a value val, returns the new length of the array with the value removed | |
i.e. the number of items in nums with val | |
Input: nums=[5, 2, 2, 5, 3] and val = 5 | |
Output: 3 | |
""" | |
try: | |
#check for cases of an empty array | |
if len(nums) == 0: |
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 exponentialBackoff(i, dt) { | |
const f = j => j >= 0 ? Math.exp(j/3)*dt : 0 | |
const ret = f(i)-f(i-1) | |
if(ret < dt) { | |
return dt | |
} else { | |
return ret | |
} | |
} |
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
from flask import Flask, render_template, request, redirect, url_for | |
from dbfunctions import add_new_task, get_complete_tasks, get_incomplete_tasks, mark_task_complete | |
app = Flask( | |
__name__, | |
template_folder = 'client/templates' | |
) | |
@app.route('/') | |
def index(): |
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
#!/bin/bash | |
# | |
# Install Python3.8 and pip on Ubuntu 16 | |
# Maintainer: [email protected] | |
set -e | |
add-apt-repository -y ppa:deadsnakes/ppa | |
apt-get update -y | |
apt-get install -y python3.8 python3.8-distutils | |
curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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
import numpy as np | |
import matplotlib.pyplot as plt | |
plt.rcParams['font.family'] = 'MEIRYO' | |
plt.rcParams["font.size"] = 18 | |
w, h, dpi = 1920, 1080, 144 | |
fig = plt.figure(figsize=(w / dpi, h / dpi), dpi=dpi, facecolor='white') |
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
React.useEffect(() => { | |
let animationFrame = 0 | |
function virtualScroller(targets, { offset, topOffset, bottomOffset } = {}) { | |
offset ??= 0 | |
topOffset ??= offset ?? 0 | |
bottomOffset ??= offset ?? 0 | |
cancelAnimationFrame(animationFrame) | |
animationFrame = window.requestAnimationFrame(() => { | |
for (let x = 0, len = targets.length; x < len; x++) { | |
let target = targets[x] |