Write KFC
with one-line-script using the string “Kentucky Fried Chicken” once.
for w in $(echo "Kentucky Fried Chicken" | tr " " "\n"); do echo -n ${w:0:1}; done;
— @xi-ao
echo "Kentucky Fried Chicken" | sed 's/[a-z ]//g'
(prn (clojure.string/replace "Kentucky Fried Chicken" #"[a-z ]" ""))
;; or
(prn (apply str (map first (clojure.string/split "Kentucky Fried Chicken" #"\s"))))
;; or
(prn (apply str (filter #(and (not= \space %) (= (clojure.string/upper-case (str %)) (str %))) "Kentucky Fried Chicken")))
;; or
(prn (apply str (remove #(= \space %) (map first (partition-by #(= \space %) "Kentucky Fried Chicken")))))
;; or
(prn (apply str (for [x (seq "Kentucky Fried Chicken") :when (and (= (clojure.string/upper-case (str x)) (str x)) (not= \space x))] x)))
;; or
(prn (apply str (remove #(= \space %) (for [x (seq "Kentucky Fried Chicken") :when (= (clojure.string/upper-case (str x)) (str x))] x))))
;; or
(prn (apply str (re-seq #"[A-Z]" "Kentucky Fried Chicken")))
;; or
(prn (apply str (filter #(Character/isUpperCase %) "Kentucky Fried Chicken")))
<style>span {display:none}</style>
<p>K<span>entucky </span>F<span>ried </span>C<span>hicken</span></p>
public class Kfc { public static void main(String[] args) { System.out.println(new String("Kentucky Fried Chicken").replaceAll("([^A-Z])", ""));}}
— Cyril
print(Array.prototype.map.call("Kentucky Fried Chicken".split(' '), function(w) { return w[0] }).join(''))
— @wo0dyn
print "Kentucky Fried Chicken" =~ m/\b(\w)/g;
<?php print join(array_map(function ($w){return $w[0];}, explode(' ', 'Kentucky Fried Chicken')));
→ Version un peu plus con⋅cise : 😁
<?php array_map(function($w) { print $w[0]; }, explode(' ', 'Kentucky Fried Chicken'));
— @wo0dyn
<?php echo str_replace(' ', '', join(array_intersect(str_split($s = "Kentucky Fried Chicken"), str_split(strtoupper($s)))));
— @xi-ao
<?php echo preg_replace('/[a-z]| /', '', "Kentucky Fried Chicken") ?>
<?php echo preg_replace('([^A-Z])', '', 'Kentucky Fried Chicken');
— @SaniOKh
<?php foreach(explode(' ', "Kentucky Fried Chicken") as $w) echo $w[0];
print ''.join(w[0] for w in 'Kentucky Fried Chicken'.split())
# or
import re; print re.sub('[^A-Z]', '', 'Kentucky Fried Chicken')
# or short-crappiest version ever (sorry!)
print 'KFC'#Kentucky Fried Chicken
# → yeah, we need more rules on that exercise…
— @wo0dyn
print ''.join(c for c in "Kentucky Fried Chicken" if c.isupper())
# or
import re; print ''.join(re.findall(r'\b\w', 'Kentucky Fried Chicken'))
# or
import re; print ''.join(re.findall(r'[A-Z]', 'Kentucky Fried Chicken'))
print "Kentucky Fried Chicken".gsub /[^A-Z]/, ''
# or
"Kentucky Fried Chicken".each_char{|c| print(('Z' >= c && 'A' <= c)?c:'')}
— Cyril