A student asked Quora to do his homework for him. Oh we can be brutal.

🎙️ MCSajjadH · 3660 points · Posted at 11:36:44 on July 7, 2016 · (Permalink)


ProfessorPhi · 1623 points · Posted at 12:42:58 on July 7, 2016 · (Permalink)

My favourite was the guy who gave an answer in lambda calculus and then finished by saying - you probably need to write your own compiler to get it to work.

digital_cucumber · 781 points · Posted at 14:22:23 on July 7, 2016 · (Permalink)

you probably need to write your own compiler to get it to work.

..."should not be too hard"

fableal · 810 points · Posted at 14:41:50 on July 7, 2016 · (Permalink)

Left as an exercise to the reader

tacticalsword · 94 points · Posted at 17:58:51 on July 7, 2016 · (Permalink)

I am having calculus flashback because of that comment

Gustephan · 29 points · Posted at 03:40:08 on July 8, 2016 · (Permalink)

Griffiths. David J. Griffiths. Not exactly calculus, but he hand-waved some severe math wizardry with the phrase, "it's easy to show that"

Nefari0uss · 3 points · Posted at 11:26:05 on July 8, 2016 · (Permalink)

Sounds like my math professor for calc 3...why the fuck would you get a professor that only teaches grad students to teach freshman. No, it's not "trivial" or "easy to show" ~ that's why I asked you to explain it...

ksarnek · 2 points · Posted at 11:26:35 on July 8, 2016 · (Permalink)

The intro to QM textbook. Some very important topics are not treated in the text and you are asked to derive them as exercise.

For example, a lot of the properties of the Schrödinger equation and its boundary conditions are taken for granted, while in my opinion they're non-trivial topics of analysis.

ksarnek · 1 points · Posted at 11:26:50 on July 8, 2016 · (Permalink)

The intro to QM textbook. Some very important topics are not treated in the text and you are asked to derive them as exercise.

For example, a lot of the properties of the Schrödinger equation and its boundary conditions are taken for granted, while in my opinion they're non-trivial topics of analysis.

Dranthe · 15 points · Posted at 20:04:48 on July 7, 2016 · (Permalink)

You mean flashes of red? Because that's the color I see when I read that phrase.

shoplifter9001 · 1 points · Posted at 19:05:16 on July 8, 2016 · (Permalink)

HAHAHAHAHA HAS ANYONE ELSE TAKEN CALCULUS???? HAHA WE'RE SUCH PROGRAMMERS!!!!

tacticalsword · 2 points · Posted at 19:50:11 on July 8, 2016 · (Permalink)

I meant kidney stones though

BlueShellOP · 28 points · Posted at 20:24:56 on July 7, 2016 · (Permalink)

Triggered.gif

St_SiRUS · 9 points · Posted at 23:51:03 on July 7, 2016 · (Permalink)

Oh god this brings back horrible memories of my algorithms and data structures lecturer

hiimmatt · 2 points · Posted at 22:03:33 on July 7, 2016 · (Permalink)

Sorry K&R, I never did those exercises. Do your own!

MRannik · 287 points · Posted at 15:26:32 on July 7, 2016 · (Permalink)*
mage2k · 71 points · Posted at 16:22:11 on July 7, 2016 · (Permalink)

I'd say this is probably the prime example of what that joke is about.

ddelux · 21 points · Posted at 16:59:16 on July 7, 2016 · (Permalink)

I actually really enjoyed the textbook, was pretty well-written IMO. Maybe I read less of it than I remember!

TyllyH · 5 points · Posted at 17:34:39 on July 7, 2016 · (Permalink)

Same, it was definitely dense, but it was also really useful.

stravant · 1 points · Posted at 22:05:19 on July 7, 2016 · (Permalink)

You probably did read less of it than you remember.

While good, it's the kind of textbook you can spend a whole day reading and really understanding just a few pages of. They explain things once and that's it, no wasted words.

[deleted] · 30 points · Posted at 16:45:35 on July 7, 2016 · (Permalink)*

[deleted]

_vi5in_ · 16 points · Posted at 16:58:12 on July 7, 2016 · (Permalink)

Skiena is the best one. I like it because he uses examples where you can actually see how the algorithm is applied.

zanaohlala · 2 points · Posted at 07:52:14 on August 19, 2016 · (Permalink)

I never did good with that humongous CLRS book, maybe I'll try some of Skiena's books for algorithms.

VanFailin · 3 points · Posted at 16:59:46 on July 7, 2016 · (Permalink)

I use it as a paperweight.

Jonno_FTW · 3 points · Posted at 01:31:59 on July 8, 2016 · (Permalink)

I'll have you know I've referred to my databases textbook 4 times since I graduated.

zem · 7 points · Posted at 22:20:31 on July 7, 2016 · (Permalink)

it was an excellent book as a companion to an actual university course, where the prof would explain stuff in class and then you could look up the details in clr, but i am amazed every time i see someone recommending it for self-study.

cheesegoat · 3 points · Posted at 22:04:16 on July 7, 2016 · (Permalink)

It also holds up my monitor nicely.

Most college textbooks retire as monitor stands.

SoulCantBeCut · 13 points · Posted at 16:34:46 on July 7, 2016 · (Permalink)

That fucking book... I still haven't learned how to remove nodes from a red black tree.

AustereSpoon · 21 points · Posted at 16:54:19 on July 7, 2016 · (Permalink)

Just make all of the pointers point to something else! Problem solved!

VanFailin · 122 points · Posted at 17:00:53 on July 7, 2016 · (Permalink)

The nodes are now gone. The tree is nowhere to be seen. The stack has grown dark and cold. You are likely to be eaten by a grue.

IICVX · 15 points · Posted at 22:20:14 on July 7, 2016 · (Permalink)

It's really interesting just how much early games were influenced by data structures.

[deleted] · 2 points · Posted at 17:28:17 on July 7, 2016 · (Permalink)*

[deleted]

What is this?

[deleted] · -1 points · Posted at 23:15:19 on July 7, 2016 · (Permalink)

You are likely to be eaten by a grue.

Eh, I just had Chinese...

BlueShellOP · 2 points · Posted at 20:23:04 on July 7, 2016 · (Permalink)

for( Object o : pointers) {

o = System.out;

}

apno · 2 points · Posted at 20:16:03 on July 7, 2016 · (Permalink)

I'd imagine even CS professors have to check Wikipedia to remember all the cases for a Red-black tree...

ColeyMoke · 2 points · Posted at 01:08:09 on July 8, 2016 · (Permalink)

Make them lean left.

elprophet · 1 points · Posted at 21:52:39 on July 7, 2016 · (Permalink)
rollducksroll · 3 points · Posted at 16:29:53 on July 7, 2016 · (Permalink)

I remember that beast...

Triddy · 3 points · Posted at 18:36:03 on July 7, 2016 · (Permalink)

Honestly, this one was up there with my operating systems textbook as one of the best textbooks I used.

mage2k · 1 points · Posted at 18:38:32 on July 7, 2016 · (Permalink)

Oh, it's good, but the level of rigor is a bit off putting for a bit when first using it in an Introduction to Algorithms class. Was the OS book you used the Tanenbaum one with Minix? I loved that book.

Triddy · 1 points · Posted at 18:48:20 on July 7, 2016 · (Permalink)

No, but looking into it I wish we had.

We used Modern Operating Systems 3rd Edition also by Tanenbaum.

I think what we can conclude from this is that the man really knows his shit, both about teaching and about operating systems.

mage2k · 1 points · Posted at 18:58:06 on July 7, 2016 · (Permalink)*

If you ever want a good chuckle you can look up some of the old newsgroup conversations between Tanenbaum and Linus Torvalds from when Torvalds was his student. Minix was all about being a modular operating system whereas Torvalds wanted to make it monolithic, which is eventually how we got Linux.

dacjames · 1 points · Posted at 19:48:36 on July 7, 2016 · (Permalink)

I'm either dumb or you forget the critical word "monolithic"!

mage2k · 1 points · Posted at 19:57:18 on July 7, 2016 · (Permalink)

Heh, no idea how I did that. It's fixed now.

zordtk · 1 points · Posted at 19:58:52 on July 7, 2016 · (Permalink)

Linus Torvalds was never a student of Tanenbaum.

perciva · 2 points · Posted at 20:32:44 on July 7, 2016 · (Permalink)

We're all students of Tanenbaum.

mage2k · 1 points · Posted at 21:24:04 on July 7, 2016 · (Permalink)

Huh. I wonder why I thought he was. Thanks for the correction!

stravant · 1 points · Posted at 22:08:17 on July 7, 2016 · (Permalink)

Yeah, I would definitely not describe it an an "introduction" to anything. The people who get the most out of that book already know quite a lot.

RAKtheUndead · 1 points · Posted at 23:09:39 on July 7, 2016 · (Permalink)

You think that's bad, take a look at The Art of Computer Programming.

Huex3 · 1 points · Posted at 23:53:06 on July 7, 2016 · (Permalink)

Except CLRS is not typically given to first-year students, but I guess it doesn't stop the most ambitious IOI/ACM-ICPC aspirants to read from front to back. :P

cbarrick · 1 points · Posted at 04:15:34 on July 8, 2016 · (Permalink)

Oh shit. I'm using that book next semester...

giantsparklerobot · 1 points · Posted at 16:41:18 on July 7, 2016 · (Permalink)

*shakes fist*

That fucking book.

UlyssesSKrunk · 1 points · Posted at 18:12:54 on July 7, 2016 · (Permalink)

I love that book. First time I read the definition of Big O in it I was hooked on algorithms.

[deleted] · 1 points · Posted at 20:24:14 on July 7, 2016 · (Permalink)

The Algorithm Design Manual?

cuteintern · 3 points · Posted at 18:00:07 on July 7, 2016 · (Permalink)

I can draw owls

  • Neo
TheCodeJanitor · 2 points · Posted at 18:11:58 on July 7, 2016 · (Permalink)

I don't remember having that problem with textbooks as much, but I frequently sat through lectures with the bunny type content only to have exam questions like the bottom part.

[deleted] · 1 points · Posted at 19:43:32 on July 7, 2016 · (Permalink)

I'm not convinced that one rabbit plus one rabbit equals two rabbits implies one plus one equals two. Going to need a formal proof.

Igggg · 1 points · Posted at 01:23:29 on July 8, 2016 · (Permalink)

Just divide by the rabbit.

MyNameIsOhm · 1 points · Posted at 22:54:32 on July 7, 2016 · (Permalink)

This is exactly how I felt my university taught calc and up.

asdfman123 · 1 points · Posted at 23:06:49 on July 7, 2016 · (Permalink)

It's funny, I feel the opposite way. Computer programming textbooks move on to the easy, logical next step, and college math texts jump from step 1 to step 9 without explaining why.

Guess the author of Abstruse Goose is better at math than programming. I'm the other way around.

tieTYT · 1 points · Posted at 05:55:34 on July 8, 2016 · (Permalink)

SICP in a nutshell.

tieTYT · 1 points · Posted at 05:55:45 on July 8, 2016 · (Permalink)

SICP in a nutshell.

mdatwood · 1 points · Posted at 15:33:52 on July 8, 2016 · (Permalink)

Haha, this is like a CS teacher I had once. He would teach X and expect you to expand X -> Y on the test. Think of learning how to add and then being expected to just figure out multiplication on the test. Easily one of the top 3 hardest classes I ever took.

jmblock2 · 1 points · Posted at 16:34:32 on July 8, 2016 · (Permalink)

It's funny because the answer also turns out to be 2.

[deleted] · 25 points · Posted at 15:01:26 on July 7, 2016 · (Permalink)

Well, to be fair, if you know LC then writing a compiler for it is trivial. But yeah.

[deleted] · 1 points · Posted at 19:40:50 on July 7, 2016 · (Permalink)*

[deleted]

Vimda · 5 points · Posted at 20:15:15 on July 7, 2016 · (Permalink)

The need to understand lambda calculus?

SilasX · 1 points · Posted at 22:00:57 on July 7, 2016 · (Permalink)

"Just an implementation issue"

[deleted] · 56 points · Posted at 16:08:14 on July 7, 2016 · (Permalink)

this part is fun too "You could improve on this version by using a y combinator to do the recursion so the functions are completely anonymous."

IICVX · 2 points · Posted at 22:20:52 on July 7, 2016 · (Permalink)

It's perfectly cromulent advice.

tinkertron5000 · 21 points · Posted at 16:56:07 on July 7, 2016 · (Permalink)

I really enjoyed the lolcode

s1295 · 16 points · Posted at 17:58:12 on July 7, 2016 · (Permalink)

Last line actually has a typo and should read applyNTimes(3)(printNTimes), unless I'm missing something.

I dunno, this solution isn't doing much for me, neither clever nor obfuscated.

FermiAnyon · 4 points · Posted at 05:07:50 on July 8, 2016 · (Permalink)

Excellent! So the student won't know if the bug is in the script or in the compiler he wrote to compile it!

cleeder · 1 points · Posted at 00:02:21 on July 8, 2016 · (Permalink)

Yeah, I was wondering about that too. It didn't quite add up to me. That makes more sense though.

silveryRain · 11 points · Posted at 22:08:07 on July 7, 2016 · (Permalink)*

I liked the one that didn't require the overhead of an OS. Why waste resources when you can just compile assemble some assembly and write it to the boot sector? The jnius one was inventive too, I thought.

mushr00m_man · 2 points · Posted at 04:00:39 on July 8, 2016 · (Permalink)

I believe you assemble assembly, not compile it.

__reset__ · 1 points · Posted at 17:27:42 on July 7, 2016 · (Permalink)

I can't find that one, link?

ralgrado · 1 points · Posted at 22:16:56 on July 7, 2016 · (Permalink)

Couldn't you transform it to something like Haskell easily?

[deleted] · 1 points · Posted at 12:03:40 on July 8, 2016 · (Permalink)

You could, but wouldn't it be better point-free?

putStr $ concat $ (=<<) (flip (++) ["\n"] . (flip take $ repeat "Smile!")) $ reverse [1..3]
aleatorya · 1 points · Posted at 09:52:24 on July 8, 2016 · (Permalink)

His code seams incorrect, the last line should be: applyNTimes(3)(printStringNTimes)

MRannik · 321 points · Posted at 15:07:48 on July 7, 2016 · (Permalink)

I didn't expect the SQL one.

petrip · 838 points · Posted at 15:18:15 on July 7, 2016 · (Permalink)

Nobody expects the Spanish Query Language!

dkarlovi · 104 points · Posted at 19:01:08 on July 7, 2016 · (Permalink)

Que?

cr125rider · 78 points · Posted at 20:32:21 on July 7, 2016 · (Permalink)

And the new-fangled schema-less version: NoQue

ajfili · 67 points · Posted at 22:47:33 on July 7, 2016 · (Permalink)

And it's Oracle owned variant: PorQue

halr9000 · 2 points · Posted at 02:19:09 on July 8, 2016 · (Permalink)

¿Por que?

ajfili · 5 points · Posted at 05:14:56 on July 8, 2016 · (Permalink)

No. That's "Why?" Porque is "because" as in "because fuck you pay me."

MRannik · 1 points · Posted at 03:43:36 on July 8, 2016 · (Permalink)

¿Por qué?

mikos · 4 points · Posted at 20:09:38 on July 7, 2016 · (Permalink)

si que el?

papers_ · 2 points · Posted at 22:05:06 on July 7, 2016 · (Permalink)

Asi se asea ese oso.

Ese oso se asea asi.

Compizfox · 3 points · Posted at 23:27:10 on July 7, 2016 · (Permalink)

I'm from Barcelona, I know nothing.

snaky · 1 points · Posted at 13:28:19 on July 8, 2016 · (Permalink)
[deleted] · 10 points · Posted at 22:49:35 on July 7, 2016 · (Permalink)

Spanish Query Language Injection...nice.

MRannik · 59 points · Posted at 15:24:00 on July 7, 2016 · (Permalink)

Ugh... take your upvote and leave.

Dutyxfree · 13 points · Posted at 18:14:55 on July 7, 2016 · (Permalink)

Still laughing. Bravo.

WildVelociraptor · 18 points · Posted at 18:47:41 on July 7, 2016 · (Permalink)

BUT WHEN DID YOU START LAUGHING

WE MUST KNOW

blue_2501 · 1 points · Posted at 05:26:16 on July 8, 2016 · (Permalink)

Look it up yourself:

SELECT start_time FROM status
WHERE user = 'Dutyxfree' AND status = 'laughing';
dkarlovi · 2 points · Posted at 06:15:29 on July 8, 2016 · (Permalink)

0000-00-00 00:00:00

Shit.

KaieriNikawerake · 1 points · Posted at 18:19:39 on July 7, 2016 · (Permalink)

ja ja ja ja...

[deleted] · 10 points · Posted at 16:13:45 on July 7, 2016 · (Permalink)

It is not even ISO SQL

fxprogrammer · 14 points · Posted at 16:39:53 on July 7, 2016 · (Permalink)

Was it that dirty ass t-sql

oneonetwooneonetwo · 2 points · Posted at 19:43:49 on July 7, 2016 · (Permalink)

I can't explain why it's as unexpected as it is. I was totally thrown when I saw that.

musicmatze · 495 points · Posted at 15:32:47 on July 7, 2016 · (Permalink)

next:

I just filed a 100 pages solution for a problem I was assigned at school, containing solutions in 42 programming languages including Brainfuck and Whitespace - My teacher kicked me out, what to do now?

voicelessfaces · 158 points · Posted at 16:53:15 on July 7, 2016 · (Permalink)

Become a professional Internet asshole

vplatt · 27 points · Posted at 17:50:45 on July 7, 2016 · (Permalink)

No... wait! Too late.

enry_straker · 1 points · Posted at 09:23:06 on July 8, 2016 · (Permalink)

He already is.

[deleted] · 46 points · Posted at 18:25:18 on July 7, 2016 · (Permalink)

Get a business degree (or take some acting classes) and become a manager.

Knomez · 20 points · Posted at 23:45:48 on July 7, 2016 · (Permalink)

Lim as GPA ->0 = business major

voicelessdeer · 2 points · Posted at 03:17:40 on July 8, 2016 · (Permalink)

I tutored this kid a little during an intro course in college. He was horrific. Constantly falling asleep in class / tutoring sessions, not paying attention, etc.

This kid literally played Motobike flash games every. Single. Class. Like.. I don't know how the hell anyone can play a game so simple for that damn long. Anyway, last I heard, he switched his major to theater arts.

[deleted] · 1 points · Posted at 03:21:08 on July 8, 2016 · (Permalink)

My next boss in the making.

Rollingprobablecause · 2 points · Posted at 03:19:50 on July 8, 2016 · (Permalink)

*Project Manager

row4land · 41 points · Posted at 16:55:42 on July 7, 2016 · (Permalink)

Break;

norsurfit · 21 points · Posted at 18:30:44 on July 7, 2016 · (Permalink)

This is the origin story for an Internet super villain.

nonsensepoem · 12 points · Posted at 19:58:40 on July 7, 2016 · (Permalink)

A mediocre villain, maybe-- definitely not super.

Throwaway_bicycling · 1 points · Posted at 00:41:09 on July 8, 2016 · (Permalink)

Like perhaps Florida Man?

[deleted] · 26 points · Posted at 01:12:29 on July 8, 2016 · (Permalink)

Given that this is Quora, I'd expect the follow-up question to be I just filed a 100 pages solution for a problem I was assigned at school, containing solutions in 42 programming languages including Brainfuck and Whitespace - am I good enough to pass Google's technical interview?

