BreakPoint

cancel
Showing results for 
Search instead for 
Did you mean: 

Rube Goldberg Code

I've recently been left with no choice but to modify some legacy code.  Two things keep going through my head:

1) this thread

2) this dilbert comic

 

 

http://dilbert.com/strips/comic/2013-02-24/

 

I have no code examples to post, my nightmare is not contained in any single block diagram. It spirals in countless interdependancies and circular references of variants coerced to multitudinous data types with no comments or descriptions.

I feel like Copernicus must have felt trying to simplify the Ptolemaic model of planitary motion. Epicycles on epicycles.

 

I know I've coded my own fair share of Rube Goldberg code over the years but I think this time the code may win. Smiley Sad

Troy - CLD "If a hammer is the only tool you have, everything starts to look like a nail." ~ Maslow/Kaplan - Law of the instrument
Message 1321 of 2,560
(11,097 Views)

I knew that I could simplify, but sometimes the daily hurry catches you and you produce a Rube! 😄

 

OP asked, besides another functions, a simple program that generate a number between 0-100 and to check if this number is Odd or Even.

 

Here is what I did:

Odd or Even.png

 

But user apok, improved it.

 

 

Also, RavensFan pointed out a important detail:

 


"RavensFan wrote:

You do not want round to nearest.  When you multiply by 100, you'll get a number between 0 and 99.99999.....   Round to nearest will give you an integer between 0 and 100. but the values of 0 and 100 will only occur half as often as the values in between.

 

You should round down.  Now you will have a number between 0 and 99 that all have equal chances of occurring.  If you want 1 to 100, then add 1.  If you want 0 to 100, then multiply by 101."



This is referred to this thread.

Regards

Mondoni
Message 1322 of 2,560
(10,976 Views)

@joaopam wrote:

I knew that I could simplify, but sometimes the daily hurry catches you and you produce a Rube! 😄

 

Also, RavensFan pointed out a important detail:


@"RavensFan wrote:

You should round down.


The round down trick is important, for example if you need to do a "fair" dice (1..6). If unsure, you should always test using a historgram.

Of course the above quoted example still used twice as may bits as needed. For 0..100, U8 would have been perfectly fine. 😄

 

The quotient&remainder technique is useful for more general problems, e.g. to check divisibility by 3 or higher.

Message 1323 of 2,560
(10,943 Views)

Thanks for the tips, Christian!

Yeah, U8 would be perfectly fine. Another flaw in my code! 🙂

 

Regards

 

[off-topic: I found insteresting your new signature phrase. It serves as inspiration to avoid Rubes. I wrote it down in our office board, in the motivational phrase section 😄 ]

 

Mondoni
Message 1324 of 2,560
(10,918 Views)

It could have been worse.  Seen Here

!rg.pngAlthough, the first two offers are not QUITE and RG'd its best to remember you do have the type def.


"Should be" isn't "Is" -Jay
Message 1325 of 2,560
(10,884 Views)

Well, I'm speachless.

All I can say is that this remembered me of some message altenbach posted once, years ago in this very thread (yes, I read the entire thread :))

This looks like an aztec pyramid! 😄

 

Nice spot!

Mondoni
0 Kudos
Message 1326 of 2,560
(10,895 Views)

If you show ALL of the False cases it resembles an Egyptian pyramid

Spoiler
Show the outermost case true it merely looks lik a waste of BD Space

 

Smiley Tongue

 


"Should be" isn't "Is" -Jay
Message 1327 of 2,560
(10,870 Views)

Looks a bit like this:

http://azpuzzles.com/wp-content/uploads/2013/01/Pyramid.png

Kind Regards,
Thierry C - CLA, CTA - Senior R&D Engineer (Former Support Engineer) - National Instruments
If someone helped you, let them know. Mark as solved and/or give a kudo. 😉
Message 1328 of 2,560
(10,847 Views)

i have seen a nice example on the idee exchange.
hire


Learning LabVIEW since January 2013
0 Kudos
Message 1329 of 2,560
(10,756 Views)

@LordNobady wrote:

i have seen a nice example on the idee exchange.
hire


Agreed, he should have used a case structure to keep everything nice and centre-aligned.

boolean.png

_____________________________
- Cheers, Ed
0 Kudos
Message 1330 of 2,560
(10,747 Views)