Skip to main content
Commonmark migration
Source Link

#R, 102, 91, 81 bytes

R, 102, 91, 81 bytes

f=function(b,v,s=table(v))(477*any(s>3)+b+10*all(s<2))%/%100+sum(s==2)+3*any(s>2)

Managed to drop 11 bytes (and fix a bug) thanks to @Giuseppe. Managed a further 10 inspired by by @Giuseppe's /10 idea.

Ungolfed

f=function(b,v){
  s = table(v)          #included in fn inputs
  a = b+10*all(s<2)     #covers all different case
  a = a+477*any(s>3)    #Covers 4 of a kind
  d = sum(s==2)+3*any(s>2) #covers 1 and 2 pair, 3 of a kind.
  a%/%100+d         #sum appropriate values
}

Try it online!

#R, 102, 91, 81 bytes

f=function(b,v,s=table(v))(477*any(s>3)+b+10*all(s<2))%/%100+sum(s==2)+3*any(s>2)

Managed to drop 11 bytes (and fix a bug) thanks to @Giuseppe. Managed a further 10 inspired by by @Giuseppe's /10 idea.

Ungolfed

f=function(b,v){
  s = table(v)          #included in fn inputs
  a = b+10*all(s<2)     #covers all different case
  a = a+477*any(s>3)    #Covers 4 of a kind
  d = sum(s==2)+3*any(s>2) #covers 1 and 2 pair, 3 of a kind.
  a%/%100+d         #sum appropriate values
}

Try it online!

R, 102, 91, 81 bytes

f=function(b,v,s=table(v))(477*any(s>3)+b+10*all(s<2))%/%100+sum(s==2)+3*any(s>2)

Managed to drop 11 bytes (and fix a bug) thanks to @Giuseppe. Managed a further 10 inspired by by @Giuseppe's /10 idea.

Ungolfed

f=function(b,v){
  s = table(v)          #included in fn inputs
  a = b+10*all(s<2)     #covers all different case
  a = a+477*any(s>3)    #Covers 4 of a kind
  d = sum(s==2)+3*any(s>2) #covers 1 and 2 pair, 3 of a kind.
  a%/%100+d         #sum appropriate values
}

Try it online!

deleted 112 characters in body
Source Link

#R, 102, 9191, 81 bytes

f=function(b,v,s=table(v))(90*any477*any(s>1s>3)+100*all+b+10*all(s==2s<2)+200*any(s>2)+477*any%/%100+sum(s>3s==2)+b+10+3*any(s>2)%/%100

Managed to drop 11 bytes (and fix a bug) thanks to @Giuseppe. Managed a further 10 inspired by by @Giuseppe's /10 idea.

Ungolfed

f=function(b,v){
  s = s=tabletable(v) #Built into function inputs to remove 2 bytes
    a=10+b+         #adds coins (b) and covers default#included ofin nofn matchesinputs
  a = 90*anyb+10*all(s==2s<2)+   #covers 1 pair, starts sums for rest of matches
    100*all(s==2)+  #covers sum forall 2different paircase
  a = 290*anya+477*any(s>2s>3)+   #covers sum for 3 of a kind, continues for#Covers 4 of a kind
  d = 477*anysum(s>3s==2) +3*any(s>2) #covers 1 #coversand sum2 forpair, 43 of a kind.
    a%/%100%100+d         #division#sum withoutappropriate remaindervalues
}

Try it online!

#R, 102, 91 bytes

f=function(b,v,s=table(v))(90*any(s>1)+100*all(s==2)+200*any(s>2)+477*any(s>3)+b+10)%/%100

Managed to drop 11 bytes (and fix a bug) thanks to @Giuseppe.

Ungolfed

f=function(b,v){
    s=table(v) #Built into function inputs to remove 2 bytes
    a=10+b+         #adds coins (b) and covers default of no matches
    90*any(s==2)+   #covers 1 pair, starts sums for rest of matches
    100*all(s==2)+  #covers sum for 2 pair
    290*any(s>2)+   #covers sum for 3 of a kind, continues for 4 of a kind
    477*any(s>3)    #covers sum for 4 of a kind
    a%/%100         #division without remainder
}

#R, 102, 91, 81 bytes

f=function(b,v,s=table(v))(477*any(s>3)+b+10*all(s<2))%/%100+sum(s==2)+3*any(s>2)

Managed to drop 11 bytes (and fix a bug) thanks to @Giuseppe. Managed a further 10 inspired by by @Giuseppe's /10 idea.

Ungolfed

f=function(b,v){
  s = table(v)          #included in fn inputs
  a = b+10*all(s<2)     #covers all different case
  a = a+477*any(s>3)    #Covers 4 of a kind
  d = sum(s==2)+3*any(s>2) #covers 1 and 2 pair, 3 of a kind.
  a%/%100+d         #sum appropriate values
}

Try it online!

added 51 characters in body
Source Link

#R, 102102, 91 bytes

f=function(b,v,s=table(as.factor(v)))(90*any(s>1)+100*all(s==2)+200*any(s>2)+387*any+477*any(s>3)+b+10)%/%100

Managed to drop 11 bytes (and fix a bug) thanks to @Giuseppe.

Ungolfed

f=function(b,v){
    s=table(as.factor(v)) #Built into function inputs to remove 2 bytes
    a=10+b+         #adds coins (b) and covers default of no matches
    90*any(s==2)+   #covers 1 pair, starts sums for rest of matches
    100*all(s==2)+  #covers sum for 2 pair
    290*any(s>2)+   #covers sum for 3 of a kind, continues for 4 of a kind
    387*any477*any(s>3)    #covers sum for 4 of a kind
    a%/%100         #division without remainder
}

#R, 102 bytes

f=function(b,v,s=table(as.factor(v)))(90*any(s>1)+100*all(s==2)+200*any(s>2)+387*any(s>3)+b+10)%/%100

Ungolfed

f=function(b,v){
    s=table(as.factor(v)) #Built into function inputs to remove 2 bytes
    a=10+b+         #adds coins (b) and covers default of no matches
    90*any(s==2)+   #covers 1 pair, starts sums for rest of matches
    100*all(s==2)+  #covers sum for 2 pair
    290*any(s>2)+   #covers sum for 3 of a kind, continues for 4 of a kind
    387*any(s>3)    #covers sum for 4 of a kind
    a%/%100         #division without remainder
}

#R, 102, 91 bytes

f=function(b,v,s=table(v))(90*any(s>1)+100*all(s==2)+200*any(s>2)+477*any(s>3)+b+10)%/%100

Managed to drop 11 bytes (and fix a bug) thanks to @Giuseppe.

Ungolfed

f=function(b,v){
    s=table(v) #Built into function inputs to remove 2 bytes
    a=10+b+         #adds coins (b) and covers default of no matches
    90*any(s==2)+   #covers 1 pair, starts sums for rest of matches
    100*all(s==2)+  #covers sum for 2 pair
    290*any(s>2)+   #covers sum for 3 of a kind, continues for 4 of a kind
    477*any(s>3)    #covers sum for 4 of a kind
    a%/%100         #division without remainder
}
Source Link
Loading