Toggle menu
Toggle personal menu
Not logged in
Your IP address will be publicly visible if you make any edits.

CodeRace/2014.8.20/eval: Difference between revisions

From ZeroWiki
imported>lyuha
No edit summary
 
(Repair batch-0001 pages from live compare)
 
(One intermediate revision by one other user not shown)
Line 1: Line 1:
== 팀명 ==
== 팀명 ==
'''eval'''
'''eval'''
언어 : python
== 팀원 ==
== 팀원 ==
[[권영기]], [[이원준]]
[[권영기]], [[이원준]]
== 코드 ==
== 코드 ==
=== phase1 ===
=== phase1 ===
  number = []
  number = []
  for i range(5):
  for i range(5):
  number.append(input())
  number.append(input())
  max(number)
  max(number)
=== phase2 ===
=== phase2 ===
  number = []
  number = []
   
   
  input = open("input.txt", encoding="utf-8").read().split("\n");
  input = open("input.txt", encoding="utf-8").read().split("\n");
  input.pop(0)
  input.pop(0)
   
   
  for x in input[0].split():
  for x in input[0].split():
  number.append(int(x))
  number.append(int(x))
   
   
  print(max(number))
  print(max(number))
=== phase3 ===
=== phase3 ===
  number = []
  number = []
   
   
  input = open("input.txt", encoding="utf-8").read().split("\n");
  input = open("input.txt", encoding="utf-8").read().split("\n");
  input.pop(0)
  input.pop(0)
   
   
  for x in input[0].split():
  for x in input[0].split():
  try:
  try:
  number.append(int(x))
  number.append(int(x))
Line 40: Line 41:
  import math
  import math
   
   
  matrix = []
  matrix = []
   
   
  input = open("input_matrix.txt", encoding="utf-8").read().split("\n");
  input = open("input_matrix.txt", encoding="utf-8").read().split("\n");
Line 46: Line 47:
   
   
  for x in input:
  for x in input:
  row = []
  row = []
  for number in x.split():
  for number in x.split():
  try:
  try:
Line 54: Line 55:
  matrix.append(row)
  matrix.append(row)
   
   
  column_max = []
  column_max = []
  row_max = []
  row_max = []
   
   
  for i in range(row_length):
  for i in range(row_length):
  row = []
  row = []
  for j in range(col_length):
  for j in range(col_length):
  if(type(matrix[i][j]) is int):
  if(type(matrix[i][j]) is int):
  row.append(matrix[i][j])
  row.append(matrix[i][j])
  if(len(row) > 0):
  if(len(row) > 0):
  row_max.append(max(row))
  row_max.append(max(row))
Line 68: Line 69:
   
   
  for i in range(col_length):
  for i in range(col_length):
  column = []
  column = []
  for j in range(row_length):
  for j in range(row_length):
  if(type(matrix[j][i]) is int):
  if(type(matrix[j][i]) is int):
  column.append(matrix[j][i])
  column.append(matrix[j][i])
  if(len(column) > 0):
  if(len(column) > 0):
  column_max.append(max(column))
  column_max.append(max(column))
Line 80: Line 81:
  print(row_max)
  print(row_max)
  for i in range(len(column_max)):
  for i in range(len(column_max)):
  print("column ", i, " : ", column_max[i])
  print("column ", i, " : ", column_max[i])
  for i in range(len(row_max)):
  for i in range(len(row_max)):
  print("row", i, " : ", row_max[i])
  print("row", i, " : ", row_max[i])
  print(max([max([x for x in column_max if type(x) is int]), max([x for x in row_max if type(x) is int])]))
  print(max([max([x for x in column_max if type(x) is int]), max([x for x in row_max if type(x) is int])]))
=== phase final ===
=== phase final ===
  import math
  import math
Line 89: Line 90:
  del __builtins__.exit
  del __builtins__.exit
   
   
  matrix = []
  matrix = []
   
   
  input = open("input final.txt", encoding="utf-8").read().split("\n");
  input = open("input final.txt", encoding="utf-8").read().split("\n");
Line 95: Line 96:
   
   
  for x in input:
  for x in input:
  row = []
  row = []
  for number in x.split():
  for number in x.split():
  try:
  try:
