Could this code have fewer lines of code? Like instructions of functional programming | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 4

Could this code have fewer lines of code? Like instructions of functional programming

https://code.sololearn.com/cl0osxPIATRs/?ref=app

20th Nov 2021, 2:23 PM
Frank Castro
Frank Castro - avatar
21 Answers
+ 5
Okay I give up, here is my 65 character code ☺️: https://code.sololearn.com/ctZ8PeXzMZKH/?ref=app
26th Nov 2021, 10:28 AM
Solo
Solo - avatar
+ 6
RUSIRU import string a = input() l = string.ascii_lowercase+' ' for i in a.lower(): n = l.index(i) print(l[25 - n], end='') 👇 import string l = string.ascii_lowercase+' ' for i in input().lower(): print(l[25 - l.index(i)], end='') 👇 import string;l=string.ascii_lowercase+' ' for i in input().lower():print(l[25-l.index(i)],end='') 👇 In one line, 99 characters 👏👏👏👍☺️: import string;l=string.ascii_lowercase+' ';print(''.join(l[25-l.index(i)]for i in input().lower()))
20th Nov 2021, 4:00 PM
Solo
Solo - avatar
+ 4
IN TWO LINES 1)a=' abcdefghijklmnopqrstuvwxyz ' 2)print(''.join([a[-a.index(i)-1] for i in input().lower()]))
20th Nov 2021, 3:48 PM
Prabhas Koya
20th Nov 2021, 6:36 PM
Brian
Brian - avatar
+ 4
😄😄 Vasiliy you have hooked me into a competition. Let my try another entry. Can you make it shorter than 83 characters? 😏 https://code.sololearn.com/c13uSM1hmQxc/?ref=app
20th Nov 2021, 11:41 PM
Brian
Brian - avatar
+ 4
Vasiliy I still count 83. If you prefer 81, then count this please: https://code.sololearn.com/c72U1VozJNTf/?ref=app
21st Nov 2021, 12:21 AM
Brian
Brian - avatar
+ 3
Frank Castro alphabet='abcdefghijklm nopqrstuvwxyz' backwardAlphabet=alphabet[::-1] inputStr=input() result='' for letter in inputStr.lower(): indexLetter=alphabet.index(letter) result+=backwardAlphabet[indexLetter] print(result) 👇 a='abcdefghijklm nopqrstuvwxyz' backwardAlphabet=a[::-1] result='' for l in input().lower(): i=a.index(l) result+=backwardAlphabet[i] print(result) 👇 a='abcdefghijklm nopqrstuvwxyz' result='' for l in input().lower(): result+=a[::-1][a.index(l)] print(result) 👇 In one line, 91 characters ☺️: a='abcdefghijklm nopqrstuvwxyz';print(''.join(a[::-1][a.index(l)]for l in input().lower()))
20th Nov 2021, 3:40 PM
Solo
Solo - avatar
+ 3
Prabhas Koya in one line, 88 characters 👏👏👏👏👏👍☺️: a='abcdefghijklm nopqrstuvwxyz';print(''.join(a[-a.index(i)-1]for i in input().lower()))
20th Nov 2021, 9:39 PM
Solo
Solo - avatar
+ 1
Try this :) import string a = input() l = string.ascii_lowercase u = string.ascii_uppercase n = 0 for i in a: if i in l: n = l.index(i) print(l[25 - n], end="") elif i in u: n = u.index(i) print(l[25 - n], end="") elif i == " ": print(i, end="")
20th Nov 2021, 3:09 PM
Rusiru Rathmina
Rusiru Rathmina - avatar
20th Nov 2021, 3:23 PM
The future is now thanks to science
The future is now thanks to science - avatar
+ 1
Brian 95 characters👏👏👏👍☺️
20th Nov 2021, 9:51 PM
Solo
Solo - avatar
+ 1
Brian, not 83, 81 characters ☺️ 👏👏👏👏👏👍
20th Nov 2021, 11:50 PM
Solo
Solo - avatar
+ 1
😳Brian, 78 char!!! ☺️ 👏👏👏👏👏👍
21st Nov 2021, 12:25 AM
Solo
Solo - avatar
+ 1
Brian, 68 char ☺️
22nd Nov 2021, 6:24 AM
Solo
Solo - avatar
+ 1
Vasiliy I think 68 char is impossible. 72 is the best I can do: https://code.sololearn.com/cw26IHs68AZ7/?ref=app
22nd Nov 2021, 6:18 PM
Brian
Brian - avatar
+ 1
Brian, I have shortened the code to 65 characters!!! ☺️
25th Nov 2021, 3:30 AM
Solo
Solo - avatar
+ 1
For some reason I am not allowed to do this, it looks like I went beyond the bounds of what is permitted 🤣🤣🤣 And it all started with this discussion. Now I can’t even share the html code in discussions, I asked a question about this, but so far there’s silence.
25th Nov 2021, 7:24 AM
Solo
Solo - avatar
+ 1
Wow Vasiliy using conditions in a new way.
26th Nov 2021, 4:41 PM
Prabhas Koya
+ 1
Prabhas Koya, I would not say that this is something new, just rare ☺️
26th Nov 2021, 6:22 PM
Solo
Solo - avatar
+ 1
Vasiliy bravo!! 🤩👏👏👏👏👏🤝
26th Nov 2021, 8:47 PM
Brian
Brian - avatar