Rosetta Stone Code Golf Challenge: Print Certain Numbers; all snippets must be same length

8

3

Rosetta Stone Code Challenges are challenges where you must complete the task in as many languages as possible.

The Challenge

You will be given two numbers, n and s, in a list as input. The n will be a number you have to count up to. n will be any number from 2 to 10000. s will be the number you skip by when counting up to n. s will be from 1 to n/2 (half of n). If n was 600, s could not be greater 300. You have to output all of the numbers up to n skipping by s starting with 1. Each output number should either be on a newline, on the same line separated by spaces, or in a list.

The Twist

For this Rosetta Stone Code Challenge, each snippet you write the program in must be the same length. ie: If your Python program has 56 characters then your Java program must also be 56 characters. Spaces and comments do not count as characters. Variable/function names can't be more than 10 characters. Remember, this is also code golf, so try to keep your code short.

Example

Input

[100, 7]

Output

1
8
15
22
29
36
43
50
57
64
71
78
85
92
99

Note: Output could be in single line separated by spaces or list format

Winning Criterion

The winner will be decided by this formula:

numberOfLanguages/codeSize

codeSize is not the total code size but the average code size of a snippet.

The user with the highest score will win. ie: An answer with 4 languages and a size of 31 bytes would win over an answer with 7 languages and a size of 80 bytes. A winner will be chosen at 2:00 UTC on March 9, 2015.

Scoreboard

All scores are rounded to the nearest thousandth

Maltysen - 14 languages / 24 characters = 0.583 ---- Winner

mbomb007 - 15 languages / 29 characters = 0.517

Jakube - 5 languages / 11 characters = 0.455

Teun Pronk - 4 languages / 51 characters = 0.078

captncraig - 1 language / 56 characters = 0.018

michaelpri

Posted 2015-02-23T02:51:00.187

Reputation: 331

Does simply padding out the code with spaces count...? Or simply using the most obtuse variable or function names...? – deceze – 2015-02-23T03:21:05.843

@deceze Should've thought of that before. Just edited in some things under the twist. spaces do not count and function/variable names have a 10 character limit – michaelpri – 2015-02-23T03:27:33.323

It still just becomes a competition of adding some useless padding to fulfil the criteria. E.g., just add "aaaaaaaaaa.."; at the end of every program, which is a valid noop in virtually all languages... – deceze – 2015-02-23T03:29:04.903

@deceze I see. I made it code golf also, so people will try to keep it short (hopefully). – michaelpri – 2015-02-23T03:33:57.393

1Maybe score by NumberOfLanguages / CodeSize? – Ypnypn – 2015-02-23T04:01:40.133

@Ypnypn I can't believe I didn't think of that before. Thanks – michaelpri – 2015-02-23T04:03:42.173

@michaelpri I think you cam remove the "all programs must be the same size" requirement since you've changed the scoring rules. Edit: I must also warn that NumberOfLanguages/Votes will simply encourage responses in a single language. – PhiNotPi – 2015-02-23T04:13:34.310

1@PhiNotPi I think the "all programs must be the same size" still adds a lot to the contest. – Ypnypn – 2015-02-23T05:04:25.573

5I think this is still flawed. If I answer only in Whitespace, I get a score of 1/0, i.e. infinity. Otherwise, I'm still better off answering in a single language where this is shortest, because adding any other language (with longer code), reduces my score. – Martin Ender – 2015-02-23T06:38:37.240

Are these snippets/functions or whole working programs? – HEGX64 – 2015-02-23T06:47:44.100

@MartinBüttner I would assume whitespace reverses the whitespace rule so only whitespace counts. – captncraig – 2015-02-23T07:44:18.997

I recommend using the sandbox next time, so these issues can be sorted out before the challenge is posted on main.

– Martin Ender – 2015-02-23T07:54:33.957

@captncraig I haven't heard of this being a common policy. But then there's still Lenguage.

– Martin Ender – 2015-02-23T07:55:13.730

