Skip to main content
added 8 characters in body
Source Link
plannapus
  • 9k
  • 23
  • 49

R - 148 137 chars

(so, far away from the rest of the competition but still)

f=function(n){s=sapply;which.max(s(lapply(strsplit(s(4:n,function(x){q=n;r="";while(q){r=paste(q%%x,r);q=q%/%x};r})," "),`==`,4),sum))+3} 

Basically transform the input from base 10 to all bases from 4 to n (using modulo %% and integer division %/%) and pick the index of the first one withhaving the most 4s.

f(624) [1] 5 f(444) [1] 10 

R - 148 137 chars

(so, far away from the rest of the competition but still)

f=function(n){s=sapply;which.max(s(lapply(strsplit(s(4:n,function(x){q=n;r="";while(q){r=paste(q%%x,r);q=q%/%x};r})," "),`==`,4),sum))+3} 

Basically transform the input from base 10 to all bases from 4 to n (using modulo %% and integer division %/%) and pick the index of the one with the most 4s.

f(624) [1] 5 f(444) [1] 10 

R - 148 137 chars

(so, far away from the rest of the competition but still)

f=function(n){s=sapply;which.max(s(lapply(strsplit(s(4:n,function(x){q=n;r="";while(q){r=paste(q%%x,r);q=q%/%x};r})," "),`==`,4),sum))+3} 

Basically transform the input from base 10 to all bases from 4 to n (using modulo %% and integer division %/%) and pick the index of the first one having the most 4s.

f(624) [1] 5 f(444) [1] 10 
deleted 59 characters in body
Source Link
plannapus
  • 9k
  • 23
  • 49

R - 148148 137 chars

(so, far away from the rest of the competition but still)

f=function(n){ q=reps=sapply;which.max(n,n) r=cs() forlapply(i in strsplit(s(4:n,function(x){ whileq=n;r="";while(q[i]q){ r[i]=paster=paste(q[i]%%iq%%x,r[i]r) q[i]=q[i]%;q=q%/%i %x}  ;r} which.max(sapply(lapply(strsplit(r)," "),`==`,4),sum))  +3} 

Basically transform the input from base 10 to all bases from 4 to n (using modulo %% and integer division %/%) and pick the index of the one with the most 4s.

f(624) [1] 5 f(444) [1] 10 

R - 148 chars

(so far away from the rest of the competition but still)

f=function(n){ q=rep(n,n) r=c() for(i in 4:n){ while(q[i]){ r[i]=paste(q[i]%%i,r[i]) q[i]=q[i]%/%i }  } which.max(sapply(lapply(strsplit(r," "),`==`,4),sum))  } 

Basically transform the input from base 10 to all bases from 4 to n (using modulo %% and integer division %/%) and pick the index of the one with the most 4s.

f(624) [1] 5 f(444) [1] 10 

R - 148 137 chars

(so, far away from the rest of the competition but still)

f=function(n){s=sapply;which.max(s(lapply(strsplit(s(4:n,function(x){q=n;r="";while(q){r=paste(q%%x,r);q=q%/%x};r})," "),`==`,4),sum))+3} 

Basically transform the input from base 10 to all bases from 4 to n (using modulo %% and integer division %/%) and pick the index of the one with the most 4s.

f(624) [1] 5 f(444) [1] 10 
deleted 8 characters in body
Source Link
plannapus
  • 9k
  • 23
  • 49

R - 156148 chars

(so far away from the rest of the competition but still)

f=function(n){ q=rep(n,n) r=c() for(i in 4:n){ while(q[i]){ r[i]=paste(q[i]%%i,r[i],sep=" ") q[i]=q[i]%/%i } } which.max(sapply(lapply(strsplit(r," "),`==`,4),sum)) } 

Basically transform the input from base 10 to all bases from 4 to n (using modulo %% and integer division %/%) and pick the index of the one with the most 4s.

f(624) [1] 5 f(444) [1] 10 

R - 156 chars

(so far away from the rest of the competition but still)

f=function(n){ q=rep(n,n) r=c() for(i in 4:n){ while(q[i]){ r[i]=paste(q[i]%%i,r[i],sep=" ") q[i]=q[i]%/%i } } which.max(sapply(lapply(strsplit(r," "),`==`,4),sum)) } 

Basically transform the input from base 10 to all bases from 4 to n (using modulo %% and integer division %/%) and pick the index of the one with the most 4s.

f(624) [1] 5 f(444) [1] 10 

R - 148 chars

(so far away from the rest of the competition but still)

f=function(n){ q=rep(n,n) r=c() for(i in 4:n){ while(q[i]){ r[i]=paste(q[i]%%i,r[i]) q[i]=q[i]%/%i } } which.max(sapply(lapply(strsplit(r," "),`==`,4),sum)) } 

Basically transform the input from base 10 to all bases from 4 to n (using modulo %% and integer division %/%) and pick the index of the one with the most 4s.

f(624) [1] 5 f(444) [1] 10 
added 8 characters in body
Source Link
plannapus
  • 9k
  • 23
  • 49
Loading
Source Link
plannapus
  • 9k
  • 23
  • 49
Loading