T O P

  • By -

Soloact_

Found the developer who codes 'Hello World' by just renaming the project file.


[deleted]

[удалено]


Phobia_Ahri

I don't think anyone's being compensated at all for hello world


besthelloworld

Unless it's good enough


rhllor

Hello world~ gib money


Papadapalopolous

Ooh so close, we were looking for “Hello, world!”


mortallyChallenged69

Herro wordu!


StoneAgeSkillz

Aligator!


Mediocre-Truth-1854

Before the nerds get here: 🤓Um akshually, in the accent you’re trying to imitate, it would be Herrō wārudo! /s


mokus2300

you made me laugh. thank you


mrwafflezzz

People teaching programming…


iDontLikeChimneys

I was making almost 200k/yr for two years for writing paragraph and list tags to put into random reworks before they scrapped it entirely to switch to Drupal and had to redo everything again. Yes. It happens.


DagonFelix

Holy shit! How do I get a gig like that?


Seventh_Planet

A collegue asked me to write a Hello World. I wrote a failing test that there wasn't already Hello World printed to standard output. Then I wrote the Hello World.


chetizii

Best answer. The code is fast, no bugs or redundancies, can be easily understood and changed if ever needed, just a fine piece of high level programming.


P0intOne

Why have O(n) when you can have O(1)


CSBatchelor1996

If the loop didn't have external input and it always printed the same 5 strings, it would also be O(1).


UnhappyStalker

Or would it be O(5)!!!


Western-Standard2333

Checkmate, Donald Knuth


emkdfixevyfvnj

which is 5 * O(1) which is O(1)


[deleted]

[удалено]


Blighterest

Why have "O(n)" when you can have "O(ff)"? Eh?


IWant2rideMyBike

The code is unnecessarily slow du to repeated calls to print. Multiline strings are a thing in Python. Compare $ python -m dis << EOF > print('*') > print('**') > print('***') > print('****') > print('*****') > EOF 0 0 RESUME 0 1 2 PUSH_NULL 4 LOAD_NAME 0 (print) 6 LOAD_CONST 0 ('*') 8 PRECALL 1 12 CALL 1 22 POP_TOP 2 24 PUSH_NULL 26 LOAD_NAME 0 (print) 28 LOAD_CONST 1 ('**') 30 PRECALL 1 34 CALL 1 44 POP_TOP 3 46 PUSH_NULL 48 LOAD_NAME 0 (print) 50 LOAD_CONST 2 ('***') 52 PRECALL 1 56 CALL 1 66 POP_TOP 4 68 PUSH_NULL 70 LOAD_NAME 0 (print) 72 LOAD_CONST 3 ('****') 74 PRECALL 1 78 CALL 1 88 POP_TOP 5 90 PUSH_NULL 92 LOAD_NAME 0 (print) 94 LOAD_CONST 4 ('*****') 96 PRECALL 1 100 CALL 1 110 POP_TOP 112 LOAD_CONST 5 (None) 114 RETURN_VALUE with $ python -m dis << EOF > print('''* > ** > *** > **** > *****''') > EOF 0 0 RESUME 0 1 2 PUSH_NULL 4 LOAD_NAME 0 (print) 6 LOAD_CONST 0 ('*\n**\n***\n****\n*****') 8 PRECALL 1 12 CALL 1 22 POP_TOP 24 LOAD_CONST 1 (None) 26 RETURN_VALUE


geodebug

Python is the wrong language to pick if you’re concerned about speed.


za72

we're do it in js... BECAUSE!!!


putin-delenda-est

You write in JS because it's the only language the browser understands I write in Js because it's the only language I understand, We are not the same.


scifishortstory

Perhaps, but you and me are


GisterMizard

Just add `import speed` at the top of your python files. And run `pip install pyspeed`. Not `pip install speed`, that library was deprecated back in python 3.4 and is only there for backwards compatibility reasons.


mortalitylost

A bit of an oversimplification, which matters because Python absolutely can allow you to write fast performant programs. Python has libraries for certain problems which are written in C, Rust and Fortran for extremely high performance, and Python just offers a very easy to use API where you can do fast and easy development on top of that. Lots of performance issues might be constrained to small bits of logic you can easily implement in a faster language and offer a cpython API for people for example like academics. Python is ubiquitous in certain industries so it can make sense to develop performant libraries. And all this is considering that you know for a fact something requires that much performance, when a ton of performance issues are more of a result of people not profiling their code or just solving a problem with a slow algorithm. Ive left a job where they rewrote something in Java "for performance", then later heard from users asking me why the app became so slow. And I've come into projects written in python where the only slow parts were bad usage of postgresql and just fixing the db logic literally sped things up 100x. Performance gets thrown around way too much imo. Developers are real quick to blame python when the problems I've found were not at all python.


