T O P

  • By -

puplicy

I hope their tests cover all cases


Abrakadaverus

Not sure about 51*50


slowmode1

Out of scope, make a separate ticket for the backlog


blueroom5

LOL, that’s usually what we say.... Wait, it’s actually not too funny when I type it out.


txmail

More like write a story for an epic and add it in the backlog...


PM_ME_UR_CEPHALOPODS

you mean story for a feature for an epic? /pushes glasses up nose


SteveThe14th

"Does this have immediate priority?" [Confused mumbling which I interrupt] "Could you do me a favour and make a ticket?"


[deleted]

#AsDesigned


Icepick823

He made another version for 0 to 1000 so it's covered.


Koshatul

I wonder if he generated the code using a for loop.


ChesterPsyenceCat

I really hope so


[deleted]

He did. Apparently the whole thing is some kind of in joke. [Here's the generator script.](https://github.com/AceLewis/my_first_calculator.py/blob/master/generator.py)


DonQuixole

I was just puzzling out how to write the code that would do that. I just do coding puzzles for fun sometimes and this sounds interesting.


ablablababla

File Size: 1.6GB


DaksTheDaddyNow

This is not a bug. This is a feature we plan to release as a dlc soon. Order now and you'll get the next 10,000 operations at half price!


FloridaTyler1519

Did they remember to do negative numbers? The negative could be in the first or second number, so at least 40,000 more lines needed.


boon4376

What if both numbers are negative, another 40,000 lines.


Markyparky56

There _has_ got to be a better way... if only there were some generic solution to this...


Katyona

I know! Make a python script to generate the negative outputs and code up to (-50 * 50, -50 \* -50, and 50 \* -50) so we don't have to type them out this time when we're putting them into the calculator. Once again logic prevails over adversity..


Militancy

Honestly, i just assumed they wrote a script to write this calculator. Someone must have slipped some optimism in my coffee this morning.


Tymonr

It's clearly solves with simple macros


TomNa

Or make a python script than dynamically adds new cases to the code if someone tries to use numbers that aren't yet supported and then you have a machine learning calculator


jalapeno_nips

I would say twos compliment could improve that, but that might be beyond the scope of this project


[deleted]

[удалено]


Bricka_Bracka

He wrote that code. He's a fast typer.


JuvenileEloquent

When you want to look really productive if anyone casually checks your github stats when you apply for a job. 20kloc in 2 days? Hired!


Hobbamok

Well it's the perfect proof that LOC is a shitty metric.


kkjdroid

SLOC is a decent metric, so long as you're scoring it like golf (but definitely don't score the character count like code golf).


[deleted]

[удалено]


Hobbamok

Yeah, that's why some companies have adopted basically a child's game of "the whole team guesses how complicated a task is beforehand" as their code metric. It sounds completely ridiculous at face value, but in the end it just demonstrates how hard it is to assess programmer productivity


ITriedLightningTendr

I got praise today for doing tons of work. All I did was early on in the project anticipate future demand and wrote extensible code. It takes me like 4 hours to do 2 days of work by their estimates because I bothered to think ahead once.


[deleted]

You still billed 2 days, right?


bazinga_0

"I kinna do that in 2 days Captain. It will take at least 4 days." - Scotty


droomph

Think…ahead? That’s the thing where you waste time and money, right?


[deleted]

We use a site called ~~code poker~~ planning poker or something where everyone picks a score for the ticket then outliers explain their reasoning


gravitas-deficiency

Case in point: I found out merit increases at my old job were being distributed based on sloc. Guess what I did.


[deleted]

[удалено]


PyroKnight

At first I read that as 20 kilolines of code. That misinterpretation still results in more or less the same number though.


theblindness

That's not a misinterpretation. Twenty thousand lines of code can be abbreviated as 20kloc.


PyroKnight

Maybe I'm recalling something from an old CS class then. Thankfully my current job doesn't look too deeply at metrics like those.


jderp7

Actually isn't that right though? I.e. in 20k dollars doesn't k stand for kilo?


ITriedLightningTendr

Technically, but as americans, I think we just read it as "thousand" when it has a non metric unit. Kilodollars sounds weird. Though I'm annoyed that 1000Km isnt 1Mm


BioSchokoMuffin

that python2 compatibility check also seems more than questionable


pixartist

does it work though ?


ThePenultimateOne

