# Briefing

The difficulty of a Code Golf question can be calculated as such:

Where v is the number of views a question has

and a is the number of answers a question has

and ⌈x⌉ is the ceiling operator.

Also:

# This question's current difficulty: ***

Write a program that will take two integers (v and a) and output the difficulty in asterisks (*).

The input can be in the form of an array, a seperated string or as seperate function arguments

# Test Data

Views   Answers Difficulty  Program Output
163     2       2           **
548     22      1           *
1452    24      1           *
1713    37      1           *
4162    32      2           **
3067    15      3           ***
22421   19      10          **********


### Example with pseudocode

v: 1713
a: 37
out = clamp(ceil(((v/a)/700)*10), 0, 10); // evaluates to 1
//program will output '*'


The shortest code in bytes wins! Trailing/ leading spaces are allowed.

• I find that LaTeX harder to understand that a simple formula string.. but whatever the majority wants I guess.. – Shaun Wild Aug 17 '16 at 13:07
• You should almost add [underhanded] for the question being underhanded. – Adám Aug 17 '16 at 13:28
• This is a Code Golf question. Not an actual system being implemented into the site. Who cares if it's unfair? – Shaun Wild Aug 17 '16 at 14:11
• its kinda early so I may be missing something here, but why /700 * 10 instead of /70? – Kevin L Aug 17 '16 at 14:21
• @KevinL Ssshhhh ;) – Shaun Wild Aug 17 '16 at 14:34

# Fourier, 46 bytes

All division in Fourier is integer division, so I just add one after division.

I*10/I/700^~X<0{1}{0~X}X>10{1}{10~X}X(42ai^~i)


Try it online!

# PHP 5.6, 66 bytes

function a($v,$a){echo str_repeat('*',max(0,min(10,1+$v/$a/70)));}


First we simplify the equation to v/a/70. From there we add 1 since PHP will use this number as an integer for the str_repeat, essentially doing abs($number+1). Then we use the hand-rolled clamp function of max($min_number, min($max_number,$the_number)) to keep it between 1 and 10.

The substr version is a few bytes shorter (due to not having to have to build in the clamp functionality), but this one was more fun to make.

# Ruby, 27 bytes

->v,a{(?**10)[1..(v/a/70)]}


## Ruby, 47 35 bytes

f=->(v,a){'*'*((v/=a*70)<9?v+1:10)}


Called with f.call(v,a)

Saved 12 bytes thanks to user3334690, now the function implicitly returns the result.

• you can probably save a bit by doing string * number like: "q=->(v,a){'*'*((v/=a*70)<9?v+1:10)}" – user3334690 Aug 19 '16 at 18:18
• You can safely remove f= – Luis Masuelli Aug 26 '16 at 13:15

# Perl 6: 32 bytes

As a lambda that takes two arguments:

{"*"x min 10,ceiling $^x/$^y/70}


## Batch, 81 bytes

@set/an=(700*%2-%1)/%2/70,n*=!(n^>^>31)
@set s=**********
@call echo %%s:~%n%%%


Port of my JavaScript answer, except that Batch uses integer arithmetic, so I wrote the formula as (700*a-v)/a/70 which will truncate towards zero, and then the n*=!(n^>^>31) clears n if it is negative.

• Batch makes my eyes bleed, but nice answer! – Mark K Cowan Aug 18 '16 at 14:57

L^,/700/10*1+i10m1_Vc"*"Gy


Try it online! or see the test suite

It's not often I get to use the ^ function flag in a code golf.

## How it works

L^,		; Create a lambda that returns the stack joined
; Example arguments:	[3067 15]
/	; Divide;		[204.46]
700/	; Divide by 700;	[0.2921]
10*	; Times by 10;		[2.91]
1+i	; Ceiling;		[3]
10m	; Minimum with 10;	[3 10 3]
1_	; Decrement;		[3 10 2]
Vc	; Keep the top value;	[2]
"*"G	; Push '*' below;	['*' 2]
y	; Repeat;		['*' '*' '*']