koreth · 8 points · Posted at 05:20:09 on July 8, 2016 · (Permalink)

Well, really, I just filed a 100 pages solution for a problem I was assigned at school, containing solutions in 42 programming languages including Brainfuck and Whitespace - can I earn at least $675,000 a year by passing Google's technical interview?

ksarnek · 2 points · Posted at 11:30:07 on July 8, 2016 · (Permalink)

/brainfuck

3 matches

oversized_hoodie · 1 points · Posted at 03:37:29 on July 8, 2016 · (Permalink)

That sounds like something I'd do just to be an ass.

IbanezDavy · 1 points · Posted at 20:43:38 on July 8, 2016 · (Permalink)

YOu laught. But that's probably exactly what he did not understanding how ridiculous it is.

textfile · 1199 points · Posted at 12:06:51 on July 7, 2016 · (Permalink)

This version picks a random number between 0 and 2,147,483,6467 (231 –1) then checks to see if that number is the unicode value for the next character to print. If it is, it returns it and prints it to the screen.

This guy gets it.

Suttonian · 199 points · Posted at 15:58:40 on July 7, 2016 · (Permalink)

How many years does that take to complete?

andrewpost · 1063 points · Posted at 16:00:35 on July 7, 2016 · (Permalink)

We ain't doing your statistics homework!

neoform · 19 points · Posted at 21:03:50 on July 7, 2016 · (Permalink)

You should have answered in an overly circuitous way!

juckele · 168 points · Posted at 16:12:12 on July 7, 2016 · (Permalink)

Depends on how fast you can generate random numbers... It's 38 characters total, and you need to randomly generate approximately 231 characters before you get one. log2 38 is about 5.25. So you need to generate and check 236.25 characters. If you can generate and check 100,000 per second, it should take around 9 days. If you can only generate and check 10K per second, it'll be closer to 3 months.

Showing my work: https://www.google.com/search?q=2%5E36.25+s+to+years&oq=2%5E36.25+s+to+years&aqs=chrome..69i57.2696j0j1&sourceid=chrome&ie=UTF-8#q=(2%5E36.25%2F100000)+seconds+to+days

yentity · 76 points · Posted at 16:15:58 on July 7, 2016 · (Permalink)

You can generate a lot more than 100K random numbers per second.

juckele · 26 points · Posted at 17:02:07 on July 7, 2016 · (Permalink)

Fair, I just wasn't sure how many my computer generates per second so I did a conservative 100K :)

[deleted] · 34 points · Posted at 17:53:29 on July 7, 2016 · (Permalink)*

[deleted]

omnilynx · 15 points · Posted at 18:58:44 on July 7, 2016 · (Permalink)

It's embedded-ready!

Bobshayd · 22 points · Posted at 19:16:44 on July 7, 2016 · (Permalink)

It's embeddedIoT-ready!

xzxzzx · 60 points · Posted at 16:35:49 on July 7, 2016 · (Permalink)*

I get about 150,000,000 per second using C#'s built in Random class.

So about 9 minutes probably.

Edit: Amusingly, it's much faster to generate one random number, then check the whole keyspace in order. I get about 1 check per CPU cycle, so about 4.3 billion checks per second on my machine (or 2 billion checks per second if I wrap around to 0 instead of also checking the negative keyspace, apparently the cost of that if is ~1 cycle).

In practice, on my machine, it consistently takes 16-19 seconds, and about 235.10 to 235.25 numbers generated.

Also, the statistics above are slightly off, you need about 230 characters generated on average per character (half the keyspace).

I_ate_a_milkshake · 9 points · Posted at 16:53:47 on July 7, 2016 · (Permalink)

doesn't that all depend on what machine you're running on?

xzxzzx · 23 points · Posted at 17:07:56 on July 7, 2016 · (Permalink)

doesn't that all depend on what machine you're running on?

Yes, and the random number generator, and whether you use multiple cores, etc.

mcmcc · 145 points · Posted at 17:37:31 on July 7, 2016 · (Permalink)

multiple cores

That's just what this problem is begging for: Multi-threading

[deleted] · 28 points · Posted at 19:58:11 on July 7, 2016 · (Permalink)*

[deleted]

Pomnom · 29 points · Posted at 20:43:40 on July 7, 2016 · (Permalink)

Serialization the result is left for reader as an exercise.

tejon · 3 points · Posted at 01:31:31 on July 8, 2016 · (Permalink)
module Main where

import Control.Concurrent.Async   -- package "async"

-- Pretend this does the random thing. I was too lazy to write that
-- but, since it's in IO, subsequent code can't tell the difference.
makeSmile :: IO String
makeSmile = pure "Smile!"

-- Spawn N individual Smile-creation threads. Concatenate the results.
makeSmileSet :: Int -> IO String
makeSmileSet n = do
  smileThreads <- replicate n <$> async makeSmile  -- spawn threads
  smiles <- traverse wait smileThreads             -- consume threads
  pure $ concat smiles

-- Make a list of SmileSets iterating from length N down to length 1
makeSmileCascade :: Int -> IO [String]
makeSmileCascade n
  | n <= 0    = pure []
  | otherwise = (:) <$> makeSmileSet n <*> makeSmileCascade (n - 1)

-- Take a SmileCascade of N=3; concat with interspersed newlines; print.
main :: IO ()
main = putStr =<< unlines <$> makeSmileCascade 3
1RedOne · 1 points · Posted at 03:49:49 on July 8, 2016 · (Permalink)

This is the perfect kind of response. Did you post in that thread too?

[deleted] · 4 points · Posted at 01:40:19 on July 8, 2016 · (Permalink)*

[deleted]

ygra · 1 points · Posted at 09:03:53 on July 9, 2016 · (Permalink)

That's actually not a bad exercise to practice using tasks and other threading abstractions, I guess.

Amuro_Ray · 1 points · Posted at 22:09:57 on July 7, 2016 · (Permalink)

Now we have prlbosme.

Ameisen · 1 points · Posted at 17:18:01 on July 8, 2016 · (Permalink)

Posting to remind myself to do this when I get home and post the results.

juckele · -1 points · Posted at 17:01:04 on July 7, 2016 · (Permalink)

Kinda, but modern machines are all somewhat close to each other in performance. The slowest laptops around are still packing 1+GHz chips while the fastest desktops are packing 3-4GHz chips. If you're running this on a Raspberry Pi, it might take 30+ minutes.

EenAfleidingErbij · 6 points · Posted at 17:26:47 on July 7, 2016 · (Permalink)

You lost me when you started using clock speeds as reference points for cpu speed.

juckele · 1 points · Posted at 17:47:56 on July 7, 2016 · (Permalink)

There's certainly a strong correlation, especially when doing very simple repetitive tasks like random number generation. I have a 4GHz AMD chip that's slower than my 2.7GHz i7, but my point was really just that no one is packing Pentium IIs anymore.

EenAfleidingErbij · 2 points · Posted at 17:55:09 on July 7, 2016 · (Permalink)

I happen to still own a Pentium 4 3.06ghz that's doing its thing with lubuntu.

Paedor · 2 points · Posted at 04:44:39 on July 8, 2016 · (Permalink)

Sorry, I'm new to programming. What does it mean to check a keyspace in order?

b4b · 1 points · Posted at 11:14:26 on July 8, 2016 · (Permalink)

4.3 billion checks per second on my machine still blows my mind

smookykins · 1 points · Posted at 20:12:45 on July 7, 2016 · (Permalink)

That's only average case.

juckele · 1 points · Posted at 20:26:49 on July 7, 2016 · (Permalink)

This is true, but with sufficiently large samples (38 characters is almost getting there), the completion time will get closer (proportionally) to the average. If you want to generate one character, yes, sometimes you'll get it a lot later and sometimes you'll get it a lot earlier. With 38 characters, you should see completion times that resemble the predictions based on CPU speed.

[deleted] · 48 points · Posted at 16:47:52 on July 7, 2016 · (Permalink)*

[deleted]

xelf · 38 points · Posted at 17:51:58 on July 7, 2016 · (Permalink)
[deleted] · 11 points · Posted at 21:23:26 on July 7, 2016 · (Permalink)*

[deleted]

OffbeatCamel · 8 points · Posted at 23:43:52 on July 7, 2016 · (Permalink)

Colouring error, I guess! It's drawn like the tour guide

domy94 · 26 points · Posted at 18:06:21 on July 7, 2016 · (Permalink)*

If I parallelize it, 3 minutes 23 seconds on my 5820K at 4.5 GHz. The single-threaded original solution took 11m46s.

https://gist.github.com/domyd/5ede8144de4f08aaa1c069918c7eed2b

I'd be happy to know of ways to make this faster :)

Edit: Compiled with VS 2015 Update 3 and .NET Framework 4.5.2, Release Build.

repsilat · 6 points · Posted at 05:25:30 on July 8, 2016 · (Permalink)

Holy balls computers are fast. My intuition was off by orders of magnitude, though this really does make sense now that I bother to scribble on the back of this envelope...

