[Boards: 3 / a / aco / adv / an / asp / b / bant / biz / c / can / cgl / ck / cm / co / cock / d / diy / e / fa / fap / fit / fitlit / g / gd / gif / h / hc / his / hm / hr / i / ic / int / jp / k / lgbt / lit / m / mlp / mlpol / mo / mtv / mu / n / news / o / out / outsoc / p / po / pol / qa / qst / r / r9k / s / s4s / sci / soc / sp / spa / t / tg / toy / trash / trv / tv / u / v / vg / vint / vip / vp / vr / w / wg / wsg / wsr / x / y ] [Search | Free Show | Home]

Can we have a code gore thread?

This is a blue board which means that it's for everybody (Safe For Work content only). If you see any adult content, please report it.

Thread replies: 72
Thread images: 11

File: 1454906413139.png (638KB, 4760x4986px) Image search: [Google]
1454906413139.png
638KB, 4760x4986px
Can we have a code gore thread?
>>
>>52858802
What the fuck was he even trying to accomplish with this?
>>
>>52858802
This has to be code generated
>>
>>52858802
I'm tempted to try to compile that, to see what the optimizer would do to it.

But not enough to bother running it through OCR.
>>
Jesus Christ. What a way to check for primes.
Probably works too.

But clearly this is someone who's bullshitting someone who's checking that code.
>>
File: meme_code.jpg (69KB, 694x670px) Image search: [Google]
meme_code.jpg
69KB, 694x670px
This?
>>
>>52858802
this thing is actually more effecient than importing and calling a bumfuck method
>>
>>52858802

http://pastebin.com/Bwn3bEhT
>>
File: compute.png (43KB, 356x425px) Image search: [Google]
compute.png
43KB, 356x425px
John Draper, aka Captain Crunch, wrote a word processor while in prison. He did have some access to a computer while on work release, but otherwise did it by hand in his cell overnight.

You guys should be smart enough to figure out OP's pic.
>>
>>52858996
Well given that it's OR'ed together it runs a compare every single one of those statements.

What should be done is probably to divide them up into small regions which you sum. If the sum is 0 then none of the statements were true and you can continue onto later checks.

Seriously doubt this is a good way to do it though. Even if you're only accepting rather low primes as you do here.
>>
>>52858996

efficient for who?
>>
>>52858996
>>52859056
From an algorithmic complexity/looping standpoint that could be true but I doubt anyone on /g/ cares enough to look into this.

(whistles)
>>
File: 1454894454267.png (55KB, 571x553px) Image search: [Google]
1454894454267.png
55KB, 571x553px
>>52858802
>>
>>52858977
what is the problem here?
>>
>>52859098
Nah it probably loses out because of SIMD. Since all of this efficiency relies on early outs it's gonna be comparatively slow without that 4x multiplier.t.
Pretty much guarantees it.
>>
>>52859085
“Who” and “whoever” aresubjective pronouns; “whom” and “whomever” are in theobjective case. That simply means that “who” (and the same for “whoever”) is always subject to a verb, and that “whom” (and the same for “whomever”) is always working as an object in a sentence. As simple and important as that distinction is, many people have difficulty deciding on the proper usage of “who” and “whom” in sentences.
>>
>>52859050
Yeah, we probably are, but we aren't in prison, so we can't be arsed.
>>
>>52859140
It compares the input number to every even number below a big number to see if the number is even. When all you have to do is num%2 and see if that's 1 or 0.
>>
>>52859111
i like this one
>>
>>52859142
What if you ran it through an Intel compiler? AVX extensions? Oh boy, can't wait to try that out.

https://software.intel.com/en-us/articles/performance-tools-for-software-developers-intel-compiler-options-for-sse-generation-and-processor-specific-optimizations
>>
>>52858830
Really hacky way of checking if a number is prime quickly. You simply iterate through known primes and see if the number is divisible by any of them that are less than or equal to sqrt(n).

It's just written in a really shitty way. The right way is to make an array of the known primes and iterate over that, rather than that mess.

>>52858848
Most likely is.
>>
https://codeshare.io/4chan
live gore
>>
>>52858802
Is this the Windows NT Kernel source code?
>>
>>52859153
I was told that &1 is a much faster way of testing it.
>>
>>52859289
Only if you disable optimization or your compiler is utter shit
>>
>>52859289
>>52859373
& 1 would probably be faster, seeing as modulus relies on the DIV/IDIV x86 instruction, which takes WAY more cycles than a AND instruction.
>>
>>52859256
lol
>>
>>52858977
What's the problem here? Apart from the fact that the start > stop check should be done before the int parsing. Also I don't know why you would be putting the args into self.args first.
>>
>>52859022

What is that even supposed to be.
>>
>>52858802

ITT people posting some variation of this "compare to known examples" style of code

Can't we do better?
>>
>>52859464
It's supposed to allow you to play Chess using the console.
>>
File: 1426727812225.jpg (37KB, 694x801px) Image search: [Google]
1426727812225.jpg
37KB, 694x801px
>>
>>52859523
Nice one anon.
>>
>>52859111
>"The number is false."
I audibly groaned at this.
>>
File: 1454445220299.png (25KB, 907x500px) Image search: [Google]
1454445220299.png
25KB, 907x500px
thisis now trigger thread
>>
File: ae6.jpg (26KB, 500x378px) Image search: [Google]
ae6.jpg
26KB, 500x378px
>>52859111
>the number is false
>>
>>52860348
>Not
if (true)
method();
>>
>>52861511
how you write code memes?
>>
>>52861511
>not
if (true) method();
>>
>>52858802

