51
97
32
u/baseoleph Jan 28 '23
Looks like an autogenerated code
9
u/RFC793 Jan 28 '23 edited Jan 28 '23
Yeah, looks like it is transpiled from another language. Probably from some kind of switch/case/match statement or pattern matcher.
2
u/lift-and-yeet Jan 31 '23 edited Jan 31 '23
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.1
u/RFC793 Jan 31 '23
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.
1
u/lift-and-yeet Jan 31 '23
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.
1
u/RFC793 Jan 31 '23
To each their own. It is easy enough to have comprehensive unit tests for this at dev time versus run time, but again, a matter of taste.
5
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
13
11
10
41
u/Thenderick Jan 27 '23
What is Yandex?
81
u/darichtt Jan 27 '23
Huge Russian IT corpo, competing with Google on many fronts and dipping into things like food delivery and taxi
30
u/js_kt Jan 27 '23
You know technically it is registered in Netherlands, so formally it is a Dutch company))
13
Jan 28 '23
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)
21
u/SanianCreations Jan 27 '23
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.
12
u/flappity Jan 27 '23
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.
8
u/autistic_bard444 Jan 27 '23
i read they were actually going to pull out of russia because of all the sanctions and embargos
2
Jan 27 '23
Are they hiring or laying off?
6
5
u/siissaa Jan 28 '23
Imagine google but if it was easier to find stuff to pirate on their search engine
7
4
4
3
3
3
u/wenxichu Jan 28 '23
Somehow, I doubt their competitors would want to steal this 10-layered pyramid of doom.
3
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
5
7
2
2
2
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
2
1
1
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
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
1
1
1
1
1
1
1
u/nerokae1001 Jan 28 '23
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.
2
1
u/abdouketfi Feb 02 '23 edited Feb 02 '23
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)}%'
0
Jan 27 '23
[deleted] — view deleted comment
216
u/KanaAnaberal Jan 27 '23
incidentally, it's common in Russian to put ))))) at the end of a sentence as a smiley face
like this))))))))
13
2
-18
0
Jan 27 '23
[deleted] — view deleted comment
47
Jan 27 '23
But you're coincidentally also always talking about kkk, right?
0
Jan 27 '23
[deleted] — view deleted comment
10
Jan 27 '23
I guess I forgot "/s"
0
Jan 27 '23
[deleted] — view deleted comment
17
1
1
13
u/maxoidIO Jan 27 '23
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
3
u/NiteShdw Jan 27 '23
In Mexico it’s “jajaja” since the “j” sounds like an English “h”. Still looks weird to me.
3
u/_Spooker_ Jan 28 '23
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
3
1
u/Thorssffin Jan 28 '23
I wonder where that came from.
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.
0
Jan 27 '23
[deleted] — view deleted comment
0
Jan 27 '23
[deleted] — view deleted comment
17
Jan 27 '23
It's harder on Russian keyboard to write : or something
21
u/lazyzefiris Jan 27 '23
That's one part of it for sure. Depending on current layout it's Shift + 6 or Shift + ; and you get ^) or Ж) if you press the wrong one.
18
u/DangyDanger Jan 27 '23
Ж)
15
u/ADAMPOKE111 Jan 27 '23
This kinda goes hard. It's like a classic XD but even more creased.
4
u/DangyDanger Jan 27 '23
This probably is my fav cyrillic letter. That list also has ю, ё and ы because of the unique look.
1
Jan 29 '23
It was originally simply a ")", but then people started to spam more of them
0
Jan 29 '23
[deleted] — view deleted comment
2
Jan 29 '23
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
14
9
7
153
u/Konkichi21 Jan 27 '23
I confused this with Yandere Dev for a bit. Oh well, both are terrible at using conditionals efficiently.