আপনার স্ট্যাক এক্সচেঞ্জ খ্যাতি গণনা করুন


13

পটভূমি:

আমি প্রায়শই এটি দেখতে পাই যে স্ট্যাকেক্সচেঞ্জের সাইটটি ব্রাউজ করার সময় আমি ভাবতে শুরু করি যে লোকেরা কীভাবে খ্যাতি অর্জন করে। আমি জানি আমি সবসময় আমার সমস্যাগুলি সমাধান করার জন্য কোডগল্ফ এসই এর উপর নির্ভর করতে পারি, সুতরাং এটি এখানে:

এমন একটি প্রোগ্রাম তৈরি করুন যা কোনও ইতিবাচক পূর্ণসংখ্যাকে গ্রহণ করবে যা কোনও ব্যক্তির খ্যাতি উপস্থাপন করে। আমরা উদারতাগুলিকে উপেক্ষা করব এবং বলব যে এগুলিই কেবল এসই-তে রেপ পেতে / হারাতে পারে (সম্পূর্ণ টেবিলটি এখানে ):

  • প্রতিটি অ্যাকাউন্ট 1 টি প্রতিনিধি দিয়ে শুরু হয় এবং এর নিচে যেতে পারে না
  • আপনার প্রশ্নটি সমুন্নত = +5
  • আপনার উত্তরটি upvated = +10
  • আপনার প্রশ্নটি অবনমিত = -2
  • আপনার উত্তর হ্রাস করা হয়েছে = -2
  • আপনি একটি উত্তরকে কম করেছেন = -1 1
  • আপনার উত্তর = +15 গৃহীত হয়েছে
  • আপনি একটি উত্তর = + ২ গ্রহণ করেন

আপনার প্রোগ্রামটি অবশ্যই এটি নির্ধারণ করতে পারে যে সেই ব্যবহারকারীর অ্যাকাউন্টে এই জাতীয় ক্রিয়াকলাপগুলির মধ্যে কতগুলি তাদের কাছে উপস্থিত রেপটি পেতে। প্রতিনিধিদের এই স্তরে পৌঁছানোর জন্য অ্যাকশনগুলির সংক্ষিপ্ত সংখ্যার এটি অবশ্যই খুঁজে বের করতে হবে। উদাহরণ:

ইনপুট: 11 আউটপুট: 1 উত্তর upvote

ইনপুট: 93 আউটপুট: 6 উত্তর গ্রহণ করে, 1 উত্তর গৃহীত হয়েছে

এই উদাহরণগুলিতে যখন আমি 'প্রশ্ন আপভোট' বলি, এর অর্থ হল সেই ব্যক্তির অনুসন্ধানটি উপুড়ে গেছে। যখন আমি বলি 'উত্তর ডাউনভোটেড', এর অর্থ তারা অন্য কারও উত্তরকে অগ্রাহ্য করেছিল।

নিয়মাবলী:

, তাই সংক্ষিপ্ততম কোড যা এই জিততে পারে।


8
যে কোনও খ্যাতি অর্জনের জন্য সীমাহীন অসংখ্য উপায় রয়েছে। সর্বদা একটি উপায় সন্ধানের জন্য কেবলমাত্র "উত্তর আপভোট" এবং "উত্তর ডাউনভোট্ট" প্রয়োগ করা যথেষ্ট, সুতরাং স্কোর পরিবর্তনের কোনও বৃহত্তর উপসেট ব্যবহার করার জন্য কোন উত্সাহ নেই। আপনি কি এই ইচ্ছা?
অ্যালগরিদমশর্ক

@ এলগরিদমশর্ক সম্পাদিত। আপনাকে অবশ্যই সেখানে সর্বনিম্ন সংখ্যক ক্রিয়া সন্ধান করতে হবে যা আপনাকে সেখানে পেয়ে যাবে
থিডক্টর

"" "আমি প্রায়শই এটি দেখতে পাই যে স্ট্যাকেক্সচেঞ্জের সাইটটি ব্রাউজ করার সময়, আমি ভাবতে শুরু করি যে লোকেরা কীভাবে তাদের সুনামের পরিমাণ অর্জন করে" "" বনাম "" "আপনাকে অবশ্যই সেখানে সবচেয়ে কম ক্রিয়া সন্ধান করতে হবে" ""। ২ য় উদ্ধৃতিটি প্রথম উক্তিটির সঠিক উত্তর নয়।

