스택 교환 평판 계산


13

배경:

나는 종종 Stackexchange 사이트를 탐색 할 때 사람들이 어떻게 명성을 얻었는지 궁금해하기 시작합니다. 내 문제를 해결하기 위해 항상 codegolf SE를 사용할 수 있다는 것을 알고 있습니다.

사람의 평판을 나타내는 양의 정수를 허용하는 프로그램을 작성하십시오. 우리는 바운티를 무시하고 이것이 SE에 대한 응답을 얻거나 잃을 수있는 유일한 방법이라고 말할 것입니다 (full table here ).

  • 모든 계정은 1 명의 담당자로 시작하며 그 아래로 내려갈 수 없습니다
  • 귀하의 질문은 upvoted = +5
  • 당신의 대답은 upvoted = +10
  • 귀하의 질문은 downvoted = -2
  • 당신의 대답은 downvoted = -2
  • 당신은 답을 downvote = -1
  • 당신의 대답은 받아 들여집니다 = +15
  • 당신은 대답을 수락 = +2

귀하의 프로그램은 해당 담당자에게 연락하기 위해 해당 사용자 계정에서 발생한 조치 수를 파악해야합니다. 이 담당자 수준에 도달하려면 가장 짧은 작업 수를 파악해야합니다. 예 :

입력 : 11 출력 : 1 응답 공감

입력 : 93 출력 : 6 응답, 1 응답 허용

이 예에서 '질문 투표'라고 말하면 사람의 질문이 상향 조정되었음을 의미합니다. '답변 다운 보트'라고 말하면 다른 사람의 답을 다운 보트 함을 의미합니다.

규칙 :

이므로이를 수행 할 수있는 가장 짧은 코드가 승리합니다.


8
주어진 평판을 얻는 방법에는 무한한 방법이 있습니다. "answer upvote"및 "answer downvoted"만 구현하면 항상 방법을 찾을 수 있으므로 점수 변화의 더 큰 부분 집합을 사용하기위한 자극이 없습니다. 이것이 당신이 의도 한 것입니까?
algorithmshark

@algorithmshark이 편집되었습니다. 당신은 그곳에 도착할 수있는 가장 적은 수의 행동을 찾아야합니다
TheDoctor

"" "Stackexchange 사이트를 탐색 할 때 사람들이 자신의 평판을 얻는 방법에 대해 궁금해하기 시작합니다." "" "" "" " "". 두 번째 인용문은 반드시 첫 번째 인용문에 대한 정답이 아닙니다.

1
@algorithmshark 일반적으로 나는 당신의 의견에 동의합니다. 그러나 6 답변 허용 + 1 답변 허용 93이 아니라 6 * 15 + 2 = 92입니다! 나는 7 가지 행동으로 그것을 할 수있는 방법을 볼 수는 없지만 8 : 6 대답을 받아 들일 수 있습니다. 한 질문은 공감하고 한 질문은 공감합니다. 닥터, "가장 적은 수의 행동"에 대한 가능성이 두 개 이상인 경우, 우리는 모든 행동을 찾거나 하나만 찾아야합니까?
Level River St

1
@steveverrill 당신은 1 개의 담당자로 시작합니다
TheDoctor

답변:


3

Golfscript, 162 144 바이트

{{}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*

작동 원리

일반적인 아이디어는 내 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

배시, 247 (202) 192 바이트

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')

작동 원리

애프터 나오지 명령이 일을 다음 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

최적의 솔루션 ( n평판 을 얻기위한 최소 이벤트 수 a)을 얻으려면 16 미만의 평판에 도달하는 데 필요한 허용 된 답변 수 ( ) 를 계산하고 (1 개의 답변 허용) 다음과 같이 잔여 물을 처리하면됩니다.

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
설명을 주셔서 감사합니다, 그것을 다루는 간단하지 -2-1downvotes.
AL

6

500 263 256 208 바이트

스크립트 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!$_

용법

입력은 스크립트에 인수로 주어진 양의 정수로 예상됩니다. 다른 조치는 행으로 출력됩니다.

테스트

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

언 골프

$_ = 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 ! $_

이전 버전

$_ = 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

편집

  • 사례 4가 수정되었습니다.
  • 또한 루프없이 수행되는 계산을 단순화합니다.
  • 도달 할 수없는 복수 "s"가 제거되어 S더 이상 기능 이 필요하지 않습니다.
  • 계산 최적화, 기능이 E더 이상 필요하지 않습니다.
  • 최적화 된 계산을 위해 2의 바이어스가 추가되었습니다.
  • 대부분의 변수를 제거하여 일부 바이트를 저장하는 다른 트릭을 제거하기 위해 다시 작성하십시오.

이에 따르면 Jon Skeet 은 44084 개의 답변이 허용되고 1 개의 답변이 투표되었습니다.
TheDoctor

6
@TheDoctor : 질문에 따르면, 이들은 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=', ')

많은 도움을 준 Dennis의 답변에 감사드립니다 .

언 골프 버전

# 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

자바 스크립트 - 270 237 227 206 192 자

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)

정확히 Bash (yeah!)만큼 많은 문자를 사용하고 Python과 Perl을 이겼습니다 14.

