[a / b / c / d / e / f / g / gif / h / hr / k / m / o / p / r / s / t / u / v / vg / w / wg] [i / ic] [r9k] [cm / hm / y] [3 / adv / an / cgl / ck / co / diy / fa / fit / hc / int / jp / lit / mlp / mu / n / po / pol / sci / soc / sp / tg / toy / trv / tv / vp / wsg / x] [rs] [status / q / @] [Settings] [Home]
Board
SettingsHome
4chan
/g/ - Technology
Text Boards: /tech/ & /prog/


Posting mode: Reply
Name
E-mail
Subject
Comment
Verification
reCAPTCHA challenge image
Get a new challenge Get an audio challengeGet a visual challenge Help
4chan Pass users can bypass this CAPTCHA. [Learn More]
File
Password (Password used for deletion)
  • Supported file types are: GIF, JPG, PNG
  • Maximum file size allowed is 3072 KB.
  • Images greater than 250x250 pixels will be thumbnailed.
  • Read the rules and FAQ before posting.
  • Japanese このサイトについて - 翻訳
  • You may highlight syntax and preserve whitespace by using [code] tags.


Toggle

→ We're taking feedback for 4chan's inline extension and catalog here. Any/all feedback, bug reports, etc are appreciated! ←

If you aren't already familiar with the inline extension or catalog, try clicking [Settings] in the upper right-hand corner of your screen, or "Catalog" in the page switcher at the bottom of the page.

Last week we added two small batches of janitors from the September recruit-o-thon. We expect to add more in the coming weeks as we get the process down and assess needs across the site.
If you're selected, you'll receive an e-mail from an @4chan.org e-mail address, so make sure you don't have any spam filters that would catch those.
Thanks again to everyone who applied.

File: 1360415174997.png-(95 KB, 1920x1080, disgusting.png)
95 KB
95 KB PNG
What is the most disgusting, inefficient, horrible but working algorithm/piece of code you have ever come up with?

http://pastebin.com/THnvR8NY
>7 for loops

This here is one of my worst creations, but not THE worst. Worst was an algorithm that would take a list of points in three dimensional space and transform them into a mesh of adjacent triangles with minimal area per triangle. It took an hour for a 16000 vertices array... Improved since then by using this code: http://goanna.cs.rmit.edu.au/~gl/research/comp_geom/delaunay/delaunay.html and adapting it to my needs.
>>
prepare to suffer. html special character de-escaping. I've gotten better at this since 4 years ago, of course.
http://sprunge.us/RSQg?c
>>
>>31392676
I see UTF conversions! I did that stuff too.

here:
http://pastebin.com/vZzpJpEG

Not very nice code either
>>
>>31392611 (OP)
what keeps you from refactoring those loops out?
>>
A Pythagorean triplet is a set of three natural numbers, a b c, for which,

a2 + b2 = c2
For example, 32 + 42 = 9 + 16 = 25 = 52.

There exists exactly one Pythagorean triplet for which a + b + c = 1000.
Find the product abc.

>Fuck it I'll brute force it

public class PythagoreanTriplet 
{
int a = 0;
int b = 0;
int c = 0;

public PythagoreanTriplet()
{
for(int i = a; i < 1000; i++)
{
for(int j = b; j < 1000; j++)
{
for(int k = c; k < 1000; k++)
{
if(checkIfTriplet(i, j, k))
{
a = i;
b = j;
c = k;

return;
}
}
}
}
}
private boolean checkIfTriplet(int a, int b, int c)
{
if(a + b + c != 1000)
return false;
if(!(a < b && b < c))
return false;
if(!(a * a + b * b == c * c))
return false;

return true;
}
public int getProduct()
{
return a * b * c;
}
public static void main(String[] args)
{
System.out.println((new PythagoreanTriplet().getProduct()));
}
}
>>
>>31392771
the simplified code implemented in Au could be of help http://sprunge.us/UhJa



Delete Post [File Only] Password
Style
[a / b / c / d / e / f / g / gif / h / hr / k / m / o / p / r / s / t / u / v / vg / w / wg] [i / ic] [r9k] [cm / hm / y] [3 / adv / an / cgl / ck / co / diy / fa / fit / hc / int / jp / lit / mlp / mu / n / po / pol / sci / soc / sp / tg / toy / trv / tv / vp / wsg / x] [rs] [status / q / @] [Settings] [Home]
[Disable Mobile View / Use Desktop Site]

[Enable Mobile View / Use Mobile Site]

- futaba + yotsuba -
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.