xxxxxxxxxx
import java.util.Scanner;
import java.util.Stack;
public class Basket {
public static void main(String[] args) {
// TODO Auto-generated method stub
Scanner frinz = new Scanner(System.in);
Stack <String> Basket = new Stack <String>();
String a = "Apple";
String m = "Mango";
String o = "Orange";
String g = "Guava";
System.out.println("Catch and eat any of these fruits:('apple', 'orange', 'mango', 'guava')");
System.out.println("How many fruits would you like to catch: ");
System.out.println("Choose a fruit to catch.Press A, O, M, or G");
int num = frinz.nextInt();
for(int i=1;i<=num;i++) {
System.out.println("Fruits " + i + " of "+ num );
String f = frinz.next();
if(f.equals("a")) {
Basket.push(a);
}else if(f.equals("m")){
Basket.push(m);
}else if(f.equals("o")){
Basket.push(o);
}else if(f.equals("g")){
Basket.push(g);
}else {
System.out.println("Not Available");
}
}
System.out.println("Your basket now has: "+ Basket);
System.out.println("Press E to eat fruit:");
while(true){
char e = frinz.next().charAt(0);
if( e == 'e'){
Basket.pop();
}
if(Basket.isEmpty()){
System.out.println("Press E to eat fruit:");
System.out.println("No more fruits");
break;
}
System.out.println("Fruit(s) in the basket:" + Basket);
System.out.println("Press E to eat fruit:");
}
}
}
xxxxxxxxxx
>>> import js2py
>>> f = js2py.eval_js('function f(x) {return x + x}')
>>> f(2)
4
>>> f()
nan
>>> f(f)
function f(x) { [python code] }function f(x) { [python code] }
xxxxxxxxxx
>>> import js2py
>>> f = js2py.eval_js( "function $(a) {return a + arguments[1]}" )
>>> f
function $(a) { [python code] }
>>> f(1, 2, 3)
3
xxxxxxxxxx
const FS = require("fs");
var Thu_muc_Media = 'Media';
var Thu_muc_Du_lieu = 'Du_lieu';
var Thu_muc_HTML = Thu_muc_Du_lieu+"\\HTML";
var Thu_muc_Nhan_vien = Thu_muc_Du_lieu+"\\Nhan_vien/";
var Thu_muc_Quan_ly = Thu_muc_Du_lieu+"\\Quan_ly_Chi_nhanh";
xxxxxxxxxx
const MongoClient = require('mongodb').MongoClient;
const mongo_username = process.env.MONGO_USERNAME
const mongo_password = process.env.MONGO_PASSWORD
const uri = `mongodb+srv://${mongo_username}:${mongo_password}@cluster0-zrtwi.gcp.mongodb.net/crmdb?retryWrites=true&w=majority`;
const client = new MongoClient(uri, { useNewUrlParser: true });
xxxxxxxxxx
function jsfuckdecode(text) {
var jsFuckText = text;
//console.log(jsFuckText);
var start = jsFuckText.indexOf("()");
var len = jsFuckText.length;
try {
var result = '';
if (jsFuckText.length > 3 && jsFuckText.slice(len - 3) == ')()') {
var txt = jsFuckText.substring(0, len - 2);
result = (/\n(.+)/.exec(eval(txt))[1]);
} else if (jsFuckText.substring(0, 2) == '[]' && start >= 0) {
var txt = jsFuckText.substring(start + 2);
result = document.getElementById("plaint_jsfuck").value = (eval(txt));
} else {
result = document.getElementById("plaint_jsfuck").value = (eval(jsFuckText));
}
return result;
} catch (e) {
return "error input";
}
xxxxxxxxxx
function coppie(a,b){
var c=[];
for(var i=0;i<a.length;i++){
for(var j=0;j<b.length;j++){
if (a[i]==b[j]){
c.push(a[i]);
}
}
}
return c;
}
xxxxxxxxxx
n = 0
while n <= 0:
n = int(input("Enter the number of lines: "))
for i in range(1, n+1):
print('*' * i)
xxxxxxxxxx
n = 0
while n <= 0:
n = int(input("Enter the number of lines: "))
for i in range(1, n+1):
for j in range(1, i+1):
print('*', end='')
print()
xxxxxxxxxx
function slowestKey(keyTimes) {
// Write your code here
const makeChar = num => String.fromCharCode(num + 97)
const map = []
for(let i = 0; i < keyTimes.length; i++){
if(keyTimes[i - 1]){
map.push([keyTimes[i][0], keyTimes[i][1] - keyTimes[i - 1] [1]])
}
else{
map.push([keyTimes[i][0], keyTimes[i][1]])
}
map.sort((first, second) => second[1] - first[1])
return makeChar(map[0][0])}