(Don't try 64 bit...)

rebthor · 1 points · Posted at 21:41:39 on July 13, 2016 · (Permalink)

CUDA-ize it and run it on your GFX card?

domy94 · 1 points · Posted at 03:16:32 on July 14, 2016 · (Permalink)

Nice idea, I'll see what I can do.

mcdade · 3 points · Posted at 16:47:13 on July 7, 2016 · (Permalink)

Compiles immediately, seems to take a while to run though. Sadly online compilers won't give me an answer : Compilation time: 0,14 sec, absolute running time: 5,03 sec, cpu time: 5,02 sec, average memory usage: 22 Mb, average nr of threads: 5 I did get the S though..

TheCodexx · 1 points · Posted at 02:51:00 on July 8, 2016 · (Permalink)

Technically I think it's O(n).

hglman · 1 points · Posted at 02:59:22 on July 8, 2016 · (Permalink)

None or all and everything between.

agbullet · 44 points · Posted at 16:34:44 on July 7, 2016 · (Permalink)

ah yes. with complexity O(bogo sort)

Fylwind · 21 points · Posted at 18:15:30 on July 7, 2016 · (Permalink)*

Not at all. Bogosort requires you to get extremely lucky by hitting ALL the characters correctly at once.

In this program, you only need to get lucky on the next character that's being printed.

madmax9186 · 4 points · Posted at 19:05:06 on July 7, 2016 · (Permalink)

The Big O time would be the same though, the only thing that would be different would be the statistical average of the runtimes.

Fylwind · 7 points · Posted at 20:31:12 on July 7, 2016 · (Permalink)

Nope, the aforementioned algorithm is O(n) (average-case) whereas bogosort is O((n+1)!) (average-case), where n is the number of characters. (Of course, there's a big constant factor on the order of 231 for the aforementioned algorithm.)

madmax9186 · 1 points · Posted at 21:47:28 on July 7, 2016 · (Permalink)*

Nope, the aforementioned algorithm is O(n) (average-case)

Yes, that's what I said. The worst case is equivalent though.

Tysonzero · 2 points · Posted at 22:12:50 on July 7, 2016 · (Permalink)

How is the worst case equivalent? Because it is O(Infinity)?

madmax9186 · 2 points · Posted at 02:27:28 on July 8, 2016 · (Permalink)

Right

EDIT: And since we're working with a discreet n, we can be confident this is true.

Fylwind · 1 points · Posted at 02:43:49 on July 8, 2016 · (Permalink)

You said:

The Big O time would be the same though

Big O time is not the same for both algorithms in the average case.

agbullet · 1 points · Posted at 23:29:37 on July 7, 2016 · (Permalink)

hmm. true dat.

BlazeOrangeDeer · 1 points · Posted at 05:13:19 on July 8, 2016 · (Permalink)

Technically if A is O(B) means that after a certain point B is always bigger than A, so they're not wrong, just not being specific.

Aegeus · 28 points · Posted at 17:05:42 on July 7, 2016 · (Permalink)

Big O time would be infinite, because Big O is worst-case and in theory it might never generate the numbers you need. Best-case scenario is n tries, though!

[deleted] · 10 points · Posted at 18:07:28 on July 7, 2016 · (Permalink)

[deleted]

deong · 31 points · Posted at 18:20:53 on July 7, 2016 · (Permalink)

You can.

Big-O just means that, whatever you're measuring, you've bounded that thing from above by some function. Big-Theta means you've bounded it from above and below. The thing you're measuring can be worst-case runtime, average-case runtime, or number of M&M's needed to convert into heat energy to power the computer via a steam engine long enough to get the answer.

Bobshayd · 6 points · Posted at 19:17:48 on July 7, 2016 · (Permalink)

Well, M&Ms needed is going to be roughly proportional to runtime.

viimeinen · 6 points · Posted at 22:32:49 on July 7, 2016 · (Permalink)

Worst runtime or avarage runtime?

Bobshayd · 3 points · Posted at 00:02:11 on July 8, 2016 · (Permalink)

Worst-case M&Ms, or average-case M&Ms?

philipwhiuk · 2 points · Posted at 11:16:27 on July 8, 2016 · (Permalink)

M&Ms are probably distributed randomly. Damn we're back where we started.

ismtrn · 2 points · Posted at 20:20:05 on July 7, 2016 · (Permalink)

Big O is an upper bound. It can bound both worst case or average case or any other case for that matter

excitebyke · 1 points · Posted at 19:45:43 on July 7, 2016 · (Permalink)*

neato, i've never considered a worst-case scenario as infinite. but i guess its technically possible with a randomized alogrithm?

hglman · 1 points · Posted at 03:01:43 on July 8, 2016 · (Permalink)

While True

Also worst case infinity.

Fylwind · 1 points · Posted at 02:54:26 on July 8, 2016 · (Permalink)

"Big-O" should not be conflated with "worst-case".

"Big-O" talks about the upper bound of a real-numbered, deterministic function. It does not care about what function you are working with. This function could be the best-case time, the average-case time, or the worst-case time of a stochastic algorithm.

Megatron_McLargeHuge · 1 points · Posted at 03:06:17 on July 8, 2016 · (Permalink)

Just assume your PRNG has a finite amount of state and therefore has a cycle. If that cycle includes every int you're back at O(n).

agbullet · 1 points · Posted at 04:56:58 on July 9, 2016 · (Permalink)

Is it ever possible to prove that a given PRNG has these properties?

Ravek · 1 points · Posted at 06:52:43 on July 8, 2016 · (Permalink)

Big O isn't worst case, big O is an upper bound. You can have different upper bounds for worst case, average case, best case and whatever other scenario you like.

lawstudent2 · 1 points · Posted at 02:16:57 on July 8, 2016 · (Permalink)

Deep cut on the bogosort.

Beefourthree · 13 points · Posted at 17:45:57 on July 7, 2016 · (Permalink)

RNG is hard. I recommend this function.

wolf550e · 2 points · Posted at 17:06:42 on July 7, 2016 · (Permalink)

that constant has an error. the rightmost "6" should not be there.

Fritzed · 2 points · Posted at 21:19:37 on July 7, 2016 · (Permalink)
KayRice · 2 points · Posted at 21:20:16 on July 7, 2016 · (Permalink)

I'm calling this bogoprint

hyh123 · 2 points · Posted at 01:33:07 on July 8, 2016 · (Permalink)

2,147,483,6467

Should be 2,147,483,647

contrarian_barbarian · 1 points · Posted at 16:02:38 on July 7, 2016 · (Permalink)

Hopefully he set it up to pull from entropy instead of a PRNG :D

garbonzo · 138 points · Posted at 15:22:39 on July 7, 2016 · (Permalink)

The one that reads in the text file and prints it out...nice

klezmai · 8 points · Posted at 16:25:53 on July 7, 2016 · (Permalink)

My favorite as well.

jfb1337 · 2 points · Posted at 10:23:05 on July 8, 2016 · (Permalink)

What about:

#!/usr/bin/tail
Smile!Smile!Smile! 
Smile!Smile! 
Smile!

With a bunch of newlines to chop off the shebang

smookykins · 1 points · Posted at 20:28:54 on July 7, 2016 · (Permalink)

Best kind of correct.

BadgerRush · 258 points · Posted at 15:37:17 on July 7, 2016 · (Permalink)*

I like the one in assembly using only bios calls to do the printing, no pesky OS needed.

Would that work on a modern UEFI based PC? (I haven't meddled in low level stuff since the turn of the century, so I'm a bit behind on how backwards compatible UEFI is.)

Rusky · 57 points · Posted at 16:33:42 on July 7, 2016 · (Permalink)

Only if the UEFI-based PC has a legacy BIOS mode. UEFI itself loads 64-bit PE executables and hands them a table of function pointers.

crozone · 16 points · Posted at 16:38:30 on July 7, 2016 · (Permalink)

It'll work on UEFI as long as the UEFI supports booting MBR partitions with BIOS emulation. As long as it runs the bootloader from the first sector of disk.

jmickeyd · 24 points · Posted at 20:00:51 on July 7, 2016 · (Permalink)

They forgot the 0x55, 0xAA boot marker at the end of the sector.

StenSoft · 10 points · Posted at 21:20:40 on July 7, 2016 · (Permalink)

Exactly my thought, ‘No bootable device’.

oneonetwooneonetwo · 8 points · Posted at 19:45:50 on July 7, 2016 · (Permalink)

That was really impressive. I'm a sucker for bare metal.

merreborn · 3 points · Posted at 22:32:51 on July 7, 2016 · (Permalink)
BadgerRush · 2 points · Posted at 00:40:29 on July 8, 2016 · (Permalink)

Thanks. I've edited there.

megablast · 2 points · Posted at 04:51:16 on July 8, 2016 · (Permalink)

Why not just write the characters directly to b800h?

Rusky · 2 points · Posted at 23:02:13 on July 9, 2016 · (Permalink)

UEFI doesn't load boot sectors, and it's not guaranteed to give you a VGA framebuffer at that address either.

olsner · 1 points · Posted at 08:13:20 on July 8, 2016 · (Permalink)

A fun variation on that might be a parallel version that boots all the CPUs and has each one write one character. And requires at least 6 CPUs to get the whole text :)

enry_straker · 1 points · Posted at 09:30:12 on July 8, 2016 · (Permalink)

Damn. The assembly is far more readable than most of the others.

peto2006 · 1 points · Posted at 13:48:45 on July 8, 2016 · (Permalink)

I would like to test this. I tried to compile it as author said. Then I copied it to beginning of sector 0 of my VirtualBox machine. (Where I previously copied sector 0 of my physical machine, so it contains 0x55AA bytes at the end.) And it's not working. Is there something I can do to make it work?

IAmYourDad_ · 94 points · Posted at 15:48:59 on July 7, 2016 · (Permalink)

LOLCODE always gets me.

VaxesAreHaxes · 53 points · Posted at 17:28:06 on July 7, 2016 · (Permalink)

O RLY? YA, RLY NO WAI

cmonster1697 · 34 points · Posted at 18:11:56 on July 7, 2016 · (Permalink)

KTHXBYE

LeartS · 24 points · Posted at 17:23:24 on July 7, 2016 · (Permalink)

I've done some project euler problems using lolcode: LeartS/loleuler

BeatLeJuce · 3 points · Posted at 06:36:56 on July 8, 2016 · (Permalink)

Those solutions are much shorter than I would've expected them to be. Nice work!

philipwhiuk · 2 points · Posted at 11:17:32 on July 8, 2016 · (Permalink)

What's the equivalent of segfault - SAD PANDA?

spkr4thedead51 · 3 points · Posted at 21:59:38 on July 7, 2016 · (Permalink)

Today is the 9 year anniversary of the 1.2 specification, per my FB memories.

plus4dbu · 3 points · Posted at 00:06:37 on July 8, 2016 · (Permalink)

TIL about LOLCODE. I'm considering implementing it for a project... Just for the lolz

kirbyfan64sos · 260 points · Posted at 13:59:04 on July 7, 2016 · (Permalink)*

My favorite:

In JavaEE:

  • Make a maven war project and add Hibernate, JaxB, deltaspike-data-JPA and RESTEasy as dependencies

  • Make a simple entity "Message" containing a String atribute and "MessageList" One

  • Annotate each class with @Entity @XmlRootElement

  • Add an jaxb.index file on these classes package listing these two Entities

  • Annotate your Attribute by @XmlElement @NotNull @Size(min=2, max=10)

  • Make a MessageListDao interface annotted with DS @Repository @Path("/")

  • Make a simple persistence.xml file mapping to your database

  • Make an interface and a REST "MessageRESTService"

  • Add a method to this interface: @Produces(Mediatype.Application_json)@Path("/sayMessage/{message}/{count}") String getMessage(@PathParam("message") message, @PathParam("count"));

  • Implement this interface injecting your DAO in your service (with @Inject), and make this implementation @ApplicationScoped

  • Create an index.html file referencing NPM AngularJS, Twitter bootstrap, SASS (you can use grunt, npm and bower to automatically fill your index.html file js dependencies, but you've to add the maven-exec-plugin to call your grunt script during the 'generate-resource' phase)

  • Make an AngularJS application, a directive, a controller

  • Create inputs in your angular directive html file to choose your message and the occurence number, plus an HTML table with 'ng-repeat' attribute on the 'TR'

  • Bind the inputs and the table to AngularJS controller methods that will call your REST service

  • Create an default web.xml file in your src/main/webapp/WEB-INF directory (google it)

  • Configure the maven-tomcat-plugin (or maven-jetty) in your Maven pom.xml file

mvn tomcat:run and point your web browser to http://localhost:8080/

nowonmai · 170 points · Posted at 15:36:05 on July 7, 2016 · (Permalink)

No unit or integration tests? Filthy casual.

Stop_Sign · 16 points · Posted at 21:40:44 on July 7, 2016 · (Permalink)

TDD for proper design, of course.

geodel · 43 points · Posted at 16:42:35 on July 7, 2016 · (Permalink)

A solution of stunning beauty and simplicity for a rather complex problem.

And still some people exist who question the user friendliness and agility of JavaEE.

xtreak · 73 points · Posted at 15:36:53 on July 7, 2016 · (Permalink)
[deleted] · 70 points · Posted at 19:29:04 on July 7, 2016 · (Permalink)

[deleted]

GurkanG · 12 points · Posted at 22:29:41 on July 7, 2016 · (Permalink)

From happiness?

the_starbase_kolob · 4 points · Posted at 06:50:58 on July 8, 2016 · (Permalink)

I know, someone finally got FizzBuzz right!

XYcritic · 53 points · Posted at 17:35:07 on July 7, 2016 · (Permalink)

"Reverting the revert commit, since it clearly did not revert as intended"

Love it.

StenSoft · 17 points · Posted at 21:26:13 on July 7, 2016 · (Permalink)

Writing FizzBuzz by hand is for losers, I prefer neural network.

_zoot · 20 points · Posted at 23:40:50 on July 7, 2016 · (Permalink)

interviewer: Um, you understand the problem is fizzbuzz, right?

me: Do I ever. So, now let's talk models. I'm thinking a simple multi-layer-perceptron with one hidden layer.

[deleted] · 5 points · Posted at 12:35:41 on July 8, 2016 · (Permalink)

I guess maybe I should have used a deeper network.

No, MORE TRAINING DATA!!!

[deleted] · 14 points · Posted at 18:57:04 on July 7, 2016 · (Permalink)

i lol'd when i opened up the factories folder. that's just amazing right there.

autranep · 3 points · Posted at 20:37:39 on July 7, 2016 · (Permalink)

Holy shit haha. I didn't bother looking that far until you mentioned it.

repsilat · 2 points · Posted at 05:34:03 on July 8, 2016 · (Permalink)

NoFizzNoBuzzStrategyFactory.java

"No fuzz no buzz" will forever replace "no pain no gain" for me...

[deleted] · 3 points · Posted at 20:33:57 on July 7, 2016 · (Permalink)

hahah needs to support deep learning

AceBacker · 9 points · Posted at 17:12:51 on July 7, 2016 · (Permalink)

God it's so funny! And true.

Breems · 21 points · Posted at 18:00:51 on July 7, 2016 · (Permalink)

As an enterprise Java developer, it made me laugh and then cry.

smookykins · 9 points · Posted at 20:22:25 on July 7, 2016 · (Permalink)

There are times you don't cry?

Stop_Sign · 13 points · Posted at 21:49:45 on July 7, 2016 · (Permalink)

Only on this step:

Add a method to this interface: @Produces(Mediatype.Application_json)@Path("/sayMessage/{message}/{count}") String getMessage(@PathParam("message") message, @PathParam("count"));

I at least feel like I'm typing enough to be worth my paycheck.

jeffsterlive · 3 points · Posted at 01:06:02 on July 8, 2016 · (Permalink)

Better than writing Angular 2 code in my opinion, but maybe that's because the Angular developers can't make up their mind on the router.

dkarlovi · 2 points · Posted at 06:19:38 on July 8, 2016 · (Permalink)

Boo!

You're right, though.

GrinningPariah · 10 points · Posted at 18:56:11 on July 7, 2016 · (Permalink)

Oh man, that hits way too close to home if you work with enterprise java.

redditu5er · 1 points · Posted at 22:28:44 on July 7, 2016 · (Permalink)

Honest question - what are your biggest grievances about enterprise Java ?  

I am a full stack Java developer (Struts .. boo .. I know) and honestly, I don't see any particular advantage / disadvantage with any modern frameworks (.Net, Ruby, PHP, Java etc). One is a good as the other.  

The biggest difference is the developers mastery of a particular framework.

GrinningPariah · 6 points · Posted at 22:56:52 on July 7, 2016 · (Permalink)

My biggest issue with Java is probably more around Java developers. It's a language with so many different versions, and so many extensions and associated tools that when you're in a project with people who try to do the most advanced stuff possible to solve problems the cleverest way, it makes the codebase extremely difficult to understand if you're new to it.

It doesn't occur to people to guard against that, and say like "okay, here you're bringing in a dependency on Spring, which makes your problem easier, but we don't use that anywhere else. Do we really need it, and if so, are there more places we can use it and maybe cut out a different pattern?"

shriek · 3 points · Posted at 11:12:49 on July 8, 2016 · (Permalink)

Bloat. Too much bloat than actually needed.

GrokFu · 7 points · Posted at 15:04:24 on July 7, 2016 · (Permalink)

That is glorious haha!

treycartier91 · 1 points · Posted at 19:44:33 on July 7, 2016 · (Permalink)

I wanted to see a long explanation like this end with, "and shove it up your butt".

Decker108 · 1 points · Posted at 01:02:28 on July 8, 2016 · (Permalink)

SFW version: "and show it to your boss".

usernameua · 1 points · Posted at 08:37:06 on July 8, 2016 · (Permalink)

not webscale, should use mongodb.

OxfordTheCat · 393 points · Posted at 12:40:55 on July 7, 2016 · (Permalink)*

I know it's Quora and can appreciate that the answers are intentionally obtuse for giggles, but this hits pretty close to home with the SO experience:

"How can I do <simple task>?"

Followed by various answers varying in obscurity, complexity, and preposterous dependencies.

Pretty good unintentional satire. All that's missing is for someone to close it and inexplicably mark it as a duplicate of another question on random number generation in Haskell or something similarly unrelated.

[deleted] · 139 points · Posted at 12:57:33 on July 7, 2016 · (Permalink)

As someone who has contributing a lot to SO, especially in the .NET realm... it can be tough to give a simple answer because it's usually not the best one.

I've seen lots of answers which use legacy (1.1. or 2.0) techniques to solve modern issues. Like people suggesting you should use ArrayList or BackgroundWorker in 4.0+ code.

Languages evolve and it saddens me when people are quick to resound with answers that are already outdated.

hungry4pie · 77 points · Posted at 13:19:01 on July 7, 2016 · (Permalink)

I decided to try and contribute, but since I don't have the stupid minimum reputation I can't do anything except try and answer questions in the 15 seconds before someone else gives a better answer.

Effnote · 47 points · Posted at 14:36:14 on July 7, 2016 · (Permalink)

That's what got me as well. You can't really build up the minimum reputation without asking some questions yourself, and I don't really have any questions suitable for stack overflow.

errorprawn · 46 points · Posted at 16:05:21 on July 7, 2016 · (Permalink)

I got to about 100 reputation on Stack Overflow by asking a fairly popular question about the Dothraki on the Scifi&Fantasy Stack Exchange.

I didn't even know that was possible, but I really can't think of a better strategy to get your initial reputation.

[deleted] · 47 points · Posted at 16:52:20 on July 7, 2016 · (Permalink)*

[deleted]

xenago · 16 points · Posted at 19:20:25 on July 7, 2016 · (Permalink)

That's a master-level plan right there

InconsiderateBastard · 17 points · Posted at 01:02:52 on July 8, 2016 · (Permalink)

This is a great idea. I think we need a JS Framework for creating JS Frameworks to make it easier for the masses to use this technique.

Maybe JS Framework Creation as a Service?

irukesu · 6 points · Posted at 09:52:41 on July 8, 2016 · (Permalink)

Now slow down there Satan.

Clamhead99 · 26 points · Posted at 18:34:12 on July 7, 2016 · (Permalink)

My most popular question is asking how to freaking change the Android Studio editor font size.

I still get some rep every month or so for it. It has quite a few responses and views.

Apparently, a lot of people have trouble figuring it out, lol.

gbersac · 15 points · Posted at 20:34:38 on July 7, 2016 · (Permalink)

Me it is how to change the vim font size. 1/4 of all my reputation. Path to StackOverflow glory : ask how to change random editor font size

Clamhead99 · 1 points · Posted at 21:55:05 on July 7, 2016 · (Permalink)
RualStorge · 1 points · Posted at 05:14:02 on July 8, 2016 · (Permalink)

Mine was about when you should remove stuff from your desk when you know you're going to quit. (I found I enjoyed personal improvement and work place sections far healthier than SO these days)

SO gets down right ugly sometimes with false duplicate flags, and users who don't follow any sort of rules.

[deleted] · 3 points · Posted at 17:04:44 on July 7, 2016 · (Permalink)*

[deleted]

nachof · 2 points · Posted at 21:26:44 on July 7, 2016 · (Permalink)

Android has a ton of questions that go unanswered or are never marked as answered.

oneonetwooneonetwo · 1 points · Posted at 19:52:48 on July 7, 2016 · (Permalink)

Which makes you wonder if all those duplicate questions are actually just attempts to get reputation points.

b4b · 1 points · Posted at 11:18:08 on July 8, 2016 · (Permalink)

Hey, I can give you a question that you can post for me if you want.

mayankkaizen · -1 points · Posted at 15:10:03 on July 7, 2016 · (Permalink)*

You don't have questions suitable for SO?

Edit: Thanks for downvotes.

Monoryable · 30 points · Posted at 15:14:51 on July 7, 2016 · (Permalink)

I've had question suitable for SO once or twice, and that was only because of me not googling enough.

Honestly, I do not believe that most of us have lots of first-of-a-kind problems, and when we do, we solve them ourselves.

RubyPinch · 16 points · Posted at 15:21:29 on July 7, 2016 · (Permalink)

from my understanding, if you had a question, and that question is suitable for SO, and not already on SO, its a-okay to "ask" SO, and then answer your own question

BarqsDew · 26 points · Posted at 15:40:01 on July 7, 2016 · (Permalink)

and not already on SO

And therein lies the problem.

CircleOfLife3 · 4 points · Posted at 15:41:10 on July 7, 2016 · (Permalink)

Don't you need like 100 points to answer questions?

ryanplant-au · 8 points · Posted at 16:20:48 on July 7, 2016 · (Permalink)

Not if you're answering your own question. There's an option directly on the submit page to submit the answer and the question at the same time, which doesn't require a reputation.

DoodleFungus · 1 points · Posted at 15:43:29 on July 7, 2016 · (Permalink)

It is.

TheCodexx · 1 points · Posted at 03:00:36 on July 8, 2016 · (Permalink)

"Topic closed. Similar to this barely-relevant question for 2003. Please see refer there."

ryanplant-au · 6 points · Posted at 16:19:45 on July 7, 2016 · (Permalink)

and when we do, we solve them ourselves.

That's actually a good way to get started. There's an option on the submit page to answer your own question. Ask a question about the problem you solved and explain its solution in one move.

RommelTJ · 6 points · Posted at 17:17:51 on July 7, 2016 · (Permalink)

I'm a shitty programmer. While I agree with you, I've found the process of posting a question to SO to be a learning experience in and of itself in the sense that coming up with the correct question and framing it in a way that other people can read and understand it is helpful in coming up with a solution.

At the risk of showing off my ignorance, here are my questions on SO: http://stackoverflow.com/users/605688/rommeltj?tab=questions I could've come up with solutions on my own, but I've never regretted posting to SO because I think it's made me a better programmer.

It reminds me of the learn, do, teach method, where teaching others is the last step in mastery. I think ask, learn, do, teach is more accurate because without asking you may never know what to learn.

muzzio · 3 points · Posted at 16:37:09 on July 7, 2016 · (Permalink)

I didn't really find any questions to ask either until I got into iOS development. I think it just has to do with how mature your platform of choice is, really.

CWagner · 8 points · Posted at 16:42:16 on July 7, 2016 · (Permalink)

So far almost all my questions for SO had either already been answered or I found the solution while fleshing out the question to be as proper and complete as possible.

readercolin · 3 points · Posted at 17:55:58 on July 7, 2016 · (Permalink)

This has been much of my experience with SO. I have question, try to flesh it out as much as possible to give a proper question, and then realize what I was doing wrong.

That being said, SO does make an excellent rubber ducky.

CWagner · 2 points · Posted at 19:25:26 on July 7, 2016 · (Permalink)

That being said, SO does make an excellent rubber ducky.

Yeah, without it I wouldn't have thought about my question in a different way :D

smog_alado · 1 points · Posted at 19:54:45 on July 7, 2016 · (Permalink)

If the question is not on SO already, you can still ask it and then immediately answer your own question. This way you help other people that come across the same problem in the future and there is also a chance that someone comes up with a different answer you didn't think about.

CWagner · 2 points · Posted at 19:57:07 on July 7, 2016 · (Permalink)

Hm, hadn't thought of that. I'll try to keep it in mind, thanks :)

salgat · 4 points · Posted at 15:31:56 on July 7, 2016 · (Permalink)

This question already has an answer here:

Gotta avoid duplicate questions, which makes a lot of questions pretty specific now.

Paradox · 3 points · Posted at 15:32:54 on July 7, 2016 · (Permalink)

More of "I'll ask stackoverflow, but let me googl... Oh"

stratoscope · 21 points · Posted at 16:55:00 on July 7, 2016 · (Permalink)

You just need this one weird trick:

Write a sketchy answer as fast as you can, something that answers the question in a minimal way but is still reasonably correct. Post it immediately. Then edit your answer to make it better. Post your work as you go. Keep doing this, amplifying and explaining your answer to turn it into something actually useful. And keep posting each improvement as soon as you can.

The only thing you have to watch out for here is posting something actually bad that will receive downvotes. But as long as your work-in-progress versions of the answer are reasonable, you should be OK.

Slerig · 25 points · Posted at 19:41:33 on July 7, 2016 · (Permalink)

Have you ever considered working for Buzzfeed?

hungry4pie · 9 points · Posted at 23:35:19 on July 7, 2016 · (Permalink)

Programmers hate him

oelsen · 3 points · Posted at 23:03:31 on July 7, 2016 · (Permalink)

That was a painful post.

katarh · 13 points · Posted at 18:10:25 on July 7, 2016 · (Permalink)

So... an iterative answer?

Decker108 · 3 points · Posted at 02:56:22 on July 8, 2016 · (Permalink)

Just standard SO gamification bullshit.

jeffsterlive · 2 points · Posted at 01:08:43 on July 8, 2016 · (Permalink)

Sounds recursive to me. Perhaps tail recursion.

payne_train · 2 points · Posted at 03:04:12 on July 8, 2016 · (Permalink)

I hear he has to break down his answers into release trains

stratoscope · 2 points · Posted at 06:12:39 on July 8, 2016 · (Permalink)

Have you ever considered working for Buzzfeed?

I hadn't considered that before, but thank you for suggesting it.

In fact, your comment changed my life. You won't believe what happened next!

fiskfisk · 3 points · Posted at 20:22:17 on July 7, 2016 · (Permalink)

Go for a smeller community for a technology you know well or want to learn about, instead of trying to give answers to massive tags like 'python'. I'm active in the Solr tag, and most questions take a day or two to get decent answers.

jeffsterlive · 1 points · Posted at 01:09:47 on July 8, 2016 · (Permalink)

I know developers have a bad stereotype as being smelly basement dwellers that play too much Starcraft and troll the Internet with memes, but I wear deodorant!

danillonunes · 2 points · Posted at 00:20:03 on July 8, 2016 · (Permalink)

That’s basically why I have an 5 yrs old SO account with no reputation.

A LOT of times I have some useful comments to make or find a better answer buried deep down, but I can’t do anything because SO system thinks one needs more reputation to upvote or comment an existing answer than to actually write one by himself.

colonwqbang · 0 points · Posted at 14:31:52 on July 8, 2016 · (Permalink)

So the problem with stack overflow is that questions get answered too quickly and too well?

[deleted] · 20 points · Posted at 13:45:16 on July 7, 2016 · (Permalink)

dumb question, but what should I use instead of array list in .net then? It's basically what I've been taught to use.

Minikloon · 46 points · Posted at 14:18:42 on July 7, 2016 · (Permalink)

You should use List<>. ArrayList is the non-generic version from before .NET introduced generics.

jquintus · 33 points · Posted at 15:54:31 on July 7, 2016 · (Permalink)

A little more explanation.

in .Net 1.1 the only options were ArrayList which is an untyped collection. This means that in order to get anything out of an ArrayList you'd have to cast it back to the type you want.

In .Net 2.0 they introduced generics which allowed you to parameterize the type. This means that your collection is strongly typed.

List<int> examples

List<int> numbers = new List<int>(){ 0, 1, 2, 3, 4 };
numbers.Add(5);

int two = numbers[2];

numbers.Add("six");  // This results in a compilation error

ArrayList examples

ArrayList numbers = new ArrayList();
numbers.Add(0);
numbers.Add(1);
numbers.Add("two");  // numbers now contains:  0, 1, "two"

int one = numbers[1];  // This results in a compiler error since numbers[1] is an object, not an int

int two = (int)numbers[2]; // Runtime error:  Specified cast is not valid.
Stop_Sign · 1 points · Posted at 21:39:07 on July 7, 2016 · (Permalink)

int two = (int)numbers[2];

int two = int.Parse(numbers[2]);

jquintus · 5 points · Posted at 23:04:29 on July 7, 2016 · (Permalink)
int two = int.Parse(numbers[2].ToString());

numbers[2] is an object. Parse takes a string.

calantorntain · 14 points · Posted at 14:19:57 on July 7, 2016 · (Permalink)

List<T>, probably.

[deleted] · 1 points · Posted at 22:54:51 on July 7, 2016 · (Permalink)

As many have mentioned, you can use generic forms of most collections: List<T>, Stack<T>, Queue<T>, Dictionary<K,V>, etc.

Those are fine for storing data within your classes and objects.

However, for methods and constructors you should try to use generic interfaces as possible. These include IEnumerable<T>, IList<T>, ICollection<T>.

The primary reason is that several collections all implement these interfaces so if you take them as input it allows your methods to be more versatile.

That combined with the power of LINQ will really make you appreciate how far C# has come as a language.

dust4ngel · -1 points · Posted at 22:10:58 on July 7, 2016 · (Permalink)

ArrayList is still legit wherever you'd use List<object>.

but you'd almost never use List<object>.

ilikzfoodz · 1 points · Posted at 03:33:47 on July 8, 2016 · (Permalink)

Not really any advantage to doing that. As a new C#/.NET developer I didn't even know ArrayList existed until seeing it here, so I'd be confused if I saw an ArrayList

dust4ngel · 1 points · Posted at 15:52:38 on July 8, 2016 · (Permalink)

i agree that there's no advantage. i had assumed that they were equivalent, but it turns out there are some real disadvantages to using ArrayList, namely memory requirements and multithreading performance. TIL.

cornpie2 · 13 points · Posted at 13:31:34 on July 7, 2016 · (Permalink)*

Might be a dumb question, but I wonder, how do you actually get to the point where you know those things? I follow different tech news site, but I feel like I'm not following the right things. Where should I keep myself up to date for a given language? I guess the release notes is a good start, but it feels I'm always behind the curve.

*And when I find documentation, I often learn later on that it was actually legacy stuff.

lobax · 9 points · Posted at 21:20:06 on July 7, 2016 · (Permalink)

Isn't always being behind the curve part of being a programmer?

Everything in IT is changing rapidly all the time, and I think it's just a healthy attitude to assume that you might have to relearn the tools you use every few years.

Decker108 · 1 points · Posted at 02:58:36 on July 8, 2016 · (Permalink)

Or if you work in javascript: every few weeks.

FarkCookies · 8 points · Posted at 16:18:59 on July 7, 2016 · (Permalink)

Best book to start with C#/.net is CLR via C#. And to keep yourself up to date you can read MS articles about new features in new versions of C# / .net.

[deleted] · 11 points · Posted at 14:47:27 on July 7, 2016 · (Permalink)

Follow blogs made by the creators of the specific framework. They tend to talk about their own framework a lot in great detail. It's insightful.

[deleted] · 1 points · Posted at 22:44:26 on July 7, 2016 · (Permalink)

Lots of good responses and it's very true that it's not easy to keep on top of everything in the programming world.

I would consider .NET my principal language (though I work in it far less lately), so I pay closer attention to the MS news and community blogs.

The best way to learn about new features is to read about them (googling and sort by newest), and playing around with the language yourself.

If you're already familiar with a language, look into to more advanced (or specialty) books for it. In the context of .NET, the Effective C# series is great as well as Stephen Cleary's book on concurrency.

DSdavidDS · 1 points · Posted at 16:17:11 on July 7, 2016 · (Permalink)

I understood the nodejs part because I spent time over the the last two summers trying to learn node and callbacks.

I understood part of pearl because I learned assembly last semester.

My point is, without attempting to learn, I never would have understood a lot of the stuff on that page. Keep learning and I think you should be able to put pieces together!

gravityGradient · 7 points · Posted at 15:04:18 on July 7, 2016 · (Permalink)

oh oh. just implemented background workers in an app. Stand by. googling alternatives.

Jdwonder · 12 points · Posted at 15:27:00 on July 7, 2016 · (Permalink)
gravityGradient · 1 points · Posted at 15:44:44 on July 7, 2016 · (Permalink)

the tpl dataflow model ftw. I've been parsing packets using a mix of background workers and calls to update the ui threas.

this might make my life easier. thankks.

Silound · 7 points · Posted at 16:19:57 on July 7, 2016 · (Permalink)

I've seen lots of answers which use legacy (1.1. or 2.0) techniques to solve modern issues. Like people suggesting you should use ArrayList or BackgroundWorker in 4.0+ code.

Languages evolve and it saddens me when people are quick to resound with answers that are already outdated.

As a .NET dev, I fully understand where you're coming from on this, but even with shiny new ways to do something, sometimes the old tricks are perfectly acceptable answers in that they work exactly the way they were designed.

To specifically take BackgroundWorker as an example, I saw an SO post where someone was asking how to process a task in the background of a WinForms application and update a status bar with progress. WinForms is not exactly hot new stuff, right? The top answer, before the question was closed and buried, was how to use async/await to write a routine that did the processing work and how to hook the response into events that trigger a redraw, thus updating the UI for the user....this is for Win-freaking-Forms! BGWorker was practically designed for this purpose!

xzxzzx · 3 points · Posted at 17:30:27 on July 7, 2016 · (Permalink)

I don't see what's wrong with async/await as an answer here. Task.Run() and the Progress class makes what you're describing about the same complexity as using a BackgroundWorker, and async/await has benefits that BackgroundWorker does not.

Silound · 4 points · Posted at 18:36:20 on July 7, 2016 · (Permalink)

There's nothing wrong with it as an answer. I agree that async/await is a totally viable answer.

My issue is that it was presented as the only solution that should ever be used, which is a poor response, especially if the original poster asking the question had no experience with asynchronous coding and really only needed a simple UI update. BackgroundWorker was purpose built for situations like relieving the main thread of a potentially long-running synchronous block of code that could stall UI updates. I admit, many people who don't understand asynchronous programming really misuse BackgroundWorker for all sorts of crazy things, but like most things in .NET, there are multiple ways of arriving at a desired outcome, some more flexible and some more specific than others.

[deleted] · 2 points · Posted at 18:23:40 on July 7, 2016 · (Permalink)

BackgroundWorker

Nice, I didn't know that, I'm from the 1.0 era and we used to handle this ourselves.

ender89 · 3 points · Posted at 16:16:17 on July 7, 2016 · (Permalink)

As someone who programs in .net for a Windows CE platform with .net 2.0, I love those people with all my heart.

[deleted] · 1 points · Posted at 22:47:55 on July 7, 2016 · (Permalink)

Haha I'm sure you do. At one of my previous gigs I was doing iOS development but had a colleague who was stuck with CE apps. He shared several tales of frustration about "well that answer is great and all but doesn't work on CE..."

I'd often lend him a hand with my .NET expertise where I could. One day he was frustrated because BackgroundWorker is not available on CE, and it was exactly what he needed in component form. I ended up writing him a drop in replacement that worked on CE.

ender89 · 1 points · Posted at 00:49:13 on July 8, 2016 · (Permalink)

I make do with normal threading and invokes, it's really not overly complicated. Often I'll just build a thing myself without even bothering to see if window CE supports something, like one time I needed a timer for a project and I wrote a background thread to update the ui every second and only realized that windows CE has a perfectly good timer event I could have used after the project was finished and deployed.

steakyfask · 1 points · Posted at 16:44:00 on July 7, 2016 · (Permalink)

It's the poor effort that most people fail to put in. Non of us would have made it as programmers if we couldn't work out simple loops. Some people just want ze codez and don't care how it works.

vijeno · 2 points · Posted at 19:03:11 on July 7, 2016 · (Permalink)

The real issue is when people like that become actual programmers, and then I have to put up with their moronic code. I had that happen about twice in my career, and most people I met are at least as good at me, and quite often better, so I consider myself blessed. But the code I have to work with in my current and last job is just abysmal. We really should try and discourage people like that from becoming programmers.

rageingnonsense · 3 points · Posted at 19:12:49 on July 7, 2016 · (Permalink)

I feel like my entire career has consisted of cleaning up the spilt milk of poor programming.

Empha · 1 points · Posted at 23:35:07 on July 7, 2016 · (Permalink)

I think in a lot of cases, being simple would make it the best answer.

TheCodexx · 1 points · Posted at 02:58:40 on July 8, 2016 · (Permalink)

Sure, but sometimes you only need a simple solution, or one that will work on most configurations. The "correct" simply might not be appropriate for a beginner, or easy to explain, or... there's any number of reasons that you might use something that's not longer standard but still a core part of the language.

1RedOne · 1 points · Posted at 03:53:20 on July 8, 2016 · (Permalink)

Whoa whoa whoa, why the fuck should I not use array list?

RualStorge · 1 points · Posted at 05:09:45 on July 8, 2016 · (Permalink)

I used to contribute a lot on SO with .NET. Got tired of "okay, to do this the current best practice it..." (writes like five lines of code explaining in detail what each line does) Then the one that is accepted is open nuget, add package "NoSeriouslyDontUseThis" and it's 12 dependencies, convert object to json, use package's non descriptive "process" method, convert results back to your object, wrap in a try catch, if catch then throw... eye spasms

Seems like every reasonable question gets the proper way to fix something as second or third response, decent upvotes, but some atrocity that should never again be spoken of takes the lead, once it gets that green check it surges to the top, even in cases where it doesn't actually even work... (all that said, I still hop on SO on occasion, but I don't respond to much anymore unless something is particularly interesting to me.)