How about you amend the scoring rules not to disregard whitespace but to forbid snippets that can be reduced in size trivially where trivial means that no snippet that comes from the posted snippet with some characters removed may solve the task? – FUZxxl – 2015-02-23T09:50:34.077

For instance, for the task return 2, return 0+2; could be reduced trivially to return 2; but return 1+1; can't since you cannot remove some characters with the effect remaining. – FUZxxl – 2015-02-23T09:51:50.897

@MartinBüttner How so? In my model whitespace do count towards the score and as far as I know no programming language exists where the empty program has the required semantics. – FUZxxl – 2015-02-23T09:57:09.907

1Also, your point about having longer programs reduces your score is incorrect. If I post one program of length 10, my score is 0.1. If I post three programs of length 20, my score is 0.15, which is higher. Shorter code size doesn't mean higher score automatically. – FUZxxl – 2015-02-23T09:59:24.667

@FUZxxl, oh I misunderstood the scoring... I thought it was divided by total code size, not the code size of each snippet. That should work then, although it will be hard to verify if submissions satisfy your rules. – Martin Ender – 2015-02-23T10:00:57.790

5-1 for disincentivising just throwing in obscure verbose languages for the fun of it, in a [rosetta-stone]. – algorithmshark – 2015-02-23T16:34:56.757

n must be >= 2, otherwise, s is zero, which doesn't work. – mbomb007 – 2015-02-25T21:17:18.623

@mbomb007 Good point didn't think of that, – michaelpri – 2015-02-25T21:18:30.587

This challenge has prompted me to delve into many languages in the last 2 days. My brain hurts... – mbomb007 – 2015-02-25T22:17:18.940

Why not change scoring to numberOfLanguages/longestCodeSize? Everyone seems to be padding their shorter codes to match their longest, this will not change scoring only readability. – freekvd – 2015-02-26T13:39:37.693

Answers

7

14 Languages - 24 bytes = 0.58333333333

**Facepalm**. I forgot not to count the space in my Python answer. So I'm at 24 bytes now.

Learned about a lot of new languages from this challenge, which I will probably using in golfs. A site that really helped me find these languages was http://www.tutorialspoint.com/codingground.htm. Just don't expect my programs to run in it, it requires a full program format, and I just used it to learn about the languages and used other REPLs to run them.

1. Pyth:

Pyth doesn't have a range by step function unlike python, so I used regular range and chopped (thanks @Jakube) used mod operator on it.

M%Hr+Z+Z+Z+Z+Z+Z+Z+Z1+1G

Defines a function g(until, step)

M          Define g(G, H)
 %H        Every H elements
  r1+1G      Range 1->G+1

2. Golfscript:

This is my first golfscript program. Probably not the best way to do it.

000000000000000;\),1>\%p

\         swap
 )        increment
  ,       range
   1>     all but first element
   \      swap
    %     take every top of stack elements
     p    print array

3. Bash Utils:

Uses the seq command which has INCREMENT param.

seq 00000000000000001 $2 $1

4,5. Python, Sage:

Self-explanatory code.

lambda a,b:range(1,a+1,b)

Sage is a language based on Python used for math stuff.

6. Mathematica:

Again, self-explanatory.

r[a_,b_]:=Range[001,a,b]

7. Matlab:

Uses Matlab's range notation and defines an anonymous function.

@(a,b)00000000000001:b:a

8. Livescript:

Like Coffeescript it is a JS derivative. Has cool range syntax. Arrow notation again.

r=((((a,b)->[1 to a by b])))

9. Erlang:

Learned erlang just for this. Pretty self explanatory, defines function r.

r(a,b)->lists:seq(1,a,b)

10. F#:

Kind of obvious, F#'s function definitions are like variables.

let r a b=seq{000001..b..a}

11. Haskell:

Haskell's range notation has you give the first two in the range for the increment, and not an explicit increment.

r a b=[00000000001,a+1..b]

12. R:

Very cool language, even if function definitions are a little verbose.

function(a,b)seq(01,a,b)

13. Julia:

