Calcola la tua reputazione di scambio di stack


13

Sfondo:

Trovo spesso che, navigando su un sito Stackexchange, comincio a chiedermi come le persone ottengano la reputazione che hanno. So di poter sempre contare su codegolf SE per risolvere i miei problemi, quindi eccolo qui:

Crea un programma che accetti un numero intero positivo che rappresenti la reputazione di una persona. Ignoreremo i doni e diremo che questi sono gli unici modi per guadagnare / perdere rep su SE (tabella completa qui ):

  • Ogni account inizia con 1 rappresentante e non può andare al di sotto di quello
  • La tua domanda è valutata = +5
  • La tua risposta è aumentata = +10
  • La tua domanda è sottovalutata = -2
  • La tua risposta è sottovalutata = -2
  • Declassate una risposta = -1
  • La tua risposta è stata accettata = +15
  • Accetti una risposta = +2

Il tuo programma deve capire quante di queste azioni sono avvenute sull'account di quell'utente per arrivare al rappresentante che hanno. Deve capire il numero più breve di azioni per arrivare a questo livello di rep. Esempi:

Ingresso: 11 Uscita: 1 risposta positiva

Input: 93 Output: 6 risposte accettate, 1 risposta accettata

In questi esempi quando dico "domanda votata", significa che il queston di quella persona è stato votato. Quando dico "risposta annullata", significa che hanno annullato la votazione della risposta di qualcun altro.

Regole:

, quindi vince il codice più breve che può farlo.


8
Esistono un numero infinito di modi per ottenere una determinata reputazione. È sufficiente implementare "rispondi votato" e "rispondi ridimensionato" per trovare sempre un modo, quindi non c'è slancio per usare un sottoinsieme più ampio delle variazioni del punteggio. È questo che intendevi?
algoritmo

@algorithmshark modificato. Devi trovare il minor numero di azioni che ti porteranno lì
TheDoctor

"" "Trovo spesso che, navigando su un sito Stackexchange, comincio a chiedermi come le persone ottengano la quantità di reputazione che hanno." "" Vs "" "Devi trovare il minor numero di azioni che ti porteranno lì" "". La seconda citazione non è necessariamente la risposta corretta alla prima citazione.

1
@algorithmshark In generale, sono d'accordo con i tuoi commenti. Tuttavia, 6 risposte accettano + 1 risposta accettata è 6 * 15 + 2 = 92, non 93! Non riesco a vedere un modo per farlo in 7 azioni, ma posso farlo in 8: 6 risposta accetta, una domanda votata, una domanda negativa: 6 * 15 + 5-2 = 93. Dottore, se esiste più di una possibilità per "il minor numero di azioni", dobbiamo trovarle tutte o solo una?
Level River St

1
@steveverrill inizi con 1 rappresentante
TheDoctor

Risposte:


3

Golfscript, 162 144 byte

{{}if}:?;~.)15/:^15*-:~3>1~8>' answer ':A' question 'if'upvote'++?^^A'accept'+:C+^1>{'s'+}??~5%:,4<,1>&1C'ed'++?,2%!1A'downvote'++,4<{'d'+}??]n*

Come funziona

L'idea generale è esattamente la stessa della mia risposta di Bash .

{{}if}:?;         # Create an `if' statement with an empty `else' block.
                  #
~.)15/:^          # Interpret the input string, subtract 1 from its only element (the
                  # reputation score), divide by 15 and save the result in `^'. This gives
                  # the number of accepted answers.
                  #
15*-:~            # Multiply the number of accepted answer by 15 and subtract the product
                  # from the reputation score. Save the result in `~'.
                  #
3>                # If the result is greater than 3:
                  #
  1               # Push 1 on the stack.
                  #
  ~8>             # If the result is greater than 8:
                  #
    ' answer ':A  # Push `answer' on the stack. Either way, save the string in `A'.
                  #
    ' question '  # Otherwise, push `question' on the stack.
                  #
  if              #
                  #
  'upvote'++      # Push `upvote' on the stack and concatenate the three strings.
                  #
?                 #
                  #
^                 # If the number of accepted answers is positive:
                  #
  ^A'accept'+:C+  # Push the number, concatenated with the string ` answer accept', on the
                  # stack. Either way, the string in `C'.
                  #
  ^1>             # If the number of accepted answers is greater than 1:
                  #
    {'s'+}        # Cocatenate the previous string with `s', for proper pluralization.
                  #
  ?               #
                  #
?                 #
                  #
