3
\$\begingroup\$

You dudes, the Most Excellent Adventure is a home brew roleplaying game system based on the Bill & Ted Films, plays gnarly air guitar riff.

In this game system, when you draw from your dice pool (you have between 1 and 12 ten-sided dice, with faces labelled 0-9) you need to connect the results as a phone number on your phone pad:

Here one person has rolled 4, 2, 8, 3, 8, and 2, dialling 3-2-2-4-8-8. The other 7, 4, 6, 3, 9, and 4, only dialling 4-4-7 or 3-6-9. And the longest number wins.

Bill and Ted want to play this game on their telephone kiosk, but haven't the first clue about programming. As Station isn't around, they want you to program it. The kiosk had access to all programming languages and OSs past and future (causality forbids you using any future technology... No imaginary python 7 !)

Your input is two numbers between 1 and 12, representing the number of dice player 1 and player 2 have respectively. The output is the result for each player, and the length of the largest number they could dial.

Input: 8 10
Output:

Player 1 rolled 1 2 3 4 5 6 7 8 with longest dialable number of 8.     
Player 2 rolled 8 8 8 2 3 1 4 0 3 3 with longest dialable number of 10.

Numbers can be reordered and pressing the same key twice counts as two digits (which is why the above sequence 8 8 8 2 3 1 4 10 3 3 makes a six digit number not a 4 digit number)

Also, as you're programming this in a telephone kiosk you can only access 0-9, a-z, the * and a # keys in your code. Letters are accessed by repeated typing, much like on a mobile phone. Every other key must be input in the kiosk as its ASCII code in hex like so: #0a the upshot is when scoring your submission, these keys "cost" three times as many.[Unclear / Incorrect?]

For instance to type ~ you press the hash key once, the 7 and then 3 three times to cycle through the digits 3de. This gives the code #7e which corresponds to ~. When you upload you code here you can just type the ~, and count it as five characters.

The keypad looks a little like this: Telephone keypad