[deleted] · 68 points · Posted at 15:35:32 on July 7, 2016 · (Permalink)*

[deleted]

SanityInAnarchy · 19 points · Posted at 18:32:48 on July 7, 2016 · (Permalink)

To be fair, there are a ton of XY problems out there. There's a reason StackOverflow's canonical answer to using regex to parse HTML is what it is.

Maybe people are sometimes a little over-zealous, but sometimes there isn't actually a good answer to "Why would you want to do that?"

[deleted] · 16 points · Posted at 18:55:57 on July 7, 2016 · (Permalink)*

[deleted]

chrono_sphere · 6 points · Posted at 01:41:25 on July 8, 2016 · (Permalink)

If there is an general 'best practice' that you are know you are violating, I think it's best for all if you preemptively explain why you're not taking the usual route in the question.

It's helpful for answerers so they don't have to call out the 'XY problem', but crucially, it's also there for beginners that stumble on the question later and makes sure they don't adopt a hacky workaround which was very specific to circumstances that you may not wish to fully explain on the question.

Stack Overflow has the goal of being a curated knowledge library as well as a Q&A medium, so I personally think it makes good sense that the general recommended approach to a problem is addressed in some way in either the question or the accepted answer.

Veedrac · 2 points · Posted at 01:54:25 on July 8, 2016 · (Permalink)*
Winter_already_came · 2 points · Posted at 09:38:26 on July 8, 2016 · (Permalink)

About JQuery I usually find the opposite. I want to do shit in vanilla js and the answers i get are "you can do this with jquery"

SanityInAnarchy · 4 points · Posted at 06:30:14 on July 8, 2016 · (Permalink)

And the XY Problem is far too referenced. The fact is you don't know if it's an XY Problem because you don't know the full context.

That's the fucking point of the XY problem. The reason you're getting referred to the XY problem is that you didn't give enough context for people to understand what you're asking. If you state your problem clearly enough -- if you show us both X and what you think your best Y is -- then you should expect people to show up with solutions for Y. But you've got a textbook case here of just showing us Y, without even hinting at what X might be:

If I ask how to parse a PDF in Javascript, I don't give a shit to hear "There are a lot of Java libraries for that. You should just use iText bc of whatever bullshit reason".

This is a classic XY problem. Insisting that you just use iText instead isn't a great answer (especially now that it's AGPL), but I'm not convinced linking to pdf.js with no context is the best answer, either. For example, if you have a PDF that you want to render in the middle of a website, you might be better off just putting it in an iframe and letting the browser deal with it -- PDF.js doesn't have the best cross-browser compatibility yet. On the other hand, if you need to generate a PDF from a website, PDF.js is much more focused on parsing and displaying than it is on generating PDFs, and you would probably be much better served by jsPDF. Plus, Chrome has "print to PDF" built in, do you really need to do it yourself in JavaScript instead?

I'm not saying you need to write out your life story when asking this question. But you should at least explain why you want to do it with JavaScript, at least to the point where you're saying "I want to do it in the browser."

You give more context later:

But what if your program isn't written in Java and your company doesn't want to run Java on the server just for that one part of the program.

First, notice how this is an entirely different question than "How do I generate PDFs in the browser without a plugin?" For example, if I told you there was a C library with proper Node.JS bindings in NPM, would your company be happy with that, or would you insist on pure JavaScript? Most Node shops would be happy, because there's already plenty of other places you need to do that anyway. Many would be happy with a server that already had JS bindings -- after all, your database probably isn't written in JavaScript either.

And sometimes, the best answer is still "You really, really should use this library, even though it's in the wrong language." For awhile, the correct answer to "How do I do fulltext search in a language other than Java?" was "Figure out how to connect to Java anyway, so you can run Lucene, because it's by far better than anything your language can run, and well worth the operational headache."

That's why you state your X. Even if you're sure that you have the correct Y, context will at worst clarify so people give a more accurate answer.

But also, try to stay a little humble. That guy asking the HTML Regex question was pretty confident he had the correct Y.

toomanybeersies · 1 points · Posted at 21:23:58 on July 7, 2016 · (Permalink)

What a shit thread. There's actually only one good answer there, it's the third one down, and it's just a link to the relevant wiki articles without actually explaining why it's not possible.

SanityInAnarchy · 1 points · Posted at 05:32:08 on July 8, 2016 · (Permalink)

True, it's not the best answer, but it's a peek into what happens to someone's mind when they answer the same XY question so many times.

The third answer isn't far off, though -- it's probably not appropriate to explain exactly how, though it would be useful to elaborate that those wiki articles mean it's mathematically impossible to parse regex with HTML.

[deleted] · 2 points · Posted at 16:11:59 on July 7, 2016 · (Permalink)

A lot of my answer which was you should do instead received good reception.

In particular the famous one: how can I have dynamic name for variable in python ?

ClimbingC · 10 points · Posted at 16:35:41 on July 7, 2016 · (Permalink)

I love the SO threads that simply claim "You should have searched for this, this is a repeat of x". Yet that is the page google sent to you. Managed to go down a rabbit hole once, where a "This is a repeat of Y" comment linked to another "This is a repeat question" and on for about 5 links, it was like a reddit switcheroo chain.

rageingnonsense · 3 points · Posted at 19:17:37 on July 7, 2016 · (Permalink)

I only like these responses if they are preceded with a direct answer to the question at hand. It is infinitely frustrating when you are trying to resolve some small issue, and you have your reasons why you are doing it that way, but someone on SO is arguing with you that you should do it this other way.

Rarely is ever does an SO question show the full context of the entire application. There may very well be a specific reason why it needs to be done this way, like a business requirement, or some drawback in the application architecture that you are stuck with.

I want to see "well this is how you do it. That being said, have you considered doing it this other way instead?". I don't want to see "Why are you even doing that? don't do that do this".

srilyk · 2 points · Posted at 20:54:51 on July 7, 2016 · (Permalink)