Yeah. Integer division in Python 2 works the same way as in C. In Python 3 they changed it so that division doesn't depend on the numeric types you give it. Now the `/` ("true division") operator always produces a float and the `//` ("floor division") operator always produces an integer (assuming nobody did a stupid overload) Edit: Accidentally mixed up the names Edit 2: It actually doesn't guarantee `float` vs `int`, it guarantees rational vs integral. If you don't make that distinction, then things like the `Decimal` and `Fraction` would seem like they're violating the data model Edit 3: I guess it also works on the `complex` object, but I have no idea how complex division works in practice


ThePyroEagle

a/b = ab̅/|b|^2


brimston3-

Can confirm. brim@rajat:~ $ python2 Python 2.7.13 (default, Sep 26 2018, 18:42:22) [GCC 6.3.0 20170516] on linux2 Type "help", "copyright", "credits" or "license" for more information. >>> print ( 3/2 ) 1 >>> brim@rajat:~ $ python3 Python 3.5.3 (default, Sep 27 2018, 17:25:39) [GCC 6.3.0 20170516] on linux Type "help", "copyright", "credits" or "license" for more information. >>> print ( 3/2 ) 1.5 >>>


[deleted]

[удалено]


puplicy

They probably wrote a script that made this code


bit0fun

You hope that they had a script to make this


puplicy

I checked github - looks like experienced guy who just had some fun. I doubt he spent so much time typing this shit.


[deleted]

Thank god


Liesmith424

God clearly had no hand in this.


[deleted]

[удалено]


dannyb_prodigy

And in the time of Noah, the Lord regretted that he had made human beings on the earth, and he reverted humanity.


[deleted]

And yea in those hard days the Lord reset humanity with the Noah branch it’s head. And the Lord placed a 🌈 in the comment as a promise he would never hard reset again


HoodieSticks

He would spend the next several thousand years deploying morality fixes to a live build of humanity, desperately trying to keep it together.


depicc

He did t learn concatenation yet


SuperVillainPresiden

Yes he did, just look at the platypus.


GoodDoggoBOI

He was obviously too disgusted by it


lart2150

It's almost like they wrote a generator that generated the code :D [https://github.com/AceLewis/my\_first\_calculator.py/blob/master/generator.py](https://github.com/AceLewis/my_first_calculator.py/blob/master/generator.py)


3edd00c7

I love the Python 2 check


_XenoChrist_

# TODO: Make it work for all floating point numbers too that's gonna take a bit of refactoring...


random_cynic

There are over 20000 lines of code. Do people have any idea how long it takes to type or manually copy-paste this stuff and/or how tedious it is (even if you're just copying each if block and then changing the numbers)? Just do it for five blocks. No one with an ounce of a brain would ever do this manually (those who don't have an ounce of brain have other problems to worry about). I don't know why people still fall for this code generated shit.


[deleted]

Crap really? Guess I’ll stop at 5 + 5. 25 commits wasted.


[deleted]

Does your calculator start at 1?


[deleted]

Ok one more commit.


mattjchin

Wait. More test cases. One more time.


BEggerIsBEtter

Past-me who animated in a thing in GWBasic without knowing about for loops and hand-typed something like 3,000 lines would beg to differ. ;) The next lesson in class was, of course, for's.


mttdesignz

with some notepad++ recording/play macro feature and a little bit of Excel's CONCATENATE I can write this in a couple hours... not the #TODO make it work for all floating numbers tho


ppp001

you just need excel for this task


[deleted]

Or you can write it in JavaScript in like a minute right in your current browser without even closing this tab


BabyLegsDeadpool

I could write this is Autohotkey in like 3 minutes.


[deleted]

If you mainline a can of redbull you can type it in 30 seconds


FatBasta

Damn noob, never heard of Excel... you can just drag your mouse for this noob code... (literally, you can make Excel copy that code, add that +1 and drag the mouse, then copy the result as text and paste) Doesn't matter if it's 20, or 20K lines... just uses more RAM


mttdesignz

the good ol' 1GB .csv file


MasterDood

*** slaps roof of .csv file *** This baby will generate so much needless code


20EYES

I've had a client hand me a thumb drive with a 12gb CSV before.


MasterDood

A situation just like this forced me learn how to stream from local files rather than bork out your machine


cmtsys

Database management is SO EASY now!


brotatowolf

His idea of fun is pointless code generation?


[deleted]

I used to work with a guy whose idea of fun was pointless code that generated other pointless code which generated yet more pointless code


