def test_2(): raised = False try: jutge.read(amount='spam') except TypeError: raised = True assert raised
def test_read_line_read(): with open('test/text/source2.txt') as source: jutge.read_line(file=source) result1 = jutge.read(int, file=source) jutge.read_line(file=source) result2 = jutge.read(float, file=source) assert result1 == -3 and result2 == 3.14
def test_3(): raised = False try: jutge.read(amount=-1) except ValueError: raised = True assert raised
def main(): turtle.penup() turtle.backward(150) turtle.pendown() n = jutge.read(int) floc_koch2(n, 100) jutge.read(chr) # espera per tancar la pantalla
def main(): n, primer = read(int), True while n is not None: if not primer: print() escriu_quadrat(n) n, primer = read(int), False
def main(): '''Llegeix una sequencia de naturals n >= 2 i escriu els octagons segons l'especificacio del problema''' n = read(int) while n is not None: octagon(n) n = read(int)
def test_bad_kwarg(): raised = False try: read(nonexistant_kwarg=42) except NameError: raised = True assert raised
def main(): trobat = False a, b, c = read(int, int, int) while not trobat and c != ÚLTIM_ELEMENT: if pic_guapo(a, b, c): trobat = True else: a, b, c = b, c, read(int) print("SI" if trobat else "NO") # operador condicional en Python com el ?: de C++.
def test_2(): jutge.set_eof_handling(jutge.EOFModes.RaiseException) source = io.StringIO('') raised = False try: jutge.read(file=source) except EOFError: raised = True finally: jutge.set_eof_handling(jutge.EOFModes.ReturnNone) assert raised
def main(): a, b = jutge.read(int, int) t1 = time.time() r = eleva(a, b) t2 = time.time() print(t2 - t1)
def main(): n, b = read(int, int) print("----------") while n > 0: print("X" * (n % b)) n //= b print("----------")
def read_input(): print("Hi, this is an efficiency test to prove the graph creation speed.") inicio = 0 while inicio < 2: print( "Please, introduce an start distance for the loop (bigger than 2): " ) inicio = read(int) fin = inicio while fin <= inicio: print( "Fine, now introduce a finish distance for the loop (bigger than the start distance)" ) fin = read(int) incremento = 0 while incremento <= 0: print("Finally, introduce an increment for the loop (bigger than 0):") incremento = read(int) return inicio, fin, incremento
def main(): n = read(int) m = read(int) g = {} for x in range(n): g[x] = [] nodes = list() for a in range(m): primer = read(int) segon = read(int) l = g[primer] l.append(segon) g[primer] = l x = read(int) y = read(int) a = dfs_recursive(g,x) if(y in a): print('yes') else: print('no')
def check(data, a, b): stream = io.StringIO(data) x, y = jutge.read(float, float, file=stream) assert x == a assert y == b
def test_1(): source = open('test/text/source3.txt') expected = range(1, 13) nums = jutge.read(int, file=source, amount=12) assert all(inp == val for inp, val in zip(nums, expected))
def test_4(): source = io.StringIO("a2 c3") expected = ('a', 2, 'c', 3) tokens = jutge.read(chr, int, amount=2, file=source) assert all(inp == val for inp, val in zip(tokens, expected))
from jutge import read a, b = read(float, float) print(a+b)
from jutge import read # La funció maxim, donats dos enters retorna un enter que és el seu màxim. def maxim(a, b): if a > b: return a else: return b # Programa que llegeix dos enters i n'escriu el seu màxim, cridant maxim(). x, y = read(int, int) print(maxim(x, y))
from jutge import read n = read(int) seq = read(int) pos = 1 while pos < n: seq = read(int) pos += 1 print("A la posicio %d hi ha un %d." % (n, seq))
def main(): n = read(int) pinta_rombe(n)
# Mitjana d'una seqüència de nombres from jutge import read s = 0 n = 0 x = read(int) while x is not None: s = s + x n = n + 1 x = read(int) print(s/n) # (divisió de reals)
def main(): n = read(int) print(fibonacci(n))
from jutge import read a = read(chr) i = 0 while a != '.': if a == 'a': i += 1 a = read(chr) print(i)
def main2(): n = read(int) print(primers_primers(n))
def main1(): n = read(int) print(primers(n))
from jutge import read n = read(int) while n is not None: v = [] for i in range(0, n): v.append(read(float)) t = read(int) while t != 0: t -= 1 x, esq, dre = read(float, int, int) print(position(x, v, esq, dre)) n = read(int)
# Calcular l'n-èsim número de Fibonacci from jutge import read n = read(int) a, b = 0, 1 i = 1 while i <= n: a, b = b, a + b i = i + 1 print(a)
from PIL import Image, ImageDraw from jutge import read n = read(int) numeros = [] colors = [] for i in range(0, n): x = read(int) numeros += [x] s = read(str) colors += [s] img = Image.new('RGB', (sum(x), max(x)), 'Black') dib = ImageDraw.Draw(img) cosa = 0 for i in range(0, n): dib.ellipse([ cosa, (max(numeros)) / 2 - (numeros[i]) / 2, (max(numeros) / 2) + (numeros[i]) / 2, cosa ], colors[i]) cosa += nums[i] img.save('output.png')
from jutge import read f = open('/etc/passwd') w = read(file=f) while w is not None: print(w) w = read(file=f)
def main(): n = read(int) v = [None for i in range(n)] u = [False for i in range(n)] genera(v, u, 0)
from jutge import read s = 0 x = read(int) while x is not None: s += x x = read(int) print(s)
def test_function(self): sys.stdin = io.StringIO("10 20 30") [x, y, z] = jutge.read(int, int, int, file=sys.stdin) assert [x, y, z] == [10, 20, 30]
def main(): n = read(int) while n is not None: escriu(n) print() n = read(int)
def main(): n = read(int) hanoi(n, 'A', 'C', 'B')