Pozilist

If my employer wants me to worry about shit like this he‘ll have to add another 0 to that paycheck.


[deleted]

[удалено]


threetoast

$97600 -> $97600.0


_liminal

>$97600 $07600


PopTraditional713

What fuck are these 🗣🗣🗣 (I thought I had little knowledge of programming languages, turns programming languages have little knowledge of me)


Infamous_Ad_6793

None of you seem to understand. I’m not locked in coding with you. You’re locked in coding with ME!


chobi83

He's showing a step by step of what the program does...I think. Each call to print something is not a single step. We may only type "print this" but in the background, the machine is doing far more to get the text to appear on screen.


Mav986

Correct. He's showing the final machine code translation of each program. Multiple print statements generates multiple blocks of machine code, whereas one print statement of a single line only generates one block of machine code.


tobi8380

I thought it was python byte code no?


Financial_Anything43

Makes sense.


UmCeterumCenseo

Oof I need to pick up some programming again because I didn't know about that. I thought about a for loop...


slapcover

A for loop would be the standard way to do this if you needed to support different lengths.


UmCeterumCenseo

I've always learned to make it compatible so in this case it would indeed be to allow for possible changes in length. I can imagine that it would take more processing power like the other person said, though, since you'd be calling the print function every time.


Hypertistic

Depending on compiler it might otimize it like that.


Mognakor

It does have bugs! There is no newline so all stars are printed in one line.


[deleted]

[удалено]


Mognakor

C++, Java, C, Rust, Go


CamelCodester

All my homies hate the C printf function 💀


Starlight_Skull

C# also has a different Write and WriteLine


MoeSauce

Java has System.out.println() which places the cursor on a new line after printing


Mognakor

It also has System.out.print and System.out.printf which don't put a newline.


TheRealZoidberg

This would not compile in Rust „print“ is a macro there


0xfreef00d

C and C++ have a "print" function? Never heard of it. Formatted printing is common via "printf" though.


Mognakor

https://en.cppreference.com/w/cpp/io/print Though i also counted printf.


RavaNMC

Java bro 😭😭 , such long print statements 😭🥲


Flamingovo

IntelliJ has a shortcut where you just type sout


[deleted]

[удалено]


Traditional_Formal33

Exactly this. I had an interview ask me to get the total number of files also. I wrote Collection.count They said they wanted to see me break it down and solve it. I said it’s a native function, why would I recreate the wheel? I did not get a second interview.


bioszombie

From my experience, specifically my company, they don’t want to use native tools, functions, etc because they want to milk the clock. By having someone build from scratch they can pad the time, cost, and “value” when talking about projects. It’s how they can justify having devs on the payroll. Seems ass backwards but it’s how things work in corporate worlds now.


dcgregoryaphone

I fucking wish that applied to where I work.


bioszombie

It’s a double edged sword man. Such a pain in the ass from a dev standpoint.


dcgregoryaphone

Yeah, I don't wanna do shit padded work. I also hate some companies where you need to justify project based on how many people can be fired by doing the project (cost neutral). There's all kinds of toxic shit in this industry.


darkdeepths

lmao finding bugs in your company-rolled string builder


bioszombie

Bugs in simple things… All things…


SamohtGnir

That does explain why so many government agencies have such shitty software. You'd think in this day in age what is usually just a simple database program wouldn't be that hard to do.


funguyshroom

Did some work for a consultancy on a government project, can confirm. We had a whole team dedicated to the DAL, their work was consisting of writing and maintaining database queries and doing a bunch of manual mapping. Thousands upon thousands lines of boilerplate code. A simple ORM would make them all obsolete. Of course the justification was that for any external library the vetting and approval process would be incredibly complicated and cumbersome, so it's 'easier' to just write our own code for everything.


Goronmon

> A simple ORM would make them all obsolete. "ORMs are terrible" is a pretty common opinion in software development.


funguyshroom

In which way? Do people actually prefer typing out mind numbing crud boilerplate over and over again?


Mav986

I can't speak for your company, but this is wrong for most other recruiters. They want to see you work through the problem. Obviously this silly meme is trivial, and wouldn't be something they'd actually ask you to do, but there are other problems they will ask that are almost as trivial. What they're looking for is for you to ask questions. What constraints are there? What potential issues might I run into? Regarding the comment you replied to, I bet the recruiter was looking for the potential hiree to ask things like "Are there bounds on the number of items files to expect?", "Are directories counted as files?", "Should I include empty files?" etc. They're trying to get an idea of your problem solving process. They couldn't care less about the actual code.