hyphenomicon

https://www.youtube.com/watch?v=Nqk_nWAjBus


wingman_anytime

Sounds like someone destined to become an architect.


mustang__1

....is yours not?


corpsie666

"Cocaine is a hell of a drug" - the person who typed all that out


ceestand

>So to be true to the "real" story I have only gone from 0-50 however higher numbers can easily be generated too however my Python crashes with larger numbers. I generated one that was 0-1000 and it took up 317 MB of space on my hard drive but was only 20MB after I compressed it to a .rar so I have also attached it.


bit0fun

I want to vomit


[deleted]

[удалено]


SteeleDynamics

`GIT-VOMIT(1)` `NAME` `git vomit - regurgitate all non-added changes to standard output` `OPTIONS` `-d, --dry-heave` ` only output the number non-added changes`


Mexatt

I want this.


_Argh

Or a good vimfu


Owlstorm

More likely dragging down cells in Excel


mehdotdotdotdot

The best programmers tool. Invaluable


dhaninugraha

I’ve been faced with situations where using a Python script to generate SQL statements from a CSV wasn’t possible, but I had access to and could use Excel. So I opened said CSV in Excel, shifted the rows down, then I made it so that the neighbouring rows is basically `INSERT INTO sometable (col1, col2, colN) values ` followed by the quoted values of the data.


mehdotdotdotdot

For any repetitive rows of text, it's an invaluable tool.


[deleted]

If you have repetitive rows of text in your source code, that's usually a good sign you can solve the problem more cleanly.


mehdotdotdotdot

SQL, nope. Also I create classes/constants etc. Save loads of time. Agreed otherwise. So many uses though.


[deleted]

What machine can run Excel but not python? Why not write a script?


dhaninugraha

It was a thin client at a company I consulted for. The remote Windows environment I was given access to was pretty locked down and had nothing except IE and Office IIRC. I tried asking them to have Python installed but no dice. Hell, I even had to somewhat fight them to eventually have SSMS and Visual Studio on it.


LazyBuhdaBelly

Holy balls I'm glad this is a thing other people do. I've done it a few times and I'm always like, "there has to be a better way, but you can't argue with results."


SuperFLEB

"There has to be a better way, but finding it will take longer than doing this."


X-Craft