~5%:,             # Calculate the reputation score modulus 5. Save the result in `,'.
                  #
4<,1>&            # If the result is less than 4 and greater than 1:
                  #
  1C'ed'++        # Push the string `1 answer accepted' on the stack.
                  #
?                 #
                  #
,2%!              # If the result is odd:
                  #
  1A'downvote'++  # Push the string `1 answer downvote' on the stack.
                  #
  ,4<             # If the result is less than 4:
                  #
    {'d'+}        # Concatente the previous string with `d'.
                  #
  ?               #
                  #
?                 #
                  #
]n*               # Join the array formed by all strings on the stack, separating the
                  # strings by newlines. This is the output.

9

Bash, 247 202 192 byte

n=$1 bash <(sed 's/E/)echo /;s/C/ Aaccept/;s/A/answer /
s/.*)/((&)\&\&/'<<<'a=(n+1)/15,a-1)s=s;q=question
aE$aC$s
r=n%5,r-4)d=d&&
r>1E1Ced
1-r%2E1 Adownvote$d
n-=15*a,n>8)q=A
n>3E1 $q upvote')

Come funziona

Dopo che il comando sed ha fatto il suo lavoro, viene eseguito il seguente script bash:

((a=(n+1)/15,a-1))&&s=s;q=question
((a))&&echo $a answer accept$s
((r=n%5,r-4))&&d=d&&
((r>1))&&echo 1 answer accepted
((1-r%2))&&echo 1 answer downvote$d
((n-=15*a,n>8))&&q=answer 
((n>3))&&echo 1 $q upvote

Per ottenere la soluzione ottimale (numero minimo di eventi per ottenere nreputazione), è sufficiente calcolare il numero di risposte accettate ( a) necessarie per ottenere una reputazione inferiore a 16 (accetta 1 risposta) e gestire il residuo come segue:

1  (no rep change)
2  answer accepted, answer downvoted
3  answer accepted
4  question upvote, answer downvote
5  question upvote, answer downvoted
6  question upvote
7  question upvote, answer accepted, answer downvoted
8  question upvote, answer accepted
9  answer upvote, answer downvote
10 answer upvote, answer downvoted
11 answer upvote
12 answer upvote, answer accepted, answer downvoted
13 answer upvote, answer accepted  
14 answer accept, answer downvote
15 answer accept, answer downvoted

2
Grazie per la spiegazione, non è semplice gestire -2e -1ridimensionare.
AL

6

Perl, 500 263 256 208 byte

Script rep.pl:

$_=1+pop;sub P($){print$=,@_,$/}$;=" answer ";$:="$;downvote";($==$_/15)&&P"$;accept"."s"x($=>1);$_%=15;$==1;P"$;upvote",$_-=10if$_>9;P" question upvote",$_-=5if$_>4;P"$;accepted"if$_>2;P$:."d"if$_%2;P$:if!$_

uso

L'input è previsto come numero intero positivo, dato come argomento allo script. Le diverse azioni vengono emesse come linee.

test

perl rep.pl 11
1 answer upvote

perl rep.pl 93
6 answer accepts
1 answer accepted

perl rep.pl 1

perl rep.pl 4
1 question upvote
1 answer downvote

perl rep.pl 12
1 answer upvote
1 answer accepted
1 answer downvoted

perl rep.pl 19
1 answer accept
1 question upvote
1 answer downvote

perl rep.pl 34
2 answer accepts
1 question upvote
1 answer downvote

perl rep.pl 127
8 answer accepts
1 question upvote
1 answer accepted
1 answer downvoted

perl rep.pl 661266
44084 answer accepts
1 question upvote

Ungolfed

$_ = pop() + 1; # read the reputation as argument,
                # remove the actionless start reputation
                # and add a bias of two to calculate
                # the answer accepts in one division.

# Actions
# -------
# answer accepts:      Your answer is accepted    = +15
# answer upvotes:       Your answer is upvoted     = +10
# question upvotes:     Your question is upvoted   = +5
# answers accepted:     You accept an answer       = +2
# answers downvoted:    You downvote an answer     = -1
# answer downvotes:     Your answer is downvoted   = -2
# (questions downvoted: Your question is downvoted = -2) not used

# Function P prints the number of actions in $= and
# the action type, given in the argument.
# The function is prototyped "($)" to omit the
# parentheses in the usage.
sub P ($) {
    print $=, @_, $/ # $/ is the line end "\n"
}
# abbreviations,
# special variable names to save a space if a letter follows
$; = " answer ";
$: = "$;downvote";