1
@ অ্যালগরিদমশর্ক সাধারণভাবে আমি আপনার মন্তব্যের সাথে একমত। তবে 6 টি উত্তর গ্রহণ করে + 1 উত্তর গৃহীত হয়েছে 6 * 15 + 2 = 92, 93 নয়! আমি এটি 7 টি ক্রিয়াকলাপ করার কোনও উপায় দেখতে পাচ্ছি না, তবে আমি 8: 6 টির মধ্যে উত্তরটি গ্রহণ করতে পারি, একটি প্রশ্নের উত্তর, একটি প্রশ্ন ডাউনওয়োট: 6 * 15 + 5-2 = 93। ডাক্তার, "ক্ষুদ্রতম সংখ্যক ক্রিয়া" করার জন্য যদি একাধিক সম্ভাবনা থাকে তবে আমাদের কী তাদের সমস্তটি খুঁজে পাওয়া দরকার বা কেবল একটি?
স্তর নদী সেন্ট

1
@ স্টিভেরিলিল আপনি 1 জন প্রতিনিধি দিয়ে শুরু করবেন
থিডক্টর

উত্তর:


3

গল্ফস্ক্রিপ্ট, 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*

কিভাবে এটা কাজ করে

আমার ধারণাটি আমার বাশ উত্তরের মতোই সাধারণ ধারণা ।

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

কিভাবে এটা কাজ করে

সেড কমান্ড এটির কাজ করার পরে , নিম্নলিখিত বাশ স্ক্রিপ্টটি কার্যকর করা হয়:

((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এবং -1ডাউনভোটগুলি সহজ নয় ।
এএল

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

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

পুরানো সংস্করণ

$_ = 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 এর বায়াস অপ্টিমাইজড গণনার জন্য যুক্ত হয়েছে।
  • বেশিরভাগ ভেরিয়েবলগুলি অপসারণ করতে বৃহত পুনর্লিখন কিছু বাইট সংরক্ষণ করার জন্য কিছু অন্যান্য কৌশল।

এই অনুসারে, জন
স্কিটির

6
@ দ্য ডক্টর: প্রশ্ন অনুসারে, 661266 খ্যাতি অর্জনের জন্য এগুলি ন্যূনতম সংখ্যক।
হাইকো ওবারডিক

4

আর, 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=', ')

ডেনিসকে তার উত্তরের জন্য ধন্যবাদ যা আমাকে অনেক সাহায্য করেছিল।

উদার সংস্করণ

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

ঠিক যতটা অক্ষর বাশ (হ্যাঁ!) হিসাবে রয়েছে, এবং পাইথন এবং পার্লকে পরাজিত করে :) এটি সুনামকে কমিয়ে দেয় যতক্ষণ না 14পরে এটি অন্যান্য প্রয়োজনীয় ক্রিয়াগুলি গ্রহণ করে, সম্পূর্ণ লুপ স্টাইলে।

সম্পাদনা 1: \nগুলি গুলি ,এস এ রূপান্তরিত হয়েছে এবং একটি ifব্লককে টার্নারিতে রূপান্তর করা হয়েছে , এবং সংক্ষিপ্ত নামের সাথে আরও ভাল মেঝে।

সম্পাদনা 2: অ্যালকনজাকে অনেক ধন্যবাদ যে আমাকে 11 টি অক্ষর কেটে দিতে সহায়তা করেছিল helped যার পরে আমি আরও 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

অবহেলিত কোড:

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

শুধুমাত্র প্রথম একটি ফায়ারফক্স কেন?
TheDoctor

1
@ দ্য ডক্টর এটি বর্তমানে ফায়ারফক্সে উপলব্ধ জেএসের বৈশিষ্ট্যটি ব্যবহার করে - function name(args){}হয়ে যায় name=(args)=>{}এবং এতে প্রচুর বাইট সংরক্ষণ করে।
গৌরাঙ্গ ট্যান্ডন

@ ডক্টর আমি আমার প্রোগ্রামকে ক্রস ব্রাউজার হিসাবে আপডেট করেছি এবং এটি এখন আগের চেয়ে অনেক ছোট!
গৌরাঙ্গ ট্যান্ডন

আপনার বর্তমান সংস্করণটি কেবল 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))।
আলকোনজা

@ অ্যালকনজা বাহ! অনেক ধন্যবাদ! অবশেষে আমি বাশের খুব কাছাকাছি! আবার অনেক অনেক ধন্যবাদ!
গৌরাঙ্গ ট্যান্ডন

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

সি # - 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));

আন-গল্ফড - নতুন

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