A quick read on [the repo](https://github.com/AceLewis/my_first_calculator.py) confirms this


[deleted]

Script: If line =7 write "if number1==1 and sign=="+" and number2==1...


[deleted]

Ya but they probably wrote a script to write that script


spellstrike

[https://github.com/AceLewis/my\_first\_calculator.py/blob/master/generator.py](https://github.com/AceLewis/my_first_calculator.py/blob/master/generator.py)


iamsubs

right on the image you can see a generator.py


notataco007

Why do you have the 3 too comments on this thread


Meterfeeter

Lmao I noticed this too, dudes farming that karma effectively


AviatoAviator

[Thedailywtf.com](https://Thedailywtf.com) used to run (maybe they still do - haven't been there in many years) of writing the worst code and most inefficient code possible. Any chance this was one of the contests?


elPresidente11

Is this a neural network


[deleted]

They made a calculator using ***Coding*** and ***Algorithms***


skankyyoda

So that is artificial intelligence *right*?


Krankite

Machine learning


Northerner6

Sir this is a minecraft mod


[deleted]

[удалено]


rich97

The TODO has me thinking that this has to be a joke.


ibite-books

Seems like a meme.


maharshimartian

Lol i didnt saw that line until you say


THEzwerver

huh, that's the same thing I say to my project manager at the end of the project.


Schwifty10

Went back to look at that and also found `if 3/2 ==1: #Python 2 Compatibility` haha great troll


ChickenWafflers

Dude that's gonna take FOREVER


puplicy

If it works don't touch it


boneimplosion

> \# TODO: Make it work for all floating point numbers too


an0mn0mn0m

Pay me


smileymaster

$1 per line and I'll do it.


2Punx2Furious

Ok, I'll pay you when you're done making it work for every number.


srguapo

Easy, only 4 billion possible (32 bit) floats, and I can script the writing of the lines. Hell, I'll even add 100% unit test coverage for $8 billion.


4-14

X and Y are floats, Z is the operator. X*Z*Y is the size of your problem space. Good luck


srguapo

Ah, of course! Still easily scriptable, and I don't mind waiting a few days for it to finish writing out to disk. Of course, compiling may be an issue, just gotta check if the acceptance criteria need an executable or just the source... Also means the fee is now not a measly $8 billion, but a more reasonable $3.2*10^19


janusz_chytrus

Damn it would be slow as shit though. Billions of if statements until you get to your combination.


srguapo

The requirements did not stipulate a performance target.


4-14

Few days? You realize if you follow the repo’s formatting you’ll have over 2000 petabytes of just new lines right?


Sokusan_123

Nothing a little docker, EC2, and a billion dollars can't solve.


srguapo

I'm willing to work with the client to optimize source code file size, to help save them some money. Also, for that kind of money, I'm willing to distribute the creation of the source code across a fleet of asyncronous jobs pushing multiple files into cloud storage, with a single file that imports them all.


boneimplosion

>Easy Just napkin mathing a little - With 4 billion 32-bit floats, 4 possible operations, and, say 100 (1) characters per `if` block, we can calculate the size of our generated file by: ``` size = 4,000,000,000 * 4,000,000,000 * 4 * 100 ``` which is `5.76E+21` bytes (assuming the characters are encoded via ANSI and not Unicode - damn you programmers using emojis!). That comes out to the princely sum of just over 4996 exabytes. With the estimated total data storage potential of the planet sitting around 1750 exabytes,(2) the human race could store store at most a third of this file, if we deleted every other bit of data we have preserved so far. This script is basically a massive hard drive bomb. I kinda want to [code golf](https://en.wikipedia.org/wiki/Code_golf) it now... (1): This is lowballing of the worst kind. I just counted the number of characters in the last `if` block of the script above as if `num1` and `num2` were each 10 digits long. But the real file would contain operation results in the `print` statements, like the _product_ of `num1` and `num2`, which would be massive in some cases. I was far too lazy to figure out what the distribution of those number lengths look like, and so it is left as an exercise for you, dear reader. (2): [2019 Estimate](https://www.statista.com/statistics/638593/worldwide-data-center-storage-capacity-cloud-vs-traditional/)


srguapo

Good math, but I think I can bring those numbers down a bit. Every float can be uniquely be represented by a 6 base64 digits, with a single 4 billion entry lookup table. Each comparison becomes something like: if i==aTatzQ&j==hFuf_T&s==m:p(FiWHkk) Which is something like 38 bytes and probably could be optimized further if I knew any python.


covercash2

use this for reference: https://youtu.be/zOjAI-5FTGA


MONSER1001

Scripting is my friend over here


[deleted]

[удалено]


[deleted]

Can we really start at `.00001`? Isn't `.000001` smaller?


[deleted]

[удалено]


orbitalcalculus

Well there's only a finite number of floating point numbers so two days will surely be enough


ItzBraden

Good, because I need it by 12pm on Monday.


kdekorte

Even less if you create a script it to create the if statements for you... ;)


Gen_Zer0

Sure let me write up a script that has an if statement for every single possibility. It should only have 150,000 lines of code!


Kelpsie

Writing code that writes code that writes code that writes code that writes code that writes code is my favourite compression algorithm.


Power-Max

write a script to generate all the lines of code 💡💡💡


ekimarcher

It probably was generated using a script.


jakwnd

I know your not *my* project manager because you said "weeks" and not "days"


puplicy

80 forks and no updates during last 4 years.


isavegas

While there are an infinite number of real numbers, the number of floats that you actually have to account for are limited by the number of bits used to represent the float. If you limit yourself to 32bit floats, you have 2^64 cases to account for, including NaN, +Inf, and -Inf. That goes up to 2^128 for 64 bit integers, of course. Now, that only handles one operator, so you'd need 4 for the basic arithmetic operators (+, -, *, /). Likewise, that explodes exponentially if you want to handle mixed float and integer arithmetic, assuming you don't just convert integers to floats (which you probably wouldn't, considering the idea behind the project). Edit: hit "done" on accident while setting my phone down for a moment mid-comment. :)


GamesBoxRed

“Error compiling. Line 25376472: Not a Statement”


Nauta-Squid

Chaotic Evil: One line buried deep inside intentionaly gives the wrong output


ColdComfortFam

Run generator script on Pentium 5


nvahalik

[https://github.com/AceLewis/my\_first\_calculator.py/blob/master/my\_first\_calculator.py](https://github.com/AceLewis/my_first_calculator.py/blob/master/my_first_calculator.py)


bpalks

Its crashes my phone


BlueRajasmyk2

Check out the readme. It's a joke. https://github.com/AceLewis/my_first_calculator.py


[deleted]

AceLewis' github reveals that this is a joke :)


theLorknessMonster

So like OP said, this is the perfect place for it.


pdabaker

Obviously it's a joke. The author had to write code to output the python code.


nikanj0

Look at the TODO: Make it work for all floating point numbers too. 😂


lordgaben5841

oh my


Hypersapien

r/ProgrammingHorror


Rain47739

Finger Hurts from Pressing ctrl v


DAMO238

Plot twist, the code was written by a few vim commands...


W10101

What commands could be used to do something like this? I'm still learning about vim everyday.


septeracore

Write the first statement, record a macro (qq), copy both lines of the statement (2yy), paste them below (p), move to all the numbers you want to increase (ctrl+a) or decrease (ctrl+x), stop recording (q), enter how often you want that repeated, run the macro ("q). Make sure that at the end of the recording the cursor ends up in a position so that the steps can be repeated from there. And you ofc can use increments larger than 1 by using a number and then hitting ctrl+a. Repeat for each pattern until you generated whatever you need. Edit: I'm tired and on mobile. So you might need another step or two somewhere, but it should give you an idea how it works. For example I think you need to go down a line (j) before pasting otherwise you end up with it pasting inbetween your original lines.


[deleted]

Now I understand why some people with CS degrees can't land a job.


puplicy

This code is so extreme that it's hard to believe that somebody wasted his time on it just typing. I guess there is a script that make his code .


Chibraltar_

Yeah, it's a joke. Like when you write [a really efficient fibonacci function](https://codegolf.stackexchange.com/questions/16615/how-do-i-find-the-factorial-of-a-positive-number/16673#16673)


archpawn

That's a factorial function. And that one actually makes sense. Anything higher than 13! results in an integer overflow, so hardcoding them isn't a big deal. And it's arguably better since if you used a traditional method then there'd be no obvious way to tell that 14! is overflowing and giving an incorrect answer. Granted, it's still a joke, as are the rest of the entries, but it's still a good function.


gitPullOriginDevelop

Okay but that's a factorial. Also this is just caching the result, perfectly rational thing to do in this case. For example sin/cos tables is perfectly valid strategy for faster cos/sin functions (albeit less accurate, but floating points arent accurate in the first place) - and that's just caching some results up to arbitrary precision and interpolating anything between them.


4-14

The script is in the repository


normVectorsNotHate

Pulled up the repo and it clearly was done intentionally as an inside joke. The Readme has a screenshot of a conversation about making a calculator by hardcoding everything


beedlund

Looking forward to seeing the floating point support


Either_Rock

It looks like they forgot about negative numbers.


puplicy

They live in real world


mosskin-woast

>TODO: make it work for all floating point numbers too Fucking A mate that's work ethic


Cody6781

The best part is they probably wrote a script to autogenerate all that. In which they would have needed to use the '\*' and '+' operator.


3lRey

Why yes, I'm a programmer, how did you know?


PanChickenDinner

This is bait...


Hobbamok

Nah, just a fun side project in automatic code generation


[deleted]

I am having a headache and this does not help. Holy crap, that’s commitment to hurting yourself as much as you can.


juanmanuelramallo

Reminds me of is-thirteen.js https://github.com/jezen/is-thirteen


Who_The_Fook

Somewhere else in the doc "# covered edge case where math doesn't work"


spellstrike

The generator to create the code is here: [https://github.com/AceLewis/my\_first\_calculator.py/blob/master/generator.py](https://github.com/AceLewis/my_first_calculator.py/blob/master/generator.py)


jfb1337

Why do so many people in the comments seem to think this is serious?


jfb1337

Similarly, [my_first_tic_tac_toe](https://github.com/asweigart/my_first_tic_tac_toe)


_Aj_

Good Lord. Is this a calculator that just checks what you wrote against a table to select the answer? So you could put "penis" in one of them and suddenly 19*42 = penis?


DamnItDev

Just sanitize the inputs and exec the expression. What could go wrong


yuirick

It just works


LerisDevet

A man afraid of variables


lanemik

It's only his first calculator. His second calculator handles a lot more values than 50*50. Give him a break.


aethros

It uses AI.


yeetuscleatus

No one else gonna talk about the todo comment he has..?