But there shouldn't have been a switch/case block like this in the original language in the first place. There should have been at most three cases, for x <= -75%, x > 95, and the remainder with the latter using arithmetic and string variable interpolation or similar to generate the text.
Personally, I’d rather have the obvious switch statement than something performing arithmetic and string formatting. And at the end of the day, some chain like this is likely more efficient than the generic approach (especially format string handling).
The procedural approach has advantages (like, I’d wish for that if the granularity changes), but that is easily YAGNI. This really spells out all of the cases (especially if the original language verifies all cases are handled), and I kind of like it outside of the horrible nesting of OP code.
I disagree; while for the approach shown it takes less time to understand the intent of the uncommented source code, there are also far too many opportunities to make typos, making this approach bad for engineering in the large due to needing significantly more attention for code review. The generic approach is easier to code review, and with proper commenting/documentation and test cases it's easy to understand the intent of as well.
They spilt they business not a while ago. Some part will be Russian company (to work inside Russia only) and the other one will still be Neatherlands (world wide)
I find that their reverse image search is actually really good, I consistently get images that look more like the source image than through other reverse image search websites.
I find its image translator to be pretty darn good. Felt a little uncomfortable/weird translating Ukrainian memes/pictures during the war using Yandex, though.
Picture on the right appears to be a cover of a book released by Yandex. ”The secrets of Python — 59 recommendations on how to write the most effective code”. Maybe they should’ve given those out to their employees too.
I didn't see that it said Python, and I couldn't understand which language it was because the syntax seemed so weird. Then I saw it was ONE lambda function 💀
My python is bit rusty maybe someone could make it more simpler.
https://onecompiler.com/python/3yw8pw9xw
import math
def print_discount(discount,step):
discount = -75 if discount < -75 else discount
s = math.floor(discount / step)*step
e = s+step-1 if s+step==100 else s+step
p = "-" if discount < 0 else "+"
f = "{0} {1}-{2}%"
r = f.format(p,abs(s),abs(e)) if discount >0 else f.format(p,abs(e),abs(s))
print(r)
discounts = [96,76,65,52,0,-3,-40,-37,-70,-75,-86,-90]
step = 5
for i in discounts:
print_discount(i,step)
Edited: backtick was wrongly inserted. I am on my phone.
from math import ceil
def func(x):
sign = '-' if x<0 else '+'
n = 5 \* ceil(x/5)
if x > 95: return '+ 95-99%'
if x <= -75: return '< -75%'
return f'{sign} {abs(n)-5}-{abs(n)}%'
not sure but it could came from times when ppl used sms on old phones (like some nokia). the price of sms depended on the count of symbols in messages. so basically skipping ":" in smiles were cheaper and that became as a habit and common thing
Russian here. We put ) at the end of the sentence because it looks like a smile: :). But because typing :) everytime is not convenient, everyone short it to just ). Some examples: Привет :). And: Привет). It tooks less time to write just ) then pressing and holding SHIFT+:, i guess that's the reason why everyone types it like that
It was dificult to type the : before the ) so people just use )))) for smiley emojis, it's easier know to do so from a smartphone to type :) but people just kept typing it like they did before.
Nono, it works normal in math and stuff, what i described only applies for texting
Edit: the one thing that's different in math, is that from what i understand, you westerners can multiply by % (i.e. 100x75%=75), which isn't a thing in math for Russians
153
u/Konkichi21 Jan 27 '23
I confused this with Yandere Dev for a bit. Oh well, both are terrible at using conditionals efficiently.
51
u/RedBlueKoi Jan 28 '23
Blyatiful engineering
97
u/[deleted] Jan 27 '23
When you want to be a lisp programmer but all you got is this lousy python
32
u/baseoleph Jan 28 '23
Looks like an autogenerated code
29
u/DrThrowawayToYou Jan 28 '23
Corporate security officer: we must follow all the best security practices to prevent source code leaks.
Devs: yeah, it'd be real embarrassing if anyone saw it.
18
u/autistic_bard444 Jan 27 '23
every time i see this i just say wtf over and over
13
u/TheUnlocked Jan 27 '23
else 0?11
u/DangyDanger Jan 27 '23
Shit, and I thought I had too much skill issue to work for them.
10
u/whenwillthealtsstop Jan 27 '23
I can't
41
u/Thenderick Jan 27 '23
What is Yandex?
7
u/hiimkir Jan 27 '23
don’t look up function names in antirobot/scripts/learn/sky_matrixnet.sh
4
u/arcalus Jan 27 '23
Rolodex FTW!!!!! ))))))))))))))
4
u/siissaa Jan 28 '23
I read that as Yan(dere)Dev and believed every word of it
3
u/Glori4n Jan 27 '23
So... Is this a slip into a Russian developer's insane mind?
3
u/lift-and-yeet Jan 28 '23
Oh no
3
u/wenxichu Jan 28 '23
Somehow, I doubt their competitors would want to steal this 10-layered pyramid of doom.
3
u/[deleted] Jan 28 '23
Picture on the right appears to be a cover of a book released by Yandex. ”The secrets of Python — 59 recommendations on how to write the most effective code”. Maybe they should’ve given those out to their employees too.
3
u/personalityson Jan 28 '23
Maybe it's for performance?
5
u/Masztufa Jan 27 '23
Leaked or decompiled?
7
u/[deleted] Jan 27 '23
Most normal Russian application
2
u/[deleted] Jan 27 '23
Now that’s what i call a nightmare when i tock over someone’s code 🤦🏻♂️
2
u/[deleted] Jan 28 '23
The was if(false) somewhere
2
u/-Konrad- Jan 28 '23
This makes me really sad
2
u/genericindividual69 Jan 28 '23
I just like the idea that the sale price can be more expensive than the normal price
2
u/FinFanInParadise Jan 28 '23
Sonarqube is already hacking and coughing before it spits out a report on code analysis saying, "what in the literal "f' are you thinking????"
2
u/[deleted] Jan 28 '23
What even is this
2
u/Bobtheblob2246 Jan 28 '23
Бляяя))))))))))))))))))
1
u/corvocures Jan 28 '23
Critical damage to my sanity...
1
u/[deleted] Jan 28 '23
I didn't see that it said Python, and I couldn't understand which language it was because the syntax seemed so weird. Then I saw it was ONE lambda function 💀
1
u/[deleted] Jan 29 '23
But python had no switch until recently, only if; elif; else. Poster on the right: Secrets of python, 59 recommendations on making effective code.
1
u/Professional_Fuel826 Jan 29 '23
How this pice of code can be rewrited to be cleaner and faster?
1
u/4bidden1337 Jan 29 '23
autogenerated or transpiled
1
u/B16D0N-XD Jan 29 '23
Ну пон
1
u/szonce1 Jan 29 '23
Couldn’t you do a for each loop and add 5% each time?
1
u/Aperture_Executive2 Feb 06 '23
bro found a lisp developer and tried to make them learn python
1
u/MarioGuyWasTaken Feb 20 '23
okay what the fuck
1
u/[deleted] Feb 26 '23
Always that one junior dev in the main branch
1
u/nerokae1001 Jan 28 '23
My python is bit rusty maybe someone could make it more simpler.
https://onecompiler.com/python/3yw8pw9xw
Edited: backtick was wrongly inserted. I am on my phone.
0
u/[deleted] Jan 27 '23
[deleted] — view deleted comment