Awesome language, will be using for golfing in the future.

r(a,b)=[00000000001:b:a]

14. CJam:

Like my old golfscript answer except with input parsing and padding.

0000000000000;q~\),1>\%p

Maltysen

Posted 2015-02-23T02:51:00.187

Reputation: 25 023

How do I run this? Mmhdcr1GH100 7 doesn't work like I thought it would. – mbomb007 – 2015-02-24T18:57:48.710

1@mbomb007 M defines a function g, which you have to call first. Try Mmhdcr1GHg100 7. – Jakube – 2015-02-24T20:03:13.347

% is the same thing as python's [::a]. No need for chopping. And I'm pretty sure your range has to go up to including G, e.g. using r1hG. – Jakube – 2015-02-24T21:41:13.503

@Jakube thanks for the tip – Maltysen – 2015-02-24T22:08:28.070

Please put a space before 7. Negative doesn't look right. – mbomb007 – 2015-02-24T22:10:02.770

@mbomb007 fixed, srry – Maltysen – 2015-02-24T22:10:47.030

I think you should have to assign your CoffeeScript function to a variable, same with R. Otherwise it can't be called since it's anonymous. Also, your function doesn't work. – mbomb007 – 2015-02-27T14:48:37.500

Same with Python too. I'm pretty sure it has to be callable by name. – mbomb007 – 2015-02-27T14:54:57.997

For the R function it s easy to solve, just get rid of the extra 0 and add f= to assign the function to a name: f=function(a,b)seq(1,a,b). Otherwise you can indeed use it as an anonymous function (i. e. (function(a,b)seq(001,a,b))(100,3) for instance), but here it is unnecessary since you can have 2 additional character without changing your score. – plannapus – 2015-02-27T15:27:43.900

@mbomb007 I don't think it is required since you can call anonymous functions by just doing (function)(a,b), but I will be naming the ones where I have chars left. Also, which one doesn't work? – Maltysen – 2015-02-27T20:49:18.793

The thing is that by calling an anonymous function that way, you have to repeat your code or surround it with something, rather than a call on the next line. Defining a function also generally means it's named so it can be called any number of times, in multiple places in your code. – mbomb007 – 2015-02-27T21:15:36.903

CoffeeScript is the one that doesn't work. Your function would have to be essentially identical to mine. Some of yours feel like you copied them, to me. But I don't really know what the policy on that is or how different a program needs to be... – mbomb007 – 2015-02-27T21:15:56.410

CoffeeScript has i for x, which can't work. – mbomb007 – 2015-03-04T16:09:51.647

@mbomb007 srry was away for a week, didn't see your comments. I didn't really copy any of of your's, except I got the idea to do coffeescript from yours. Idk the rules on that, but ill take it down just to be safe. – Maltysen – 2015-03-04T21:34:28.593

Congratulations! You won. – michaelpri – 2015-03-09T01:47:52.333

Yeah, congrats. yours were shorter, making it harder for me to catch up on score. – mbomb007 – 2015-04-15T18:43:55.123

9

23 languages, 15 characters = 1.5333333

