*
  Мысли   Галерея   Проекты   Тексты  
  Мысли   Галерея   Проекты   Тексты  
Giver: 99 бутылок  (2009-04-14 20:15:19)

Играли каналом в 99 бутылок пива по полному тексту, я писал сначала на схеме, затем на перле, резульатат на схеме — 404 байта, перл - 272. Scheme:

(let* ((& string-append)(b " bottle")(o " of beer")
(w " on the wall")(t ".nTake one down and pass it around, ")(m " more")(q(& b "s" o)))
(define (s . z)(map display z))(define (v n N g)(s t n g w ".nn" N g w ", " n g))
(define (f n e) (v n n q)(if (= n 2)(begin(v 1 1 (& b o))(v "no" "No" (& m q))
(s"nGo to the store and buy some" m ", 99" q w "."))
(f (- n 1) 's)))(s 99 q w ", " 99 q)(f 98 's) 0)

Perl:

$b=$q=" bottles of beer";$b=~tr/s//d;$w=" on the wall";
sub p{print @_}sub v{($n,$g)=@_;p
".nTake one down and pass it around, $n$g$w.nn".uc($n)."$g$w, $n$g"}
p "99$q$w, 99$q";v 98-$_,$q for 0..96;v 1,$b;v "n","o more$q";p
"nGo to the store and buy some more, 99$q$w."

Итого финишировал вторым. Первое место занял парень на dc с результатом 266 байт. Правда потом нашли соревнование взрослых дядь, но текст у них упрощен. Зато лучший результат 165 байт на перле, как и вся десятка лучших, кроме девятой позиции на PHP

UPD: После упорного колупания пёрла удалось вырваться на первое место со счетом 216, а "взрослые дяди", как оказалось, играют по сокращенному тексту, без последнего куплета. Вот что вышло после изменений:

print 99,$q=" bottles of beer",$w=" on the wall",$m=", 99$q",(map{/^1 /&&s/s//;$l=lc;".
Take one down and pass it around, $l$w.

$_$w, $l"}((map-$_.$q,-98..-1),"No more$q")),".
Go to the store and buy some more$m$w."

Попутно уловил баг перла — lc модифицировала $_ при обращении к ней, после пересборки перла баг исчез.


cialis online от 2020-07-10 21:40:16:
Prix Cialis 10mg En Pharmacie FeemnedsTeno https://ascialis.com/# - where can i buy cialis on line reinty Comprar Cialis En Andorra durbiz Cialis Intoneefat Viagra Kaufen Aus Deutschland
johnan от 2020-08-26 15:03:53:
s05tfw hi guys http://xnxx.in.net/
buy cialis generic online cheap от 2020-08-27 06:08:51:
buy accutane online safe FeemnedsTeno https://biracialism.com/ - cialis reinty All Top Meds durbiz buying cialis online Intoneefat Where To Buy Tretinoin Uk
Merrill от 2020-08-27 16:24:49:
Have you got a telephone directory? buy online bimatoprost Around 1,200 new cases are diagnosed in Ireland every year as a result of cancer treatment.
Myles от 2020-08-27 16:24:50:
What sort of music do you like? neurontin gabapentin 600 mg But in a report shared with South Africa's government two weeks after the speech, Israel's intelligence agency, Mossad, said that though Iran was improving its enrichment capability, it "does not appear to be ready" to enrich uranium to levels needed for a nuclear weapon.
Khloe от 2020-08-27 16:24:51:
Very funny pictures comprar minocycline 50 mg price in india He was a rat-catcher called Vic Maggot, and he developed this extraordinary convoluted language that this guy spoke
Brain от 2020-08-27 16:24:52:
Where do you study? buy domperidone breastfeeding Deep-winter sea ice in Antarctica now stands at an all-time high, as measured in the modern satellite record - and researchers are trying to work out why it has not followed the sharp decline seen in the Arctic.
DE от 2020-08-27 16:24:53:
A few months buy bimatoprost protocol The revised offer from QIA is still below Songbird’s boosted net asset value of 381p-a-share
Wesley от 2020-08-27 16:31:09:
Your account's overdrawn neurontin annular disc tear "The range of projects that we have identified is wide and the redevelopment of the Drumfork Club in particular is a perfect example of how this funding will be used to create a modern, vibrant, 21st century hub for families."
Phillip от 2020-08-27 16:31:10:
I read a lot amitriptyline hydrochloride 10 mg 1 night and North Korea last year (14), when Sony Pictures, the film studio behind the release, was hacked by cyberterrorists, who threatened to leak private documents unless the film was pulled from cinemas