Generated by the communtiy
Script
function processes(arr) {
var obj = {};
var p1_count = 0;
var p2_count = 0;
var a = 0;
var b = 0;
for (var i = 0; i < arr.length; i++) {
if (arr[i] === "PROC1") {
p1_count += 1;
a = p1_count;
} else {
p2_count += 1;
b = p2_count;
}
if (a === b) {
obj[arr[i]] = b;
a = 0;
b = 0;
}
}
return obj;
}
processes(["PROC1", "PROC1", "PROC1", "PROC2", "PROC2", "PROC2"]);
#include <iostream>
int main() {
std::cout << "Hello World!" << std::endl;
return 0;
}
public interface FiguraGeometrica {
double calcularArea();
double calcularPerimetro();
}
fn swap(left: &mut usize, right: &mut usize) {
let temp = *left;
*left = *right;
*right = temp;
}
fn main() {
let mut left = 1;
let mut right = 2;
swap(&mut left, &mut right);
println!("left: {}, right: {}", left, right);
}
DELIMITER //
CREATE PROCEDURE ListProducts()
BEGIN
SELECT * FROM Products
INNER JOIN Categories
ON
Products.categoryID = Categories.categoryID
INNER JOIN Suppliers
ON
Products.supplierID = Suppliers.supplierID
END //
DELIMITER ;
def ban_ip(ip):
os.system("iptables -A INPUT -s %s -j DROP" % ip)
os.system("service iptables save")
os.system("service iptables restart")
def unban_ip(ip):
os.system("iptables -D INPUT -s %s -j DROP" % ip)
os.system("service iptables save")
os.system("service iptables restart")
function Add(a, b) {
console.log(a + b)
}
Add(1, 2)
DELIMITER //
CREATE PROCEDURE ListProducts()
BEGIN
SELECT * FROM Products
INNER JOIN Categories
ON
Products.categoryID = Categories.categoryID
INNER JOIN Suppliers
ON
Products.supplierID = Suppliers.supplierID
END //
DELIMITER ;
int main(int argc, char** argv) {
// Create a file reader
cv::VideoCapture cap;
// Open the video file
cap.open(0);
// Create a window to display the video
cv::namedWindow("Video");
// Show the image in the window
cv::imshow("Video", video);
// Wait for the user to press a button
cv::waitKey(0);
}
int main(){
int i;
for(i=8;i<=500;i+=8){
printf("\n%d",i);
}
return 0;
}
function Dice() {
this.value = 0;
this.numberOfThrows = 0;
this.renderTo = "";
}
Dice.prototype.render = function () {
document.querySelector(this.renderTo).innerHTML = this.value;
};
Dice.prototype.throw = function () {
this.numberOfThrows++;
this.value = Math.ceil(Math.random() * 6);
};
Dice.prototype.getNumberOfThrows = function () {
return this.numberOfThrows;
};
Dice.prototype.getValue = function () {
return this.value;
};
DROP PROCEDURE IF EXISTS Premis_Proven_RHY;
DELIMITER //
CREATE PROCEDURE Premis_Proven_RHY(OUT numero_premiat INT)
BEGIN
SET numero_premiat = FLOOR(1 + RAND() * 50);
END //
DELIMITER ;
CALL Premis_Proven_RHY(@premi);
SELECT @premi;
++
void intercambiar(int *a, int *b)
{
int temp;
temp = *a;
*a = *b;
*b = temp;
}
void main()
{
int a, b;
cout << "a = "; cin >> a;
cout << "b = "; cin >> b;
intercambiar(&a, &b);
cout << "a = " << a << endl;
cout << "b = " << b << endl;
}
tmp_file.close
lic double areaTriangle(double a, double b, double c)
{
return (a * b * Math.Sqrt(Math.Pow(c, 2) - Math.Pow(a, 2) - Math.Pow(b, 2))) / 2;
}
public double areaSquare(double a)
{
return a * a;
}
public double area
int main()
{
int a, b, c;
cin>>a>>b>>c;
if(a>b && a>c)
{
cout<<a<<" ";
if(b>c)
cout<<b<<" "<<c;
else
cout<<c<<" "<<b;
}
else if(b>a && b>c)
{
cout<<b<<" ";
if(a>c)
cout<<a<<" "<<c;
else
cout<<c<<" "<<a;
}
else if(c>a && c>b)
{
cout<<c<<" ";
if(a>b)
cout<<a<<" "<<b;
else
cout<<b<<" "<<a;
}
return 0;
}
import java.util.Scanner;
public class Ejercicio4 {
public static void main(String[] args) {
Scanner entrada = new Scanner(System.in);
String[] novelas = { "El Alquimista", "Como agua para chocolate", "Cien años de soledad" };
String[] ciencia = { "La física de lo imposible", "El universo elegante", "La teoría del todo" };
String[] tecnologia = { "El futuro de la humanidad", "El viaje de la computadora", "La revolución de Bitcoin" };
System.out.println("Libros de Novelas");
System.out.println("================");
for (String i : novelas) {
System.out.println(i);
}
System.out.println("Libros de Ciencia");
System.out.println("================");
for (String i : ciencia) {
System.out.println(
<a href="mailto:+79186788247">+79186788247</a>
int main(int argc, char** argv) {
// Create a file reader
cv::VideoCapture cap;
// Open the video file
cap.open(0);
// Create a window to display the video
cv::namedWindow("Video");
// Show the image in the window
cv::imshow("Video", video);
// Wait for the user to press a button
cv::waitKey(0);
}
function checkValidOrderIdOnly(s)
{
let len = s.length;
if (len !== 17) throw new Error('参数错误,orderid非法');
let v = parseInt(s);
if (!Number.isFinite(v))
throw new Error('参数错误,orderid非法');
let d = new Date(v);
if (d.getTime() !== v)
throw new Error('参数错误,orderid非法');
let now = Date.now();
if (v > now || v < now - 24 * 60 * 60 * 1000)
throw new Error('参数错误,orderid非法');
}
def big_vowels(sentence, word):
def print_people(people_list):
for p in people_list:
print(p[0], p[1])
print_people(people)
def file_to_dict(file_name):
file_dict = {}
# open the file
with open(file_name) as f:
# loop through each line in the file
for line in f:
# remove new line character
key = line.rstrip()
# get the number of files in the directory
file_dict[key] = len(os.listdir(key))
return file_dict
def file_to_sorted_list(file_name):
file_dict = file_to_dict(file_name)
# return a list of directory name and number of files
return sorted(file_dict.items(), key=lambda kv: kv[1])
# test
for dir_name, number_of_files in file_to_sorted_list('directorios.txt'):
print(f'{dir_name} has {number_of_files} files')
SELECT name, year, war FROM database WHERE (war WHERE year=2002)+(war WHERE year=2003)>5
while (i <= 100) {
j = 2;
while (j <= (int) Math.sqrt(i)) {
if (i % j == 0) break;
// else
j++;
}
if (j > (int) Math.sqrt(i)) {
// i is prime
if (Math.sqrt(i) % 1 == 0) {
// i is square
System.out.println(i);
}
}
i++;
}
Please keep input under 1000 characters
DROP PROCEDURE IF EXISTS Premis_Proven_RHY;
DELIMITER //
CREATE PROCEDURE Premis_Proven_RHY(OUT numero_premiat INT)
BEGIN
SET numero_premiat = FLOOR(1 + RAND() * 50);
END //
DELIMITER ;
CALL Premis_Proven_RHY(@premi);
SELECT @premi;
function add(a, b) {
return a + b;
}
add(1, 2);
int[] sort(int[] vector)
{
// code here
return vector;
}
def sql(s):
return s.lower() == "a"
func round(input float64) float64 {
return math.Floor(input*1000) / 1000
}
The query selects the minimum value of Fees from the table Course and renames it as Course_Fees.
def sql(s):
return s.lower() == "a"
public static void main(String[] args) {
System.out.println("Hello World");
}
def multiply(x, y)
return x * y
docstringFri, 10 Feb 2023 def add(a, b):
"""Returns the sum of a and b."""
return a + b
def serie(resistencias):
total = 0
for resistencia in resistencias:
total += resistencia
return total
def paralelo(resistencias):
total = 0
for resistencia in resistencias:
if resistencia == 0:
return 0
total += 1 / resistencia
return 1 / total
def total(resistencias, tipo):
if tipo == "serie":
return serie(resistencias)
elif tipo == "paralelo":
return paralelo(resistencias)
else:
print("Tipo de resistencia no reconocida")
return None
resistencias = []
while True:
cantidad = int(input("Ingrese la cantidad de resistencias: "))
if cantidad > 0:
break
print("Ingrese una cantidad positiva")
for i in range(cantidad):
while True:
#LMM
library(lme4)
m2 <- clm(categorical_FOD_FODs ~ 0 + Condition_FODs:Language_used_FODs - 1, random = ~1|subject, data = indvar_FODs)
summary(m2)
#LM
m2 <- clm(categorical_FOD_FODs ~ Condition_FODs:Language_used_FODs - 1, data = indvar_FODs)
summary(m2)
#post-hoc analysis
library(lsmeans)
contrast(m2, "pairwise", list(Condition_FODs = c("A", "B", "C", "D")))
library(emmeans)
emmeans(m2, pairwise~Condition_FODs, adjust = "bonferroni")
docstringFri, 10 Feb 2023 def add(a, b):
"""Returns the sum of a and b."""
return a + b
def factorial(x):
if x == 0:
return 1
return x * factorial(x - 1)
factorial(5)
plt.figure(figsize = (12, 4))
plt.bar(data.index, data['nutri'], color = 'darkblue', label = 'nutri')
plt.bar(data.index, data['mineral'], color = 'brown', label = 'mineral')
plt.title('Comparison of Nutrient and Mineral Content')
plt.xlabel('Nutrient|Mineral')
plt.ylabel('Amount')
plt.legend()
plt.show()
t unittest
class TestLed(unittest.TestCase):
def test_led(self):
led = Led(pin=13)
self.assertEqual(led.pin, 13)
self.assertEqual(led.value, 0)
self.assertEqual(led.on(), 0)
self.assertEqual(led.off(), 1)
self.assertEqual(led.toggle(),
categories.of.variable <- function(x){
return(length(levels(x)))
}
tmp_file.close
b <- c(1,1,1,1,1,1,1,0,0,0,0,0,0,0)
while (mean(b) > 0.40) {
b[sample(which(b==1), 1)] <- 0
}
from random import randint
def diceRoll(userGuess, numRoll):
if userGuess == numRoll:
return True
else:
return False
def main():
numRoll = randint(1, 6)
userGuess = int(input("Guess a number from 1 to 6: "))
if diceRoll(userGuess, numRoll):
print("You win!")
else:
print("You lose. Better luck next time!")
main()
Future<void> signUp(String email, String password) async {
var result = await _cognitoUserPool.signUp(email, password, [
AttributeArg(name: 'email', value: email),
AttributeArg(name: 'name', value: 'minh'),
AttributeArg(name: 'phone_number', value: '0932919800'),
AttributeArg(name: 'gender', value: 'male'),
]);
print('signUp result: $result');
}
def ban_ip(ip):
os.system("iptables -A INPUT -s %s -j DROP" % ip)
os.system("service iptables save")
os.system("service iptables restart")
def unban_ip(ip):
os.system("iptables -D INPUT -s %s -j DROP" % ip)
os.system("service iptables save")
os.system("service iptables restart")
var products = [
{ name: 'Galletas', description: 'Lorem ipsum dolor sit amet, consectetur adipisicing elit.' },
{ name: 'Bebidas', description: 'Lorem ipsum dolor sit amet, consectetur adipisicing elit.' },
{ name: 'Comida', description: 'Lorem ipsum dolor sit amet, consectetur adipisicing elit.' },
{ name: 'Papas', description: 'Lorem ipsum dolor sit amet, consectetur adipisicing elit.' },
{ name: 'Tortas', description: 'Lorem ipsum dolor sit amet, consectetur adipisicing elit.' },
]
var carousel = document.getElementById('carousel');
var html = '';
html += '<div class="products">'
for (var i = 0; i < products.length; i++) {
html += '<div class="product">';
html += '<
from tkinter import *
def my_callback():
print("This is my first callback")
root = Tk()
button = Button(root, text='Click Me!', command=my_callback)
button.pack()
root.mainloop()
import matplotlib.pyplot as plt
import cartopy.crs as ccrs
plt.axes(projection=ccrs.PlateCarree())
plt.contourf(lon, lat, temp_data[0, :, :], 60, transform = ccrs.PlateCarree())
plt.colorbar(orientation='horizontal', shrink = 0.8)
plt.show()
Script
function processes(arr) {
var obj = {};
var p1_count = 0;
var p2_count = 0;
var a = 0;
var b = 0;
for (var i = 0; i < arr.length; i++) {
if (arr[i] === "PROC1") {
p1_count += 1;
a = p1_count;
} else {
p2_count += 1;
b = p2_count;
}
if (a === b) {
obj[arr[i]] = b;
a = 0;
b = 0;
}
}
return obj;
}
processes(["PROC1", "PROC1", "PROC1", "PROC2", "PROC2", "PROC2"]);
@Entity
@Table(name = "orders")
public class Order implements Serializable {
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
private Long id;
@Column(name = "total_amount")
private Double totalAmount;
@OneToMany(cascade = CascadeType.ALL, mappedBy = "order")
private List<OrderItem> orderItems;
// getters and setters
}
// This is a "stub" file. It's a little start on your solution.
// It's not a complete solution though; you have to write some code.
// Package greeting should have a package comment that summarizes what it's about.
// https://golang.org/doc/effective_go.html#commentary
package greeting
// HelloWorld needs a comment documenting it as package does.
func HelloWorld() string {
return "Hello, World!"
}
def big_vowels(sentence, word):
#include<stdio.h>
#include<stdlib.h>
#include<windows.h>
int main()
{
float producto[3][4][12],promedio[4][12];
int i,j,k;
for(i=0;i<3;i++)
{
for(j=0;j<4;j++)
{
for(k=0;k<12;k++)
{
printf("Ingrese venta del producto %d, mes %d, año %d\n",i+1,j+1,k+1);
scanf("%f",&producto[i][j][k]);
}
}
}
for(j=0;j<4;j++)
{
for(k=0;k<12;k++)
{
promedio[j][k]=0;
for(i=0;i<3;i++)
{
promedio[j][k
The regex matches the first bracket, then any character, then any number of characters, then a comma.
#
public static Panel CreatePanel()
{
var panel = new Panel();
var textBox = new TextBox();
textBox.Location = new Point(10, 10);
textBox.Size = new Size(200, 50);
panel.Controls.Add(textBox);
var button = new Button();
button.Location = new Point(10, 70);
button.Size = new Size(200, 50);
button.Text = "Execute";
panel.Controls.Add(button);
return panel;
}
private void button1_Click(object sender, EventArgs e)
{
var panel = CreatePanel();
Controls.Add(panel);
}
<div class="heart">
<div class="heart-main">
<div class="heart-line">
<div class="heart-line1"></div>
<div class="heart-line2"></div>
<div class="heart-line3"></div>
<div class="heart-line4"></div>
<div class="heart-line5"></div>
<div class="heart-line6"></div>
<div class="heart-line7"></div>
<div class="heart-line8"></div>
<div class="heart-line9"></div>
<div class="heart-line10"></div>
<div class="heart-line11"></div>
<div class="heart-line12"></div>
<div class="heart-line13"></div>
<div class="heart-line14"></div>
<div class="heart-line15"></div>
<div class="heart-line16"></div>
<div class="heart-line17"></div>
++
void intercambiar(int *a, int *b)
{
int temp;
temp = *a;
*a = *b;
*b = temp;
}
void main()
{
int a, b;
cout << "a = "; cin >> a;
cout << "b = "; cin >> b;
intercambiar(&a, &b);
cout << "a = " << a << endl;
cout << "b = " << b << endl;
}
private void extract_Click(object sender, EventArgs e)
{
string input = data.Text;
string[] parts = input.Split(',');
foreach (string part in parts)
{
listBox1.Items.Add(part);
}
}
// This is a "stub" file. It's a little start on your solution.
// It's not a complete solution though; you have to write some code.
// Package greeting should have a package comment that summarizes what it's about.
// https://golang.org/doc/effective_go.html#commentary
package greeting
// HelloWorld needs a comment documenting it as package does.
func HelloWorld() string {
return "Hello, World!"
}
plt.figure(figsize = (12, 4))
plt.bar(data.index, data['nutri'], color = 'darkblue', label = 'nutri')
plt.bar(data.index, data['mineral'], color = 'brown', label = 'mineral')
plt.title('Comparison of Nutrient and Mineral Content')
plt.xlabel('Nutrient|Mineral')
plt.ylabel('Amount')
plt.legend()
plt.show()