Line 107: Line 108:
  matrix.append(row)
  matrix.append(row)
   
   
  column_max = []
  column_max = []
  row_max = []
  row_max = []
   
   
  for i in range(row_length):
  for i in range(row_length):
  row = []
  row = []
  for j in range(col_length):
  for j in range(col_length):
  if(type(matrix[i][j]) is int):
  if(type(matrix[i][j]) is int):
  row.append(matrix[i][j])
  row.append(matrix[i][j])
  if(len(row) > 0):
  if(len(row) > 0):
  row_max.append(max(row))
  row_max.append(max(row))
Line 121: Line 122:
   
   
  for i in range(col_length):
  for i in range(col_length):
  column = []
  column = []
  for j in range(row_length):
  for j in range(row_length):
  if(type(matrix[j][i]) is int):
  if(type(matrix[j][i]) is int):
  column.append(matrix[j][i])
  column.append(matrix[j][i])
  if(len(column) > 0):
  if(len(column) > 0):
  column_max.append(max(column))
  column_max.append(max(column))
Line 133: Line 134:
  print(row_max)
  print(row_max)
  for i in range(len(column_max)):
  for i in range(len(column_max)):
  print("column ", i, " : ", column_max[i])
  print("column ", i, " : ", column_max[i])
  for i in range(len(row_max)):
  for i in range(len(row_max)):
  print("row", i, " : ", row_max[i])
  print("row", i, " : ", row_max[i])
  print(max([max([x for x in column_max if type(x) is int]), max([x for x in row_max if type(x) is int])]))
  print(max([max([x for x in column_max if type(x) is int]), max([x for x in row_max if type(x) is int])]))
 

Latest revision as of 23:56, 26 March 2026

팀명

eval 언어 : python

팀원

권영기, 이원준

코드

phase1

number = []
for i range(5):
	number.append(input())
max(number)

phase2

number = []

input = open("input.txt", encoding="utf-8").read().split("\n");
input.pop(0)

for x in input[0].split():
	number.append(int(x))

print(max(number))

phase3

number = []

input = open("input.txt", encoding="utf-8").read().split("\n");
input.pop(0)

for x in input[0].split():
	try:
		number.append(int(x))
	except ValueError:
		continue

try:
	print(max(number))
except ValueError:
	print("NaN")
finally:
	pass

phase4

import math

matrix = []

input = open("input_matrix.txt", encoding="utf-8").read().split("\n");
row_length, col_length = map(int, input.pop(0).split())

for x in input:
	row = []
	for number in x.split():
		try:
			row.append(int(number))
		except ValueError:
			row.append('NaN')
	matrix.append(row)

column_max = []
row_max = []

for i in range(row_length):
	row = []
	for j in range(col_length):
		if(type(matrix[i][j]) is int):
			row.append(matrix[i][j])
	if(len(row) > 0):	
		row_max.append(max(row))
	else:
		row_max.append("NaN")

for i in range(col_length):
	column = []
	for j in range(row_length):
		if(type(matrix[j][i]) is int):
			column.append(matrix[j][i])	
	if(len(column) > 0):		
		column_max.append(max(column))
	else:
		column_max.append("NaN")

print(column_max)
print(row_max)
for i in range(len(column_max)):
	print("column ", i, " : ", column_max[i])
for i in range(len(row_max)):
	print("row", i, " : ", row_max[i])
print(max([max([x for x in column_max if type(x) is int]), max([x for x in row_max if type(x) is int])]))

phase final

import math

del __builtins__.exit

matrix = []

input = open("input final.txt", encoding="utf-8").read().split("\n");
row_length, col_length = map(int, input.pop(0).split())

for x in input:
	row = []
	for number in x.split():
		try:
			row.append(eval(number))
		except NameError:
			row.append('NaN')
		except SyntaxError:
			row.append('NaN')
		except ValueError:
			row.append('NaN')
	matrix.append(row)

column_max = []
row_max = []

for i in range(row_length):
	row = []
	for j in range(col_length):
		if(type(matrix[i][j]) is int):
			row.append(matrix[i][j])
	if(len(row) > 0):	
		row_max.append(max(row))
	else:
		row_max.append("NaN")

for i in range(col_length):
	column = []
	for j in range(row_length):
		if(type(matrix[j][i]) is int):
			column.append(matrix[j][i])	
	if(len(column) > 0):		
		column_max.append(max(column))
	else:
		column_max.append("NaN")

print(column_max)
print(row_max)
for i in range(len(column_max)):
	print("column ", i, " : ", column_max[i])
for i in range(len(row_max)):
	print("row", i, " : ", row_max[i])
print(max([max([x for x in column_max if type(x) is int]), max([x for x in row_max if type(x) is int])]))