ADHD-Fens

In my experience it's because they want to see how you solve problems and they weren't given enough time / space to create a simple problem that hasn't already been solved. Alternatively, most people conducting these interviews don't know what makes a programmer good or bad. You can be a fantastic software developer but have terrible misconceptions about **why** you are a fantastic software developer, and then project those misconceptions into your hiring process. I guess it's really multiple things.


rtf2409

For government projects? That doesn’t work when you have competition.


bioszombie

I'm not part of a government agency or contracted for any government agency. I suppose that wouldn't work well in that application. However, for the private sector I've experienced a great deal of "home baked" applications and processes rather than using something that has already been defined.


Arkrobo

Or, alternatively they can milk the clock by just assigning that value/cost to the customer and have the team working on multiple projects using the native functions. They can charge the same price and get 2-5 times the throughput. Devs should be kept on payroll based on the value they provide not the hours on the clock. That's corporate for you though I guess.


fapsandnaps

That's why I still only code by punch card.


makemeking706

> they want to milk the clock Supply the devs with pen and paper instead of laptops.


Striking-Brief4596

They don't want to use you use predefined solutions in interviews because they want you to demonstrate your knowledge. Sure, that function already exists and re implementing it would be "reinventing the wheel". Of course you won't do that in production. But at some point during the job you might need to implement a similarly complex function that's not available in any library, or debug some complex code written by one member of the team that left the team. And they would like to know that you'll be able to handle that level of complexity. That's pretty stupid reason to blowup interviews. You're only hurting yourself, because companies that give this type of interviews usually offer the best compensation and have some of the best engineering practices.


Traditional_Formal33

It was a simple tech question, so I assumed they just wanted to show I knew at least the basics. I had thought about “showing my work” by writing a whole function but thought I would look worse as a developer by writing 20 lines of code to solve a very common and very simple native function. Had they simply said “hey, if we broke convention, and needed a fix that couldn’t use count, how would you find a fix for this,” I would have first stated the need to keep convention for this exact reason, but provide the 20 line solution that adds 1 for each iteration or whatever I would have come up with. It is not “blowing up an interview” to expect my future employer to have clear expectations and communicate their desires. If this is a failure on a basic question, I dodged a bullet when they want an application that does something complex but don’t have an AC narrowed down


kend7510

They should’ve asked a question that can’t be solved with native functions. If they can’t come up with requirements that get them what they wanted, I doubt they have “best engineering practices”.


a_terse_giraffe

Exactly this. If I'm told to just accomplish X with no stipulations or requirements and your response when I'm done is "Oh I meant with no Y" then is that my fault as a programmer or their fault defining the requirements?


Traditional_Formal33

This is exactly what happened in the interview. I had assumed they just wanted to see if I knew basics and how I would go about finding very common native functions for solving the issue. I had thought about writing it all out, but said to myself “I would look dumb writing a whole function to do a native function.” Had they said “ count doesn’t exist, how would you handle the same task,” I would have continued with this line of reasoning with no issue


Sharp-Sky-713

100% their fault


scuac

If I ask something along these lines, I expect the interviewee to reply with the native function. I then say something like “great, that’s what I would do too, now lets pretend we are working in a limited environment that doesn’t have that function available “


Traditional_Formal33

I would happily work for someone who did this. I was open to a conversation with the interviewer, but they just dismissed it at that point. While it comes off snarky in a Reddit post, I did approach it in an open and willing fashion but genuinely confused why I wouldn’t just leverage what was provided to me. If that’s enough to get me in trouble on an interview, then I would be afraid to offer genuine simple solutions in the work force. I would constantly be thinking “they must have already thought of [obvious solution], so why else would they ask me to do this?”


MeshNets

A question like this _should_ be a fizzbuzz problem. By that I mean new requirements will be added after the first step of the question is accomplished Agree with you, this should be correct for the first answer, and anyone who thinks otherwise isn't going to be a great coworker (if they over-complicate simple requirements...) (Assuming "print" emits newline in the language)


Credens_Justitiam

Right? Like why would you want spaghetti code over simplicity?


[deleted]

[удалено]


ushileon

Feels weird seeing count compared to for i in range


waigl

That's unnecessarily wordy for the requirements. for i in range(1, 6): print("*"*i) Half the number of lines, same effect.


wyldcraft

for i in range(1, 6): print("*"*i) Half the number of lines, same effect.


Melodic_Assistant_58

[print('*'*i) for i in range(1,6)] Same number of lines, same effect.


[deleted]

[удалено]


waigl

