← Back to Community
Not a coding question (for once)
Profile icon
FARHEENPALAGIRI

Hi everybody, it's me again. Don't worry I'm not going to bother you about codes that I find really difficult (yet), I'm just honestly curious about something. Has anyone else noticed that most of the time when you think you have to write a giant code, and the model solution is like the simplest thing ever? Like, this one time I had to write a code that printed the number directly after the decimal. Any decimal size. My code looked like this:

a = input()
b = a.split(" . ")
c = len(b)
if (c == 2):
c = pop(1)
clo = list(str(c))
ans = clo.pop(0)
print(ans)
else:
print(0)

And the sample solution was this:
print(int(float(input()*10)%10))

I was so pissed. I was working on this code for two freaking days and it was this simple? Has this ever happened to anyone or does this kind of thing just happen to me?

Voters
Profile icon
pyelias
Profile icon
FARHEENPALAGIRI
Comments
hotnewtop
Profile icon
21natzil

What about "12.43".split(".")[1][0]?

Profile icon
pyelias

I think what happens here is that once you think of a solution, you just use it without consider other possible approaches. Planning is always helpful. (and if your code is too complicated, you're probably doing something wrong)
Even most large projects I've worked on usually have simple code, just a lot of it.

Profile icon
John_WardWard

@FAHREENPALAGARI Please don't curse!

Profile icon
FARHEENPALAGIRI

@John_WardWard Sorry :D