# Calculation and printing the result
# -----------------------------------
($= = $_ / 15) && # integer division because of the special variable $=
P "$;accept" .
  "s" x ($= > 1); # short for: ($= == 1 ? "" : "s")
$_ %= 15;
$= = 1;           # now the action count is always 1 if the action is used
P "$;upvote",         $_ -= 10 if $_ > 9;
P " question upvote", $_ -=  5 if $_ > 4;
P "$;accepted"                 if $_ > 2;
P $: . "d"                     if $_ % 2;
P $:                           if ! $_

Versione precedente

$_ = pop() + 1; # read the reputation as argument
                # subtract start reputation (1)
                # add bias (2)

# Actions
# -------
# $= answer accepts:      Your answer is accepted    = +15
# $b answer upvotes:      Your answer is upvoted     = +10
# $c question upvotes:    Your question is upvoted   = +5
# $d answers accepted:    You accept an answer       = +2
# $e answers downvoted:   You downvote an answer     = -1
# $f answer downvotes:    Your answer is downvoted   = -2
# -- questions downvoted: Your question is downvoted = -2

# Calculaton of answer accepts by a simple division that is
# possible because of the bias.
$= = $_ / 15; # integer division because of the special variable $=
$_ %= 15;

# The older version of the calculation can be simplified further, see below.
# Also the older version did not use the bias.
#
# function E optimizes the construct "$_ == <num>" to "E <num>"
# sub E {
#     $_ == pop
# }
#
# $d = $e = 1 if E 1;       #  1 =     +2 -1
# $d++ if E 2;              #  2 =     +2
#
# $c = $f = 1 if E 3;       #  3 =  +5 -2
# $c = $e = 1 if E 4;       #  4 =  +5 -1
# $c++ if E 5;              #  5 =  +5
# $c = $d = $e = 1 if E 6;  #  6 =  +5 +2 -1
# $c = $d = 1 if E 7;       #  7 =  +5 +2
#
# $b = $f = 1 if E 8;       #  8 = +10 -2
# $b = $e = 1 if E 9;       #  9 = +10 -1
# $b++ if E 10;             # 10 = +10
# $b = $d = $e = 1 if E 11; # 11 = +10 +2 -1
# $b = $d = 1 if E 12;      # 12 = +10 +2
#
# $=++, $f++ if E 13;       # 13 = +15 -2
# $=++, $e++ if E 14;       # 14 = +15 -1

$b++, $_ -= 10 if $_ > 9;
$c++, $_ -=  5 if $_ > 4;

# Now $_ is either 0 (-2), 1 (-1), 2 (0), 3 (1), or 4 (2).
# The number in parentheses is the remaining reputation change.

# The following four lines can be further optimized. 
# $f++        if ! $_;    # "! $_" is short for "$_ == 0"
# $e++        if $_ == 1;
# $d = $e = 1 if $_ == 3;
# $d++        if $_ == 4;

# Optimized version of the previous four lines:

$f++ if ! $_;
$e++ if $_ % 2;
$d++ if $_ > 2;

# function P optimizes the printing and takes the arguments for "print";
# the first argument is the action count and the printing is suppressed,
# if this action type is not needed.
sub P {
    print @_, $/ if $_[0]
    # $/ is "\n"
}

# some abbreviations to save some bytes
$; = " answer ";
$D = "$;downvote";

# output the actions

P $=, "$;accept", ($= == 1 ? "" : "s");
P $b, "$;upvote";
P $c, " question upvote";
P $d, "$;accepted";
P $e, $D, "d";
P $f, $D

Le modifiche

  • Il caso 4 è stato risolto.
  • Ciò semplifica anche il calcolo che ora viene eseguito senza un ciclo.
  • Rimossa la "s" non raggiungibile, la funzione Snon è più necessaria.
  • Calcolo ottimizzato, funzione Enon più necessaria.
  • Bias di 2 aggiunto per un calcolo ottimizzato.
  • Riscrittura più grande per rimuovere la maggior parte delle variabili alcuni altri trucchi per salvare alcuni byte.

secondo questo, Jon Skeet ha 44084 risposta accetta e 1 voto positivo
TheDoctor

6
@TheDoctor: Secondo la domanda, si tratta del numero minimo di azioni per ottenere una reputazione di 661266.
Heiko Oberdiek

4

R, 454 421