Why.
>>
>>52862275
>not
if (method());
>>
>>52862508
>not
method();
>>
File: 1454923547581.png (147KB, 1680x1050px) Image search: [Google]
1454923547581.png
147KB, 1680x1050px
this anon ...
people even convinced him to use float
>>
>>52858802

code generators, not even once
>>
>>52863105
>Winshit
Please go.
>>
>>52863105
kek'd >>52861475
>>
>>52859449
Could the compiler detect this and optimize for that?
>>
>>52863148
it's not me retard
>>
>>52858802
I once wrote a monte carlo simulation for some physics stuff in python that could take 2+ hours to run to completion on my home machine, depending on the starting parameters. Using the computing cluster at school, the runtime for the exact same parameters could be brought down to around 20 minutes.

At the time, I thought the performance was reasonable, but looking back on it, I can't help but feel like most of it might pass as "code gore".
>>
>>52863105
R8 my fix of that?
>>
>>52863105
>taskar on top

GO AWAY
O

A
W
A
Y
>>
>>52858802
all number goes by +2 +4 and +6.
this is the siht happening when coders don't know any math.
>>
File: bane.jpg (23KB, 250x376px) Image search: [Google]
bane.jpg
23KB, 250x376px
>>52859085
For you.
>>
>>52858802
Jesus Christ, what possessed a man to do this? You'd think half-way into writing this he'd realize his mistake, or maybe he kept going because he'd already gone too far.
>>
>>52863105
That's what he gets for not going into the DPT.
>>
File: 1431830050040.png (927KB, 571x553px) Image search: [Google]
1431830050040.png
927KB, 571x553px
>>52862259
Take a template and write code over it with software such as Gimp.

Here is a template I just made.
>>
>>52859056
From the C standard:
>lhs || rhs
>There is a sequence point after the evaluation of lhs. If the result of lhs compares unequal to zero, then rhs is not evaluated at all (so-called short-cirquit evaluation)
>>
>>52859462
>start > stop check should be done before the int parsing
what?
>>
>>52864145
I don't think that's real
>>
>>52864313
If that was the operational truth then that's be even worse. Because we'd certainly like to take advantage of windowing here. Regardless my method has less operations on average. Which is probably the case you want to optimize for.
>>
>>52858977

What is wrong with this?
>>
>>52864037

Someone get this hothead outta here
>>
>>52862275
That fucks up GUI debuggers. And counts as mayor issue on Sonarqube.
>>
>>52858802
I once had to check if a string was F1, F2, F3... F11, F12 and return which F was it or -1 if error.
I found my code:
int f_key(char* s) {
if (s[0] != 'F')
return -1;
int x = -1;
if (s[1] >= '1' && s[1] <= '9')
x = s[1] - '0';
if (x == -1)
return -1;
if (s[2] == '\0')
return x;
int y = -1;
if (s[2] >= '0' && s[2] <='2')
y = s[2] - '0';
if (y == -1)
return -1;
if (s[3] != '\0')
return -1;
if (x != 1)
return -1;
return x * 10 + y;
}


Am I a meme?
>>
>>52868156
>what is atoi
>>
>>52863911
declare your variables beforehand so your assignments are aligned you fuckikng nigger
>>
>>52868897
I heard it was deprecated.
>>
>>52859289
&1 won't work for negative ints in all machines.
>>
>>52869074
Don't reinvent the wheel
>>
>>52858848
Duh.
>>
>>52859523
I laughed so fucking hard
>>
>>52859225
You can also use modulo on every odd number between itself and 2 and if none are equal to 0 then its a prime. (if num%num-1==0 return false, etc..)
Thread posts: 72
Thread images: 11


[Boards: 3 / a / aco / adv / an / asp / b / bant / biz / c / can / cgl / ck / cm / co / cock / d / diy / e / fa / fap / fit / fitlit / g / gd / gif / h / hc / his / hm / hr / i / ic / int / jp / k / lgbt / lit / m / mlp / mlpol / mo / mtv / mu / n / news / o / out / outsoc / p / po / pol / qa / qst / r / r9k / s / s4s / sci / soc / sp / spa / t / tg / toy / trash / trv / tv / u / v / vg / vint / vip / vp / vr / w / wg / wsg / wsr / x / y] [Search | Top | Home]

I'm aware that Imgur.com will stop allowing adult images since 15th of May. I'm taking actions to backup as much data as possible.
Read more on this topic here - https://archived.moe/talk/thread/1694/


If you need a post removed click on it's [Report] button and follow the instruction.
DMCA Content Takedown via dmca.com
All images are hosted on imgur.com.
If you like this website please support us by donating with Bitcoins at 16mKtbZiwW52BLkibtCr8jUg2KVUMTxVQ5
All trademarks and copyrights on this page are owned by their respective parties.
Images uploaded are the responsibility of the Poster. Comments are owned by the Poster.
This is a 4chan archive - all of the content originated from that site.
This means that RandomArchive shows their content, archived.
If you need information for a Poster - contact them.