আন-গল্ফড - ওল্ড (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                                             |..|

আপনি কীভাবে প্রশ্ন এবং উত্তর সংখ্যা ইত্যাদি প্রদর্শিত করবেন? আপনার কোডে এই স্ট্রিংগুলি নেই (অন্যান্য উত্তরগুলি দেখুন), সুতরাং আমি ভয় করি যে আউটপুট নিয়মের সাথে সম্মতিযুক্ত নয়।
এএল

আউটপুটটি খুব গল্ফ হয় কারণ এটি সম্পর্কে কোনও প্রয়োজন ছিল না। এটি নিম্নোক্ত প্রশ্ন / উত্তরগুলি পৃথকভাবে -2 পয়েন্ট হিসাবে বিবেচনা করে না, ফলস্বরূপ যে তালিকাটি মুদ্রিত হয় তা স্কোর অর্জনের স্বল্পতম ক্রম।
লেবুবয়

হ্যাঁ, নিয়মগুলি এই পয়েন্টটি সম্পর্কে বিশদে যায় না। তবে আপনি খেয়াল করতে পারেন যে অন্যান্য উত্তরে আউটপুটটি স্ট্যান্ডার্ড এবং ডিসপ্লে এক্স উত্তর গ্রহণ করে , ওয়াই উত্তর আপভোটস ইত্যাদি But তবে এটি কোনও সমস্যা নয় কারণ আপনার সংক্ষিপ্ততম কোডটি নেই।
এএল

@ লেমনবয় আমি তিনটি দোভাষীর উপর এটি চেষ্টা করেছি এবং এটি কার্যকর হয় না। সবাই বলে EOF। আপনি কি দয়া করে আমাকে কোনও সংকলকটির দিকে নির্দেশ করতে পারেন যা কাজ করে (এবং যা আমার ভবিষ্যতের রেফারেন্সের জন্য রাখা উচিত)?
গৌরাঙ্গ ট্যান্ডন

1
@ গৌরাংট্যান্ডন দীর্ঘশ্বাস ফেললেন, আপনি কফিস্ক্রিপ্ট দোভাষী
লেমনবয়ের

1

সি ++, 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));}

সতর্কতা সহ জিসিসির সাথে সংকলন করে। উদাহরণ:

$ ./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 পদ্ধতির জন্য ম্যাথ.ফ্লোর সরানো হয়েছে।

প্রম্পটে () প্যারামে কিছু সূচনাটি সরানো হয়েছে, কিছু বন্ধনী সরানো হয়েছে, চূড়ান্ত স্ট্রিং সংযোজন সহ সতর্কতা।


কোডগলফ.এসই তে স্বাগতম! নির্দেশাবলী বলে: "এমন একটি প্রোগ্রাম তৈরি করুন যা ইতিবাচক পূর্ণসংখ্যাকে গ্রহণ করবে" -> যাতে আপনার ব্যবহারের প্রয়োজন হবে prompt, এবং মানটিকে হার্ড কোড করতে পারবেন না।
গৌরাঙ্গ ট্যান্ডন

কোনও উদ্বেগ নেই, সংযুক্ত প্রম্পট () যা এটি 161 অবধি বিঘ্নিত হয়
ম্যাট

এটি আরও নীচে নামার জন্য @ গৌরাঙ্গট্যান্ডনের স্মার্ট প্রম্পট () - 1 এবং সতর্কতা আউটপুট পদ্ধতির অনুসরণ করছেন। কিছু হার্ডকডযুক্ত স্ট্রিং স্টোরেজও হ্রাস পেয়েছে।
ম্যাট

1

পাইথন 3, 188 বি

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>যেখানে এই স্ক্রিপ্টটি স্কোর.পি হিসাবে সংরক্ষণ করা হয়।

নমুনা আউটপুট:

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

গৃহীত = গ্রহণ + ডি, ডাউনভোটড = ডাউনভোট + ডি, আপভোটিড পুনরাবৃত্তি হয়।
বিল উড্ডার

হ্যাঁ তবে এই বিকল্পগুলি সামগ্রিকভাবে কোনও অক্ষর সংরক্ষণ করে না - এটি ব্যবহার করে দেখুন
অ্যালেক্সান্ডার-ব্রেট
আমাদের সাইট ব্যবহার করে, আপনি স্বীকার করেছেন যে আপনি আমাদের কুকি নীতি এবং গোপনীয়তা নীতিটি পড়েছেন এবং বুঝতে পেরেছেন ।
Licensed under cc by-sa 3.0 with attribution required.