how the heck am i getting wrong answer on bishops??i'm pretty sure the answer is 2*n -2, except for 1 where it's 1.
How the ... do you think can anyone know without having a look at your code??
value = io.readline()
value = int(value)
if value == 1:
value = 2*value -2
Be careful with unspecified "except"-clauses. Stupid mistake! Try this:
[bbone=Python,122]import syswhile True: try: value = io.readline() except EOFError: break value = int(value) if value == 1: print(1) else: value = 2*value -2 print(value)[/bbone]
i am getting wrong answer why?
You are ignoring a particular case.
Help neededHow to run bishop code when test cases are in files?
n=raw_input()n=int(n)sum=2*n-2if n==1: sum=1print sum
What kind of files?Input is read via stdin, output via stdin.
According to your code: If you show Python code you must have a look at the indentation.
If you are getting WA(using strings in c++), check for corner cases:
N = 0, 1, 5, 50, 500, 5000…so on
Required output for these cases is 0, 1, 8, 98, 998, 9998,…so on respectively.
And not : 8, 0, 08, 098, 0998, 09998…so on respectively.