r=as.integer(commandArgs(T)[1])-1;p=function(...){paste(...,sep='')};a='answer ';b='accept';e='ed';f='d';v='vote';d=p('down',v);u=p('up',v);q='question ';z=c();t=r%/%15;if(t>0){z=c(p(t,' ',a,b));r=r%%15;};if(r%in%(8:12))z=c(z,p(a,u));if(r%in%(3:7))z=c(z,p(q,u));if(r%in%c(1,2,6,7,11,12))z=c(z,p(a,b,e));if(r%in%(13:14))z=c(z,p(a,b));if(r%in%c(3,8,13))z=c(z,p(a,d));if(r%in%c(1,4,6,9,11,14))z=c(z,p(a,d,f));cat(z,sep=', ')

Grazie a Dennis per la sua risposta che mi ha aiutato molto.

Versione Ungolfed

# read input
r = as.integer(commandArgs(T)[1]) - 1

# shortcut to join strings (... will pass the parameter to paste() *as is*)
p = function(...) {paste(..., sep = '')}

# strings
a = 'answer '; b = 'accept'; e = 'ed'; f = 'd'
v = 'vote'; d = p('down',v); u = p('up',v)
q = 'question '

z = c()

# +15
t = r %/% 15;
if (t > 0) {
    z = c(p(t,' ',a,b))
    r = r %% 15
}

if (r %in% (8:12))              z = c(z,p(a,u));    # answer upvote
if (r %in% (3:7))               z = c(z,p(q,u));    # question upvote
if (r %in% c(1,2,6,7,11,12))    z = c(z,p(a,b,e));  # answer accepted
if (r %in% (13:14))             z = c(z,p(a,b));    # answer accept
if (r %in% c(3,8,13))           z = c(z,p(a,d));    # answer downvote
if (r %in% c(1,4,6,9,11,14))    z = c(z,p(a,d,f));  # answer downvoted

# print operations
cat(z,sep = ', ')

4

JavaScript - 270 237 227 206 192 caratteri

p=prompt,r=p()-1,a="1answer ",v="vote,";s=(r/15|0)+"answer accept,",r%=15;if(r>9)s+=a+"+"+v,r-=10;if(r>2)s+="1question +"+v,r-=5;r>0?s+=a+"accepted,":0;r<-1?s+=a+"-"+v:0;p(r&1?s+=a+"-voted":s)

Esattamente quanti caratteri come Bash (sì!), E batte Python e Perl :) Riduce la reputazione fino a 14quando non prende le altre azioni necessarie, completamente in stile loop.

EDIT 1: convertito \ns in se ,convertito un ifblocco in ternario, e migliore pavimentazione con nomi brevi.

EDIT 2: Grazie mille ad Alconja che mi ha aiutato a ridurre 11 caratteri. Dopo di che ho apportato alcune correzioni per ridurre altri 2 caratteri.


Versione precedente:

r=prompt()-1,a="1answer ",q="1question ",v="vote,";s=(c=r/15|0)+"answer accept,",r-=c*15;if(r>9)s+=a+"+"+v,r-=10;if(r>2)s+=q+"+"+v,r-=5;r>0?s+=a+"accepted,":0;if(r<-1)s+=a+"-"+v;r&1?s+=a+"-voted":0;alert(s)

Test:

INGRESSO: 42
USCITA:

2answer accept,1answer +vote,1answer accepted,1answer -voted

/*I sincerely hope the output is clear and easy to make out*/

INGRESSO: 1337
USCITA:

89answer accept,1answer accepted,1answer -voted

Codice Ungolfed:

// different version from the golfed code
rep = prompt() - 1
string = ""

function $(z, c, k){
  while(rep > 0 && rep >= z - 2) c += 1 , rep -= z;

  if(c) string += c + k + "\n"
}

a=" answer ", q=" question "

$(15, 0, a + "accept")
$(10, 0, a + "upvote")
$(5, 0, q + "upvote")
$(2, 0, a + "accepted")

function _(z, c, str){
  while(rep <= z) c += 1, rep -= z

  if(c) string += c + str + "\n";
}

_(-2, 0, a + "downvote");
_(-1, 0, a + "downvoted");

alert(string);

Perché il primo è solo Firefox?
TheDoctor

1
@TheDoctor Utilizza la funzione di JS attualmente disponibile solo in Firefox - function name(args){}diventa name=(args)=>{}e quindi salva molti byte.
Gaurang Tandon,

@TheDoctor Ho aggiornato il mio programma per essere cross-browser ed è ora molto più breve di prima!
Gaurang Tandon,

