Grasshopper

algorithmic modeling for Rhino

Playing off of Danny's computer language conversion theme, make a definition that converts any integer up to 65535 (one less than 16^4) to its 4-digit hex equivalent.

Examples:

0 = 0000

1 = 0001

9 = 0009

10 = 000A

16 = 000F

65535 = FFFF

Scripting will obviously be the shortest. I think finding the shortest native def. is more interesting. Mine's 13 components including a slider for input, a panel for output, and a couple other panels to hold pertinent info (I just mean there is data that could be internalized to shave off a couple components, but there is no internalized data in mine).

Best,

Brian

Views: 1379

Replies to This Discussion

14 components, including a very inelegant function component

Attachments:

well, if we allow functions and expressions as "native" then we can go down to 8 components.

but that feels like cheating... ;-)

Attachments:

ok, just for fun, attached definition which can handle any number of digits, not just 4

and actually any base(radix) up to 16

Attachments:

EDIT: I just opened this file, very nice. I like how you defined the function to be evaluated. And obviously at this point you win :)

Nice. Your first one looks like it's pretty much the same as mine, except at each step I just divided by 16 and used the results as indices for retrieving equivalent values from a param component.

A bit late to the party but this is what it took to change the Dec to Bin into a universal Base Changer.

Attachments:

RSS

About

Translate

Search

Photos

  • Add Photos
  • View All

Videos

  • Add Videos
  • View All

© 2024   Created by Scott Davidson.   Powered by

Badges  |  Report an Issue  |  Terms of Service