I, as an OP, have occasionally been stuck with a requirement to do a thing a certain way (actually, now that I think about it the only times I've really been stuck with that requirement is because I was trying to satisfy my own curiosity). And I've stated such in my question. Something to the effect of:

I know this is probably a stupid way to do things, I'm just interested to see if it can be done.

or

I'm dealing with some horrible, no good, very bad code that does some very weird things. So now I'm left with these pieces that don't fit together. What duct tape and baling wire do I need to use to put them together?

I've never had a bad result asking that way.

lynyrd_cohyn · 1 points · Posted at 21:59:25 on July 7, 2016 · (Permalink)

Any chance of a link? That sounds funny.

(I did try and solve the problem myself first, using Google. Here's another page on the topic but it lacks the snark I would expect from the SO version)

[deleted] · 2 points · Posted at 09:53:25 on July 8, 2016 · (Permalink)
lynyrd_cohyn · 1 points · Posted at 11:21:50 on July 8, 2016 · (Permalink)

Thank you!

mikeash · 5 points · Posted at 15:57:55 on July 7, 2016 · (Permalink)

In my experience (I rarely touch SO, but I've seen similar things in other places), it's often because <simple task> is only simple in its result or action, but is complex in its implementation. Or it's only simple if you ignore edge cases or errors.

But yes, sometimes it really is simple, and complex answers come out anyway.

maxd · 4 points · Posted at 15:59:14 on July 7, 2016 · (Permalink)

Thought you mean "significant other".

"Hey baby, how do I do the laundry?"

TinynDP · 3 points · Posted at 18:25:02 on July 7, 2016 · (Permalink)

"simple task" leaves out all context. So you get answers for all possible contexts.

pohatu · 2 points · Posted at 16:50:31 on July 7, 2016 · (Permalink)

There was a pretty good rant making the rounds recently about JavaScript frameworks. To do anything, even write smile n times you need to first create the universe. This sort of reminds me of that.

[deleted] · 2 points · Posted at 18:13:29 on July 7, 2016 · (Permalink)

[deleted]

rageingnonsense · 2 points · Posted at 19:24:27 on July 7, 2016 · (Permalink)

I think it is fair to warn people of their terrible decisions, but also answer the question. Otherwise you are not helping at all.

NoMoreNicksLeft · 1 points · Posted at 17:26:52 on July 7, 2016 · (Permalink)

For the last few months, I've been seeing threads here complaining about SO. I usually defend it, as it seemed to me that these criticisms weren't all that valid... SO just doesn't seem to be a place that's very toxic. Ask questions or give answers in good faith, and it looked like the worst that could happen would be that they were ignored.

But since then, it's just been brutal on me. If I dare ask something that can't be answered with simple research, it seems like I'm being punished by those trying to rep farm.

If all you're getting is bad answers there... you're doing better than I am.

rageingnonsense · 2 points · Posted at 19:22:54 on July 7, 2016 · (Permalink)

It's luck of the draw. One time, a few years ago, I have a mysterious issue where a particular COM Add-In I was tasked with making. It would reliably, without fail, cause me to BSOD when I used a certain function of it. I was having enormous trouble trying to figure out on my own wtf was causing it. I turn to SO...

All I get is "That is not possible; you can't BSOD in modern version of windows from usercode." and things liek that. Well that's not true asshole, because I am and it is happening reliably! Why would I have even asked the question if it was not happening?

In the end, it the issue resovled itself afterI got desperate and ran some windows updates. Who knows what the hell it updated, but whatever it was fixed the issue. The point though is that instead of seeing the question and just moving along, people wasted their time telling me that it is not possible.

ltran96 · 1 points · Posted at 19:16:02 on July 7, 2016 · (Permalink)

To be fair, it was a very low effort question. He was asking us to do his homework for him.

[deleted] · 1 points · Posted at 19:34:52 on July 7, 2016 · (Permalink)

I think there's a difference between asking a simple question and asking someone to do your homework for you.

Artillect · 1 points · Posted at 01:38:23 on July 8, 2016 · (Permalink)

You forgot your question being locked for some obscure reason which isn't covered anywhere.

im-a-koala · 1 points · Posted at 02:21:16 on July 8, 2016 · (Permalink)

I feel like most of my SO (and related site) experience involves having questions closed as duplicates when the "duplicate" is asking something completely different.

And being unable to clarify something with a comment because I don't live on SO.

m1el · 104 points · Posted at 12:03:34 on July 7, 2016 · (Permalink)

Tbh, the top answer in perl is too concise.

DinosaurEggnog · 28 points · Posted at 14:27:01 on July 7, 2016 · (Permalink)

It's hard for me to read PERL that's more than one line. DWE RegEx?

wasdninja · 52 points · Posted at 19:20:30 on July 7, 2016 · (Permalink)

Nobody can read perl except the author of that particular piece of code and that only last until next week, regardless of rigorousness of the comments.

StenSoft · 7 points · Posted at 21:23:54 on July 7, 2016 · (Permalink)

I would say it's too verbose and easy to read. With proper Perl code, you can't distinguish between plain text and encrypted version.

gin_and_toxic · 5 points · Posted at 15:48:13 on July 7, 2016 · (Permalink)

Need to make the code the shape of a smile, like the camel code.

frezik · 1 points · Posted at 03:46:57 on July 8, 2016 · (Permalink)

If you want a real answer:

say "Smile!" x $n

Where $n is set to the number of smiles to output. Or, if you want to avoid the x operator:

print "Smile!" for 1..$n;
print "\n";

Building a convoluted list of ASCII values, as in the Perl solution there, would look ugly in any language.

dspeyer · 1 points · Posted at 06:03:45 on July 8, 2016 · (Permalink)

Part of the appeal of perl is that it's concise. By making every character valid at every position, it maximizes the per-byte information and minimizes the bytes needed.

gastropner · 37 points · Posted at 15:06:26 on July 7, 2016 · (Permalink)

Why one language per answer when you can do three?

mindbleach · 52 points · Posted at 15:56:18 on July 7, 2016 · (Permalink)

I love how the syntax highlighting is like "I dunno, man, you're on your own."

Garbaz · 7 points · Posted at 20:23:46 on July 7, 2016 · (Permalink)

You could add Whitespace.

gastropner · 2 points · Posted at 20:46:16 on July 7, 2016 · (Permalink)

Hm. Yes, shouldn't be too hard. The machine code part on the first line has six spaces, which - if I understand Whitespace correctly - should do nothing worse than push the number 4 onto the stack. Whitespace programs can exit prematurely, so it can all fit into the part before the next preprocessor statement, without fear of unwanted statements in the rest of the file.

1RedOne · 1 points · Posted at 04:02:55 on July 8, 2016 · (Permalink)

That looks like super messed up PowerShell code. Was that just weird af C#?

gastropner · 2 points · Posted at 09:09:24 on July 8, 2016 · (Permalink)

It is three things; C code, PowerShell script, and a .COM DOS executable. Just rename file as needed.

Altreus · 69 points · Posted at 15:00:28 on July 7, 2016 · (Permalink)

A Perl programmer with a PhD not using strict and warnings? Is it 2004?

workpuppy · 53 points · Posted at 17:10:17 on July 7, 2016 · (Permalink)

Strict and warnings on obfuscated code? That completely defeats the purpose.

Altreus · 0 points · Posted at 23:21:19 on July 7, 2016 · (Permalink)

That's not obfuscated...

Makars · 1 points · Posted at 06:30:08 on July 8, 2016 · (Permalink)

It is to someone asking to have their "hello world" homework done for then

[deleted] · 14 points · Posted at 16:33:51 on July 7, 2016 · (Permalink)*

[deleted]

workpuppy · 33 points · Posted at 17:11:05 on July 7, 2016 · (Permalink)

Perl is amazing! It's just other people's Perl that sucks.

giantsparklerobot · 13 points · Posted at 17:00:45 on July 7, 2016 · (Permalink)

IT WAS ALL WE HAD FOR CGI! Well not all we had for CGI but it was common on commercial Unix machines running the web early on. Servers didn't tend to have compilers installed so you couldn't write CGI programs in C or Fortran. No (few?) commercial Unixes shipped Python by default and PHP wasn't a thing yet. This left Perl, bash, and TCL for CGI on most machines.

Perl was already popular as a glue language so when it came to putting programs on the web via CGI Perl was an obvious choice. It could do all the same gluing as on workstations but spit HTML to stdout.

[deleted] · 7 points · Posted at 17:14:59 on July 7, 2016 · (Permalink)

Oh, I understand. I work every day on Unix systems that only offer Perl as a programming language, and I'm not allowed to install so much as a C compiler. So my choice is Perl, Awk, or Tcl for any of my sysadmin work. I hate Perl, but I am heavily versed in it. It's all I have to work with, which makes me hate it more.

indrora · 6 points · Posted at 22:22:04 on July 7, 2016 · (Permalink)

Learn you Awk. Seriously, go do it if you don't already know how to use it. I write awk oneliners to grab stuff all the time. Hell, I've even written awk that eats INI files and turns them into XML.

That was a bad day.

[deleted] · 2 points · Posted at 22:37:14 on July 7, 2016 · (Permalink)

I use awk all the time. Awk is fantastic, but it's really bad when you need to write any large programs (Perl is also horrible for this, but minimally less so). Most of the Perl things I need to write have to parse command line parameters and/or configuration files, and frequently have to send emails as well.

Berberberber · 1 points · Posted at 07:40:24 on July 8, 2016 · (Permalink)

Write a C compiler in Perl, duh.

Decker108 · 3 points · Posted at 03:02:51 on July 8, 2016 · (Permalink)

Perl, bash or TCL? Man.... talk about "pick your poison"!

giantsparklerobot · 1 points · Posted at 03:36:16 on July 8, 2016 · (Permalink)

As I've made good money writing Perl and have managed to write good Perl, I can't really bash it much. If you don't go nuts with "high magic" syntax, factor your scripts sanely, and enforce coding conventions in the organization then Perl is a great language. It's powerful out of the box and CPAN set the bar for all library repositories that have some since. It gets a bad reputation from people that go crazy with "high magic", i.e. lots of shorthand and magic operators, rather than trying to write readable code. The TMTOWTDI philosophy leads to technical debt and maintenance nightmares.

Decker108 · 1 points · Posted at 09:42:04 on July 8, 2016 · (Permalink)

Right. If I had to choose between the three aforementioned for a large-ish project, I would probably have gone with Perl as well.

mak12 · 2 points · Posted at 00:06:51 on July 8, 2016 · (Permalink)

Oh god TCL. Thank you for the nightmares.

GotPerl · 5 points · Posted at 15:41:01 on July 7, 2016 · (Permalink)

I knew my username would be relevant one day!

smookykins · 2 points · Posted at 20:31:09 on July 7, 2016 · (Permalink)

And that day was sometime in 1998.

GotPerl · 1 points · Posted at 23:43:38 on July 7, 2016 · (Permalink)

1999 actually. I went the the Perl conference in Monterey that year and made a bunch of Got Perl? t-shirts and sold them for $20 each. Thats where it came from

[deleted] · 0 points · Posted at 21:01:58 on July 7, 2016 · (Permalink)

and that day was sometime in 1998.

klezmai · 36 points · Posted at 16:31:31 on July 7, 2016 · (Permalink)

"I believe that what the poster is really waiting for is a solution in Malbolge."

ta872016 · 3 points · Posted at 06:54:52 on July 8, 2016 · (Permalink)

well here.

zelnoth · 1 points · Posted at 10:13:10 on July 8, 2016 · (Permalink)

It would have been really funny to turn in a homework assignment in malbolge. I wanted to, but we never really got anything as simple as this to start with.

[deleted] · 81 points · Posted at 19:04:34 on July 7, 2016 · (Permalink)*

[deleted]

ostracize · 15 points · Posted at 19:53:45 on July 7, 2016 · (Permalink)

I think your fully commented version is much more amusing.

[deleted] · 11 points · Posted at 00:59:39 on July 8, 2016 · (Permalink)

I almost feel sorry for you for knowing so much about Perl.

Just kidding. That is damn impressive!

enry_straker · 2 points · Posted at 09:33:57 on July 8, 2016 · (Permalink)

It has more to do with bases and bit operations than perl per se - but still kudos to /u/vsTerminus for taking the time and the trouble to break it down so nicely.

[deleted] · 1 points · Posted at 12:32:42 on July 8, 2016 · (Permalink)

[deleted]

CantHearYouBotEX · 3 points · Posted at 12:33:02 on July 8, 2016 · (Permalink)

IF ANYONE WANTS AN EXPLANATION FOR THE PERL CODE, YOU HAVE TO PROMISE NOT TO CRUCIFY ME FOR USING INCORRECT TERMINOLOGY OR POOR COMPARISONS TO EXPLAIN CONCEPTS. THIS IS INTENTIONALLY OVERSIMPLIFIED, AND YET STILL ASSUMES YOU HAVE SOME BASELINE KNOWLEDGE IN BASES (BINARY, HEXADECIMAL, OCTAL, DECIMAL) AND BITWISE OPERATIONS.

FEEL FREE TO CORRECT ANYTHING I AM MISTAKEN ABOUT, BUT DO REMEMBER THAT IT IS OVERSIMPLIFIED ON PURPOSE.

HERE'S THE RAW ANSWER:

#!/USR/BIN/PERL

$HELL = SUB { $O=""; FOREACH(@{$[0]}) { $O .= CHR($); } RETURN $O; };

$Z = 0B100;

$X = [0123];

$X->[1] = 0X6D;

$X->[2] = $$X[1] & ~$Z;

PUSH @$X, @$X[1,2];

$Y = \$$X[$Z];

$X->[0B11]--;

$$Y -= $Z;

$X->[05] = (666>>$Z)-($Z<<1);

WHILE(--$Z) { FOR(1..$Z) { PRINT $HELL->($X); } PRINT $/; }

AND HERE IT IS WITH A FEW NEWLINES ADDED, AND A FEW VERY BASIC COMMENTS

#!/USR/BIN/PERL

# THIS FUNCTION BUILDS THE "SMILE!" STRING AND RETURNS IT TO THE CALLER.

$HELL = SUB

{

$O="";

FOREACH(@{$_[0]})

{

$O .= CHR($_);

}

RETURN $O;

};

# THIS BLOCK BUILDS AN ARRAYREF CONTAINING THE ASCII DECIMAL VALUES FOR THE PHRASE "SMILE!"

$Z = 0B100;

$X = [0123];

$X->[1] = 0X6D;

$X->[2] = $$X[1] & ~$Z;

PUSH @$X, @$X[1,2];

$Y = \$$X[$Z];

$X->[0B11]--;

$$Y -= $Z;

$X->[05] = (666>>$Z)-($Z<<1);

# THIS LOOP IS RESPONSIBLE FOR CALLING THE FUNCTION AT THE TOP THE CORRECT NUMBER OF TIMES PER LINE

# AND FOR THE CORRECT NUMBER OF LINES.

WHILE(--$Z)

{

FOR(1..$Z)

{

PRINT $HELL->($X);

}

PRINT $/;

}

NOW LET'S GO THROUGH AND EXPLAIN IT.

#!/USR/BIN/PERL

# THIS IS A SUBROUTINE. WHILE IT DOESN'T SPECIFICALLY PRINT "SMILE!" AND ONLY "SMILE!",

# IT CAN BE USED TO ACCOMPLISH THIS GOAL.

# THE SUBROUTINE ITSELF SIMPLY ACCEPTS AN ARRAY OF CHARACTERS AND CONCATENATES THEM INTO A SINGLE STRING

# VARIABLE, WHICH IT THEN RETURNS TO THE CALLER.

$HELL = SUB

{

$O=""; # START WITH AN EMPTY STRING

# FOREACH CHARACTER IN THE ARRAY

# $_ IS A SPECIAL VARIABLE THAT REFERS TO A DEFAULT ARGUMENT OR SEARCH SPACE.

# IT CAN BE USED ALL OVER THE PLACE, BUT HERE IT REFERS TO AN ARRAY OF ARGUMENTS PASSED INTO THE FUNCTION.

# $_[0] IS THE FIRST ARGUMENT, WHICH WILL BE AN ARRAY REF CONTAINING 6 ELEMENTS. MORE ON THAT LATER.

# @{ $_[0] } ALLOWS US TO TREAT THE REFERENCE AS AN ARRAY SO IT CAN BE GIVEN TO

# THE FOREACH LOOP TO PROCESS ONE AT A TIME.

FOREACH ( @{ $_[0] } )

{

# THE CHR FUNCTION TAKES A NUMERICAL VALUE AND RETURNS THE EQUIVALENT CHARACTER.

# THIS CHARACTER IS APPENDED TO $O

$O .= CHR( $_ );

}

# ONCE ALL NUMBERS WITHIN THE ARRAY REF HAVE BEEN CONVERTED TO CHARACTERS AND

# APPENDED TO THE $O STRING, RETURN IT TO THE CALLER.

RETURN $O;

};

# THE SAME WAY YOU WOULD WRITE "0X____" TO DENOTE HEXADECIMAL, YOU CAN USE

# "0B____" TO DENOTE BINARY. 100 IN BINARY IS 4 IN DECIMAL.

# THIS ESSENTIALLY READS $Z = 4, AND IS OUR LOOP COUNTER, CONTROLLING HOW MANY LINES OF SMILES WE PRINT.

$Z = 0B100;

# $X IS INITIALLY DEFINED AS AN ARRAY REFERENCE CONTAINING ONLY THE VALUE 0123 IN POSITION ZERO

# FOR YOU C DEVS, IT'S KIND OF LIKE USING A POINTER.

# THE INTERESTING THING ABOUT 0123 IS THAT THE LEADING ZERO DENOTES THAT THIS IS IN OCTAL. OCT 123 = DEC 83

# SO OUR INITIAL ARRAY CONTAINS: [83]

$X = [0123];

# THE NEXT LINE DEFINES POSITION ONE OF THE ARRAY TO BE 0X6D

# 6D IN HEX IS 109 IN DECIMAL

# THE -> IS NECESSARY TO DEREFENCE THE ARRAY REFERENCE, JUST LIKE A C POINTER.

$X->[1] = 0X6D;

# THIS LINE DEFINES THE THIRD VALUE OF THE ARRAY (IN POSITION 2)

# $$X[1] IS A "SIMPLE SCALAR CONTAINING A REFERENCE", AND IS AN ALTERNATIVE WAY

# TO GET AT THE ARRAY ELEMENTS INSTEAD OF USING THE -> TO DEREFERENCE.

# UNARY "~" PERFORMS BITWISE NEGATION, THAT IS, 1'S COMPLEMENT.

# THE 1'S COMPLEMENT OF A BINARY NUMBER IS DEFINED AS THE VALUE OBTAINED

# BY INVERTING ALL THE BITS IN THE BINARY REPRESENTATION OF THE NUMBER (SWAPPING 0S FOR 1S AND VICE VERSA).

# IN THIS CASE, $$X[1] IS 0X6D OR 0B01101101 AND $Z IS 0B100 (4 IN DECIMAL)

# ~$Z (1'S COMPLEMENT) IS 0B011, EXCEPT BECAUSE CHARACTERS ARE 32 BITS AND

# THE OTHER 29 WERE ZEROES BEFORE, THEY ARE ONES NOW.

# THAT GIVES US 11111111111111111111111111111011, OR 4294967291 IN DECIMAL.

# SO NOW WE'RE DOING A BITWISE "AND" OPERATION ON THOSE TWO BINARY VALUES,

# MEANING ONLY POSITIONS WHERE BOTH NUMBERS CONTAIN A 1 REMAIN A 1, THE REST BECOME ZERO.

# 00000000000000000000000001101101

# & 11111111111111111111111111111011

# = 00000000000000000000000001101001

# AKA, 105 IN DECIMAL

$X->[2] = $$X[1] & ~$Z;

# SO NOW OUR ARRAY WITHIN $X CONTAINS: [83, 109, 105]

# THIS NEXT LINE JUST TAKES POSITIONS 1 AND 2 (109 AND 105) AND ADDS THEM TO THE END OF THE ARRAY,

# LEAVING US WITH [83, 109, 105, 109, 105]

# @$X IS JUST LIKE $$X[1] ABOVE, EXCEPT WE NEED TO ACCESS THE REFERENCE AS IF IT WERE AN ARRAY,

# NOT A SCALAR THIS TIME.

PUSH @$X, @$X[1,2];

# $Y IS ACCESSING POSITION 4 (REMEMBER $Z = 4) OF OUR ARRAY, BUT RATHER THAN COPYING THE VALUE,

# THE \ DENOTES A REFERENCE TO THE ACTUAL VARIABLE IN MEMORY.

# IN ESSENCE, CHANGING $Y CHANGES POSITION 4 OF OUR ARRAY (WHICH CURRENTLY CONTAINS THE VALUE 105)

$Y = \$$X[$Z];

# 0B11 IS 11 IN BINARY OR 3 IN DECIMAL.

# WE'RE SUBTRACTING 1 FROM THE VALUE IN POSITION 3 OF THE ARRAY (FROM 109 TO 108)

$X->[0B11]--;

# NOW WE'RE SUBTRACTING THE VALUE OF $Z (4) FROM $$Y, WHICH ALSO SUBTRACTS 4 FROM

# WHATEVER IS IN POSITION 4 OF THE ARRAY (FROM 105 TO 101)

$$Y -= $Z;

# THE ARRAY NOW LOOKS LIKE: [83, 109, 105, 108, 101]

# FINALLY, WE'RE GOING TO ADD A 6TH ELEMENT TO THE ARRAY ( IN POSITION 5 )

# >> AND << ARE BITWISE OPERATORS THAT SHIFT ALL OF THE BITS OVER BY ONE POSITION LEFT OR RIGHT.

# 666 IN DECIMAL IS 0000001010011010 AND WE ARE SHIFTING IT TO THE RIGHT BY $Z (4) PLACES, LEAVING US WITH

# 0000000000101001 OR 41

# NEXT, $Z IS 4, OR 0100 IN BINARY.

# SHIFT THAT ONE PLACE TO THE LEFT AND WE GET 1000 OR 8 IN DECIMAL.

# THE STATEMENT NOW READS 41 - 8, SO OUR 6TH ELEMENT IN THE ARRAY IS GOING TO BE 33.

$X->[05] = (666>>$Z)-($Z<<1);

# THE ARRAY IS NOW [83, 109, 105, 108, 101, 33]

# IF YOU HAVEN'T FIGURED IT OUT YET, TAKE A LOOK AT AN ASCII TABLE ON GOOGLE.

# CONVERT THE DECIMAL VALUES IN OUR ARRAY TO THE CHARACTERS THEY REPRESENT.

# 83 = S

# 109 = M

# 105 = I

# 108 = L

# 101 = E

# 33 = !

# SO ALL WE DID WAS USE SOME DIFFERENT BASES (BINARY, HEX, OCTAL, AND DECIMAL) AND SOME

# BITWISE OPERATIONS TO BUILD AN ARRAY OF CHARACTERS THAT SPELL OUT "SMILE!"

# THIS IS THE MAIN LOOP.

# WE WILL START BY DECREMENTING $Z AND THEN CHECK THAT IT IS STILL > 0.

# SINCE $Z = 4, BUT WE'RE GOING TO DECREMENT IT TO 3 BEFORE CHECKING, WE WILL PRINT LINES AT

# VALUES 3, 2, AND 1 BEFORE STOPPING.

WHILE(--$Z)

{

# THIS CONTROLS HOW MANY TIMES WE PRINT "SMILE!" ON A LINE.

# WE COUNT FROM 1 TO $Z, BUT SINCE $Z IS DECREASING WITH EACH ITERATION OF THE LOOP,

# WE WILL PRINT ONE LESS SMILE! EACH TIME.

# FIRST LINE 1, 2, 3

# SECOND LINE 1, 2

# THIRD LINE 1

FOR(1..$Z)

{

# NOW WE CALL THE $HELL SUBROUTINE FROM THE TOP OF THE PROGRAM, WHICH

# BUILDS A STRING OUT OF OUR ARRAY AND RETURNS IT TO THE PRINT FUNCTION.

# EFFECTIVE IT PRINTS "SMILE!"

PRINT $HELL->($X);

}

# $/ IS THE INPUT RECORD SEPARATOR; NEWLINE BY DEFAULT. AKA, PRINT A NEWLINE (\N)

PRINT $/;

}


I am a bot, and I don't respond to myself.

[deleted] · 1 points · Posted at 15:54:35 on July 8, 2016 · (Permalink)

LOL

m1el · 46 points · Posted at 16:46:03 on July 7, 2016 · (Permalink)*

Easy, just use javascript.

FALSE = a=>b=>b
TRUE = a=>b=>a
PAIR = x=>y=>f=>f(x)(y)
LEFT  = p=>p(x=>y=>x)
RIGHT = p=>p(x=>y=>y)
NIL = PAIR(TRUE)(TRUE)
NILQ = LEFT
CONS = l=>x=>PAIR(FALSE)(PAIR(x)(l))
CAR = l=>LEFT(RIGHT(l))
CDR = l=>RIGHT(RIGHT(l))
Z = f=>(x=>f(y=>x(x)(y)))(x=>f(y=>x(x)(y)))
JOIN_ = s=>Z(f=>l=>x=>NILQ(l)(x=>'')(x=>s+CAR(l)+f(CDR(l))(x))())
JOIN = s=>l=>NILQ(l)('')(CAR(l)+NILQ(CDR(l))('')(JOIN_(s)(CDR(l))()))
LINE = n=>JOIN(' ')(n(x=>CONS(x)('Smile!'))(NIL))
INC = n=>p=>x=>p(n(p)(x))
ONE = f=>x=>f(x)
LINES = n=>RIGHT(n(p=>p(x=>l=>PAIR(INC(x))(CONS(l)(LINE(x)))))(PAIR(ONE)(NIL)))
THREE = f=>x=>f(f(f(x)))
JOIN('\n')(LINES(THREE))
Nippius · 15 points · Posted at 18:21:50 on July 7, 2016 · (Permalink)

Because i didn´t hate javascript enough... how the hell does that even work! :O

barsoap · 22 points · Posted at 19:19:30 on July 7, 2016 · (Permalink)

Untyped Lambda Calculus. The thing doesn't have any data types so you build up everything from functions.

Here's the same kind of stuff a bit more readable in Haskell, and with type signatures:

pair :: a -> b -> (a -> b -> c) -> c
pair x y f = f x y

myPair :: (String -> Char -> t) -> t
myPair = pair "string" 'c'

left :: ((a -> b -> a) -> c) -> c
left p = p (\x y -> x)

Take a piece of paper, write down left myPair, expand the definitions, apply the reduction rules, and you end up with "string".

Of course, writing Z as above won't work in Haskell (because types) but you can use fix, instead.

Nippius · 1 points · Posted at 11:11:54 on July 8, 2016 · (Permalink)

Unfortunately i don´t now much about haskell but i see what you are trying to say. It's just concatenating the output of the nested lambda expressions?

barsoap · 1 points · Posted at 11:37:44 on July 8, 2016 · (Permalink)

It's just concatenating the output of the nested lambda expressions?

Yep.

dspeyer · 3 points · Posted at 06:12:52 on July 8, 2016 · (Permalink)

If the syntax itself is throwing you, that's because it's full of Fat-arrow lambdas -- a wonderfully compact bit of syntax that's now supported in Firefox and Chrome, but not Safari or IE so you can't really depend on it.

Nippius · 1 points · Posted at 09:29:29 on July 8, 2016 · (Permalink)

Ah! It's part of ES6. That explains it, but yes the syntax was really throwing me off, even thougth it looks a lot like lambdas in c# (i wonder if i can do the same in c#.. i think i'll give it a shot just for the heck of it).

Ironically this is making me like a little bit more of javascript. This will be really usefull for cleaning up the callback hell, at least visually.

m1el · 2 points · Posted at 10:33:03 on July 8, 2016 · (Permalink)

Yes, you can, but you have to use "dynamic", because types.

https://gist.github.com/m1el/95056d95ceecd4572892

Nippius · 2 points · Posted at 11:08:58 on July 8, 2016 · (Permalink)

Uau that's even less legible then javascript! But yeah i figured it would be possible using var and dynamic.

That is actually quite cool. I must use it in my next interview xD

Anyway there is a odd thing with the code. When running, it stops for a second before starting generating the fizzbuzz. why is that? is it the overhead of the dynamic keyword?

m1el · 2 points · Posted at 11:23:45 on July 8, 2016 · (Permalink)

When running, it stops for a second before starting generating the fizzbuzz. why is that? is it the overhead of the dynamic keyword?

That's an overhead of managing and calling a gazillion of lambdas. This code is likely to cause nightmares for C# maintainers.

The "fizzbuzz" list here is lazy, which means that you won't do any computation until you ask for the value (in general). So when result gets assigned, almost no computation was made at that point, but when you iterate over (var row in to_list(result)), it makes a lot of function calls.

superezfe · 24 points · Posted at 15:54:20 on July 7, 2016 · (Permalink)

Everybody needs their emoji

DSdavidDS · 3 points · Posted at 16:22:56 on July 7, 2016 · (Permalink)

Just the concept of not using strings completely throws me off when trying to understand that code >.<

claypigeon-alleg · 21 points · Posted at 18:17:36 on July 7, 2016 · (Permalink)

I'm a high school programming teacher. Despite my efforts, I'm sure some students get an inappropriate level of help from the internet.

Last year, I had one student copy/paste this and turn it in as his project. The wonky design of the program was an immediate tip-off, and I caught him by Googling his main function.

Veedrac · 8 points · Posted at 02:12:20 on July 8, 2016 · (Permalink)

You might find it's harder to copy other people's code if you made the questions a little more novel.

Something as simple as having a list of animals where you're searching by size (aka. elephant, cow, mouse) would probably work. Given people cheating on these tests probably don't understand composition very well, they'll find it hard to convert the linked question to this "new" version.

Idunno, though.

claypigeon-alleg · 3 points · Posted at 03:17:32 on July 8, 2016 · (Permalink)

You're not wrong (and I have other projects that are more unique). The guessing game has a number of features that allow me to put a lot of interesting material into one project, which is probably why a lot of teachers use it as a project.

For starters, everyone understands the premise, and there's a number of ways to implement it. My students are just getting the hang of looping when we do it, so we can talk using a for loop vs while loop (and when each approach is better). There's an extended if/else ladder that some students find challenging. We can talk about break and continue, and using boolean flags to "remember" if the player won or not. It's a game, and every 15-year-old boy that walks into my classroom has dreams of being a game developer. Being a game, we use random number generation in a meaningful way, and talk about how random number generation is important in a lot of different types of games.

We can also talk about game strategy, and (if we're limiting guesses) how many guesses to allow the player to make the game challenging. Working through that math gives some students their first introduction to logarithms, which I bring back when we analyze different kinds of sorts.

If you can think of another project that checks so many different topical boxes, I'm all ears! :)

Crosshack · 3 points · Posted at 04:36:07 on July 8, 2016 · (Permalink)

Yeah, as a student I've seen the guessing game a whole bunch of times, and I never realised why it was so popular until you explained it. Hell, it even gives you a good run up into understanding binary search as well. There obviously exist other problems that can be solved in logarithmic time, but none of them fit the other requirements of being simple to implement and understand.

Damn. It's actually such a good problem. I guess it's like how every course goes over sorting as well.

Veedrac · 2 points · Posted at 15:27:48 on July 8, 2016 · (Permalink)

It's a little more complicated, but how about an old turn based fighting game like Pokemon? A typical transcript might go like this:

Hero HP: 553
Minotaur HP: 1532

1) Attack for 100-200 damage
2) Power up for 50% extra damage
3) Heal 50-100 HP

