5
\$\begingroup\$

There seems to be agreement that numeric input is by default accepted in either decimal or unary bases.

The linked meta-question doesn't address the issue of whether separate inputs of the same program can use different bases. For example, consider a program or function that accepts two inputs. Can the first input be in decimal and the second in unary?

The reationale is that choosing the base of each input independently can lead to more efficient programs, or to reduced length in code golf.

\$\endgroup\$
2
  • 3
    \$\begingroup\$ Please don't use meta as a simple poll by posting all the possible opinions. Post yours and let someone who can actually argue for the opposite side actually make a case for it. \$\endgroup\$ Feb 3, 2016 at 12:11
  • \$\begingroup\$ @MartinBüttner Sorry. I change that in a minute \$\endgroup\$
    – Luis Mendo
    Feb 3, 2016 at 12:12

3 Answers 3

14
\$\begingroup\$

No

The rationale for allowing unary input is that for some languages unary is the natural representation of natural numbers. Obvious examples include string-based or tape-based languages. Allowing them to use their natural representation for input reduces unconscious bias against such languages.

That rationale cannot reasonably stretch to mixed input. The argument that taking input in a mixture of forms, some of them "unnatural", allows you to golf your answer better logically extends to arguing that the input format should be such that your program just needs to be eval(input()), and should be treated with the same derision that the latter deserves.

\$\endgroup\$
2
  • \$\begingroup\$ Allowing an input format that reduces the program to eval is very different from allowing unary. What I'm proposing is let the programmer choose among two, numeric formats. An hypothetical format that only needs to be eval'ed implies letting the programmer choose among an infinite set of non-numeric "formats" \$\endgroup\$
    – Luis Mendo
    Feb 3, 2016 at 14:11
  • 4
    \$\begingroup\$ @LuisMendo I think what Peter is saying is that it's a slippery slope, and allowing different bases goes beyond "using a language's natural representation" towards "outsourcing some preprocessing of the data into the input format". \$\endgroup\$ Feb 3, 2016 at 18:23
0
\$\begingroup\$

By default, mixed input bases can be used, BUT...

...only if using mixed bases doesn't trivialize0 the problem, and only if the input bases are constant1. My answer is very similar to the common consensus, having the same sort of logic (i.e. wishing to allow esoteric languages to compete but not ruining the challenge entirely) behind it.

0 - trivialize meaning "make the problem a simple task, where the code in question can be thought of as 'abusive' (using a loophole similar to the standard loopholes) or as 'trolling', akin to taking the challenge too literally, solving a considerable amount of work i.e. base conversion by having the user do it, etc.

1 - constant meaning that if you take two arguments a and b in bases c and d, c and d must not change when running the program with different inputs, unless the nature of the problem is to have multi-base inputs.

\$\endgroup\$
6
  • 2
    \$\begingroup\$ What do you mean by constant? Can you ellaborate? Also, "trivialize the problem" is a dangerous term. Someone's "trivializing" may be someone else's "more efficient code" \$\endgroup\$
    – Luis Mendo
    Feb 3, 2016 at 12:22
  • \$\begingroup\$ @LuisMendo constant meaning that if you take two arguments a and b in base s c and d, c and d must bit change when running the program with different inputs, unless the nature of the problem is to have multi base inputs \$\endgroup\$ Feb 3, 2016 at 12:27
  • \$\begingroup\$ Got it. I agree with the "constant" part. I suggest you ellaborate in the answer for clarity \$\endgroup\$
    – Luis Mendo
    Feb 3, 2016 at 12:30
  • 1
    \$\begingroup\$ It's not at all the same logic. \$\endgroup\$ Feb 3, 2016 at 13:24
  • \$\begingroup\$ @CᴏɴᴏʀO'Bʀɪᴇɴ Peter already explained this claim in this answer. \$\endgroup\$ Feb 3, 2016 at 15:24
  • \$\begingroup\$ This answer has neither my upvote nor my downvote. \$\endgroup\$ Feb 3, 2016 at 15:28
-4
\$\begingroup\$

Yes, each input can use a different base (decimal or unary) by default

Of course, the challenge can always override this default.

\$\endgroup\$
0

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .