Python to Java Converter
print('jjj');
Inexpensive Ibex
print('jjj');
sorted(iterable, key=None, reverse=False)
array=list(map(int,input().split(",")))
array=sorted(array)
j=[]
j.append(array[0])
j.append(array[1])
for i in range(2,len(array)):
if j[i-1]+j[i-2] in array:
j.append(j[i-1]+j[i-2])
else:
break
print(j)
def getUmbrellas(requirement, sizes):
for i in sizes:
if i > requirement:
pass
else:
q = requirement / i
r = requirement % i
if r == 0:
return q
if r in sizes:
return q + 1
return -1
# cook your dish here
from sys import stdin
input = lambda : stdin.readline().strip()
from math import ceil,sqrt,factorial,gcd
from collections import deque
from bisect import bisect_left
def beauty(n,m,s,x,y):
degree=[0 for i in range(n)]
graph={i:[] for i in range(n)}
for i in range(m):
x[i]-=1
y[i]-=1
graph[x[i]].append(y[i])
degree[y[i]]+=1
q=deque()
for i in range(n):
if degree[i]==0:
q.append(i)
count=0
ans=0
dp=[[0 for i in range(26)]for i in range(n)]
while count<n and q:
a=q.popleft()
count+=1
dp[a][ord(s[a])-97]+=1
for i in graph[a]:
for j in range(26):
dp[i][j]=max(dp[i][j],dp[a][j])
degree[i]-=1
if degree[i]==0:
q.append(i)
if count!=n:
return -1
else:
ans=0
for i in range(n):
ans=max(ans,max(dp[i]))
return ans
def main():
print(beauty(6,6,"xzyabc",[1,3,2,5,4,6],[2,1,3,4,3,4]))
if __name__ == "__main__":
main()
n=7
n1=0
conta=0
s=0
for i in range(50):
conta=conta+1
print("Termino",str(conta),": ",n)
s=n+s
n=n+n1+1
n1=n1+1
prom=s/50
print("El Promedio es:",prom)
print("La suma es:",s)
import numpy as np
from itertools import permutations
# affinity_matrix
a = np.array([[60, 0, 45, 60], [0,50,50,10], [45, 50, 95, 55], [60, 10, 55, 70]])
print('Affinity Matrix: \n', a, '\n')
# return twice the sum of the multiplied columns
def bond(a_x, a_y):
return 2 * sum(a_x * a_y)
# check the matrix is square
assert a.shape[0] == a.shape[1]
dim = a.shape[0]
# get all permuations
permutations = list(permutations(range(dim)))
# initialize loop variables
best_score = 0
best = None
# calculate and take the best score of all
for p in permutations:
bond_energy = []
for i in range(dim-1):
bond_energy += [bond(a[:,[p[i]]],a[:,[p[i+1]]])]
print('Order:', p, 'Bond Energy:', bond_energy)
if sum(bond_energy) > best_score:
best_score = sum(bond_energy); best = p
print('\n')
print('Best Order:', best, 'Highest Bond Energy', best_score)
import random
import win32clipboard
win32clipboard.OpenClipboard()
win32clipboard.EmptyClipboard()
randomlist = ""
for i in range(0,500):
n = random.randint(0,100)
m = "\n" + str(n)
randomlist += m
print(randomlist)
win32clipboard.SetClipboardText(randomlist)
win32clipboard.CloseClipboard()
a = int(input("enter first number: "))
b = int(input("enter second number: "))
sum = a + b
print("sum:", sum)
Tokenizer