Your action: 2

You powered up! Damage increased!
The minotaur attacked for 43 damage!

Hero HP: 510
Minotaur HP: 1532

1) Attack for 150-300 damage
2) Power up for 50% extra damage
3) Heal 50-100 HP

Your action: 1

You dealt 187 damage!
The minotaur attacked for 80 damage!

... etc

Here's an example implementation, written how your students might attempt it.

You could start with a first version that doesn't have any randomness, or is missing some options (like healing or powering up).

claypigeon-alleg · 2 points · Posted at 23:17:45 on July 8, 2016 · (Permalink)

This really has potential! I teach C++ instead of Python, but this is a project that would give the students experience building data structures and top-down design. I have a couple of other projects like this, but this would probably be more fun to write! Thanks!

Veedrac · 2 points · Posted at 23:45:59 on July 8, 2016 · (Permalink)

Glad you like the suggestion :).

Berberberber · 1 points · Posted at 07:57:02 on July 8, 2016 · (Permalink)

Repeated/Iterated Prisoner's Dilemma - each student programs their own game with a strategy for whether to cooperate or defect, and then they can "play" against each other's programs. You could develop this further with other games, possibly culminating in having students' programs play against each other.

[deleted] · 1 points · Posted at 16:21:48 on July 8, 2016 · (Permalink)

In University we all had to write our own "Game of Risk" AI in Prolog and then the professor held a tournament and grades were assigned based on how well you did in the tourny.

My favorite was the guy who wrote an AI that turtled into the corner for the whole game and when the prof asked what was going on he said, "I only tested it starting on the other side of the map..."

enry_straker · 2 points · Posted at 09:36:35 on July 8, 2016 · (Permalink)

Students, and programmers, will look for shortcuts, given a chance.

This is where your creativity and uniqueness of questions comes in. Open ended questions are the best but it means a lot more work for you :-)

claypigeon-alleg · 2 points · Posted at 04:19:05 on July 9, 2016 · (Permalink)*

You're not wrong! I don't mind open-ended questions, but they require exponentially time and creativity in all points of the assignment. It's very difficult to come up with these things all by yourself, much less design, administer, and grade the assignment.

I'm actually lobbying to bring in a STEM-oriented program that include a lot of open-ended curricula like this, but it would require a decent chunk of cash to bring into the school, and another cash infusion to hire someone to teach the straight math courses that I also teach.

enry_straker · 3 points · Posted at 06:13:04 on July 9, 2016 · (Permalink)

You are right.

It takes a lot of time and effort - and no one seems to recognize the amount of work put in by teachers.

One method i use when i am teaching new programmers is to take some simple open source project, go back to one of the earlier commits, remove the source while retaining a passing unit test - and ask folks to fill it in and make the test pass.

Anyways good luck, dude. The world needs more folks like you.

Asylumrunner · 41 points · Posted at 15:16:14 on July 7, 2016 · (Permalink)

Lol, that Perl answer was my Org. of Programming Languages professor

KamiKagutsuchi · 39 points · Posted at 14:14:15 on July 7, 2016 · (Permalink)

I submitted an answer in jsfuck. The script itself is 181378 characters long.

Skhmt · 9 points · Posted at 15:35:15 on July 7, 2016 · (Permalink)*

I was about to do that haha

Mine came out to 93k characters.

justmyspareaccount · 7 points · Posted at 23:35:07 on July 7, 2016 · (Permalink)

Very easy to find when scrolling through the thread: Just wait until the browser stops for a couple seconds and the scrollbar jumps up by a third or so.

[deleted] · 40 points · Posted at 21:40:19 on July 7, 2016 · (Permalink)

Let me add a simple C# implementation.

using System;
namespace _a
{
    abstract class cc {private cc _v0; public abstract cc e(cc arg);
        public cc v { get { cc tmp = this; if (_v0 != null) tmp = _v0;
            while (tmp is L) tmp = ((L)tmp).run(); _v0 = tmp; return tmp; }}
        public object vl { get { cc tmp = v; if(tmp is O) return ((O)tmp).value; else return new O(){value=tmp};}}}
    class ccI : cc {public override cc e(cc arg) {return arg;}}
    class ccK0 : cc {public cc x = null; public override cc e(cc arg) { return x; }}
    class ccK : cc {public override cc e(cc arg) { return new ccK0() { x = arg };}}
    class ccS0 : cc {public cc x;public override cc e(cc arg){return new ccS1(){y=arg,x=x};}}
    class ccS1 : cc {public cc x,y;public override cc e(cc arg){var a1 = new L() { f = x, a = arg };
            return new L(){f=a1,a=new L(){f=y,a=arg}};}}
    class ccS : cc {public override cc e(cc arg) { return new ccS0() { x = arg };}}
    class O : cc { public object value; public override cc e(cc arg) { return this; } public override string ToString() { return value.ToString();} };
    class F0 : cc { public cc x; public Func<object, Func<object, object>> f;
     public override cc e(cc arg){var x1=x.v;var a1=arg.v;
         return new O(){value=f(x1.vl)(a1.vl)};}}
    class F : cc {public Func<object, Func<object, object>> f;public override cc e(cc arg){return new F0(){f=f,x=arg};}}
    class L : cc {public cc f, a;public cc run(){var f1=f.v;return f1.e(a);}
        public override cc e(cc arg){return this;}}

    class cc1
    {
        static cc o(object v){return new O(){value=v};} static cc a(cc x,cc y){return new L(){f=x,a=y};}
        static cc I=new ccI(),S=new ccS(),K=new ccK(),
          B=a(a(S,a(K,S)),K),
          C=a(a(S,a(a(S,a(K,S)),a(a(S,a(K,K)),S))),a(K,K)),
          BS=a(a(S,a(a(S,a(K,S)),a(a(S,a(K,K)),a(a(S,a(K,S)),a(a(S,a(K,K)),a(a(S,a(K,S)),K)))))),a(K,a(a(S,a(K,S)),K))),
          SS=a(a(S,a(K,a(S,a(K,S)))),a(a(S,a(K,S)),K)),
          seq=new F(){f=x=>y=>y},
          print=new F(){f=io=>v=>{Console.Write(v);return null;}};

        ///////////////////////////
        static cc res1=a(a(a(a(a(a(a(a(a(a(a(C,a(a(C,a(a(a(BS,BS),a(SS,a(SS,a(SS,a(SS,a(SS,a(SS,C))))))),a(a(a(SS,a(SS,a(SS,C))),
                       a(a(C,a(a(a(BS,C),a(a(BS,C),a(a(BS,C),a(a(BS,BS),a(SS,a(SS,C)))))),a(a(C,a(a(a(BS,C),a(a(BS,C),a(a(BS,C),
                       a(a(BS,C),a(a(BS,C),a(a(BS,C),a(a(BS,B),S))))))),a(a(a(SS,a(SS,a(SS,a(SS,a(SS,a(SS,a(SS,a(SS,C)))))))),
                       a(a(a(SS,a(SS,a(SS,a(SS,a(SS,S))))),a(a(C,a(a(a(BS,C),a(a(BS,C),a(a(BS,C),a(a(BS,C),a(a(BS,C),a(a(BS,BS),
                       a(SS,C))))))),a(a(a(SS,a(SS,a(SS,S))),a(a(C,a(a(a(BS,C),a(a(BS,S),a(a(BS,a(BS,a(SS,a(SS,a(SS,C))))),a(SS,C)))),
                       a(a(a(SS,a(SS,a(SS,C))),a(a(a(SS,a(SS,a(BS,a(a(BS,a(BS,a(SS,C))),a(SS,C))))),a(a(C,a(a(a(BS,C),a(a(BS,BS),a(SS,C))),
                       a(a(a(SS,a(SS,a(SS,a(SS,a(SS,a(SS,a(SS,a(SS,a(SS,S))))))))),a(a(a(SS,a(SS,a(SS,a(SS,a(SS,a(SS,a(SS,a(SS,a(SS,C))))))))),
                       a(a(a(SS,a(SS,a(SS,a(SS,a(SS,a(SS,a(SS,a(SS,a(SS,a(SS,SS)))))))))),a(a(a(SS,a(SS,a(SS,a(SS,a(SS,a(SS,a(SS,a(SS,a(SS,S))))))))),
                       a(a(a(SS,a(SS,a(SS,a(SS,C)))),a(a(a(SS,a(SS,a(SS,a(SS,C)))),a(a(C,a(a(a(BS,C),a(a(BS,a(SS,a(BS,a(a(BS,BS),C)))),a(a(BS,S),
                       a(a(BS,a(BS,a(SS,a(SS,S)))),S)))),a(a(S,a(a(a(BS,C),a(a(BS,C),a(a(BS,C),a(a(BS,C),a(a(BS,BS),S))))),a(a(a(SS,a(SS,a(SS,C))),
                       a(C,a(a(a(BS,C),a(a(BS,C),a(a(BS,BS),C))),a(a(a(SS,a(SS,a(SS,C))),a(a(S,a(BS,a(C,a(a(a(BS,C),a(a(SS,a(SS,a(SS,a(SS,a(SS,a(SS,
                       a(SS,a(SS,B)))))))),a(a(a(SS,a(SS,a(SS,a(SS,a(SS,a(SS,a(SS,C))))))),a(a(a(BS,a(a(SS,a(SS,a(SS,C))),a(a(a(SS,a(SS,C)),a(a(a(SS,
                       a(BS,a(a(BS,a(SS,BS)),a(a(BS,a(SS,C)),a(a(SS,a(BS,BS)),C))))),a(a(a(BS,a(BS,a(a(BS,K),a(C,I)))),C),a(C,I))),a(K,a(C,I)))),a(K,
                       a(K,a(K,K)))))),K),a(a(a(BS,K),K),a(C,BS)))),a(K,a(K,a(K,a(K,a(a(a(BS,K),K),C)))))))),a(a(a(BS,K),K),a(a(a(BS,K),K),a(a(a(BS,K),K),
                       a(a(a(BS,K),K),a(C,I))))))))),I)),a(B,K))))),a(K,a(a(B,K),a(a(a(BS,a(a(SS,B),S)),K),a(C,B))))))),B))),a(K,a(a(C,a(a(a(BS,a(SS,a(SS,a(SS,C)))),
                       a(a(SS,a(SS,C)),a(a(a(SS,a(SS,a(BS,a(SS,BS)))),a(a(C,a(a(a(BS,a(SS,BS)),a(a(BS,BS),a(SS,B))),a(C,C))),a(K,B))),a(K,a(K,SS))))),
                       a(a(a(BS,K),K),a(a(a(BS,K),a(SS,C)),a(C,a(BS,B)))))),a(K,a(K,a(K,K))))))),a(K,a(K,a(K,a(K,K)))))),a(a(B,K),a(a(a(BS,K),K),
                       a(a(a(SS,C),a(a(a(SS,a(BS,B)),BS),a(K,a(a(a(BS,B),S),a(a(C,S),a(a(C,print),o("\n"))))))),a(K,a(C,a(a(a(BS,C),a(a(BS,S),a(a(SS,a(SS,seq)),print))),
                       a(C,a(BS,K)))))))))),a(a(a(BS,K),K),a(a(a(BS,K),a(B,a(a(BS,K),K))),a(a(a(SS,a(SS,C)),a(a(a(SS,a(SS,a(SS,BS))),a(a(C,a(a(a(SS,BS),a(a(a(SS,BS),BS),
                       a(K,B))),a(K,a(a(BS,B),S)))),a(C,C))),a(K,a(K,a(K,a(a(SS,C),a(a(a(BS,a(a(BS,C),a(a(SS,SS),a(SS,seq)))),a(C,a(SS,a(BS,K)))),K))))))),a(K,a(K,K))))))),
                       a(K,a(K,a(K,a(K,a(a(B,K),a(a(a(BS,K),K),a(a(a(BS,K),K),a(C,C)))))))))),a(a(B,K),a(a(a(BS,K),K),a(a(a(BS,K),K),a(a(a(BS,K),a(a(BS,K),K)),
                       a(a(C,a(a(C,BS),B)),a(a(C,I),o("Smile"))))))))),a(a(B,K),a(a(a(BS,K),K),a(a(a(BS,K),a(B,K)),a(a(a(SS,C),a(a(a(SS,a(SS,BS)),
                       a(a(a(SS,a(SS,BS)),a(a(C,a(a(a(SS,BS),BS),a(K,B))),a(SS,S))),a(K,a(K,a(a(SS,a(SS,S)),a(C,a(BS,B))))))),a(K,a(K,a(a(BS,K),K))))),
                       a(K,B)))))))),K)),a(K,a(K,a(a(a(SS,C),a(C,I)),I))))),a(K,a(K,a(K,K)))))),a(a(B,a(a(BS,K),K)),a(C,a(a(a(BS,C),a(C,I)),K))))),
                       a(K,a(K,a(K,a(a(B,a(a(BS,K),K)),a(a(C,a(a(a(BS,S),a(a(BS,B),B)),a(C,I))),I)))))))),K)),a(K,a(K,a(K,a(K,a(K,B))))))),a(K,a(K,a(K,a(K,a(K,a(K,a(a(B,K),
                       a(a(S,B),I))))))))))),C))),K)),a(K,a(K,a(K,a(a(a(BS,K),C),a(C,I)))))))),a(B,K))),a(a(a(BS,a(a(BS,K),K)),a(a(BS,K),K)),a(C,I))),a(a(S,a(a(C,B),a(a(S,I),I))),
                       a(a(C,B),a(a(S,I),I)))),a(K,I)),a(S,B)),K),a(K,I)),a(a(a(SS,C),a(a(a(SS,a(SS,SS)),a(a(C,a(a(C,BS),a(B,a(C,I)))),a(C,I))),a(K,a(K,K)))),
                       a(K,a(K,I)))),a(a(B,C),a(C,I))),a(a(C,I),K)),a(a(C,I),a(K,I))).v;
        static void Main(){if(res1==null) o(0);}
    }
}

