20
2
In the webcomic Darths & Droids, Pete, who plays R2-D2 in the fictional roleplaying campaign around which the comic is based, once claims (warning: potential spoilers in the linked comic) that, with the Lost Orb of Phanastacoria rigged up to his shock probe, he can now dish out a whopping 1048576d4 of damage. (The GM has neither confirmed nor denied this.) Since it should be reasonably obvious that almost no one will actually have the patience to roll that many dice, write a computer program to do it for him, outputting the total value rolled in some reasonable format. Entries will be ranked by program size (shortest program, by byte count, wins), both overall and per-language, with run time breaking ties. Answer may be either a full program or a function definition.
Scores Per-Language
Pyth
Maltysen - 8 bytes*
Jakube - 10 bytes
APL
Alex A - 10 bytes
CJam
Optimizer - 11 bytes
J
ɐɔıʇǝɥʇuʎs - 12 bytes **
Clip10
Ypnypn - 12 bytes **
K
JohnE - 13 bytes
Ti-84 BASIC
SuperJedi224 - 17 bytes*
R
MickyT - 23 bytes
OCTAVE/MATLAB
Oebele - 24 bytes
PARI/GP
Charles - 25 bytes **
Wolfram/Mathematica
LegionMammal978 - 27 bytes
Perl
Nutki - 29 bytes
AsciiThenAnsii - 34 bytes
Ruby
Haegin - 32 bytes **
ConfusedMr_C - 51 bytes **
Commodore Basic
Mark - 37 bytes **
PHP
Ismael Miguel - 38 bytes
VBA
Sean Cheshire - 40 bytes **
PowerShell
Nacht - 41 bytes **
Javascript
Ralph Marshall - 41 bytes
edc65 - 54 bytes (Requires ES6 functionality not available in all browsers.)
Lua
cryptych - 51 bytes
Java
RobAu - 52 bytes **
Geobits - 65 bytes
C
Functino - 57 bytes
Python
CarpetPython - 58 bytes
Postgre/SQL
Andrew - 59 bytes **
Swift
Skrundz - 69 bytes
GoatInTheMachine - 81 bytes
Haskell
Zeta - 73 bytes **
ActionScript
Brian - 75 bytes **
><>
ConfusedMr_C - 76 bytes
GO
Kristoffer Sall-Storgaard - 78 bytes
C#
Brandon - 91 bytes **
Andrew - 105 bytes
Ewan - 148 bytes
Scratch
SuperJedi224 - 102 bytes
C++
Michelfrancis Bustillos - 154 bytes
Polyglots
Ismael Miguel (Javascript/ActionScript2) - 67 bytes
Top 10 Overall
Maltysen Alex A Jakube Optimizer ɐɔıʇǝɥʇuʎs/Ypnypn (order uncertain) JohnE SuperJedi224 MickyT Oebele
Warning- entries marked with a * are VERY SLOW.
Programmed marked ** I have not yet been able to properly test
Wait, do I have to give the sum of the dice roll or just all the rolls in a list? – Maltysen – 2015-04-30T01:58:03.007
The sum of the dice roll. – SuperJedi224 – 2015-04-30T02:01:58.230
5Your question, as it stands, will likely be criticized for being unclear or being overly broad. It would be very helpful if you described in specific, objective terms how programs will be scored and what methods programs should have available to them. Also, the notation of
1048576d4
may be unclear to some users. It would be helpful to provide a description of precisely what should be computed, and any guidelines that must be followed. – BrainSteel – 2015-04-30T02:05:15.6802This problem can be done too quickly to be a good time trial. – isaacg – 2015-04-30T02:57:44.990
I think you need to update your post: there have been several faster answers than the Perl answer by @AsciiThenAnsii. – ɐɔıʇǝɥʇuʎs – 2015-04-30T09:14:53.613
I'm working on updating it now. – SuperJedi224 – 2015-04-30T10:07:43.403
@isaacg yeah, I think you're right – SuperJedi224 – 2015-04-30T12:58:26.013
12
You could try your hand at making a stack snippet leaderboard to avoid having to manually keep the list of submissions up to date.
– Alex A. – 2015-04-30T14:32:08.3671I absolutely love this title. – ASCIIThenANSI – 2015-04-30T22:19:26.350
How are you calculating your overall leaderboard ? – Optimizer – 2015-05-01T08:38:11.103
It's code size, with run time to break ties. I believe it says that in the current version of the question. – SuperJedi224 – 2015-05-01T09:54:04.293
Actually, the polyglot is in ActionScript2. The version is very important, since the
var
statement is required in version 3, but on version 2 it may be left behind in some situations. – Ismael Miguel – 2015-05-03T17:59:52.027Since this question was asked, the party has lost the Lost Orb. Again. – SuperJedi224 – 2016-04-22T11:58:34.867