Skip to main content
We’ve updated our Terms of Service. A new AI Addendum clarifies how Stack Overflow utilizes AI interactions.
Code Golf

Return to Answer

Commonmark migration
Source Link

#R, 98 bytes

R, 98 bytes

Very similar to Alex's solution, but uses a substitution rather than a match to determine consecutive letters. Scan is used to get the input and also to split the substitution result on spaces.

cat(names(a<-table(scan(,'',t=gsub('([A-z]?)(\1円?)[^A-z]*','\\U\2円 ',scan(,''),T,T))))[a==max(a)])

A couple of tests

> cat(names(a<-table(scan(,'',t=gsub('([A-z]?)(\1円?)[^A-z]*','\\U\2円 ',scan(,''),T,T))))[a==max(a)])
1: 11 was a race horse, 22 was one too. 11 won one race and 22 one won too.
19: 
Read 18 items
Read 2 items
O
> cat(names(a<-table(scan(,'',t=gsub('([A-z]?)(\1円?)[^A-z]*','\\U\2円 ',scan(,''),T,T))))[a==max(a)])
1: Sally's friends Jimmy and Bobby rummaged for seashells.
9: 
Read 8 items
Read 5 items
L M
> cat(names(a<-table(scan(,'',t=gsub('([A-z]?)(\1円?)[^A-z]*','\\U\2円 ',scan(,''),T,T))))[a==max(a)])
1: 11ss11nn
2: 
Read 1 item
Read 2 items
N S
> 

#R, 98 bytes

Very similar to Alex's solution, but uses a substitution rather than a match to determine consecutive letters. Scan is used to get the input and also to split the substitution result on spaces.

cat(names(a<-table(scan(,'',t=gsub('([A-z]?)(\1円?)[^A-z]*','\\U\2円 ',scan(,''),T,T))))[a==max(a)])

A couple of tests

> cat(names(a<-table(scan(,'',t=gsub('([A-z]?)(\1円?)[^A-z]*','\\U\2円 ',scan(,''),T,T))))[a==max(a)])
1: 11 was a race horse, 22 was one too. 11 won one race and 22 one won too.
19: 
Read 18 items
Read 2 items
O
> cat(names(a<-table(scan(,'',t=gsub('([A-z]?)(\1円?)[^A-z]*','\\U\2円 ',scan(,''),T,T))))[a==max(a)])
1: Sally's friends Jimmy and Bobby rummaged for seashells.
9: 
Read 8 items
Read 5 items
L M
> cat(names(a<-table(scan(,'',t=gsub('([A-z]?)(\1円?)[^A-z]*','\\U\2円 ',scan(,''),T,T))))[a==max(a)])
1: 11ss11nn
2: 
Read 1 item
Read 2 items
N S
> 

R, 98 bytes

Very similar to Alex's solution, but uses a substitution rather than a match to determine consecutive letters. Scan is used to get the input and also to split the substitution result on spaces.

cat(names(a<-table(scan(,'',t=gsub('([A-z]?)(\1円?)[^A-z]*','\\U\2円 ',scan(,''),T,T))))[a==max(a)])

A couple of tests

> cat(names(a<-table(scan(,'',t=gsub('([A-z]?)(\1円?)[^A-z]*','\\U\2円 ',scan(,''),T,T))))[a==max(a)])
1: 11 was a race horse, 22 was one too. 11 won one race and 22 one won too.
19: 
Read 18 items
Read 2 items
O
> cat(names(a<-table(scan(,'',t=gsub('([A-z]?)(\1円?)[^A-z]*','\\U\2円 ',scan(,''),T,T))))[a==max(a)])
1: Sally's friends Jimmy and Bobby rummaged for seashells.
9: 
Read 8 items
Read 5 items
L M
> cat(names(a<-table(scan(,'',t=gsub('([A-z]?)(\1円?)[^A-z]*','\\U\2円 ',scan(,''),T,T))))[a==max(a)])
1: 11ss11nn
2: 
Read 1 item
Read 2 items
N S
> 
Source Link
MickyT
  • 12.3k
  • 2
  • 27
  • 49

#R, 98 bytes

Very similar to Alex's solution, but uses a substitution rather than a match to determine consecutive letters. Scan is used to get the input and also to split the substitution result on spaces.

cat(names(a<-table(scan(,'',t=gsub('([A-z]?)(\1円?)[^A-z]*','\\U\2円 ',scan(,''),T,T))))[a==max(a)])

A couple of tests

> cat(names(a<-table(scan(,'',t=gsub('([A-z]?)(\1円?)[^A-z]*','\\U\2円 ',scan(,''),T,T))))[a==max(a)])
1: 11 was a race horse, 22 was one too. 11 won one race and 22 one won too.
19: 
Read 18 items
Read 2 items
O
> cat(names(a<-table(scan(,'',t=gsub('([A-z]?)(\1円?)[^A-z]*','\\U\2円 ',scan(,''),T,T))))[a==max(a)])
1: Sally's friends Jimmy and Bobby rummaged for seashells.
9: 
Read 8 items
Read 5 items
L M
> cat(names(a<-table(scan(,'',t=gsub('([A-z]?)(\1円?)[^A-z]*','\\U\2円 ',scan(,''),T,T))))[a==max(a)])
1: 11ss11nn
2: 
Read 1 item
Read 2 items
N S
> 

AltStyle によって変換されたページ (->オリジナル) /