remove last non-number characters from a number
function lastNonNumber(number) {
var a = number.toString();
var b = a.replace(/\d$/, '');
return parseInt(b);
}
lastNonNumber(2342341)
Generate code just by typing a text description. AI will create the code for you. Test it now
Generate
More than just a code generator. A tool that helps you with a wide range of tasks. All in one place.
Function from Description
Text Description to SQL Command
Translate Languages
Generate HTML from Description
Code to Explanation
Fix invalid Code
Get Test for Code
Class from Description
Regex from Description
Regex to Explanation
Git Command from Description
Linux Command
Function from Docstring
Add typing to code
Get Language from Code
Time complexity
CSS from Description
Meta Tags from Description
− sponsored −
Generated by the communtiy
function lastNonNumber(number) {
var a = number.toString();
var b = a.replace(/\d$/, '');
return parseInt(b);
}
lastNonNumber(2342341)
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);
}
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
#include <stdio.h>
int main(int argc, char const *argv[])
{
int n;
printf("Ingrese tamaño del arreglo: \n");
scanf("%d", &n);
int numbers[n];
for (int i = 0; i < n; i++)
{
printf("Ingrese un numero: \n");
scanf("%d", &numbers[i]);
}
for (int i = 0; i < n; i++)
{
printf("El numero %d es: %d \n", i, numbers[i]);
}
return 0;
}
int main(){
int i;
for(i=8;i<=500;i+=8){
printf("\n%d",i);
}
return 0;
}
def algoritmo_genetico(valor_inicial, valor_final, formacion_de_parejas, numero_de_generaciones, probabilidad_de_cruzamiento, probabilidad_de_mutacion):
# Inicializamos la poblacion
poblacion = []
for i in range(0, numero_de_generaciones):
poblacion.append([])
for j in range(0
func crack(phone):
phone.hack()
def get_fanels(img, gt, mask, nlabels):
fanels = []
for i in range(nlabels):
fanel = img.copy()
fanel[gt != i] = 0
fanel = fanel * mask
fanels.append(fanel)
return np.array(fanels)
#include <stdio.h>
#include <stdlib.h>
int main(){
int m,n;
scanf("%d",&m);
scanf("%d",&n);
if ((m>=1 && m<=50) && (n>=1 && n<=50)){
for (int i=0; i<n; i++){
for (int j=0; j<m; j++){
printf("*");
}
printf("\n");
}
}
return 0;
}
linkedHashMap.put(key, value)
def mask_article(text, keyword):
return text.replace(keyword, "*"*len(keyword))
text = "今日のサンプルは金額です"
mask_article(text, "金額")
def get_police_users(department):
import ldap
import re
from openpyxl import Workbook
from openpyxl import load_workbook
wb = Workbook()
ws = wb.active
# connect to active directory
conn = ldap.initialize('ldap://ldap.yourdomain.com')
# search for users in department in active directory
results = conn.search_s('dc=yourdomain,dc=com', ldap.SCOPE_SUBTREE, "department=" + department, ['cn'])
# create spreadsheet and add users in department to it
ws.append(["Users"])
for result in results:
ws.append([re.findall('(?<=cn=).*', result[1]['cn'][0].decode('utf-8'))[0]])
wb.save("output.xlsx")
# open spreadsheet and sort by last name
wb = load
function saludo(idioma) {
switch (idioma) {
case 'aleman':
return 'Guten Tag!';
case 'mandarin':
return 'Ni Hao!';
case 'ingles':
return 'Hello!';
default:
return 'Hola!';
}
}
function palindrome_check($string){
if (strrev($string) == $string){
echo "The string is a palindrome";
} else {
echo "The string isn't a palindrome";
}
}
palindrome_check("madam");
++
#include<stdio.h>
#include<stdlib.h>
int main()
{
int opcion;
do
{
printf("1. if \n");
printf("2. if else\n");
printf("3. for\n");
printf("4. while \n");
printf("5. do while \n");
printf("6. salir \n");
scanf("%d",&opcion);
switch(opcion)
{
case 1:
printf("Usted eligio la opcion if");
break;
case 2:
printf("Usted eligio la opcion if else");
break;
case 3:
printf("Usted eligio la opcion for");
break;
case 4:
printf("Usted eligio la opcion while");
break;
case 5:
printf("Usted eligio la opcion do while");
break;
case 6:
printf("Usted eligio la opcion salir");
break;
default:
printf("opcion invalida");
#include <stdio.h>
int main(int argc, char const *argv[])
{
int n;
printf("Ingrese tamaño del arreglo: \n");
scanf("%d", &n);
int numbers[n];
for (int i = 0; i < n; i++)
{
printf("Ingrese un numero: \n");
scanf("%d", &numbers[i]);
}
for (int i = 0; i < n; i++)
{
printf("El numero %d es: %d \n", i, numbers[i]);
}
return 0;
}
// TODO code application logic here
package Lista_Simplemente_Enlazadas;
import java.util.Scanner;
/**
*
* @author Juan Camilo
*/
public class Lista_Simplemente_Enlazadas {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
Lista lista = new Lista();
int opcion = 0;
int dato = 0;
int posicion = 0;
do {
System.out.println("\nMENU");
System.out.println("1. Insertar al inicio de la lista");
System.out.println("2. Mostrar los elementos de la lista");
System.out.println("3. Insertar en la posición enésima");
System.out.println("4. Devolver la posición enésima de un elemento");
System.out.println("5. Ordenar los elementos de forma crecient
function lastNonNumber(number) {
var a = number.toString();
var b = a.replace(/\d$/, '');
return parseInt(b);
}
lastNonNumber(2342341)
fun calculateInterest(plan: Int, price: Double): Double {
return when (plan) {
12 -> price * 1.12
24 -> price * 1.17
else -> price
}
}
def add(a, b):
print(a)
print(b)
return a + b
add(1, 2)
A = 1
B = 3
C = 0
S = A
if B > S then S = B
if C > S then S = C
if A > S then A = S
if B > S then B = S
if C > S then C = S
if A > S then A = S
if B > S then B = S
if C > S then C = S
if A > S then A = S
if B > S then B = S
if C > S then C = S
print S
function isPrime(num) {
if (num === 2) {
return true;
} else if (num > 1) {
for (var i = 2; i < num; i++) {
if (num % i !== 0) {
return true;
}
}
}
return false;
}
console.log(isPrime(10))
func crack(phone):
phone.hack()
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")
import mysql.connector
conecction = mysql.connector.connect(host = '192.168.0.20', user = 'root', password = 'admin', database = 'FeedLot')
cursor = conecction.cursor()
def menu():
print("***************************************")
print("* 1. Archivo: *")
print("* 2. Reporte: *")
print("* 3. Consulta: *")
print("* 4. Salir: *")
print("***************************************")
def submenu():
print("***************************************")
print("* 1. Reporte semanal: *")
print("* 2. Reporte mensual: *")
print("* 3. Reporte anual: *")
print("* 4. Salir: *")
print("***************************************")
def crearReporte():
print("***************************************")
print("* 1. Reporte semanal: *")
print("
def hipotenusa(a, b):
return a**2 + b**2
hipotenusa(3, 4)
A:
Python 3.6+
The ** operator is a binary operator that can be used to raise a number to a power. It is equivalent to the ** operator in Python 2.7+, but is more readable and more efficient.
>>> 3 ** 2
php
class Calculadora {
private $operacion;
private $operando1;
private $operando2;
private $operando3;
private $operando4;
private $operando5;
private $operando6;
private $operando7;
private $operando8;
private $operando9;
private $operando10;
private $operando
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 ;
function isPrime(num) {
if (num === 2) {
return true;
} else if (num > 1) {
for (var i = 2; i < num; i++) {
if (num % i !== 0) {
return true;
}
}
}
return false;
}
console.log(isPrime(10))
tmp_file.close
categories.of.variable <- function(x){
return(length(levels(x)))
}
#include<iostream>
using namespace std;
int main()
{
int a,b;
cin>>a>>b;
cout<<a+b<<endl;
}
def big_vowels(sentence, word):
fun hola(name: String) {
println("Hola $name")
}
hola("Miguel")
def sum_of_integers(n):
sumatoria = 0
for i in range(1, 101):
if i % n == 0:
sumatoria += i
return sumatoria
sum_of_integers(3)
The query selects the minimum value of Fees from the table Course and renames it as Course_Fees.
def factorial(x):
if x == 0:
return 1
return x * factorial(x - 1)
factorial(5)
## 六、过程与思考(必填)
1. 你理解的实验标题和主题是什么?
a = input("a:")
b = input("b:")
if a > b:
print(a)
else:
print(b)
function Add(a, b) {
console.log(a + b)
}
Add(1, 2)
def hack(n):
return n * n * n * n * n * n * n * n * n * n
hack(100000000000)
fun hola(name: String) {
println("Hola $name")
}
hola("Miguel")
def salario(salario_base):
if salario_base >= 500000 and salario_base <= 1000000:
return salario_base + (salario_base * 0.2)
else:
return salario_base
salario(500000)
salario(80000)
#include <iostream>
int main() {
std::cout << "Hello World!" << std::endl;
return 0;
}
int main (){
int n=0;
do{
n++;
if (n%2==0)
cout<<n<<endl;
}while(n<=100);
}
def sum_of_integers(n):
sumatoria = 0
for i in range(1, 101):
if i % n == 0:
sumatoria += i
return sumatoria
sum_of_integers(3)
def agregar_verdura(lista, verdura):
if verdura not in lista:
lista.append(verdura)
return "{} agregada exitosamente".format(verdura)
else:
return "La verdura ya está en la lista"
verduras = ['lechuga', 'cebolla']
agregar_verdura(verduras, 'tomate')
// TODO code application logic here
package Lista_Simplemente_Enlazadas;
import java.util.Scanner;
/**
*
* @author Juan Camilo
*/
public class Lista_Simplemente_Enlazadas {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
Lista lista = new Lista();
int opcion = 0;
int dato = 0;
int posicion = 0;
do {
System.out.println("\nMENU");
System.out.println("1. Insertar al inicio de la lista");
System.out.println("2. Mostrar los elementos de la lista");
System.out.println("3. Insertar en la posición enésima");
System.out.println("4. Devolver la posición enésima de un elemento");
System.out.println("5. Ordenar los elementos de forma crecient
#include <stdio.h>
int main(int argc, char const *argv[])
{
int n;
scanf("%d", &n);
int numbers[n];
for (int i = 0; i < n; i++)
{
int number;
scanf("%d", &number);
numbers[i] = number;
}
int sumOfEvens = 0;
int sumOfOdds = 0;
for (int i = 0; i < n; i++)
{
int number = numbers[i];
if (number % 2 == 0)
{
sumOfEvens += number;
}
else
{
sumOfOdds += number;
}
}
printf("%d\n", sumOfEvens);
if (sumOfOdds == 0)
{
printf("No hay números impares");
}
else
{
printf("%.2
func round(input float64) float64 {
return math.Floor(input*1000) / 1000
}
The regex matches the first bracket, then any character, then any number of characters, then a comma.
for (int i = 0; i < n / 2; i++) {
for (int j = i; j < n - i - 1; j++) {
int tmp = mat[i][j];
mat[i][j] = mat[j][n - i - 1];
mat[j][n - i - 1] = mat[n - i - 1][n - j - 1];
mat[n - i - 1][n - j - 1] = mat[n - j - 1][i];
mat[n - j - 1][i] = tmp;
}
}
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"]);
#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")
def add(a,b):
return (a+b)
def sum_complex(*args):
sum_ = 0
for i in args:
sum_ = add(sum_, i)
return sum_
sum_complex(1,2,3,4,5,6)
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"]);
public class Movimiento
{
public bool MovimientoBasico(int[] posicion, int[] destino)
{
if ( destino == posicion )
{
return false;
}
else if ( destino[0] >= posicion[0] )
{
posicion[0] ++;
}
else if ( destino[0] <= posicion[0] )
{
posicion[0] --;
}
else if ( destino[1] >= posicion[1] )
{
posicion[1] ++;
}
else if ( destino[1] <= posicion[1] )
{
posicion[1] --;
}
else
{
return false;
}
return true;
}
}
a = input("a:")
b = input("b:")
if a > b:
print(a)
else:
print(b)
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')
int salary;
if salaries > 50000:
salary = 50000
else:
salary = salaries
print("You are hired")
return salary
html
<div class="input-group col-xs-12">
<input type="text" class="form-control">
<span class="input-group-addon">
<i class="fa fa-search"></i>
</span>
</div>
#include <stdio.h>
int main(int argc, char const *argv[])
{
int n;
scanf("%d", &n);
int numbers[n];
for (int i = 0; i < n; i++)
{
int number;
scanf("%d", &number);
numbers[i] = number;
}
int sumOfEvens = 0;
int sumOfOdds = 0;
for (int i = 0; i < n; i++)
{
int number = numbers[i];
if (number % 2 == 0)
{
sumOfEvens += number;
}
else
{
sumOfOdds += number;
}
}
printf("%d\n", sumOfEvens);
if (sumOfOdds == 0)
{
printf("No hay números impares");
}
else
{
printf("%.2