+---------------+----------------------+----------------+
|    Language   |         Code         |      Kind      |
+---------------+----------------------+----------------+
|          gs2  |  B/4[RRRRRRRRRRR     |  (stack)       |
|         Pyth  |  M%+Z+Z+Z+Z+ZHSG     |  (definition)  |
|   GolfScript  |  \),000000001>%p     |  (stack)       |
|         CJam  |  \),000000001>%p     |  (stack)       |
|          zsh  |  seq 00000001 $2 $1  |  (script)      |
|         Bash  |  seq 00000001 $2 $1  |  (script)      |
|   FlogScript  |  \),0000001>\%Pa     |  (stack)       |
|          APL  |  {00001+⍵×⍳⌈⍺÷⍵}     |  (lambda)      |
|      Mathics  |  00001~Range~##&     |  (lambda)      |
|  Mathematica  |  00001~Range~##&     |  (lambda)      |
|            J  |  ({.\00001+i.)~-     |  (lambda)      |
|       Matlab  |  @(a,b)00001:b:a     |  (lambda)      |
|       Octave  |  @(a,b)00001:b:a     |  (lambda)      |
|    Burlesque  |  jrojcoq-]m[m]uN     |  (stack)       |
|            K  |  {0001+&~(!x)!y}     |  (lambda)      |
|          Pip  |  {_%b=001FI,++a}     |  (lambda)      |
|      Haskell  |  ff a b=[1,b+1..a]   |  (definition)  |
|        Clean  |  ff a b=[1,b+1..a]   |  (definition)  |
|        Curry  |  ff a b=[1,b+1..a]   |  (definition)  |
|        Frege  |  ff a b=[1,b+1..a]   |  (definition)  |
|        Julia  |  ff(a,b)=[1:b:a]     |  (definition)  |
|       Scotch  |  f(a,b)=[1..a,b]     |  (definition)  |
|        Perl6  |  {1,$^b+1...$^a}     |  (lambda)      |
+---------------+----------------------+----------------+

Lynn

Posted 2015-02-23T02:51:00.187

Reputation: 55 648

1Since you have Matlab, why not add Octave? – alephalpha – 2015-10-22T13:12:48.327

That might work. Would the code be exactly the same? – Lynn – 2015-10-22T13:17:33.530

Yes, it's exactly the same. – alephalpha – 2015-10-22T13:25:57.667

Neat. I've added it! – Lynn – 2015-10-22T13:41:52.217

jrojcoq-]m[m]uN would be a Burlesque Version that outputs number and doesn't push dummy data to the stack just to pop it again. – mroman – 2015-10-22T14:13:29.760

4

15 languages, 29 characters = (15/29) ≈ 0.517

I've fixed all my code so far. Now I'm searching for other languages.

1. Python (24 golfed)

f=lambda n,s:range(0001,n+1,s)

2. ><> (Fish) - (19 + junk chars)

This program assumes that the number and the step size were are on the stack beforehand, pushed in that order. Uses ao to print newlines between numbers.