La tua versione corrente utilizza quna sola volta, quindi puoi incorporarla. Inoltre, puoi eliminare la cvariabile e fare un r%=15invece di r-=c*15. Dovresti portarti a 195 caratteri ( r=prompt()-1,a="1answer ",v="vote,";s=(r/15|0)+"answer accept,",r%=15;if(r>9)s+=a+"+"+v,r-=10;if(r>2)s+="1question +"+v,r-=5;r>0?s+=a+"accepted,":0;if(r<-1)s+=a+"-"+v;r&1?s+=a+"-voted":0;alert(s)).
Alconja,

@Alconja Wow! Molte grazie! Finalmente sono molto vicino a Bash! Grazie ancora!
Gaurang Tandon,

1

Game Maker Language, 276

p=real(keyboard_string())-1j="#"s=""z=" answer"w=" accept"x=" upvoted"+j;y=w+"ed"v=" question"u=" downvoted"if m=floor(p/15)s+=(m+z+y)+j;r=p-m*15if m=floor(r/10)s+=(m+z+x)r-=m*10if m=floor(r/5)s+=(m+v+x)r-=m*5n=floor(r/2)r-=n*2if m=r{n++;s+=(m+u+z)+j}s+=(n+y+z)show_message(s)

1

C # - 391

Un po 'lungo e non l'ho testato a fondo (molto). :)