A bit of fun here: SK combinators (with some optimisations), Church numerals, Church pairs, infinite lists with lazy evaluation, etc.

[deleted] · 43 points · Posted at 23:40:24 on July 7, 2016 · (Permalink)*

[deleted]

tjsr · 37 points · Posted at 03:02:46 on July 8, 2016 · (Permalink)

This is justification for a compiler optimiser that looks at your code and just says "no".

greatestfall · 4 points · Posted at 08:58:14 on July 8, 2016 · (Permalink)

you deserve so many upvotes for how hard this made me laugh.

[deleted] · 3 points · Posted at 12:44:28 on July 8, 2016 · (Permalink)

Compilers are rioting on the streets!

[deleted] · 2 points · Posted at 09:10:10 on July 8, 2016 · (Permalink)

In fact, an optimising compiler with partial evaluation + inlining can have a lot of fun with such code (effectively obfuscating it even further, instantiating the graph reduction engine at all the @-nodes).

[deleted] · 7 points · Posted at 07:18:47 on July 8, 2016 · (Permalink)

It is a demonstration of a combinator-based obfuscation technique which is even more cryptic than the VM-based approaches. By not using machine level control flow, data structures and arithmetics you can encode, say, a crucial part of an algorithm that you do not want to be reverse engineered.

It is trivial to generate such a code from an untyped lambda calculus (see it in some other answers here), but a reverse transform is much harder.

galaris · 1 points · Posted at 12:32:47 on September 19, 2016 · (Permalink)

What did you use to produce this?

[deleted] · 1 points · Posted at 12:52:23 on September 19, 2016 · (Permalink)

An algorithm described in detail in A. J. Field, P. G. Harrison, "Functional programming" (1)

See the implementation in Racket here (2)

(1) https://books.google.co.uk/books/about/Functional_Programming.html?id=nYtQAAAAMAAJ

(2) http://pastebin.com/KuBpJEtR

Could not find the version I used to build this example, so here is an older Racket implementation. The payload contained implementations for the Church numerals, Church pairs, etc., see a detailed explanation here:

https://en.wikipedia.org/wiki/Church_encoding

[deleted] · 18 points · Posted at 15:32:47 on July 7, 2016 · (Permalink)*

[deleted]

G01denW01f11 · 31 points · Posted at 01:17:50 on July 8, 2016 · (Permalink)

Restarting Eclipse while chanting mantras, for example.

jeffsterlive · 2 points · Posted at 04:30:25 on July 8, 2016 · (Permalink)

While Eclipse is restarting or butchering your workbook, install IntelliJ.

alexshatberg · 2 points · Posted at 12:39:27 on July 8, 2016 · (Permalink)

But then be prepared to run "Invalidate Caches/Restart" ten times per a coding session.

vplatt · 2 points · Posted at 22:09:42 on July 7, 2016 · (Permalink)

Yeah, he forgot the half dozen or so visits to SO to troubleshoot things that go wrong in the middle of the process. But I guess that's implied. ;)

teiman · 32 points · Posted at 15:02:54 on July 7, 2016 · (Permalink)

Nobody using tools like yacc to write a compiler to solve this? is the programmers race weakening?

[deleted] · 16 points · Posted at 16:29:41 on July 7, 2016 · (Permalink)*

[deleted]

renrutal · 1 points · Posted at 05:04:45 on July 10, 2016 · (Permalink)

Or a

npm install smile
xelf · 31 points · Posted at 18:04:16 on July 7, 2016 · (Permalink)

The fact that this works makes me giggle more than it should have:

HAI
    HOW DUZ I PRINTSMILE
        VISIBLE "SMILEZ!"!
    IF U SAY SO

    HOW DUZ I PRINTSMILEZ NUMBERZ
        I HAS A SMILEZLINE ITZ ""
        IM IN YR LOOP NERFIN YR NUMBERZ WHILE NUMBERZ BIGGR THAN 0
            SMILEZLINE R SMOOSH SMILEZLINE AN "SMILEZ!" MKAY
        IM OUTTA YR LOOP
        VISIBLE SMILEZLINE
    IF U SAY SO

    VISIBLE "O HAI! NOT MY WERK! LOL!:):)DIS WAY CUZ I LIEK SMOOSH:)"

    I HAS A COUNTER ITZ 3
    IM IN YR LOOP NERFIN YR COUNTER WHILE COUNTER BIGGR THAN 0
        PRINTSMILEZ COUNTER
    IM OUTTA YR LOOP
    VISIBLE ":)N DIS WAY CUZ QUESTION. LOL!:)"
    COUNTER R 3
    IM IN YR LOOP NERFIN YR COUNTER WHILE COUNTER BIGGR THAN 0
        I HAS A UDDERCOUNTER ITZ COUNTER
        IM IN YR INNERLOOP NERFIN YR UDDERCOUNTER WHILE UDDERCOUNTER BIGGR THAN 0
            PRINTSMILE
        IM OUTTA YR INNERLOOP
        VISIBLE ":)"!
    IM OUTTA YR LOOP
    VISIBLE ":)LOLOLOLOLOLOLOLOLOLOLOLOL!:):)KTHXBYE"
KTHXBYE
🎙️ MCSajjadH · 3 points · Posted at 18:05:41 on July 7, 2016 · (Permalink)

what language is this?

GravityTracker · 11 points · Posted at 18:13:36 on July 7, 2016 · (Permalink)
sirin3 · 2 points · Posted at 21:27:25 on July 7, 2016 · (Permalink)

Is there a W40K WAAAGH language?

greatestfall · 2 points · Posted at 09:00:04 on July 8, 2016 · (Permalink)

I am so glad this exists.

1RedOne · 2 points · Posted at 04:09:55 on July 8, 2016 · (Permalink)

I want this on a shirt with proper syntax highlighting

quatch · 15 points · Posted at 15:37:31 on July 7, 2016 · (Permalink)

Someone needs to do verilog

flarkis · 12 points · Posted at 20:33:13 on July 7, 2016 · (Permalink)
module display(
    input clk,
    input rst)

    reg [2:0] cnt;

    always @(posedge clk) begin
        if (rst == 1'b0) begin
            cnt <= 2'b0;
        end else if (cnt != 2'b11) begin
            cnt <= cnt + 2'b1;
            for (i = 0; i < 3-cnt; i++) begin
                $display("Smile!");
            end
            $display("\n");
        end
    end
endmodule

Dead simple verilog module that will print the correct results when run through a verilog simulator. The module will print the 3 lines and then hold in the final state. A reset low signal will start the module again. Might be a syntax error somewhere, didn't test. Hardware development is expensive so it's best to save resources when you can.

[deleted] · 2 points · Posted at 12:18:56 on July 8, 2016 · (Permalink)

Ok. You asked for it. Placed and route for the iCEstick dev board. Not tested. Must work with UART configured at 115200bps, 8bit.

http://pastebin.com/VH9gQRhk

the_evergrowing_fool · 1 points · Posted at 21:16:43 on July 8, 2016 · (Permalink)

So you have a compiler for everything...Awesome.

[deleted] · 1 points · Posted at 10:56:40 on July 9, 2016 · (Permalink)

This code is generated by Yosys, from a higher level Verilog (two FSMs and an UART core).

oversized_hoodie · 1 points · Posted at 03:40:46 on July 8, 2016 · (Permalink)

import degree.engineering.computer

mdempsky · 16 points · Posted at 17:07:40 on July 7, 2016 · (Permalink)

It's sad that so many upvoted answers don't actually address the poster's question...

Have the program define a function that displays the string Smile! once, and have the program use the function as often as needed.

Look how many of those solutions missed such a simple requirement!

driusan · 11 points · Posted at 23:35:03 on July 7, 2016 · (Permalink)

I had the same reaction, so I just wrote this C version which meets all the requirements, so should get full marks:

#include <stdio.h>

void smile(void) {
    printf("Smile!");
}

void dohomework(int n) {
    int l = n;
line: switch(n = l--) {
    default:
    smile:  
        if(n--) {
            smile();
            goto smile;
        }
        printf("\n");
        goto line;
    case 0: break; /* no more lines */
    }
}

int main(int argc, char **argv) {
    dohomework(3);
}
Crosshack · 3 points · Posted at 04:39:48 on July 8, 2016 · (Permalink)

This is how you get the asker shot by his teacher.

[deleted] · 3 points · Posted at 16:46:56 on July 8, 2016 · (Permalink)

I found some C++ code I wrote back in 2002 when I was first learning.

 27  void wait()
 28 {
 29  for (long a=0;a<=1000000000;a++){a;}
 30 }

And then in an updated version from a few months later I found

 42  void wait()
 43  /*Delay no longer differs based on processor speed*/
 44 {
 45  long curr_time;
 46  curr_time = biostime(0, 0L);
 47  while (biostime(0, 0L)<=curr_time)
 48     ; //do nothing
 49 }

Sometimes I'm not sure I should have been allowed to become a professional software developer >.>

yadec · 1 points · Posted at 20:32:58 on July 24, 2016 · (Permalink)

I am 16 days late on the reply here but your first wait function with a for loop is exactly one of the recommended ways to insert delay in a TI-BASIC program (the one that is still used by every high school student with a TI-83 to TI-84+CSE). The other recommended method was to generate a bunch of random numbers.

The TI-84+CE, just released this year, is the first to have a built-in wait function. But most people still recommend against using it as it breaks compatibility with older devices.

[deleted] · 1 points · Posted at 20:37:36 on July 24, 2016 · (Permalink)

That's interesting. Around the same time I wrote that code I was also learning TI-BASIC instead of paying attention in math class, so maybe there was some carry-over there.

I think it probably just had more to do with "I didn't know there was an actual sleep/wait function built in so I used what I knew."

driusan · 2 points · Posted at 12:35:50 on July 8, 2016 · (Permalink)

But it's even commented!

nikniuq · 13 points · Posted at 00:04:22 on July 8, 2016 · (Permalink)

Here's one in untyped lambda calculus. In principle it should work, though you'll need to write a compiler for this dialect. Shouldn't be too hard.

Ok, gold star for that guy.

davemani5 · 10 points · Posted at 02:32:56 on July 8, 2016 · (Permalink)

Somewhere in a dystopian A.I. future these answers will be used as a Rosetta stone for programming languages.

_TheDust_ · 12 points · Posted at 17:01:50 on July 7, 2016 · (Permalink)

The JavaEE one really hurt. Like 40 bullets on how to set up XML files, annotations, classes, interfaces, configurations...

tjsr · 2 points · Posted at 03:08:13 on July 8, 2016 · (Permalink)

It's okay, it won't be too painful to implement as we'll write those up as cards and hire a contractor to do the implementation.

pigeon768 · 10 points · Posted at 20:11:13 on July 7, 2016 · (Permalink)*

All of these answers are too complicated. It's a lot simpler if you just use Python.

print("\n".join(("".join(("Smile!" for _ in range(n))) for n in range(3,0,-1))))

edit: if you have to write it in C, it is unfortunately much more complicated. It takes three times as many lines of code.

void main() {
  unsigned long long a = 2851469261368659ULL;
  for(int i=7;--i;write(1,&a,6+!(i&(i-1))));
}

edit 2, with nasm on linux x86_64:

section .data
a:  dq 2851469261368659
section .text
global _start
_start: mov rbx,6
.l: mov rax,1
    mov rdi,1
    mov rsi,a
    mov rdx,rbx
    dec rdx
    and rdx,rbx
    neg rdx
    sar rdx,7
    add rdx,7
    syscall
    dec rbx
    jnz .l
    mov rax,60
    xor rdi,rdi
    syscall
tjsr · 2 points · Posted at 03:07:37 on July 8, 2016 · (Permalink)

Can you save a few bytes using:

unsigned long long a = 0xA21656C696D53ULL;
Veedrac · 1 points · Posted at 02:18:04 on July 8, 2016 · (Permalink)
print("\n".join(("".join(("Smile!" for _ in range(n))) for n in range(3,0,-1))))

Pff, print(*map("Smile!".__mul__,(3,2,1)),sep="\n").

dspeyer · 1 points · Posted at 06:18:57 on July 8, 2016 · (Permalink)

The python code is far to reasonable, but I like the C

Celdron · 38 points · Posted at 15:04:37 on July 7, 2016 · (Permalink)

In F# because why not:

let f = printf [| 083; 109; 105; 108; 101; 033; 000 |]

Wow such functional.

PM_ME_UR_OBSIDIAN · 12 points · Posted at 16:30:08 on July 7, 2016 · (Permalink)*

Truly more readable than those lousy imperative programs :o)

(Honestly though, did you test it? I haven't written any serious F# in years but OTOH I'm suspecting a type error. I can't verify because I'm on my phone.)

Celdron · 7 points · Posted at 16:58:07 on July 7, 2016 · (Permalink)

You're right, printf takes TextFormatWriter<T>. F# is not my mother tongue. Updated code:

let f = for c in [| 083; 109; 105; 108; 101; 033 |] do printf "%c" (char c)

There is not implicit conversion for strings either, so it becomes a tidbit more verbose.

GetRekt · 6 points · Posted at 16:56:01 on July 7, 2016 · (Permalink)*

It won't because there's no format string

Additionally it's an array so you couldn't print it as a string anyway without an intermediate to turn it into a string

Unless there's a format specifier to take 'a [] and turn it into string

Pidgey_OP · 1 points · Posted at 20:00:39 on July 7, 2016 · (Permalink)

fff
ff
f

PM_ME_UR_OBSIDIAN · 1 points · Posted at 16:59:02 on July 7, 2016 · (Permalink)

Now do it with type providers!

mindbleach · 9 points · Posted at 16:30:01 on July 7, 2016 · (Permalink)

It might be more fun to write correct-looking "Smile!" code that's really an obfuscated JAPH program.

urquan · 7 points · Posted at 00:11:19 on July 8, 2016 · (Permalink)

He should forget this programming nonsense and use Smile!-as-a-service.io instead. I mean outsourcing 100% of your expertise is the growth hack that all VCs recommend in the hype-based startup economy and your best bet to make that get-bought-by-facebook business plan a success.

faizaanceg · 16 points · Posted at 16:08:19 on July 7, 2016 · (Permalink)

Haha, weird to see my quora answer here XD. It was fun writing that at the time, but looking back it does feel a bit harsh. SO also suffers from this kind of rebuking I guess, but the Quora crowd is a bit merrier.

FimbrethilTheEntwife · 2 points · Posted at 23:42:32 on July 7, 2016 · (Permalink)

Which one is yours? If you don't want to say, what is a group of five that include yours?

faizaanceg · 3 points · Posted at 00:11:47 on July 8, 2016 · (Permalink)

This is mine.

FimbrethilTheEntwife · 6 points · Posted at 00:14:21 on July 8, 2016 · (Permalink)

I love it! Some of the code in others is just dumb, you did it well, just in a manner no one would ever need. It's wonderful.

faizaanceg · 3 points · Posted at 00:20:37 on July 8, 2016 · (Permalink)

Umm thanks. :)

polyguo · 7 points · Posted at 19:15:51 on July 7, 2016 · (Permalink)

Someone please do a TensorFlow implementation.

[deleted] · 3 points · Posted at 20:11:52 on July 7, 2016 · (Permalink)*

This comment has been overwritten by an open source script to protect this user's privacy. It was created to help protect users from doxing, stalking, and harassment.

If you would also like to protect yourself, add the Chrome extension TamperMonkey, or the Firefox extension GreaseMonkey and add this open source script.

Then simply click on your username on Reddit, go to the comments tab, scroll down as far as possibe (hint:use RES), and hit the new OVERWRITE button at the top.

polyguo · 3 points · Posted at 23:13:26 on July 7, 2016 · (Permalink)

Yes it is. There was an article about someone who was asked in an interview to do something very simple and replied with "can I use TensorFlow?" very amusing, I thought. If we're going with roundabout ways to get a certain function, I think ML is a beautiful way to convolute things.

StenSoft · 7 points · Posted at 21:13:15 on July 7, 2016 · (Permalink)

The Perl version is really clever, using six different ways to put a value into an array, each for one of the letters.

klezmai · 2 points · Posted at 03:23:26 on July 8, 2016 · (Permalink)
actual_satan · 19 points · Posted at 13:34:42 on July 7, 2016 · (Permalink)

I think I died at the brainfuck answer!

LesterKurtz · 71 points · Posted at 15:39:56 on July 7, 2016 · (Permalink)

I wrote this in Brainfuck because I hate myself

That has to be the best opening line to an answer I've seen so far.

klezmai · 36 points · Posted at 16:27:36 on July 7, 2016 · (Permalink)

Someone later said "I'm sure there's a more compact solution, but I don't think I hate myself as much as the guy who offered the Brainfuck solution"

IonTichy · 5 points · Posted at 17:07:29 on July 7, 2016 · (Permalink)

How about one written in Malbolge?

Andernerd · 2 points · Posted at 00:45:50 on July 8, 2016 · (Permalink)

Yeah, that one is genuinely impressive.

nickthegeek1 · 2 points · Posted at 07:03:15 on July 8, 2016 · (Permalink)

its been done! Malbolge.