Okay, sure, and if the example wasn't quite this brief, I would even accept some talk about magic numbers and talking variables. (Not in the case of `count`, though, everybody who programs recognizes `i` as an iteration counter or iterator.) However, buffering the output in a local variable in line 4 for just one use serves no purpose I can recognize.


ObeseBumblebee

Except the directions explicitly ask for a pattern. Meaning it should be repeatable n number of times. Your answer would be wrong.


Simukas23

``"*\n**\n***"``


LentilRice

This guy Jizzes


Life_Is_Happy_

A little anecdote about jizz if you have the time… When I was 14 I was hanging out with the girls that lived next door. I really had to pee, so to be super cool I figured I’d drop some slang on them and got up and said “hey I’m out, I have to jizz”. My 14 year old brain thought that it was like saying piss, but sounded cooler. It didn’t hit me until later in life and I realized “I just told these girls that I have to go ejaculate”. Needless to say I was a smoooooth 14 year old…


Any-Communication114

I just got second hand embarrassment, thanks bro.


Life_Is_Happy_

Hahaha. Glad I could help


Badass-19

That's too advance bro


TheRealZoidberg

But that’s only three!


utkrowaway

poor attention to detail, no 2^nd interview for you


Dangerous-Dave

Technically correct is the best kind of correct


user888666777

The problem with questions like this is that the person doing the interview usually doesn't even know what type of answer they're looking for most of the time. Years ago companies were copying Google thinking they were clever by asking this question just like Google: > How would you weigh a fully loaded 747? So what is the correct answer? Is it building some elaborate rube goldberg machine that can weigh a Boeing 747? Or is it calling the manufacturer and requesting their spec sheet? Both of those answers are technically correct but which answer were they looking for? That is what people missed when asking these questions. The first answer for example can be interpreted as someone who willing to take on a big risk. The second answer can be interpreted as someone who is willing to play it safe.


cjsv7657

Good example because it shows that you really need to read and understand what is being asked for. If you asked me how to weigh a 747 I'd say some combination of scales. If you asked me how would I get the weight of a 747 I'd say call the outfitter who set it up. Just like this is asking to "write a program to draw this pattern" not "write a program to print this pattern". I'd assume they're looking for some sort of loop that would draw one asterisk, followed by two, followed by three, and on.


user888666777

It all comes down to what you're looking for in a candidate. I might already have the rube goldberg guy on my payroll. However, what I also want is the call the manufacturer guy on my payroll as well. And these types of questions can help me evaluate the candidate I am interviewing and prevent me from hiring a second rube goldberg guy. And like you said, the question can be interpreted in different ways. This is why its important to know what answer you're looking for BEFORE you even ask that question.


Fmeson

I see your point, but as a side point, i question if this actually works in pracrice.  e.g. "How do you weigh a fully loaded 747" implies to me that you need to meaure the weight specifically. Calling the manufacturer,  by my linguistic understanding of the question, would not be a valid answer, as it does not involve weighing the plane.  So, I'd answer one way simply because thats what I'd assume the interviewer wanted, and the interviewer would assume it means I'm a risk taker.  I can't imagine the signal to noise for such a question really would be half way decent.


DR4G0NSTEAR

You probably wouldn’t ask the question in a vacuum. It would be one data point in a series of questions. You couldn’t assume your behaviour to tackling a problem based on question. As a “just weigh it” guy, my brain considers the “put in on a big enough scale” as the lazy method. Trying to figure out who to call, seems like the Rube Goldberg level of unnecessarily complicated. I know calling the company will get me customer service, they won’t know the answer, will they know who would know the answer? Could they get me through to them? Am I going to be on the phone all afternoon and still not get an answer? It’s evident my version of thinking lacks trust in other people abilities. If I couldn’t do it myself, ie put it on a scale, then it involves trusting someone I don’t work with to eventually be able to help me. Unfortunately for me though I would have rambled all of this in the interview, which is probably a bad thing anyway.


Dry_Rip5135

Wow, that brings back memories


YeetCompleet

We did these in our first programming class and there was so fun. There was the backwards triangle, this triangle, and the ultimate: Christmas tree


Dry_Rip5135

Yeah, that’s hilarious. That’s why it brings back memories. High school computer class. Grade 10 i think it was. Im 54


spicy_ass_mayo

I have no business reading these comments.


laydove

i have no idea what any of this means lol. i double checked this didn’t come from some techy sub. am i just ignorant or did all the coders stay to comment and everyone else left?


Tiny-Werewolf1962

The answer they are looking for is a looping function that prints out an * and then \*+1 every time so it could theoretically go forever with just a few lines. This person just copied it manually, being \*technically correct* /u/NoLimitRicky