1           v
$:@+:{:}(?!;>:nao
~~~~~~~~~~

Explanation (code, stack after preceding code executes, comments):

1               1 s n           start n0=1. stack is (top)1 s n(bottom)
(skip to print code - last line of explanation, then come back)
 $:@            s 1 s n         swap, duplicate, rotate top 3 (this all is OVER in Forth)
   +:           n1 n1 s n       add step to x and dup
    {:}         n n1 n1 s n     compare to n
       (        n1>n n1 s n     if !(n1 > n), JUMP: dup and print (continue)
        ?!;     n1 s n          else exit
          :nao  n1 s n          dup, print n1, newline, loop around

3. APL (19 golfed)

fffffffff←{(⌈⍵÷⍺)↑1+⍺∘.×(⍳⍵)}

Golfed. Paste into here: http://ngn.github.io/apl/web/

f←{(⌈⍵÷⍺)↑1+⍺∘.×⍳⍵}

Call like this: 7 f 100. This creates an array from 1 to n, multiplies every element by s, adds one to each element, then takes the first ceil(n/s) elements.

4-7. Haskell, Clean, Curry, Frege (14 golfed - spaces don't count)

This program is valid in Haskell, Clean, Curry, and Frege.

ffffffffff nnnn s=[1,s+1..nnnn]

Golfed. Run here: https://ideone.com/Ii0pgP

f n s=[1,s+1..n]

8. Scotch (15 golfed)

fffffffff(nnnn,s)=[1..nnnn,s]

9. Jaskell (24 golfed) - Built based on documentation.

Filter the list where the remainder modulo s is 1.

ffffff n s=filter(.%s==1)[1..n]

10. CoffeeScript (25 golfed) Run here

fffff=(n,s)->x for x in[1..n]by s

11. R (25 golfed) Run here: http://www.r-fiddle.org/#/fiddle?id=k3vRnCOW&version=2

fffff=function(n,s)seq(1,n,s)

12. Cobra (26 golfed)

def ffff(n,s)
    for i in 1:n:s
        print i

13. S-Lang (28 golfed)

define ff(n,s){return [1:n:s];}

14. Boo (29)

Not sure if range function can take 3 parameters...

def f(n,s):return range(n)[::s]

15. Funge-98 (29, any help golfing?)

As close as I could get to my ><> program. Since there's no "rotate" stack instruction, I had to use "put" and "get" instead. Befunge really needs some stack rotation/shift instructions, or even an "over" instruction.

22p1v
    >:.a,\:33p\33g+:22g\`!j@

Explanation:

        n s
22p     s           (store n at 2,2)
1       1 s         (push 1)
(v and > are direction changes, so the above only happens once)
\:      s s 1       (swap, dup)
33p     s 1         (store s at 3,3)
\33g    s 1 s       (get s)
+:      n1 n1 s     (add, dup)
22g     n n1 n1 s   (get n)
\`!     !(n1>n) n1 s    (swap, >, not)
j@      n1 s        (conditional exit)
:.a,    n1 s        (print n1, newline)


NOT USING AT THE MOMENT, TOO LONG - My score is improved by not including these.

Ruby (35) Run here: http://ideone.com/yFZELR

def f(n,s)
    (1..n).select{|x|x%s==1}
end

PowerShell (38)

function f($n,$s){(1..$n|?{$_%$s-eq 1})}

Perl (39) Run here: https://ideone.com/HGoleN

sub f{join(" ",grep $_%@_[1]==1, 1..@_[0])}

mbomb007

Posted 2015-02-23T02:51:00.187

Reputation: 21 944

Notice that your ><> program counts backwards from n to one by skipping s, thus it produces 2 9 16 23 30 37 44 51 58 65 72 79 86 93 100 for n=100, s=7 instead of 1 8 15 22 29 36 43 50 57 64 71 78 85 92 99 as specified in OP's example. – cirpis – 2015-02-24T20:14:52.200

@cirpis I fixed ><>, still have to fix Befunge. – mbomb007 – 2015-02-24T20:51:56.000

Rather than assuming everything's on the stack for ><>, I think you can use the -v flag to supply input. Normally flags add a byte, but I'm not sure whether that means you need to remove a junk char or not (since apparently we only care about "code size") – Sp3000 – 2015-02-24T20:58:20.413

I see people assuming stuff is on the stack all the time for Befunge, GolfScript, etc. But I don't know how to input, other than i, which pushes a character. Also, while we're on the topic of stuff, is it acceptable for the program to crash after successfully completing its output (by popping an empty stack)? – mbomb007 – 2015-02-24T21:05:46.183

there is no in code way to read input as a number in ><>, however in the python ><> interpreter there is a special flag "-v" that prepopulates the stack, e.g. calling -v 100 7 will make the first value of the stack 100 and the second one 7 – cirpis – 2015-02-24T21:11:54.360

The ><> code is still not right :D (please consider using the interpreter). It does not print the 1 as the first number and the ")" should be a "(". – cirpis – 2015-02-24T21:23:53.763

I don't currently have access to one, unless there's one online. That's what you get when you create an esoteric language, and have little documentation. – mbomb007 – 2015-02-24T21:37:35.397

You should try R, basically the same type of syntax as Python. – freekvd – 2015-02-25T07:55:11.460

I made one in Scala, but it's far too long for me. ((n:Int,s:Int)=>((1 until n)toList)filter(_%s+s-1==0))(100,7) – mbomb007 – 2015-02-25T17:36:49.890

1@mbomb007 With seq.int(). It works the same as range in Python. Then you can get it to 29. – freekvd – 2015-02-25T19:41:23.773

@mbomb007 actually you can use seq() as well as seq.int(). – freekvd – 2015-02-26T16:12:16.617

Huh. It never occurred to me to try that. – mbomb007 – 2015-02-26T17:02:28.160

Note, updated the "padding" on the programs. Golfed CoffeeScript down to 25. – mbomb007 – 2015-02-26T17:15:40.820

4

5 languages 11 characters = 0.4545

Took this challenge as an opportunity to check out some new languages (CJam, Burlesque, zsh, gs2). First time I've worked with these languages.

The method behind creating the output is different in nearly each language. Only the CJam and the gs2 method are identical. The 4 methods are, creating a range [1, 100] and slice it with modulo (CJam and gs2), creating the range [1, ..., 100] and filter for elements that are 1 mod 7 (Pyth), creating the range [1, ..., 100], divide it into chunks of len 7 and use the first element of each chunk (Burlesque), and creating the sequence directly (zsh).

I tried to design each program in such a way, that it looks golfed to someone, who is not familiar with the language.

edit 1: added Burlesque, previous 2 languages with 10 characters = 0.2

edit 2: added gs2, previous 3 languages with 11 characters = 0.2727

edit 3: added zsh, previous 4 languages with 11 characters = 0.3636

CJam

q~\1+,0-\%p

Test it online with the input 100 7.

q~           push the evaluated input (100 7)
  \          swap (7 100)
   1         push 1 (7 100 1)
    +        add last to elements (7 101)
     ,        create the range (7, [0, 1, ..., 100])
      0       push 0 (7, [0, 1, ..., 100], 0)
       -      delete 0 from the range (7, [1, 2, ..., 100])
        \     swap ([1, 2, ..., 100], 7)
         %    use every 7th entry ([1, 8, ..., 99])
          p   print pretty

Burlesque

jrojcoq-]m[

Beside zsh, this is the only golfed program. Burlesque is quite awesome, it has a very large range of different functions, like ro. Sadly there's nothing like the Python [::a] slicing operator.

There is no online interpreter, but you can get Burlesque here. Since Burlesque doesn't support functions or IO, you have to put the values onto the stack first, like 100 7 jrojcoq-]m[

j            Swap (7 100)
 ro          Range (7 {1 2 ...  100})
   j         Swap ({1 2 ... 100} 7)
    co       ChunksOf ({{1 2 ..  7} {8 ... 14} ... {99 100}})
      q      Create Block ({{1 2 ..  7} {8 ... 14} ... {99 100}} {}) 
       -]    head (first element) ({{1 2 ..  7} {8 ... 14} ... {99 100}} {-]}) 
         m[  map the chunks to the head-block

gs2

read-nums dup head inc range tail swap reverse head mod unlines

Yep, this is only 11 chars. In gs2 each byte has a different meaning. But because writing in bytes is quite hard and not any fun, you can also write in mnemonics, which you can compile to the actual gs2 code. The gs2 code, which gets executed is

W@!'."B !4+

or as hex-dump:

57 40 21 27 2e 22 42 20 21 34 2b

Fun fact: I didn't write in mnemonics, but directly the numbers of the hex-dump.

You can test it by downloading the compiler. Compile the mnemonics file with python gs2c.py < mnemonics.txt > compiled or simply copy W@!'."B !4+ to a file named compiled and then execute it with echo 100 7 | python gs2.py compiled.

The mnemonics is pretty self explainable, but here's what's going on in the stack.

57 40 21 27 2e 22 42 20 21 34 2b 
57                                 read-nums ([100 7])
   40                              dup ([100 7] [100 7])
      21                           head ([100 7] 100)
         27                        inc ([100 7] 101)
            2e                     range ([100 7] [0 1 ... 100])
               22                  tail ([100 7] [1 2 ... 100])
                  42               swap ([1 2 ... 100] [100 7])
                     20            reverse ([1 2 ... 100] [7 100])
                        21         head ([1 2 ... 100] 7)
                           34      mod ([1 8 ... 99])
                              2b   unlines ('1\n8\n...\n99')
                                   everything on the stack gets printed

Btw, 8 bytes are possible, maybe even less.

edit: I forked gs2, slightly manipulated a command and made a pull request, which is already merged. So now the task can be done with 6 bytes: read-nums extract-array swap range1 mod unlines, which translates to 57 0e 42 2f 34 2b, which is even better than the optimal pyth.

zsh

f() seq 1 $2 $1

This defines a function f, that creates the a sequence. To use it on Windows, I installed the babun shell, where you can simply type these commands. Simply write f() seq 1 $2 $1 and in the next line f 100 7.

First I tried to write this in Bash, but there you have to write () around the code block, like f() ( seq 1 $2 $1 ). So I switched to zsh instead.

Pyth

fq1%TeQUhhQ

This really hurts, since of course I see the obvious 7 byte golf. You can test it online with the input 100, 7.

                 Q = input()
       UhhQ      the range [0, 1, ..., Q[0]]
f                filtered (only use those elements T, which satisfy the equation
 q1%TeQ             1 == T % Q[1]

Jakube

Posted 2015-02-23T02:51:00.187

Reputation: 21 462

Technically Burlesque has an "EveryNth"-Command. Like 100ro7en?i which produces {8 15 22 29 36 43 50 57 64 71 78 85 92 99}. You can go even shorter by using 7mo14.+?i. – mroman – 2015-05-12T12:28:00.997

@mroman Quite a long time since I wrote this code. But as far as I remembered the "EveryNth"-Command doesn't work like the [::a] command in Python. EveryNth([1,2,3,4,5,6,7,8, 9], 3) returns [3, 6, 9] and not [1,4,7], like it was required in this challenge. – Jakube – 2015-05-12T12:33:02.693

Yes, you're right. The en works different than one would expect from other languages. I curse the day I implemented it this way :D. Common workarounds for that are either using the mo I mentioned above or by using co as in 9ro3co)-] which produces {1 4 7}.

PS: I had an online interpreter back in the old days but my new hoster doesn't support CGI anymore but I might be able to convince someone who has a Server with CGI support to host the online interpreter again :) – mroman – 2015-10-22T14:38:33.650

3

4 languages 51 characters = (4/51) = 0,0784313725490196

No idea how many numbers after comma you want so i'll just leave it like this.
All snippets are 51 characters long when you remove all the whitespace.
Working on more and shorter code but it's a start.

Log

Initial answer
Submitted Python(3.4), Lua(5.1) and Javascript.
Score: 3/51 = 0,0588235294117647

Update 1
Added Ruby
Score: 4/51 = 0,0784313725490196.

Python 3.4

def f(NUMB,ST):
    CNT=1
    while CNT<=NUMB:
        print(CNT)
        CNT+=ST

Lua 5.1

function f(num,st)
    for cn=1,num,st do
        print(cn);
    end;
end;

Javascript

function f(n,s){
  for(i=1;i<=n;i+=s){
    console.log(i);
  }
}

Ruby

def faa(numb,st) 
  for i in 1..numb 
    if i%st==1 
      puts i 
    end 
  end 
end

Teun Pronk

Posted 2015-02-23T02:51:00.187

Reputation: 2 599

If you want another language, here's STATA: di _reque(s) _reque(n) gl a=1 while $a<=$n{ di $a gl a=$a+$s } – bmarks – 2015-02-24T14:35:37.617

@bmarks Thanks, seems a bit lame to add someone else's code to the answer though ;) – Teun Pronk – 2015-02-24T14:36:33.080

In the javascript function, I think you need i<=n instead of i<n. Also, I think you can shorten most of these by using the alert function in javascript and shortening variable names in the others. – bmarks – 2015-02-24T14:56:16.020

@bmarks the variable names used to be 1 character each, same for function names. I just padded them a bit to get them to be the same length. and youre right about the javascript. Ill change it. – Teun Pronk – 2015-02-24T14:58:40.177

I only count 50 chars in the Ruby solution. – Jakube – 2015-02-25T12:28:09.833

2

1 language - 56 characters = 0.01785714285

piet (2x28) -

http://www.pietfiddle.net/img/JpdU9zE1lR.png?cs=15

captncraig

Posted 2015-02-23T02:51:00.187

Reputation: 4 373