편집 1 : \ns를 ,s로 변환하고 하나의 if블록을 3 진으로 변환 하고 짧은 이름으로 더 나은 바닥을 만들었습니다.

편집 2 : 11 자를 줄 이도록 도와 준 Alconja 에게 큰 감사를 합니다. 그 후 나는 2 문자를 더 줄이기 위해 약간 더 수정했습니다.


이전 버전 :

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)

테스트:

입력 : 42
출력 :

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

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

입력 : 1337
출력 :

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

Ungolfed Code :

// 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);

첫 번째 Firefox 만있는 이유는 무엇입니까?
TheDoctor

1
@TheDoctor 그것은 단지 파이어 폭스에서 현재 사용 가능한 JS의 기능을 활용 - function name(args){}되고 name=(args)=>{}따라서 바이트를 많이 절약 할 수 있습니다.
Gaurang Tandon

@TheDoctor 저는 프로그램을 크로스 브라우저로 업데이트했습니다. 이제는 이전보다 훨씬 짧아졌습니다!
Gaurang Tandon

현재 버전은 q한 번만 사용 하므로 인라인 할 수 있습니다. 또한 c변수를 삭제하고 r%=15대신 작업을 수행 할 수 있습니다 r-=c*15. 195 자 ( 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 와우! 고마워요! 나는 마침내 Bash에 매우 가깝습니다! 다시 한번 감사드립니다!
Gaurang Tandon

1

게임 메이커 언어, 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

조금 길었고 나는 이것을 철저히 테스트하지 않았습니다. :)

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));

언 골프-NEW

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));
    }
}

언 골프-OLD (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));
    }
}

테스트:

> prog.exe 120

7 answer accepted, 1 answer upvotes, 2 answer accepts 

1

파이썬 - 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])))

긴 기능 이름을 저주하십시오!

예 : (마지막 줄 바꿈 무시)

$ 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                                             |..|

질문 및 답변 투표 수 등을 어떻게 표시합니까? 코드에 이러한 문자열이 포함되어 있지 않으므로 (다른 답변 참조) 출력이 규칙을 준수하지 않을까 걱정됩니다.
AL

그에 대한 요구 사항이 없었기 때문에 출력도 골프를 쳤다. 다운 봇 된 질문 / 응답은 둘 다 -2 점을 주므로 개별적으로 처리되지 않으며, 인쇄 된 결과 목록은 점수를 달성하는 가장 짧은 순서입니다.
LemonBoy

예, 규칙은이 시점에 대한 세부 사항으로 들어 가지 않습니다. 그러나 다른 답변에서는 출력이 표준이며 X 응답 수락 , Y 응답 upvotes 등이 표시됩니다 . 그러나 코드가 가장 짧기 때문에 문제가되지 않습니다.
AL

@LemonBoy 세 통역에서 이것을 시도했지만 작동하지 않습니다. 모두 말한다 EOF. 작동하고 나중에 참조 할 수 있도록 컴파일러를 알려 주시겠습니까?
Gaurang Tandon

1
@GaurangTandon 한숨, 커피 스크립트 인터프리터를 사용하여 Python 코드를 실행하려고합니다
LemonBoy

1

C ++, 276 (316 포함 / 포함)

#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));}

경고와 함께 GCC로 컴파일합니다. 예:

$ ./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

타입 선언이 필요없는 언어로 이것을 자유롭게 포팅하고 자신의 것으로 게시하십시오.


1

자바 스크립트 - 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)

계산과 출력을 합하여 총 287 개까지 골프를 쳤다.

편집 : 몇 가지 변수를 조금 더 짧게 만들었습니다.

| 0 접근 방식에 대한 Math.Floor를 제거했습니다.

초기화를 prompt () 매개 변수로 옮기고 대괄호를 제거하고 최종 문자열 추가로 경고합니다.


codegolf.SE에 오신 것을 환영합니다! 명령어는 "양의 정수를 허용하는 프로그램을 작성하십시오"->라고 말해야합니다.를 사용해야 prompt하며 값을 하드 코딩 할 수 없습니다.
Gaurang Tandon

걱정하지 않고 prompt ()를 추가하여 최대 161까지 올렸습니다.
Matt

@GaurangTandon의 더 똑똑한 prompt ()-1 및 경고 출력 접근 방식을 따르면이 문제를 더 줄일 수 있습니다. 하드 코드 된 문자열 스토리지의 일부도 줄었습니다.
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))

사용법 : python3 score.py <ret> 11 <ret>이 스크립트는 score.py로 저장됩니다.

샘플 출력 :

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

수락 됨 = 수락 + d, 하향 투표 = 하향 투표 + d, 상향 투표가 반복됩니다.
Bill Woodger

그렇습니다. 그러나 이러한 대체물은 전체적으로 어떤 문자도 저장하지 않습니다. 시도해보십시오
alexander-brett
당사 사이트를 사용함과 동시에 당사의 쿠키 정책개인정보 보호정책을 읽고 이해하였음을 인정하는 것으로 간주합니다.
Licensed under cc by-sa 3.0 with attribution required.