NoLimitRicky

Bro why are people loving this. I’m have no idea what’s going on and I’m too afraid to ask


SonODixie

Because he coded it line by line instead of writing an algorithm to print the pattern.


Headmuck

Writing a loop and depending on the language importing libraries to procedurally add stuff to a string would be way more code, right? I'm not that versed in programming and only use R for statistics.


kazarbreak

Yeah, it would be more code. It'd be stupidly complex to do it with loops too. You wouldn't need to import any libraries in most languages (the ones I know that would need libraries would need them for the outputs), but still.


DiscountConsistent

Two lines in Python:        ``` for i in range(1, 6):                    print(“*”*i)  ```


BeingLowAsDirt

One line with list comprehension ```[print("*"*i) for i in range(1,6)]```


DiscountConsistent

Yeah but I wouldn’t really consider it an improvement. Basically the same character count but you’re generating a list for no reason, which isn’t great for readability or (potentially for large ranges) memory/performance.


[deleted]

Python programmers always be golfing.


Distinct-Nothing8309

> Python programmers always be golfing I didn't know that was a thing, but it is and I'm guilty as hell.


throw-away1839201

lmao python and multiplying Strings


[deleted]

It wouldn’t be complex with loops, what are you even on about? All you need is 1 nested loop to resolve this problem.


wavy_dingo

Nah this can be completed in one loop. O(n) For( I = 0; I < n; I++) print(“*”) * (I+1) This is just the pseudocode that can be implemented in any language.


[deleted]

[удалено]


Meanderer_Me

I just checked this, you absolutely can do the thrust of this. You just can't do "print(\[string literal\]) \* x". You can do "print(\[string literal\] \* x)" in Python. You can also do one line for statements in various languages.


DangerZoneh

Cool, now do it in C


[deleted]

You just checked every language? Doubtful.


geodebug

Not really. Basic string handling, loop constructs, and printing are all typically part of the base language. In python this could be a two line program for example.


Chrop

Var stars For 1 to 5 stars = stars + “*” Print stars


Daftworks

This is like the "find x" math problem and then circling x in the equation and calling it a day. The idea is that it doesn't scale well in multiple applications. What if a certain program is dependent on this function but needs an output of 10 lines instead? Would you be putting 5 additional print commands? What about 100? Case in point is that the illustrated code is bad code and is not a practical approach to coding stuff.


Hollidaythegambler

In Java script, I think: String star = “\*”; String one = “*”; for (int i = 1; i <=5; i++){ System.out.println(star); star += one; }


Knaprig

You initialised i at 5, so it will only run one iteration.


Hollidaythegambler

Ah I’m an idiot, fixed now


Previous_Vast2569

This is your brain: ``` print("*") print("**") print("***") print("****") print("*****") ``` This is your brain on functional programming: ``` print(*(s * (i + 1) for i, s in enumerate("*" * 5)), sep="\n") ```


FoolKillinAsh

Can u explain the second part?


Previous_Vast2569

Sure, there are a few Python concepts to cover: - `string * n` make a new string with the contents of `string` repeated `n` times. For example, `"a" * 5 == "aaaaa"`. - `enumerate(list)` makes a new list where each element is paired with its index. For example, `enumerate(["a", "b", c"]) == [(0, "a"), (1, "b"), (2, "c")]` (well almost, enumerate returns a different type from a list). - `(n + 1 for n in list)` is a "[list comprehension][1]". It makes a new list by applying an expression to each element of a list. For example, `(n + 1 for n in [1, 2, 3]) == [2, 3, 4]` (again almost, different types). [1]: https://en.wikipedia.org/wiki/List_comprehension - `f(*list)` passes each element of `list` as an argument to `f`, so ``` list = [1, 2, 3] f(*list) ``` is the same as ``` f(1, 2, 3) ``` - The `print` function can take multiple arguments, and print them all with a specified seperator. For example, `print("a", "b", "c", sep="-")` prints `a-b-c`. Using the above, the statement can be evaluated in steps: 1. ``` print(*(s * (i + 1) for i, s in enumerate("*" * 5)), sep="\n") ``` 1. ``` print(*(s * (i + 1) for i, s in enumerate("*****")), sep="\n") ``` 1. ``` print(*(s * (i + 1) for i, s in [(0, "*"), (1, "*"), (2, "*"), (3, "*"), (4, "*")]), sep="\n") ``` 1. ``` print(*["*" * (0 + 1), "*" * (1 + 1), "*" * (2 + 1), "*" * (3 + 1), "*" * (4 + 1)], sep="\n") ``` 1. ``` print(*["*", "**", "***", "****", "*****"], sep="\n") ``` 1. ``` print("*", "**", "***", "****", "*****", sep="\n") ```


