-3
\$\begingroup\$

"Bracket" numerals are a type of 'numerals' I made up once, and thought would be a nice challenge here. Basically, you convert the input number into base 6, and then transliterate the 012345 respectively with ()[]{}, so every 0 becomes (, every 1 becomes ), etc.
You don't have to use ()[]{} per se. As long as you specify what characters you use, you can use any other characters (except for digits, otherwise just converting to base-6 would have been enough!)

Since this is tagged , the score is in bytes, where the least amount of bytes wins.

A few examples: 6 = )(. 100200 = [(})}[(. 44790 = }{][)(.

Here is some lengthy JavaScript code which accomplishes what I described above. Since it's a snippet (using variable x) instead of a function or full program, it isn't valid however:

var [x,q,w] = [0,0,0];q = x.toString('6');w = q.replace(/0/g, '(');q = w.replace(/1/g, ')');w = q.replace(/2/g, '[');q = w.replace(/3/g, ']');w = q.replace(/4/g, '{');q = w.replace(/5/g, '}');console.log(q);

Yes, that is 207 bytes. You probably can do better! I will accept an answer on June 1st, 2019, but you can continue to post answers afterwards of course.

Standard rules apply for your answer with default I/O rules, so you are allowed to use STDIN/STDOUT, functions/method with the proper parameters and return-type, full programs. Your call. So you aren't allowed to have a var x like I did in my example JavaScript snippet.
Default Loopholes are forbidden.

\$\endgroup\$
  • 8
    \$\begingroup\$ The contest ended 2 weeks ago? Can you give some sample inputs/outputs and test cases? \$\endgroup\$ – Expired Data May 16 at 15:19
  • 7
    \$\begingroup\$ Penalties and bonuses generally don't make challenges more fun. That said, I think you intended to make using a variable as input penalised but it actually gives an unbeatable score of zero? I'd recommend just removing them but if you want to keep them then that definitely needs to change. \$\endgroup\$ – FryAmTheEggman May 16 at 15:30
  • 6
    \$\begingroup\$ As long as you specify what characters you use, you don't need to use brackets: so we can just convert to base 6? \$\endgroup\$ – Arnauld May 16 at 15:33
  • 3
    \$\begingroup\$ Do we need to support \$n=0\$? \$\endgroup\$ – Arnauld May 16 at 16:05
  • 3
    \$\begingroup\$ Whether or not 0 needs to be handled as input still needs to be addressed. Also, can we use unprintable characters in the replacement? \$\endgroup\$ – Shaggy May 16 at 22:10

12 Answers 12

6
\$\begingroup\$

Python 3 + NumPy (non-competing), 40 * 0 = 0 bytes

This answer is no long competing, for the bonuses were removed.

from numpy import*
print(base_repr(n,6))

Try it online!

If your code requires you to set a variable as your input, your score gets multiplied by 0.

Takes input from a variable n.

As long as you specify what characters you use, you don't need to use brackets.

0 instead of (, a 1 instead of ), 2 instead of [, 3 instead of ], 4 instead of {, and 5 instead of }.

\$\endgroup\$
  • 1
    \$\begingroup\$ The "bonuses" have been removed. \$\endgroup\$ – Shaggy May 17 at 20:12
2
\$\begingroup\$

Japt, 4 bytes

Uses [objec.

s6îM

Try it

Alternative 4 bytes

Uses the (unprintable) characters at codepoints 1-6.

s6õd

Try it

Or, if that's not allowed:

5 bytes

Using !"#$%&.

s6õdH

Try it

Or, also (using wander):

s`æ`â

Try it

If I can figure out a 6 letter word that Shoco can compress to a single character then that last one can be golfed to 3 bytes.

\$\endgroup\$
  • \$\begingroup\$ ;sF¯6 also works for 5 \$\endgroup\$ – Embodiment of Ignorance May 17 at 2:58
  • \$\begingroup\$ @EmbodimentofIgnorance, that's different enough to post yourself. I was deliberately avoiding the alt. variables 'cause having to add 25% to my score with ; was annoying me! \$\endgroup\$ – Shaggy May 17 at 18:42
1
\$\begingroup\$

05AB1E, 11 10 5 4 bytes

All three programs below will return a list of characters instead of a joined string.

žOÅв

Uses aeiouy instead of ()[]{} for 0123456 respectively.

Try it online.


Answers which actually use ()[]{}:

11 10 8 bytes:

žu„<>мÅв

Try it online

8 bytes alternative by @Grimy:

…([{º{Åв

Try it online.

Explanation:

žO        # Push string builtin "aeiouy"
  Åв      # Convert the (implicit) input to this custom base-"aeiouy"
          # (which is output implicitly as result)

žu        # Push string builtin "()<>[]{}"
  „<>м    # Remove the "<>" from this string: "()[]{}"
      Åв  # Convert the (implicit) input to this custom base-"()[]{}"
          # (which is output implicitly as result)

…([{      # Push string "([{"
    º     # Mirror it vertically to "([{}])"
     {    # Sort the characters in the string: "()[]{}"
      Åв  # Convert the (implicit) input to this custom base-"()[]{}"
          # (which is output implicitly as result)
\$\endgroup\$
  • \$\begingroup\$ There's a builtin which pushes ()<>[]{}? Just why? \$\endgroup\$ – Embodiment of Ignorance May 17 at 3:00
  • \$\begingroup\$ @EmbodimentofIgnorance it could be because ()<>[]{} are all the typeable "bracket" characters on your keyboard i.e. all of them are used to enclose something. Maybe the purpose is so you can do what @KevinCruijssen did here and crop out some characters so you have some else. \$\endgroup\$ – Ethan Slota May 17 at 12:05
  • 1
    \$\begingroup\$ Alternative 8-byter using ()[]{}: …({[º{Åв. (Or drop the { for a 7 byter using the same characters but in a different order). \$\endgroup\$ – Grimy May 17 at 12:45
  • \$\begingroup\$ @Grimy Ah, I indeed tried with both …({[ and º as well to see if I could make something shorter, but ended up at 10 bytes. Didn't realize the sort would put them in the desired ()[]{} order. :) \$\endgroup\$ – Kevin Cruijssen May 17 at 12:51
1
\$\begingroup\$

JavaScript (ES6),  36  34 bytes

Saved 2 bytes thanks to @Shaggy

Character set: [,o,b,j,e and c.

f=n=>(n>5?f(n/6|0):'')+({}+0)[n%6]

Try it online!

\$\endgroup\$
  • \$\begingroup\$ 34 bytes, using alternative characters. \$\endgroup\$ – Shaggy May 16 at 23:03
  • 1
    \$\begingroup\$ So you saved -28 bytes? I think you replaced the wrong digit. \$\endgroup\$ – fəˈnɛtɪk May 17 at 17:21
0
\$\begingroup\$

Wolfram Language (Mathematica), 64 bytes

#~IntegerDigits~6/.Table[k->StringTake["()[]{}",{k+1}],{k,0,5}]&

Try it online!

\$\endgroup\$
0
\$\begingroup\$

PHP, 53 bytes

<?=strtr(base_convert($argn,10,6),'012345','()[]{}');

Try it online!

I'll be honest, I still don't understand the bonus, but here's a PHP version.

\$\endgroup\$
  • 1
    \$\begingroup\$ Huh.. How are you able to post an answer when it's closed as unclear for more than an hour? \$\endgroup\$ – Kevin Cruijssen May 16 at 19:12
  • 1
    \$\begingroup\$ @KevinCruijssen, you can still post from the SE app after a question has been closed if you loaded it before it was closed or had a draft saved. \$\endgroup\$ – Shaggy May 16 at 22:01
  • \$\begingroup\$ @kevincruijssen, I just posted this from the web version. Possibly I hadn't refreshed the page since the question was closed and it doesn't check for it. Smells like a SE bug report! \$\endgroup\$ – gwaugh May 16 at 22:06
0
\$\begingroup\$

C# (Visual C# Interactive Compiler), 47 bytes

n=>m=>{do m[0]+="()[]{}"[n%6];while((n/=6)>0);}

Try it online!

\$\endgroup\$
0
\$\begingroup\$

Jelly, 3 bytes

ṃØỵ

Try it online!

Uses ‘aeiouy’ for ‘01235’.

\$\endgroup\$
0
\$\begingroup\$

APL (Dyalog Extended), 13 bytes

'()[]{}'⊇⍨6∘⊤

Try it online!

Pretty straightforward tacit function. Test cases used are 15 randomly selected integers between 0 and 999.

Uses ⎕IO←0.

Thanks to @Adám for 2 bytes

How:

'()[]{}'⊇⍨6∘⊤ ⍝ Tacit function
          6∘⊤ ⍝ Convert input to base 6
        ⊇     ⍝ Index the right argument with the indices in the left argument
         ⍨    ⍝ With arguments swapped
'()[]{}'      ⍝ Character vector
\$\endgroup\$
0
\$\begingroup\$

Bash, 65 63 bytes

Using STDIN and not command line arguments:

while read n;do echo "obase=6;$n"|bc -q|tr 012345 '()[]{}';done

Try it online!

\$\endgroup\$
  • \$\begingroup\$ Nice one. You may try dc, is often shorter than bc: while read n;do dc<<<6o$n\ p|tr 012345 '()[]{}';done. \$\endgroup\$ – manatwork May 17 at 15:22
  • \$\begingroup\$ Ahh! Don't use dc very much -- cannot stand RP notation :-), reminds me of very old steam powered calculators. Thanks for the tip mind. And yes, I could have removed the first pair of ' ' but habit means I left them in. \$\endgroup\$ – PJF May 17 at 15:58
0
\$\begingroup\$

Charcoal, 8 bytes

⍘N()[]{}

Try it online! Link is to verbose version of code. Explanation:

 N          Input as a number
⍘           Base convert using specified characters
  ()[]{}    Literal string of required characters

5 bytes using the letters a-f (or A-F also works):

⍘N…β⁶

Try it online! Link is to verbose version of code. Explanation:

 N      Input as a number
⍘       Base convert using
  … ⁶   First six characters of
   β    Lowercase alphabet
\$\endgroup\$
0
\$\begingroup\$

Ruby, 28 bytes

Uses abcdef in place of 012345.

->x{x.to_s(6).tr'0-5','a-f'}

Try it online!

\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.