For instance If your code had print() that would cost 15 for the print (7p 7pqr 4ghi 6mn 8t) plus 6 for the () (#28 #29).

This is code golf as Bill and Ted will get bored otherwise. Let the coding commence plays gnarly air guitar riff.

\$\endgroup\$
41
  • 3
    \$\begingroup\$ You roll a 12-sided dice to obtain a number from 0-9? Is this right? \$\endgroup\$
    – nneonneo
    Jun 27, 2014 at 1:10
  • 1
    \$\begingroup\$ I think your tags are not going to work for this challenges. First, the restriction is really arbitrary and doesn't make codes any more interesting. And second it is not a good fit for popularity-contest. What should I judge by? Popularity of the language/poster? And your idea with added features make this challenge too broad. \$\endgroup\$
    – Howard
    Jun 27, 2014 at 6:28
  • 5
    \$\begingroup\$ The restriction to only using 0123456789ab*# rules out even the esoteric languages most commonly used on this site. You'll be lucky to get one answer, let alone two. PS What d10s are you using which have 10 rather than 0? \$\endgroup\$ Jun 27, 2014 at 8:25
  • 5
    \$\begingroup\$ Please use the sandbox next time \$\endgroup\$ Jun 27, 2014 at 8:36
  • 2
    \$\begingroup\$ The roll "8 8 8 2 3 1 4 0 3 3" can be reordered "3 3 3 2 1 4 8 8 8 0" to make a 10 digit number on the keypad, if I'm not mistaken. \$\endgroup\$ Jun 27, 2014 at 17:25

1 Answer 1

3
\$\begingroup\$

VBScript - 1668 telephone keypresses (was 1708)

My entry is golfed a bit more - I realized (doh!) that the variable names should be characters that require less telephone keypresses (a,d,g,j,etc).

This program produces the output exactly as shown and takes the input as command line parameters. If line endings are 1 byte there is no advantage to using : to put it all on one line (#0a vs #3a). Run it with cscript script.vbs 8 10 replacing 8 and 10 with whatever values you want - it tries every combination in order to get the maximum string so it is SLOW.

I just have one question: if you needed a two numbers beside each other that were both on the same key isn't it a bit ambiguous. Wouldn't the text a=e (22#333333) be the same keypresses as a>d (22#333333)? How do you differentiate where the character boundaries are? I didn't specifically check for every possible occurance of where things on the same key are beside themselves and I don't know what I would have done if I did notice it...

sub b(d,m)
p=true
a=len(m)
for g=1to a-1
p=p and instr(split("7890*1245*123456*2356*124578*123456789*235689*45780*4567890*56890","*")(mid(m,g,1)),mid(m,g+1,1))>0
next
if p and t<a then t=a
if d=""then exit sub
a=len(d)
for g=1to a
w=""
if g>1then w=left(d,g-1)
p=""
if g<a then p=mid(d,g+1)
b w+p,m+mid(d,g,1)
next
end sub
randomize
set m=wscript.arguments
for e=1to 2
d=""
j="Player "+cstr(e)+" rolled"
for t=1to mid(10000+m.item(0)*100+m.item(1),e*2,2)
w=cstr(int(rnd()*10))
j=j+" "+w
d=d+w
next
j=j+" with longest dialable number of"
t=0
b d,""
wscript.echo j+" "+cstr(t)
next

Ok, I am finally ready to score my entry - that of course means no more changes to it because of how long it takes to transform it to a score. The transformed phone input is:

77777888222#20222#2833#2222266#29#02277#333887777888333#02222#3335555333666#2866#29#02233336666777
7#2044#3331886666#2022#2331#02277#33377#202266633#20444466677777887777#2877777775555444488#28#2278
90*1245*123456*2356*124578*123456789*235689*45780*4567890*56890#22#22222#22*#22#29#2866444433#2866
#2222244#222221#29#29#2222266444433#2866#2222244#22221#222221#29#29#33330#02266633399988#022444433
33#2077#202266633#2088#3222222#2088444333666#2088#33322#02244443333#2033#333#22#2288444333666#2033
3999444488#2077777888222#02222#3335555333666#2833#29#022333366667777#2044#3331886666#2022#02299#33
3#22#22#02244443333#2044#3333188444333666#2099#3335555333333388#2833#2222244#2331#29#02277#333#22#
22#02244443333#2044#3222222#2088444333666#2077#33366444433#2833#2222244#22221#29#022222#2099#22227
7#2222266#222266444433#2833#2222244#222221#29#02266633399988#02233366633#2077777888222#02277772266
633666666444499999333#0227777733388#2066#33399777772222777744447788#233322777744888663336668877777
#022333366667777#20333#3331886666#202#02233#333#22#22#02255#333#22#5055552299993337777#20#22#22222
22277777887777#28333#29#2222#22#20777766665555555533333#22#022333366667777#2088#3331886666#2066444
433#2810000#222266#233344448833366#280#29*100#222266#233344448833366#281#29#22222333*2#222222#29#0
2299#333222277777887777#28444466688#28777766633#28#29*10#29#29#02255#33355#2222#22#20#22#222299#02
233#33333#222299#02266633399988#02255#33355#2222#22#2099444488444#2055556666666443337777788#203344
44225555222225555333#20666888662223337777#2066663333#22#02288#3330#022222#2033#22222#22#22#0229977
7772222777744447788#233333322224446666#2055#2222#22#20#22#2222222277777887777#2888#29#022666333999
88
\$\endgroup\$
2
  • 2
    \$\begingroup\$ You don't need to count newlines as 2 bytes. It does not matter whether you are on Windows or not, here you can always count them as 1 byte. \$\endgroup\$
    – ProgramFOX
    Jul 3, 2014 at 9:38
  • \$\begingroup\$ I have just had an idea how to make it much shorter - I'll have a new version soon (and I will put the linefeeds back if they count as the same length as a colon) \$\endgroup\$ Jul 4, 2014 at 2:29

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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