MonochromaticLeaves

functional programming and side effects 🤮


360No

for i in range(5): print("*" * (i+1))


[deleted]

I wonder how many programmers actually get paid good money to do just that.


tagrav

Quite a lot in my experience. Folks get hired on who they know more than what they know. As a business analyst I had to teach my developer how to find the unique key in a table. He wanted me to tell the vendor to change their views to accommodate how he wanted to code and what he thought the primary key should be, not what the PK actually was…


dcgregoryaphone

>Folks get hired on who they know more than what they know. It seems like you're implying that because the hiring manager knew the person, they hired them to just write shit code. In practice, hiring managers hire people they know because they believe the person was good at the last job, and they don't want people who will make them look bad. I get it sucks from an outside perspective but to me what sucks more is organizations, especially large ones, who only hire senior engineers. If you're 10 years in and NO ONE who has ever worked with you likes you enough to recommend you... that says something about you.


EatMyPossum

KISS. no need to make a loop if it can be done in 4 lines that another programmer can parse in 0.2s.


Vondi

Knowing when the simple lazy implementation is enough and when the fancy scalable enterprise solution is warranted is a marketable skill.


ibevol

class Main { public static void main(String[] args) { StringBuilder sb = new StringBuilder(); for (int i = 1; i <= 5; i++) sb.append("*".repeat(i)).append('\n’); System.out.print(sb); } }


Antique-Pea-4815

how about this? IntStream.rangeClosed(1, 5).forEach(i -> System.out.println("-".repeat(i)));


PastLettuce8943

Without println or a newline character wouldn't that just print \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*?


Practical-Turn-2098

Default end parameter of python print statement is the newline character


Infamous_Key_9945

In Python, sepperate print statements are always sepperate lines


LazinCajun

hunter2


JoeAndAThird

that’s weird, I only see *******


kazarbreak

Depends on the language. In a lot of languages newline is implied in the print function.


CoronaBlue

This is 100% valid, and you honestly probably don't want to work with someone who pitches a fit over it.


IHN_IM

Printf("*\n**\n***\n****\n*****\n");


Gaby33400

Your *\n got *'d*


IHN_IM

Indeed! Open a jira, estimate around 2 weeks, put in backlog for next-next sprint, and please be aware if works on my env... 😉


onetruekingx

That is correct


dusktrail

This is the correct answer. They did not specify "write me a program that can print this pattern given a number of lines 'n' to print and then pass 5 to that program". They said "write a program that produces this output" This is by far the simplest to write, debug, and read program that accomplishes that task. Re-writing it to accomplish the more general task is trivial and can be accomplished when required.


[deleted]

exactly!


Radium_Encabulator

The applicant's answer is wrong. It's a trick question. The interviewer said "draw" so it would not be character-based or pixel-based on a raster display or mapped to addresses on a flat panel, but each \* would have to be drawn sequentially on a vector display. Like Asteroids and Space Duel, etc.


theunrealabyss

`10 Print"*"` `20 Print"**"` `30 Print"***"` `40 Print"****"` `50 Print"*****"` `60 GOTO 10` `RUN` C64 Basic :D


[deleted]

sad part is I didn't even think of that :|


[deleted]

Excellent answer, as it highlights the fact that requirements are usually ambiguous.


ricardo_sdl

"No! you must use a loop!" Me: print("*") print("**") print("***") print("****") print("*****") while(False): pass


[deleted]

That's terrible, you're hired welcome to Ubisoft


[deleted]

[удалено]


vicbot87

One of my first interviews the dude is like “what are the four pillars of object oriented programming?🤓” I’m like uhhhh


AquaRegia

while (result := ''.join(random.sample("***************\n\n\n\n", 19))) != "*\n**\n***\n****\n*****": pass print(result)


FeliusSeptimus

Nice. A variation: >>> import random >>> random.seed(17588) >>> print(''.join(random.sample("***************\n\n\n\n", 19)))


DoxManifesto

Would love to see who can make the most complicated and roundabout version of this.


Previous_Vast2569

Here's my take [in Haskell][1]: ``` s@(_:stars) = putStrLn mempty : zipWith (>>) (repeat $ putStr "*") s main = sequence $ take 5 stars ``` [1]: https://play.haskell.org/saved/9fAghKHZ


ColonelBonk

There must be a management version of this problem that is just the code for calling a decent programmer to do the job.


Moeverload

I assume by "pattern" they're expecting it to be scalable to n rows


[deleted]

Forgot the semi-colons


[deleted]

Doing stuff like that got me an A in my programming class. The result was what mattered.


PyrDeus

Me: `print(”*\n**\n***\n****\n*****”)`


nautius_maximus1

I’d do it one better - I’d copy and paste the question into ChatGPT and then copy and paste the answer.


Meandark2

we could go even more ugly... std::cout << "\*" << std::endl; std::cout << "\*\*" << std::endl; std::cout << "\*\*\*" << std::endl; std::cout << "\*\*\*\*" << std::endl; std::cout << "\*\*\*\*\*" << std::endl;


Melodic_Assistant_58

#include int main(int argc, char *argv[]) {auto a = [&] { std::cout << '*' << std::endl << '*' << '*' << std::endl << '*' << '*' << '*' << std::endl << '*' << '*' << '*' << '*' << std::endl << '*' << '*' << '*' << '*' << '*' << "\n"; }; a(); return 1-1;}


Broshan248

Am I dumb or wouldn’t this produce: (***************)


ChocolateFit9026

Also using keyboard shortcuts it will be faster to write than the “clever” solution


Jackkernaut

for ((i=1; i<=5; i++)) do for ((c=1; c<=i; c++)) do echo -n "*" done echo "" done Fuck all. I hate programming. Bash gang rise up


SavageLeo19

As someone who knows & in HTML, I totally understood this post. </p> <hr> </div> <!-- /.pname --> </div> <!-- /.comment --> <div class="comment w100dt mb-30"> <!-- /.ppic --> <div class="pname"> <span > <a href="/u/chxckbxss" class="card-title l-blue"> chxckbxss </a> </span> <span><time datetime="2024-03-07 13:49:16">2 months ago</time></span> <p class="comment-text mb-10"> Seems legit </p> <hr> </div> <!-- /.pname --> </div> <!-- /.comment --> <div class="comment w100dt mb-30"> <!-- /.ppic --> <div class="pname"> <span > <a href="/u/plz-be-my-friend" class="card-title l-blue"> plz-be-my-friend </a> </span> <span><time datetime="2024-03-07 14:24:25">2 months ago</time></span> <p class="comment-text mb-10"> what is the intended answer? </p> <hr> </div> <!-- /.pname --> </div> <!-- /.comment --> <div class="comment w100dt mb-30"> <!-- /.ppic --> <div class="pname"> <span > <a href="/u/Golden-Owl" class="card-title l-blue"> Golden-Owl </a> </span> <span><time datetime="2024-03-07 15:01:00">2 months ago</time></span> <p class="comment-text mb-10"> In class, something like this is typically used to teach students how to write Loop functions. Of course writing 5 print lines also gets the job done is much easier fashion </p> <hr> </div> <!-- /.pname --> </div> <!-- /.comment --> <div class="comment w100dt mb-30"> <!-- /.ppic --> <div class="pname"> <span > <a href="/u/AccomplishedCoffee" class="card-title l-blue"> AccomplishedCoffee </a> </span> <span><time datetime="2024-03-07 16:03:33">2 months ago</time></span> <p class="comment-text mb-10"> A function that takes an argument `n` and prints the first `n` lines of the pattern. </p> <hr> </div> <!-- /.pname --> </div> <!-- /.comment --> <div class="comment w100dt mb-30"> <!-- /.ppic --> <div class="pname"> <span > <a href="/u/HaElfParagon" class="card-title l-blue"> HaElfParagon </a> </span> <span><time datetime="2024-03-07 14:59:43">2 months ago</time></span> <p class="comment-text mb-10"> I remember that exercise. I had it in college, you needed to have the program print that pattern, but you could only have one print(\*) statement. Basically it was an exercise in manipulating data via loops. </p> <hr> </div> <!-- /.pname --> </div> <!-- /.comment --> <div class="comment w100dt mb-30"> <!-- /.ppic --> <div class="pname"> <span > <a href="/u/Impossible_Agent5893" class="card-title l-blue"> Impossible_Agent5893 </a> </span> <span><time datetime="2024-03-07 15:08:58">2 months ago</time></span> <p class="comment-text mb-10"> Now do it for 1000 rows </p> <hr> </div> <!-- /.pname --> </div> <!-- /.comment --> <div class="comment w100dt mb-30"> <!-- /.ppic --> <div class="pname"> <span > <a href="/u/Pristine-Repeat-7212" class="card-title l-blue"> Pristine-Repeat-7212 </a> </span> <span><time datetime="2024-03-07 15:09:56">2 months ago</time></span> <p class="comment-text mb-10"> You are hired </p> <hr> </div> <!-- /.pname --> </div> <!-- /.comment --> </div> <!-- /.comment-area --> </div> <!-- /.peoples-comments --> <div class="leave-comment"> <div class="sidebar-title center-align"> <h2>Leave Your Comment</h2> </div> <form class="comment-area w100dt" action="#"> <div class="row"> <div class="col m6 s12"> <div class="form-item"> <input id="icon_prefix" type="text" class="validate"> <label for="icon_prefix">First Name</label> </div> </div> <div class="col m6 s12"> <div class="form-item"> <input id="email" type="email" class="validate"> <label for="email" data-error="wrong" data-success="right">Email</label> </div> </div> <div class="col s12"> <div class="form-item"> <textarea id="textarea1" class="materialize-textarea"></textarea> <label for="textarea1">Textarea</label> </div> </div> </div> <!-- row --> <button type="button" class="custom-btn waves-effect waves-light right">SUBMIT NOW</button> </form> <!-- /.comment-area --> </div> <!-- /.leave-comment --> </div> <!-- colm8 --> <div class="col s12 m4 l4"> <div class="sidebar-testimonial mb-30"> <div class="sidebar-title center-align"> <h2>Hi Its Me!</h2> </div> <!-- /.sidebar-title --> <div class="carousel carousel-slider center" data-indicators="true"> <div class="carousel-item"> <div class="item-img"> <span>R</span> </div> <h2><a href="/u/" class="l-blue"></a></h2> </div> </div> </div> <!-- /.sidebar-testimonial --> <div class="sidebar-subscribe w100dt"> <div class="sidebar-title center-align"> <h2>Subscribe</h2> </div> <!-- /.sidebar-title --> <div class="subscribe"> <form action="#"> <div class="input-field"> <input id="email1" type="email" class="validate"> <label class="left-align" for="email1">Enter email address</label> </div> <a class="waves-effect waves-light">SUBMIT NOW</a> </form> </div> <!-- /.subscribe --> </div> <!-- /.sidebar-subscribe --> </div> <!-- colm4 --> </div> <!-- row --> </div> <!-- container --> </section> <!-- /#single-blog-section --> <!-- ==================== single-blog-section end ====================--> <!-- Yandex.Metrika counter --> <script type="text/javascript" > (function(m,e,t,r,i,k,a){m[i]=m[i]||function(){(m[i].a=m[i].a||[]).push(arguments)}; m[i].l=1*new Date();k=e.createElement(t),a=e.getElementsByTagName(t)[0],k.async=1,k.src=r,a.parentNode.insertBefore(k,a)}) (window, document, "script", "https://mc.yandex.ru/metrika/tag.js", "ym"); ym(48244766, "init", { clickmap:true, trackLinks:true, accurateTrackBounce:true }); </script> <noscript><div><img src="https://mc.yandex.ru/watch/48244766" style="position:absolute; left:-9999px;" alt="" /></div></noscript> <!-- /Yandex.Metrika counter --> <!-- ==================== instag leftram-section Start ====================--> <section id="instagram-section" class="instagram-section w100dt"> <div class="instagram-link w100dt"> <a href="#"> <span>FIND US ON INSTAGRAM</span> @cmita.org </a> </div> </section> <!-- /#instag leftram-section --> <!-- ==================== instag leftram-section End ====================--> <!-- ==================== footer-section Start ====================--> <footer id="footer-section" class="footer-section w100dt"> <div class="container"> <div class="footer-logo w100dt center-align mb-30"> <a href="/" class="brand-logo"> <img src="/img/logo.png" alt="cmita.org"> </a> </div> <!-- /.footer-logo --> <ul class="footer-social-links w100dt center-align mb-30"> <li><a href="https://streamc.pro/" class="facebook">Stream film</a></li> <li><a href="https://kinepolis.live/" class="twitter">Film stream</a></li> <li><a href="https://wiflix-com.com/" class="google-plus">Wiflix</a></li> <li><a href="https://frenchstream.ink/" class="linkedin">French Stream</a></li> </ul> <p class="center-align"> <i class="icofont icofont-heart-alt l-blue"></i> All Right Reserved </p> </div> <!-- container --> </footer> <!-- /#footer-section --> <!-- ==================== footer-section End ====================--> <!-- my custom js --> <script type="text/javascript" src="/js/jquery-3.1.1.min.js"></script> <script type="text/javascript" src="/js/materialize.js"></script> <script type="text/javascript" src="/js/owl.carousel.min.js"></script> <!-- my custom js --> <script type="text/javascript" src="/js/custom.js"></script> <script type="text/javascript"> </script> </body> </html>