KayRice · 5 points · Posted at 21:22:08 on July 7, 2016 · (Permalink)

Worth noting someone posted a solution in Brainfuck before COBOL.

EDIT Also lol to iwannamakeprettypicturesnothomeworkyo()

aidenr · 4 points · Posted at 01:44:46 on July 8, 2016 · (Permalink)

Probably billed a bank $250/hr too.

elZaphod · 4 points · Posted at 16:12:58 on July 7, 2016 · (Permalink)

Some of those answers were simply beautiful.

FimbrethilTheEntwife · 1 points · Posted at 23:41:51 on July 7, 2016 · (Permalink)

I've never felt so much joy while reading code. I giggled at the ridiculousness of some.

yaxis50 · 4 points · Posted at 17:19:58 on July 7, 2016 · (Permalink)

Sad VBA was not represented, it's the writing on the wall :(

pickten · 2 points · Posted at 17:49:58 on July 7, 2016 · (Permalink)

There was some, but it was very far down.

spectrogramaniac · 3 points · Posted at 23:34:50 on July 7, 2016 · (Permalink)

The question is from a book called C Primer Plus by Stephen Prata.

John_Saxon · 3 points · Posted at 00:05:26 on July 8, 2016 · (Permalink)

BRB, writing solution in Malbolge. Estimated time of completion: Heat death of the universe.

xanitrep · 3 points · Posted at 02:48:54 on July 8, 2016 · (Permalink)

I got a kick out of this:

-- First, we need Peano numbers so that we can count things.
-- Always define your own, never trust the built-in integers!
BilgeXA · 4 points · Posted at 19:22:59 on July 7, 2016 · (Permalink)

It's interesting to me that a site like Quora can continue to exist in a StackOverflow World.

Jafit · 2 points · Posted at 15:14:39 on July 7, 2016 · (Permalink)
ghost1082 · 2 points · Posted at 17:08:36 on July 7, 2016 · (Permalink)

That brainfuck, jeez.

realbetag · 2 points · Posted at 18:17:16 on July 7, 2016 · (Permalink)

The brainfuck one was hilarious

88leo · 2 points · Posted at 19:36:24 on July 7, 2016 · (Permalink)

Complete with pointer arithmetic.

[deleted] · 2 points · Posted at 19:49:47 on July 7, 2016 · (Permalink)

I really don't feel like making a Quora account, but for fun, I made a stupidly simple Piet program that will do this. You can execute the file at npiet online.

thewookie34 · 0 points · Posted at 20:25:09 on July 7, 2016 · (Permalink)

Wtf is that and why does it look like a ton of penis drawings?

[deleted] · 1 points · Posted at 20:42:36 on July 7, 2016 · (Permalink)

Piet, a fun esoteric programming language. I wasn't trying to do penis drawings, but if that's what they look like, it's a happy mistake.

smookykins · 2 points · Posted at 20:09:40 on July 7, 2016 · (Permalink)
Garbaz · 2 points · Posted at 20:24:51 on July 7, 2016 · (Permalink)

Still waiting for one in Malbolge.

random314 · 2 points · Posted at 22:37:10 on July 7, 2016 · (Permalink)

Damn I wish i can repeat my old cse courses, I'd ace them so hard.

[deleted] · 2 points · Posted at 23:51:14 on July 7, 2016 · (Permalink)

[deleted]

[deleted] · 1 points · Posted at 07:55:45 on July 8, 2016 · (Permalink)

And now this Quora answer is going to be the highest ranking link, to help thousands of students to realise that CS/SE major was a stupid choice.

Aweorih · 2 points · Posted at 23:57:19 on July 7, 2016 · (Permalink)

Could someone explain this please?
L"Smile!"V3*-3NyZ

bfoo · 2 points · Posted at 00:53:08 on July 8, 2016 · (Permalink)

Did not scroll down, but I hope someone has sent him some 0day shellcode that would have flashed the bios to write "Smile!" on the screen or morse code it through the speaker.

sk_2013 · 2 points · Posted at 01:02:25 on July 8, 2016 · (Permalink)

This... this is beautiful.

[deleted] · 2 points · Posted at 02:05:54 on July 8, 2016 · (Permalink)

The programming class I took in college was a complete joke. We only used visual basic and our tests were HAND WRITTEN. No one learned a damn thing AND he was a tough grader.

TheEdes · 1 points · Posted at 10:37:59 on July 8, 2016 · (Permalink)

I don't see any inherent problems with hand written code. If you can write it on the computer why can't you write it by hand?

Xaayer · 2 points · Posted at 02:11:48 on July 8, 2016 · (Permalink)

This was fun to scroll through and see all these languages. Never heard of most of these

PunctuationsOptional · 2 points · Posted at 02:43:31 on July 8, 2016 · (Permalink)

I don't code and I have no idea what I was looking at. Seemed interesting though.

Berberberber · 2 points · Posted at 08:02:30 on July 8, 2016 · (Permalink)

Am I the only one that immediately thought, "Generate Pascal's triangle backwards and then replace every number with 'Smile!'"?

techsin101 · 5 points · Posted at 17:57:54 on July 7, 2016 · (Permalink)*

Ruby Does it best:

gets.to_i.downto(1) { |n|
    puts 'Smile!'*n
}
zscruz · 5 points · Posted at 18:11:02 on July 7, 2016 · (Permalink)

The best thing on the internet right now

it_roll · 2 points · Posted at 16:54:45 on July 7, 2016 · (Permalink)

"Ha ha ha! I have no idea what's going on."

Lollemberg · 1 points · Posted at 17:58:55 on July 7, 2016 · (Permalink)

you're not alone

womblepelt · 3 points · Posted at 14:42:20 on July 7, 2016 · (Permalink)

Haha this is too hilarious!

hugthemachines · 1 points · Posted at 17:28:29 on July 7, 2016 · (Permalink)

If I had that homework I think I would write a program that just generated random letters in a row, as many as in the requested output and only show them if they are correct. Not sure how much time it would take though.

mordisko · 1 points · Posted at 19:39:12 on July 7, 2016 · (Permalink)

I miss the AnorldC in there m

michael5029 · 1 points · Posted at 21:42:57 on July 7, 2016 · (Permalink)

So it's a typical homework question answer section?

pinpinbo · 1 points · Posted at 22:35:55 on July 7, 2016 · (Permalink)

I don't see this amongst the answers:

Full MEAN stack:

  • node.js

  • mongodb

  • npm

  • npmscript or grunt or gulp or others

  • angular 2

  • angular component to write <smile></smile>

  • TypeScript

  • google closure compiler

  • bootstrap framework to make it looks professional.

AkivaAvraham · 1 points · Posted at 00:50:33 on July 8, 2016 · (Permalink)

Disappointed that I did not see an APL solution

dirtyturb · 1 points · Posted at 01:36:15 on July 8, 2016 · (Permalink)

I know a few of these words...

muckrucker · 1 points · Posted at 02:44:20 on July 8, 2016 · (Permalink)

Oh man, those beautiful bastards! Well played!

Athaa · 1 points · Posted at 02:51:56 on July 8, 2016 · (Permalink)

No Pascal? :'(

jtoxification · 1 points · Posted at 03:06:34 on July 8, 2016 · (Permalink)

Best of.

things_random · 1 points · Posted at 03:15:37 on July 8, 2016 · (Permalink)*

So after spending about an hour on the javascript one liner I finally got it.

+ 

does a numeric boolean coercion to 1/0 and

! 

does a regular boolean coercion to true/false.

so

![]==false // I guess [] is 'falsey' ?? someone please confirm this.
+![]==0 // the + is converting false to 0
+[]==0 // the + is converting a 'falsey' value to 0

then

!+[]==true
+!+[]==1

When you add a number to an array it converts the number to a string. So

1+[0]=='10'
+!+[]+[+[]]=='10'

And that's as far as i got. gotta sleep now.

1RedOne · 1 points · Posted at 03:46:53 on July 8, 2016 · (Permalink)

I love the example in tsql with hilarious variable names. FrownedUpon and function imSoLazy

[deleted] · 1 points · Posted at 12:09:33 on July 8, 2016 · (Permalink)

I wish I could write that complex code in purpose for such an easy task!

comp-sci-fi · 1 points · Posted at 13:47:12 on July 8, 2016 · (Permalink)

perl before swine

pmf · 1 points · Posted at 14:29:30 on July 8, 2016 · (Permalink)

The JS answers are actually best practices, as my extensive study of YC news has shown.

Eilai · 1 points · Posted at 19:43:46 on July 8, 2016 · (Permalink)

Which of these is the most useful from a learning and curiosity perspective?

jputnam · 1 points · Posted at 04:13:52 on July 9, 2016 · (Permalink)

I am disappointed by the lack of Intercal. Also, the Haskell version doesn't take advantage of laziness, which seems odd. By being lazy, we can be sure we call the printing function as many times as necessary, because we call it infinitely many times:

main = do
    let mkSmile = putStr "Smile!" -- to meet the requirements
        smiles = return () : map (mkSmile >>) smiles
    sequence_ . reverse . take 3 . tail . map (>> putStrLn "") $ smiles
[deleted] · -3 points · Posted at 17:27:14 on July 7, 2016 · (Permalink)

This seems unnecessarily prickish. They never asked for the function to be written, they asked how to write it. Someone should have just given them a brief tutorial on functions (which, yes, he could have googled).

That kind of attitude (not wanting to help new programmers) most certainly dissuades students from learning computer science. If they asked on quora, we should give them the benefit of the doubt and assume their professor is not explaining things well.

very_mechanical · 16 points · Posted at 17:52:42 on July 7, 2016 · (Permalink)

Nah, it's just not wanting to help people who are too lazy to help themselves. Anyone, no matter how new at programming, should be able to break the problem down and ask something like "How do I output 'Smile!' to the screen?" or "How do I create a loop that will call a function three times?".

You can't help someone if they aren't going to take the smallest sort of initiative.

[deleted] · -1 points · Posted at 20:22:41 on July 7, 2016 · (Permalink)

Who says he isn't taking initiative? I'd say that knowing when to ask for help is definitely initiative.

LetsGoHawks · 1 points · Posted at 20:53:38 on July 7, 2016 · (Permalink)

Perhaps he should have taken the initiative of paying the slightest bit of attention in class.

kLinus · 2 points · Posted at 17:35:12 on July 7, 2016 · (Permalink)

It's sad to me that this is the only comment pointing out how dickish these responses are. The person even mentioned in the question that it was a homework question. It's not like he was trying to be sneaky about it.

Calam1tous · 2 points · Posted at 17:44:44 on July 7, 2016 · (Permalink)

Yeah seemed pretty obvious that's what he was looking for.

whozurdaddy · 0 points · Posted at 20:14:21 on July 7, 2016 · (Permalink)

yeah but to be fair - isnt that why he is in a programming class? To learn from his teacher? If he isnt learning, then he needs to go back to his teacher and tell him he doesnt understand. Else drop the course and let the Internet teach him everything.

[deleted] · 1 points · Posted at 20:21:35 on July 7, 2016 · (Permalink)

Many colleges don't let you drop after the first few classes without a penalty. And who says he hasn't tried asking his professor? An intro to computer science class is likely to have tons of students asking for help, and many professors just aren't accommodating.

It seems like if the professor won't help, your peers are just as lost as you, and you need the course credit, then your best option is to ask the internet.

whozurdaddy · -1 points · Posted at 20:40:10 on July 7, 2016 · (Permalink)

if Im paying a professor for an education, and he wont help... thats not an issue i will just skip over.

GreatEqualist · 2 points · Posted at 22:12:01 on July 7, 2016 · (Permalink)

That's not an issue you can easily fix.

[deleted] · 0 points · Posted at 21:23:10 on July 7, 2016 · (Permalink)

I take it you haven't taken an introductory course at a large university?

whozurdaddy · 2 points · Posted at 02:57:31 on July 8, 2016 · (Permalink)

lol... I take it you've never stood up for yourself?

astroteacher · 0 points · Posted at 21:33:52 on July 7, 2016 · (Permalink)

You're spot on here. If it was a real kid with a real question you've ensured he'll never ask another. You guys may be good at programming but you know fuck all about teaching.

lordcirth · 1 points · Posted at 03:36:13 on July 8, 2016 · (Permalink)

It was a real kid with a real question that he didn't bother thinking about for as much time as it took to type the question out.

astroteacher · 2 points · Posted at 05:56:58 on July 8, 2016 · (Permalink)

You're probably right... But in my class, I respect all questions. A kid brave enough to ask a question may have just summoned the courage to ask in whatever way they can. Sometimes right after I just answered it. So if I think a kid can do more than just receive a free answer I'll meter my response rather than tell the kid he is lazy or incompetent. For example in this situation a proper response might have been ... In what language? Do you understand methods or loops or index counters .... Instead we tell him or her they are lazy. I don't think I can conclude that from a single question.

lordcirth · 1 points · Posted at 23:31:44 on July 8, 2016 · (Permalink)

You, as a teacher, are getting paid and have a responsibility to teach the student as best you can even if he makes that difficult. The people on Quora don't.

mrthesis · 1 points · Posted at 16:30:44 on July 7, 2016 · (Permalink)

Man, english can look/sound stupid at times. From the Maven JavaEE

but you've to

michaelochurch · 1 points · Posted at 17:38:15 on July 7, 2016 · (Permalink)

Quora still exists?

yoonssoo · 1 points · Posted at 22:21:49 on July 7, 2016 · (Permalink)

All the responses are filled with ingenuity. Hilarious.....

astroteacher · 0 points · Posted at 15:47:35 on July 7, 2016 · (Permalink)*

10 input "n?";n 20 for I = n to 1 step -1 30 print "Smile!"; 40 next I 50 n=n-1 60 print ASC(13) 70 if n=0 then END 80 goto 20

Wow BASICally down voted to oblivion ... A language used by millions of people back in the day. Thanks Reddit. Your snobbish response explains why CS is so isolating.

[deleted] · -17 points · Posted at 12:31:29 on July 7, 2016 · (Permalink)

Who are "we"?

[deleted] · 16 points · Posted at 15:38:12 on July 7, 2016 · (Permalink)*

[deleted]

[deleted] · 2 points · Posted at 12:20:18 on July 8, 2016 · (Permalink)

You surely meant "quora users", not "programming community"? Those snippets are witless and boring.

JohnLayman · -2 points · Posted at 16:38:13 on July 7, 2016 · (Permalink)

Hahahaha, Ahhaha, oh that's good. That's great.....er....someoneexplainthemtome

klezmai · 1 points · Posted at 03:28:12 on July 8, 2016 · (Permalink)

You got a proof this is not for some homework?

steakyfask · -1 points · Posted at 16:39:04 on July 7, 2016 · (Permalink)

'$hell' niiiice :-)

GinsengandHoney · -6 points · Posted at 19:34:50 on July 7, 2016 · (Permalink)

Yes, let's just attack the guy for trying to learn. God forbid somebody else is not born with innate knowledge of code.

klezmai · 2 points · Posted at 03:33:10 on July 8, 2016 · (Permalink)

The whole point of this thread is that the OP intentions came accros the exact opposite way. The way he asked his question seems like hes trying to avoid any kind of effort to learn anything. It looks like hes shamelessly asking for quora users to do his homework for him.

lordcirth · 1 points · Posted at 03:38:17 on July 8, 2016 · (Permalink)

More like for not attending class or reading the first few pages of the textbook, then asking Quora for help instead of a TA, student, or prof.

joequin · 0 points · Posted at 16:48:52 on July 7, 2016 · (Permalink)

JaxB

evil

[deleted] · 0 points · Posted at 22:03:20 on July 7, 2016 · (Permalink)

Im genuinely upset there were no FORTRAN solutions.

[deleted] · 0 points · Posted at 22:08:21 on July 7, 2016 · (Permalink)

Yer cool

leftofzen · 0 points · Posted at 04:07:58 on July 8, 2016 · (Permalink)

FFS this was on the front page just 60 hours ago and you're already reposting it? That's the definition of karma-whore right there.

https://www.reddit.com/r/ProgrammerHumor/comments/4rcs8h/op_asks_for_homework_help_people_decide_to_do_his/

Aeolun · 2 points · Posted at 04:59:49 on July 8, 2016 · (Permalink)

Didn't see it before, karma successfully retrieved.

bigfig · -7 points · Posted at 16:27:54 on July 7, 2016 · (Permalink)

Chris Irwin Davis, Ph.D. computer science, A.I. researcher, ex-Fortune 500 technology R&D manage...

Ok, I've seen enough.

google_you · -21 points · Posted at 14:25:32 on July 7, 2016 · (Permalink)

In node.js:

var f = () => process.stdout.write('Smile!');
f(); f(); f(); 
f(); f();
f();

I don't know how to print new lines programically. Sorry.

Jafit · 22 points · Posted at 15:13:52 on July 7, 2016 · (Permalink)

2/10

Not even asynchronous. You're blocking the stack.

AyrA_ch · 7 points · Posted at 15:44:01 on July 7, 2016 · (Permalink)
function f(x,y){if(y>=0){setImmediate(f,x,--y);}process.stdout.write(y>=0?x:"\n");return x;}f(f(f("smile",3),2),1);

It's clearly async because the return value is somewhere in the middle

Jafit · 6 points · Posted at 16:18:05 on July 7, 2016 · (Permalink)

2/10

Doesn't use ES2015 promises.

AyrA_ch · 1 points · Posted at 16:29:47 on July 7, 2016 · (Permalink)

Who needs promises if we have infinitely stacked callbacks

Jafit · 1 points · Posted at 21:25:36 on July 7, 2016 · (Permalink)

Because promises are actually pretty nice to work with. Unless you don't know how to use them and you just treat them like callbacks and stack them inside of each other.

AyrA_ch · 1 points · Posted at 00:08:41 on July 8, 2016 · (Permalink)

You know what would be nice? The feature from the 50s called multithreading

Jafit · 1 points · Posted at 09:22:02 on July 8, 2016 · (Permalink)

Threads are a pain in the ass.

AyrA_ch · 1 points · Posted at 09:23:08 on July 8, 2016 · (Permalink)

Depends on the language

[deleted] · 1 points · Posted at 18:29:20 on July 7, 2016 · (Permalink)*
((s) => new Promise(resolve => resolve({string: s})).then(data => console.log([...data.string].filter(c => c.charCodeAt() > 103).map((x, i) => (data.string + ' ').repeat(++i)).reverse().join('\n'))))('Smile');

Only 208 bytes. Keep in mind this does not support IE, so you will have to polyfill String.prototype.repeat if you want to use it in a production environment

Jafit · 1 points · Posted at 21:26:46 on July 7, 2016 · (Permalink)

Nice, but the original guy who we all downvoted said we're using node.js. So no need for minification or polyfills.

CaptainJaXon · -3 points · Posted at 16:45:45 on July 7, 2016 · (Permalink)

This?

<html><body>Smile!Smile!Smile!<br>Smile!Smile!<br>Smile!</body></html>

whozurdaddy · 4 points · Posted at 20:15:42 on July 7, 2016 · (Permalink)

markup not programming.

CaptainJaXon · 2 points · Posted at 03:26:45 on July 8, 2016 · (Permalink)

Twas a jest, but I believe it wasn't very good.

[deleted] · -16 points · Posted at 16:43:31 on July 7, 2016 · (Permalink)

[deleted]

God-of-Thunder · 6 points · Posted at 17:15:07 on July 7, 2016 · (Permalink)

Found the guy who asked the question