class R{void Main(string[] a){var r=int.Parse(a[0])-1;var a=new[]{15,10,5,2};var o=new List<string>();Func<int,string>y=z=>{var w="";if(z==15)w=" answer accepted";if(z==10)w=" answer upvotes";if(z==5)w=" question upvotes";if(z==2)w=" answer accepts";return w;};foreach(var x in a)if(r/x>0){o.Add(r/x+y(x));r-=(r/x)*x;}if(r==1)o.Add("1 question downvotes");Console.Write(string.Join(", ",o));

Non golfato - NUOVO

class R
{
    void Main(string[] a)
    {
        var r = int.Parse("122")-1; // subtracts 1 from total rep
        var a = new[] {15,10,5,2};
        var o = new List<string>();

        Func<int,string> y = 
            z => 
                {
                    var w="";
                    if(z==15) w=" answer accepted";
                    if(z==10) w=" answer upvotes";
                    if(z==5) w=" question upvotes";
                    if(z==2) w=" answer accepts";
                    return w;
                };

        foreach(var x in a) {
            if (r/x>0) {
                o.Add(r/x+y(x));
                r-=(r/x)*x;
            }
        }

        if(r==1)
            o.Add("1 question downvotes");

        Console.Write(string.Join(", ",o));
    }
}

Non golfato - VECCHIO (409)

class R
{
    void Main(string[] a)
    {
        var r = int.Parse(a[0])-1; // subtracts 1 from total rep
        var v = new[] {" question"," answer"," downvotes"," upvotes"," accepts"," accepted"};
        var o = new List<string>();

        // Starts from 15, then checks all the lower values.
        if (r/15>0) {
            o.Add(r/15+v[1]+v[5]);
            r-=(r/15)*15; // automatic rounding down due to int
        }
        if(r/10>0) {
            o.Add(r/10+v[1]+v[3]);
            r-=(r/10)*10;
        }
        if(r/5>0) {
            o.Add(r/5+v[0]+v[3]);
            r-=(r/5)*5;
        }
        if(r/2>0) {
            o.Add(r/2+v[1]+v[4]);
            r-=(r/2)*2;
        }
        if(r==1) {
            o.Add("1"+v[0]+v[2]);
        }
        Console.Write(string.Join(", ",o));
    }
}

Test:

> prog.exe 120

7 answer accepted, 1 answer upvotes, 2 answer accepts 

1

Python - 213 207

p,k=__import__('itertools').combinations_with_replacement,int(input())
t,m,u=[5,10,-2,-1,15,2],[],iter(range(0,k))
while not m:m=list(filter(lambda v:k-1==sum(v),p(t,next(u))))
print(''.join(map(chr,m[0])))

Maledici i nomi lunghi delle funzioni!

Esempio: (ignora la nuova riga finale)

$ echo "93" | python per.py | hexdump -C
00000000  0f 0f 0f 0f 0f 0f 02 0a                           |........|

$ echo "11" | python per.py | hexdump -C
00000000  0a 0a                                             |..|

Come visualizzi il numero di domande e risposte, ecc.? Il tuo codice non contiene queste stringhe (vedi le altre risposte), quindi temo che l'output non sia conforme alle regole.
AL

L'output è anche golfato poiché non vi era alcun requisito al riguardo. Non tratta separatamente le domande / risposte declassate poiché entrambe danno -2 punti, l'elenco risultante che viene stampato è la sequenza più breve per raggiungere il punteggio.
LemonBoy

Sì, le regole non entrano nei dettagli su questo punto. Ma puoi notare che nelle altre risposte l'output è standard e visualizza la risposta X che accetta , Y che rispetta i voti , ecc. Ma questo non è un problema poiché non hai il codice più corto.
AL

@LemonBoy Ho provato questo su tre interpreti e non funziona. Tutti dicono EOF. Potete per favore indicarmi un compilatore che funziona (e che dovrei conservare per riferimento futuro)?
Gaurang Tandon,

1
@GaurangTandon sospiro, stai cercando di eseguire il codice Python utilizzando l'interprete del coffeescript
LemonBoy

1

C ++, 276 (316 w / include)

#include <stdio.h>
#include <stdlib.h>
p(int&q,int*d){int r;char*s[]={"downvoted","accepted","question","answer","upvoted"};
if(r=(q&&q>=*d)){q-=(*d?*d:2);printf("%s %s\n",s[*(++d)],s[*(++d)]);}return r;}main(
int n,char**v){int q=atoi(v[1]);int d[]={-1,3,0,0,3,1,5,4,2,10,4,3,15,1,3};n=15;while
(p(q,d+n-3)||(n-=3));}

Compila con GCC, con avvisi. Esempio:

$ ./a.out 0
$ ./a.out 1
accepted answer
downvoted answer
$ ./a.out 2
accepted answer
$ ./a.out 5
question upvoted
$ ./a.out 10
answer upvoted
$ ./a.out 15
answer accepted
$ ./a.out 16
answer accepted
accepted answer
downvoted answer
$ ./a.out 17
answer accepted
accepted answer

Sentiti libero di portarlo in una lingua che non richiede dichiarazioni di tipo e pubblicalo come tuo.


1

JavaScript - 273 256 235

p=prompt(s=j="\n")-1;z=" answer",w=" accept",x=" upvoted"+j,y=w+"ed",v=" question",u=" downvoted";if(m=p/15|0)s+=m+z+y+j;r=p-m*15;if(m=r/10|0)s+=m+z+x;r-=m*10;if(m=r/5|0)s+=m+v+x;r-=m*5;n=r/2|0;if(m=r-=n*2)n++,s+=m+u+z+j;alert(s+n+y+z)

Calcolo e output combinati, e golf ulteriormente per un totale di 287.

Modifica: ha eliminato alcune variabili per alcuni più brevi.

Rimosso Math.Floor per l'approccio | 0.

Spostato un po 'di inizializzazione nel parametro prompt (), rimosso alcune parentesi, avvisato con l'appendice finale della stringa.


Benvenuto in codegolf.SE! Le istruzioni dicono: "Crea un programma che accetti un numero intero positivo" -> quindi dovrai usarlo prompte non puoi codificare il valore.
Gaurang Tandon,

Nessun problema, ha aggiunto prompt (), che lo porta a 161.
Matt

Seguendo il prompt più intelligente di @ GaurangTandon () - 1 e l'avviso dell'output si avvicinano ulteriormente. Ridotta anche una parte della memoria delle stringhe codificata.
Matt

1

Python3, 188B

n=input()+1
a=n//15
n%=15
A='answer '
print("%d %saccepted\n%d %supvoted\n%d question upvoted\n%d accept %s\n%d downvote %s\n%d %sdownvoted"%(a,A,n//10,A,n%10//5,n%5>2,A,n%5%2,A,n%5==0,A))

Utilizzo: python3 score.py <ret> 11 <ret>dove questo script viene salvato come score.py.

Uscita campione:

$ python score.py
5543
369 answer accepted
0 answer upvoted
1 question upvoted
1 accept answer 
0 downvote answer 
0 answer downvoted

accettato = accetta + d, downvoted = downvote + d, l'upgrade è ripetuto.
Bill Woodger,

Sì, ma quelle sostituzioni non salvano alcun personaggio in generale - provalo e vedi
alexander-brett
Utilizzando il nostro sito, riconosci di aver letto e compreso le nostre Informativa sui cookie e Informativa sulla privacy.
Licensed under cc by-sa 3.0 with attribution required.