<?xml version='1.0' encoding='UTF-8'?><?xml-stylesheet href="http://www.blogger.com/styles/atom.css" type="text/css"?><feed xmlns='http://www.w3.org/2005/Atom' xmlns:openSearch='http://a9.com/-/spec/opensearchrss/1.0/' xmlns:blogger='http://schemas.google.com/blogger/2008' xmlns:georss='http://www.georss.org/georss' xmlns:gd="http://schemas.google.com/g/2005" xmlns:thr='http://purl.org/syndication/thread/1.0'><id>tag:blogger.com,1999:blog-8657487033851500757</id><updated>2024-12-06T16:59:57.781+02:00</updated><category term="python"/><category term="codility.com"/><category term="train"/><category term="hack"/><category term="javascript"/><category term="js"/><category term="ubuntu"/><category term="системный администратор"/><category term="АБС Б2"/><category term="программист"/><category term="linux"/><category term="manageengine"/><category term="php"/><category term="service desk"/><category term="банк"/><category term="праздник"/><category term="рабочий день"/><category term="easy"/><category term="google"/><category term="medium"/><category term="oracle"/><category term="postgresql"/><category term="sdp"/><category term="very easy"/><category term="windows"/><category term="креатив"/><category term="CREATOR"/><category term="SOA"/><category term="SYS"/><category term="lesson 1"/><category term="lesson 2"/><category term="lesson 4"/><category term="python3"/><category term="weblogic"/><category term="украина"/><category term="централизация"/><category term="HARPER"/><category term="OCR"/><category term="android"/><category term="cloud9"/><category term="convert"/><category term="cyrillic"/><category term="d2mobile"/><category term="fwdays"/><category term="ide"/><category term="jquery"/><category term="lesson 3"/><category term="maps"/><category term="monster world"/><category term="mysql"/><category term="node.js"/><category term="password"/><category term="sytec"/><category term="wooga"/><category term="процессинг"/><category term="разработка"/><category term="рейтинг"/><category term="хостинг"/><category term="2015"/><category term="Active Directory"/><category term="ESB"/><category term="LDAP"/><category term="PyQt"/><category term="PyQt4"/><category term="TOS"/><category term="Talend"/><category term="a2048"/><category term="adwords"/><category term="apache"/><category term="aperon"/><category term="archlinux"/><category term="auth"/><category term="bi publisher"/><category term="bing"/><category term="bip"/><category term="blogger"/><category term="blogspot"/><category term="bom"/><category term="card-reader"/><category term="codenjoy"/><category term="d2"/><category term="debug"/><category term="draft"/><category term="drupal"/><category term="dwa-110"/><category term="events"/><category term="exchange"/><category term="frameworksdays"/><category term="html5"/><category term="htpasswd"/><category term="java"/><category term="jdeveloper"/><category term="joomla"/><category term="kml"/><category term="kubuntu"/><category term="lesson 5"/><category term="life:)"/><category term="lotus"/><category term="mod_proxy"/><category term="nod32"/><category term="notes"/><category term="outlook"/><category term="plsql"/><category term="portmone.com"/><category term="pos"/><category term="quest software"/><category term="smart"/><category term="sms"/><category term="sql navigator"/><category term="tomcat"/><category term="translit"/><category term="upc online"/><category term="utf8"/><category term="vbs"/><category term="websockets"/><category term="wsdl"/><category term="xsd"/><category term="yandex"/><category term="алгоритм"/><category term="бот"/><category term="букет"/><category term="доставка"/><category term="жаба"/><category term="игра"/><category term="интернет"/><category term="лето"/><category term="магазин"/><category term="наше творчество"/><category term="нумерология"/><category term="осень"/><category term="отдых"/><category term="пасхальное яйцо"/><category term="родовид банк"/><category term="рыцарь"/><category term="сессии"/><category term="цветы"/><category term="эквайринг"/><category term="юзабилити"/><title type='text'>Век живи - век учись</title><subtitle type='html'></subtitle><link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='http://blog.kalinchyk.com/feeds/posts/default'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8657487033851500757/posts/default?redirect=false'/><link rel='alternate' type='text/html' href='http://blog.kalinchyk.com/'/><link rel='hub' href='http://pubsubhubbub.appspot.com/'/><link rel='next' type='application/atom+xml' href='http://www.blogger.com/feeds/8657487033851500757/posts/default?start-index=26&amp;max-results=25&amp;redirect=false'/><author><name>Unknown</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><generator version='7.00' uri='http://www.blogger.com'>Blogger</generator><openSearch:totalResults>89</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>25</openSearch:itemsPerPage><entry><id>tag:blogger.com,1999:blog-8657487033851500757.post-404686272408889123</id><published>2017-02-19T00:28:00.000+02:00</published><updated>2017-02-19T14:34:15.535+02:00</updated><title type='text'>Магазин для своего сервера Minecraft.</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
&lt;h2 style=&quot;text-align: left;&quot;&gt;
&lt;span style=&quot;text-align: justify;&quot;&gt;Установка магазина на Apache&lt;/span&gt;&lt;/h2&gt;
&lt;h3 style=&quot;text-align: left;&quot;&gt;
&lt;/h3&gt;
&lt;h3 style=&quot;text-align: left;&quot;&gt;
Установка mod_wsgi&lt;/h3&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
В первую очередь необходимо установить модуль wsgi. Либо воспользовавшись исходным кодом (что я и сделал, когда впервые потребовалось прикрутить python к apache) следуя по &lt;a href=&quot;http://code.google.com/p/modwsgi/wiki/QuickInstallationGuide&quot; target=&quot;_blank&quot;&gt;инструкции&lt;/a&gt;. Либо взять готовый модуль из репозитория:&lt;/div&gt;
&lt;blockquote class=&quot;tr_bq&quot;&gt;
&lt;span style=&quot;font-family: &amp;quot;courier new&amp;quot; , &amp;quot;courier&amp;quot; , monospace; font-size: x-small;&quot;&gt;~$ sudo apt-get install libapache2-mod-wsgi&lt;/span&gt;&lt;/blockquote&gt;
&lt;h3 style=&quot;text-align: left;&quot;&gt;
&lt;/h3&gt;
&lt;h3 style=&quot;text-align: left;&quot;&gt;
Настройка виртуального хоста&lt;/h3&gt;
Для этого перейдем в директорию:&lt;br /&gt;
&lt;blockquote class=&quot;tr_bq&quot;&gt;
&lt;span style=&quot;font-family: &amp;quot;courier new&amp;quot; , &amp;quot;courier&amp;quot; , monospace; font-size: x-small;&quot;&gt;~$ cd&amp;nbsp;/etc/apache2/sites-enabled/&lt;/span&gt;&lt;/blockquote&gt;
и отредактируем наш конфигурационный файл:&lt;br /&gt;
&lt;blockquote class=&quot;tr_bq&quot;&gt;
&lt;span style=&quot;font-family: &amp;quot;courier new&amp;quot; , &amp;quot;courier&amp;quot; , monospace; font-size: x-small;&quot;&gt;~$ sudo vi kalinchyk-ssl.conf&lt;/span&gt;&lt;/blockquote&gt;
&lt;div&gt;
должно получиться что-то в этом роде:&lt;br /&gt;
&lt;div&gt;
&lt;span style=&quot;font-family: &amp;quot;courier new&amp;quot; , &amp;quot;courier&amp;quot; , monospace; font-size: x-small;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-family: &amp;quot;courier new&amp;quot; , &amp;quot;courier&amp;quot; , monospace; font-size: x-small;&quot;&gt;&amp;lt;VirtualHost *&amp;gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-family: &amp;quot;courier new&amp;quot; , &amp;quot;courier&amp;quot; , monospace; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; ServerName www.kalinchyk.com&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-family: &amp;quot;courier new&amp;quot; , &amp;quot;courier&amp;quot; , monospace; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; ServerAdmin viacheslav@kalinchyk.com&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-family: &amp;quot;courier new&amp;quot; , &amp;quot;courier&amp;quot; , monospace; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp;&amp;nbsp;DocumentRoot /var/www/minecraft&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-family: &amp;quot;courier new&amp;quot; , &amp;quot;courier&amp;quot; , monospace; font-size: x-small;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-family: &amp;quot;courier new&amp;quot; , &amp;quot;courier&amp;quot; , monospace; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; WSGIDaemonProcess wsgi user=www-data group=www-data processes=1 threads=5&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-family: &amp;quot;courier new&amp;quot; , &amp;quot;courier&amp;quot; , monospace; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; WSGIScriptAlias /api /var/www/wsgi/app.wsgi&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-family: &amp;quot;courier new&amp;quot; , &amp;quot;courier&amp;quot; , monospace; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;lt;Directory /var/www/wsgi&amp;gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-family: &amp;quot;courier new&amp;quot; , &amp;quot;courier&amp;quot; , monospace; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; WSGIProcessGroup wsgi&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-family: &amp;quot;courier new&amp;quot; , &amp;quot;courier&amp;quot; , monospace; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; WSGIApplicationGroup %{GLOBAL}&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-family: &amp;quot;courier new&amp;quot; , &amp;quot;courier&amp;quot; , monospace; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Require all granted&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-family: &amp;quot;courier new&amp;quot; , &amp;quot;courier&amp;quot; , monospace; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;lt;/Directory&amp;gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-family: &amp;quot;courier new&amp;quot; , &amp;quot;courier&amp;quot; , monospace; font-size: x-small;&quot;&gt;&amp;lt;/VirtualHost&amp;gt;&lt;/span&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
Здесь мы сообщили Apache, что необходимо при обращении клиента к директории /api выполнять python wsgi-скрипт (который физически размещен в директории /var/www/wsgi/app.wsgi) от имени пользователя www-data.&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;i&gt;Обязательно проверьте, что вашему пользователю доступны импортируемые библиотеки и все файлы он может читать, а при необходимости и вносить изменения.&lt;/i&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
Также в настройках виртуального хоста указана основная директория с которой будет клиент работать (/var/www/minecraft).&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
В этом кусочке конфигурации я убрал строки для настройки ssl-сертификата, логирования и т.д., чтобы не перегружать пример.&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
После изменений конфигурационных файлов Apache требуется перезапустить:&lt;/div&gt;
&lt;blockquote class=&quot;tr_bq&quot; style=&quot;text-align: justify;&quot;&gt;
&lt;span style=&quot;font-family: &amp;quot;courier new&amp;quot; , &amp;quot;courier&amp;quot; , monospace; font-size: x-small;&quot;&gt;~$ sudo service apache2 restart&lt;/span&gt;&lt;/blockquote&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;h3 style=&quot;text-align: justify;&quot;&gt;
BackEnd&lt;/h3&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
Сначала устанавливаем backend (API магазина). Для этого забираем исходные коды с &lt;a href=&quot;https://gitlab.com/kalinchyk/shop-mc/repository/archive.zip?ref=master&quot; target=&quot;_blank&quot;&gt;git-репозитория&lt;/a&gt;. Распаковываем архив и содержимое wsgi копируем в нашу wsgi директорию (в моем случае это /var/www/wsgi/). &lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
Т.к. мы для повышения безопасности указали, что python скрипты должны выполняться от имени www-data, то необходимо проверить чтобы директория и содержимое принадлежат этому пользователю.&lt;/div&gt;
&lt;blockquote class=&quot;tr_bq&quot; style=&quot;text-align: justify;&quot;&gt;
&lt;span style=&quot;font-family: &amp;quot;courier new&amp;quot; , &amp;quot;courier&amp;quot; , monospace; font-size: x-small;&quot;&gt;~$ sudo chmod -R 644 /var/www/wsgi&lt;br /&gt;~$ sudo chown -R www-data:www-data /var/www/wsgi&lt;/span&gt;&lt;/blockquote&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
Первым делом необходимо создать базу данных, выполнив db_update.py от имени нашего пользователя.&lt;/div&gt;
&lt;blockquote class=&quot;tr_bq&quot; style=&quot;text-align: justify;&quot;&gt;
&lt;span style=&quot;font-family: &amp;quot;courier new&amp;quot; , &amp;quot;courier&amp;quot; , monospace; font-size: x-small;&quot;&gt;~$ python db_update.py&lt;/span&gt;&lt;/blockquote&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
А также при последующих обновлениях необходимо не забывать про эту операцию. Этот скрипт выполняет важные изменения в структуре базы данных. Хоть скрипт самостоятельно сделает резервную копию базы, но необходимо об этом также не забывать и периодически самостоятельно архивировать критически важные данные.&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;h3 style=&quot;text-align: justify;&quot;&gt;
Устанавливаем зависимости&lt;/h3&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
Для корректной работы python приложения необходимо установить несколько зависимостей, а именно bottle, bottle_sqlite, bottle_errorrest. Их можно установить из пакетного менеджера pip:&lt;br /&gt;
&lt;blockquote class=&quot;tr_bq&quot;&gt;
&lt;span style=&quot;font-family: &amp;quot;courier new&amp;quot;, courier, monospace; font-size: x-small;&quot;&gt;~$ sudo apt-get install python-pip&lt;/span&gt;&lt;/blockquote&gt;
&lt;blockquote class=&quot;tr_bq&quot;&gt;
&lt;span style=&quot;font-family: &amp;quot;courier new&amp;quot;, courier, monospace; font-size: x-small;&quot;&gt;~$ sudo -u www-data -H pip install pip&lt;/span&gt;&lt;/blockquote&gt;
&lt;blockquote class=&quot;tr_bq&quot;&gt;
&lt;span style=&quot;font-family: &amp;quot;courier new&amp;quot; , &amp;quot;courier&amp;quot; , monospace; font-size: x-small;&quot;&gt;~$ sudo -u www-data -H pip install bottle&lt;/span&gt;&lt;/blockquote&gt;
&lt;blockquote class=&quot;tr_bq&quot;&gt;
&lt;span style=&quot;font-family: &amp;quot;courier new&amp;quot; , &amp;quot;courier&amp;quot; , monospace; font-size: x-small;&quot;&gt;~$ sudo -u www-data -H pip install bottle_sqlite&lt;/span&gt;&lt;/blockquote&gt;
&lt;blockquote class=&quot;tr_bq&quot;&gt;
&lt;span style=&quot;font-family: &amp;quot;courier new&amp;quot; , &amp;quot;courier&amp;quot; , monospace; font-size: x-small;&quot;&gt;~$ sudo -u www-data -H pip install bottle_errorsrest&lt;/span&gt;&lt;/blockquote&gt;
&lt;div&gt;
И обязательно устанавливаем их для нашего пользователя (параметр &lt;b&gt;-u ww-data&lt;/b&gt;), под которым будет выполняться скрипт (параметр &lt;b&gt;-H&lt;/b&gt;).&lt;br /&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;h3&gt;
Проверяем работу приложения&lt;/h3&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
В браузере указав адрес своего сервера и директорию, которая обслуживает wsgi, а также суффикс /whoami мы должны получить положительный отклик от сервера.&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;blockquote class=&quot;tr_bq&quot;&gt;
&lt;span style=&quot;font-family: &amp;quot;courier new&amp;quot; , &amp;quot;courier&amp;quot; , monospace; font-size: x-small;&quot;&gt;~$ curl https://test.kalinchyk.com/api/whoami&lt;br /&gt;{&quot;object&quot;: &quot;CUSTOMER&quot;}&lt;/span&gt;&lt;/blockquote&gt;
&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;h3 style=&quot;text-align: justify;&quot;&gt;
Настраиваем приложение&lt;/h3&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
Для настройки приложения необходимо создать файл с именем minecraft.json:&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;div&gt;
&lt;span style=&quot;font-family: &amp;quot;courier new&amp;quot; , &amp;quot;courier&amp;quot; , monospace; font-size: x-small;&quot;&gt;{&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-family: &amp;quot;courier new&amp;quot; , &amp;quot;courier&amp;quot; , monospace; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &quot;minecraft&quot;: {&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-family: &amp;quot;courier new&amp;quot; , &amp;quot;courier&amp;quot; , monospace; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &quot;acquiring&quot;: {&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-family: &amp;quot;courier new&amp;quot; , &amp;quot;courier&amp;quot; , monospace; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &quot;form_method&quot;: &quot;post&quot;,&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-family: &amp;quot;courier new&amp;quot; , &amp;quot;courier&amp;quot; , monospace; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &quot;form_url&quot;: &quot;https://sci.interkassa.com/&quot;,&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-family: &amp;quot;courier new&amp;quot; , &amp;quot;courier&amp;quot; , monospace; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &quot;id&quot;: &quot;&lt;b&gt;[идентификатор_кассы_в_interkassa]&lt;/b&gt;&quot;,&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-family: &amp;quot;courier new&amp;quot; , &amp;quot;courier&amp;quot; , monospace; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &quot;sign&quot;: &quot;&lt;b&gt;[секретный_ключ_для_формирования_подписи]&lt;/b&gt;&quot;,&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-family: &amp;quot;courier new&amp;quot; , &amp;quot;courier&amp;quot; , monospace; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &quot;sign_test&quot;: &quot;&lt;b&gt;[секретный_ключ_для_проверки_подписи_(тест)]&lt;/b&gt;&quot;,&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-family: &amp;quot;courier new&amp;quot; , &amp;quot;courier&amp;quot; , monospace; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &quot;type&quot;: &quot;interkassa&quot;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-family: &amp;quot;courier new&amp;quot; , &amp;quot;courier&amp;quot; , monospace; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; },&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-family: &amp;quot;courier new&amp;quot; , &amp;quot;courier&amp;quot; , monospace; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &quot;admin_username&quot;: &quot;&lt;b&gt;[логин_администратора]&lt;/b&gt;&quot;,&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-family: &amp;quot;courier new&amp;quot; , &amp;quot;courier&amp;quot; , monospace; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &quot;admin_password&quot;: &quot;&lt;b&gt;[пароль_администратора]&lt;/b&gt;&quot;,&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-family: &amp;quot;courier new&amp;quot; , &amp;quot;courier&amp;quot; , monospace; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &quot;cookie_name&quot;: &quot;minecraft_cookie&quot;,&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-family: &amp;quot;courier new&amp;quot; , &amp;quot;courier&amp;quot; , monospace; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &quot;cookie_sign&quot;: &quot;minecraft_secret&quot;,&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-family: &amp;quot;courier new&amp;quot; , &amp;quot;courier&amp;quot; , monospace; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &quot;server_host&quot;: &quot;&lt;b&gt;[адрес_к_серверу_minecraft]&lt;/b&gt;&quot;,&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-family: &amp;quot;courier new&amp;quot; , &amp;quot;courier&amp;quot; , monospace; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &quot;server_query_port&quot;: 25565,&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-family: &amp;quot;courier new&amp;quot; , &amp;quot;courier&amp;quot; , monospace; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &quot;server_rcon_password&quot;: &quot;&lt;b&gt;[пароль_к_rcon]&lt;/b&gt;&quot;,&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-family: &amp;quot;courier new&amp;quot; , &amp;quot;courier&amp;quot; , monospace; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &quot;server_rcon_port&quot;: 25575,&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-family: &amp;quot;courier new&amp;quot; , &amp;quot;courier&amp;quot; , monospace; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &quot;server_url&quot;: &quot;&lt;b&gt;https://test.kalinchyk.com/&lt;/b&gt;&quot;,&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-family: &amp;quot;courier new&amp;quot; , &amp;quot;courier&amp;quot; , monospace; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &quot;server_api&quot;: &quot;&lt;b&gt;https://test.kalinchyk.com/&lt;/b&gt;&quot;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-family: &amp;quot;courier new&amp;quot; , &amp;quot;courier&amp;quot; , monospace; font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; }&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-family: &amp;quot;courier new&amp;quot; , &amp;quot;courier&amp;quot; , monospace; font-size: x-small;&quot;&gt;}&lt;/span&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
Жирным выделены параметры, которые необходимо заполнить в первую очередь.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;h3 style=&quot;text-align: left;&quot;&gt;
FrontEnd&lt;/h3&gt;
&lt;div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
Теперь можно приступить к установке веб-интерфейса магазина. Из ранее извлеченного архива, который был получен на &lt;a href=&quot;https://gitlab.com/kalinchyk/shop-mc/repository/archive.zip?ref=master&quot; target=&quot;_blank&quot;&gt;сайте&lt;/a&gt;,&amp;nbsp;содержимое minecraft копируем в нашу minecraft директорию (в моем случае это /var/www/minecraft/).&lt;/div&gt;
&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;h3 style=&quot;text-align: left;&quot;&gt;
Настраиваем frontend&lt;/h3&gt;
В директории /var/www/minecraft/ создаем файл .htaccess&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;font-family: &amp;quot;courier new&amp;quot; , &amp;quot;courier&amp;quot; , monospace; font-size: x-small;&quot;&gt;Options -Indexes +FollowSymLinks&lt;br /&gt;RewriteEngine on&lt;br /&gt;RewriteCond %{REQUEST_FILENAME} !-f&lt;br /&gt;RewriteCond %{REQUEST_FILENAME} !-d&lt;br /&gt;RewriteRule .* /var/www/minecraft/index.html [L]&lt;br /&gt;DirectoryIndex index.html&lt;/span&gt;&lt;br /&gt;
&lt;div&gt;
&lt;span style=&quot;font-family: &amp;quot;courier new&amp;quot; , &amp;quot;courier&amp;quot; , monospace; font-size: x-small;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;br /&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
Здесь мы включаем модуль rewrite и перенаправляем все запросы на несуществующие файлы/директории будут перенаправлены на index.html&lt;/div&gt;
&lt;br /&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://blog.kalinchyk.com/feeds/404686272408889123/comments/default' title='Комментарии к сообщению'/><link rel='replies' type='text/html' href='http://blog.kalinchyk.com/2017/02/minecraft.html#comment-form' title='Комментарии: 0'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8657487033851500757/posts/default/404686272408889123'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8657487033851500757/posts/default/404686272408889123'/><link rel='alternate' type='text/html' href='http://blog.kalinchyk.com/2017/02/minecraft.html' title='Магазин для своего сервера Minecraft.'/><author><name>Unknown</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8657487033851500757.post-7034268907507282028</id><published>2015-10-05T00:00:00.000+03:00</published><updated>2015-10-05T21:08:56.346+03:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="oracle"/><category scheme="http://www.blogger.com/atom/ns#" term="password"/><category scheme="http://www.blogger.com/atom/ns#" term="SOA"/><category scheme="http://www.blogger.com/atom/ns#" term="weblogic"/><title type='text'>WebLogic Server. Encrypt &amp; Decrypt password.</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
На днях возникла задача хранения некоторой части данных в базе данных. Из темы ясно, что данные должны быть зашифрованы. Чтобы не изобретать велосипед, первым делом отправился в www.google.com с вопросом как же шифруются пароли weblogic&#39;а.&lt;br /&gt;
&lt;br /&gt;
В результате получился маленький класс для шифровки и расшифровки паролей по аналогии как это делает weblogic server.&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;font-size: x-small;&quot;&gt;
&lt;pre class=&quot;brush: java&quot;&gt;package com.kalinchyk.util;

import weblogic.security.internal.SerializedSystemIni;
import weblogic.security.internal.encryption.*;

public final class WebLogicSecure {
    
    private static EncryptionService es = null;
    private static ClearOrEncryptedService ces = null;

    public static String decrypt(String pwd) throws Exception {
        es = SerializedSystemIni.getExistingEncryptionService();
        if (es == null)
            throw new Exception(&quot;Unable to initialize decryption service&quot;);
        ces = new ClearOrEncryptedService(es);
        return ces.decrypt(pwd);
    }    

    public static String encrypt(String pwd) throws Exception {
        es = SerializedSystemIni.getExistingEncryptionService();
        if (es == null)
            throw new Exception(&quot;Unable to initialize encryption service&quot;);
        ces = new ClearOrEncryptedService(es);
        return ces.encrypt(pwd);
    }
}
&lt;/pre&gt;
&lt;/div&gt;
&lt;br /&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
Но необходимо учесть, что данные зашифрованные на одном сервере не могут быть расшифрованы на другом, т.к. мы используем ключ самого wls, который формируется (генерируется) в момент установки и будет уникальным для всех серверов.&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
Для тестирования на локальной машине можно использовать файл SerializedSystemIni.dat из IntegratedWebLogicServer, который необходимо сохранить в директорию с вашим проектом.&lt;/div&gt;
&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://blog.kalinchyk.com/feeds/7034268907507282028/comments/default' title='Комментарии к сообщению'/><link rel='replies' type='text/html' href='http://blog.kalinchyk.com/2015/10/weblogic-server-encrypt-decrypt-password.html#comment-form' title='Комментарии: 0'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8657487033851500757/posts/default/7034268907507282028'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8657487033851500757/posts/default/7034268907507282028'/><link rel='alternate' type='text/html' href='http://blog.kalinchyk.com/2015/10/weblogic-server-encrypt-decrypt-password.html' title='WebLogic Server. Encrypt &amp; Decrypt password.'/><author><name>Unknown</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8657487033851500757.post-8767740893828253732</id><published>2015-04-27T00:00:00.000+03:00</published><updated>2015-04-27T22:44:46.703+03:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="2015"/><category scheme="http://www.blogger.com/atom/ns#" term="fwdays"/><category scheme="http://www.blogger.com/atom/ns#" term="javascript"/><title type='text'>JavaScript Frameworks Day 2015</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
На прошедших выходных (26 апреля 2015 года) прошел очередной ивент от frameworksdays по тематике JavaScript. Как обычно было очень много интересных докладов, конкурсов, подарков!&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
Спасибо организаторам за яркое воскресенье.&amp;nbsp;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
Есть желание посетить следующие ивенты?&amp;nbsp;&lt;a href=&quot;http://frameworksdays.com/event/js-frameworks-day-2015?ref=cd4af8ed4018f906d22c7249097e7443&quot; target=&quot;_blank&quot;&gt;Регистрируйтесь&lt;/a&gt;&amp;nbsp;и приходите.&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://blog.kalinchyk.com/feeds/8767740893828253732/comments/default' title='Комментарии к сообщению'/><link rel='replies' type='text/html' href='http://blog.kalinchyk.com/2015/04/javascript-frameworks-day-2015.html#comment-form' title='Комментарии: 0'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8657487033851500757/posts/default/8767740893828253732'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8657487033851500757/posts/default/8767740893828253732'/><link rel='alternate' type='text/html' href='http://blog.kalinchyk.com/2015/04/javascript-frameworks-day-2015.html' title='JavaScript Frameworks Day 2015'/><author><name>Unknown</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8657487033851500757.post-5226588999339391685</id><published>2015-04-22T00:00:00.000+03:00</published><updated>2015-04-22T12:37:33.770+03:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="cyrillic"/><category scheme="http://www.blogger.com/atom/ns#" term="oracle"/><category scheme="http://www.blogger.com/atom/ns#" term="plsql"/><category scheme="http://www.blogger.com/atom/ns#" term="translit"/><title type='text'>PL/SQL. Транслитерация украинского языка</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
Моя функция для транслитерации украинского языка в pl/sql.&lt;br /&gt;
Правила описаны в законе Украины: &lt;br /&gt;
&lt;a href=&quot;http://zakon4.rada.gov.ua/laws/show/55-2010-%D0%BF&quot;&gt;http://zakon4.rada.gov.ua/laws/show/55-2010-п&lt;/a&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;a name=&#39;more&#39;&gt;&lt;/a&gt;
&lt;br /&gt;
&lt;pre&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;create or replace function fn_embossing_name(p_name varchar2) return varchar2
/* http://zakon4.rada.gov.ua/laws/show/55-2010-п

                               ТАБЛИЦЯ 
            транслітерації українського алфавіту латиницею 
   

  ------------------------------------------------------------------
  | Український | Латиниця |  Позиція у |    Приклади написання    |
  |   алфавіт   |          |   слові    |--------------------------|
  |             |          |            |українською |  латиницею  |
  |             |          |            |    мовою   |             |
  |-------------+----------+------------+------------+-------------|
  |      Аa     |    Aа    |            |Алушта      |Alushta      |
  |             |          |            |Андрій      |Andrii       |
  |-------------+----------+------------+------------+-------------|
  |      Бб     |    Bb    |            |Борщагівка  |Borshchahivka|
  |             |          |            |Борисенко   |Borysenko    |
  |-------------+----------+------------+------------+-------------|
  |      Вв     |    Vv    |            |Вінниця     |Vinnytsia    |
  |             |          |            |Володимир   |Volodymyr    |
  |-------------+----------+------------+------------+-------------|
  |      Гг     |    Hh    |            |Гадяч       |Hadiach      |
  |             |          |            |Богдан      |Bohdan       |
  |             |          |            |Згурський   |Zghurskyi    |
  |-------------+----------+------------+------------+-------------|
  |      Ґґ     |    Gg    |            |Ґалаґан     |Galagan      |
  |             |          |            |Ґорґани     |Gorgany      |
  |-------------+----------+------------+------------+-------------|
  |      Дд     |    Dd    |            |Донецьк     |Donetsk      |
  |             |          |            |Дмитро      |Dmytro       |
  |-------------+----------+------------+------------+-------------|
  |      Ее     |    Ee    |            |Рівне       |Rivne        |
  |             |          |            |Олег        |Oleh         |
  |             |          |            |Есмань      |Esman        |
  |-------------+----------+------------+------------+-------------|
  |      Єє     |    Ye    | на початку |Єнакієве    |Yenakiieve   |
  |             |          |    слова   |Гаєвич      |Haievych     |
  |             |    ie    |  в інших   |Короп&#39;є     |Koropie      |
  |             |          |  позиціях  |            |             |
  |-------------+----------+------------+------------+-------------|
  |      Жж     |  Zh zh   |            |Житомир     |Zhytomyr     |
  |             |          |            |Жанна       |Zhanna       |
  |             |          |            |Жежелів     |Zhezheliv    |
  |-------------+----------+------------+------------+-------------|
  |      Зз     |    Zz    |            |Закарпаття  |Zakarpattia  |
  |             |          |            |Казимирчук  |Kazymyrchuk  |
  |-------------+----------+------------+------------+-------------|
  |      Ии     |    Yy    |            |Медвин      |Medvyn       |
  |             |          |            |Михайленко  |Mykhailenko  |
  |-------------+----------+------------+------------+-------------|
  |      Іі     |    Ii    |            |Іванків     |Ivankiv      |
  |             |          |            |Іващенко    |Ivashchenko  |
  |-------------+----------+------------+------------+-------------|
  |      Її     |    Yi    | на початку |Їжакевич    |Yizhakevych  |
  |             |          |    слова   |Кадиївка    |Kadyivka     |
  |             |     i    |  в інших   |Мар&#39;їне     |Marine       |
  |             |          |  позиціях  |            |             |
  |-------------+----------+------------+------------+-------------|
  |      Йй     |    Y     | на початку |Йосипівка   |Yosypivka    |
  |             |          |    слова   |Стрий       |Stryi        |
  |             |    i     |  в інших   |Олексій     |Oleksii      |
  |             |          |  позиціях  |            |             |
  |-------------+----------+------------+------------+-------------|
  |      Кк     |    Kk    |            |Київ        |Kyiv         |
  |             |          |            |Коваленко   |Kovalenko    |
  |-------------+----------+------------+------------+-------------|
  |      Лл     |    Ll    |            |Лебедин     |Lebedyn      |
  |             |          |            |Леонід      |Leonid       |
  |-------------+----------+------------+------------+-------------|
  |      Мм     |    Mm    |            |Миколаїв    |Mykolaiv     |
  |             |          |            |Маринич     |Marynych     |
  |-------------+----------+------------+------------+-------------|
  |      Нн     |    Nn    |            |Ніжин       |Nizhyn       |
  |             |          |            |Наталія     |Nataliia     |
  |-------------+----------+------------+------------+-------------|
  |      Оо     |    Oo    |            |Одеса       |Odesa        |
  |             |          |            |Онищенко    |Onyshchenko  |
  |-------------+----------+------------+------------+-------------|
  |      Пп     |    Pp    |            |Полтава     |Poltava      |
  |             |          |            |Петро       |Petro        |
  |-------------+----------+------------+------------+-------------|
  |      Рр     |    Rr    |            |Решетилівка |Reshetylivka |
  |             |          |            |Рибчинський |Rybchynskyi  |
  |-------------+----------+------------+------------+-------------|
  |      Сс     |    Ss    |            |Суми        |Sumy         |
  |             |          |            |Соломія     |Solomiia     |
  |-------------+----------+------------+------------+-------------|
  |      Тт     |    Tt    |            |Тернопіль   |Ternopil     |
  |             |          |            |Троць       |Trots        |
  |-------------+----------+------------+------------+-------------|
  |      Уу     |    Uu    |            |Ужгород     |Uzhhorod     |
  |             |          |            |Уляна       |Uliana       |
  |-------------+----------+------------+------------+-------------|
  |      Фф     |    Ff    |            |Фастів      |Fastiv       |
  |             |          |            |Філіпчук    |Filipchuk    |
  |-------------+----------+------------+------------+-------------|
  |      Хх     |  Kh kh   |            |Харків      |Kharkiv      |
  |             |          |            |Христина    |Khrystyna    |
  |-------------+----------+------------+------------+-------------|
  |      Цц     |  Ts ts   |            |Біла Церква |Bila Tserkva |
  |             |          |            |Стеценко    |Stetsenko    |
  |-------------+----------+------------+------------+-------------|
  |      Чч     |  Ch ch   |            |Чернівці    |Chernivtsi   |
  |             |          |            |Шевченко    |Shevchenko   |
  |-------------+----------+------------+------------+-------------|
  |      Шш     |  Sh sh   |            |Шостка      |Shostka      |
  |             |          |            |Кишеньки    |Kyshenky     |
  |-------------+----------+------------+------------+-------------|
  |      Щщ     |Shch shch |            |Щербухи     |Shcherbukhy  |
  |             |          |            |Гоща        |Hoshcha      |
  |             |          |            |Гаращенко   |Harashchenko |
  |-------------+----------+------------+------------+-------------|
  |      Юю     |    Yu    | на початку |Юрій        |Yurii        |
  |             |          |    слова   |Корюківка   |Koriukivka   |
  |             |    iu    |  в інших   |            |             |
  |             |          |  позиціях  |            |             |
  |-------------+----------+------------+------------+-------------|
  |      Яя     |    Ya    | на початку |Яготин      |Yahotyn      |
  |             |          |    слова   |Ярошенко    |Yaroshenko   |
  |             |    ia    |  в інших   |Костянтин   |Kostiantyn   |
  |             |          |  позиціях  |Знам&#39;янка   |Znamianka    |
  |             |          |            |Феодосія    |Feodosiia    |
  ------------------------------------------------------------------ 

  _______________ 
  Примітка: 1. Буквосполучення &quot;зг&quot; відтворюється латиницею як &quot;zgh&quot; 
               (наприклад,  Згорани - Zghorany, Розгон - Rozghon) на 
               відміну від &quot;zh&quot; -  відповідника  української  літери 
               &quot;ж&quot;. 

            2. М&#39;який знак і апостроф латиницею не відтворюються. 

            3. Транслітерація  прізвищ  та  імен осіб і географічних 
               назв здійснюється шляхом  відтворення  кожної  літери 
               латиницею. 

Проверка преобразований по списку из &quot;постановы&quot;:
with name_test as ( select &#39;Алушта&#39; name_1, &#39;Alushta&#39; name_2 from dual union all
                    select &#39;Андрій&#39;, &#39;Andrii&#39; from dual union all
                    select &#39;Борщагівка&#39;, &#39;Borshchahivka&#39; from dual union all
                    select &#39;Борисенко&#39;, &#39;Borysenko&#39; from dual union all
                    select &#39;Вінниця&#39;, &#39;Vinnytsia&#39; from dual union all
                    select &#39;Володимир&#39;, &#39;Volodymyr&#39; from dual union all
                    select &#39;Гадяч&#39;, &#39;Hadiach&#39; from dual union all
                    select &#39;Богдан&#39;, &#39;Bohdan&#39; from dual union all
                    select &#39;Згурський&#39;, &#39;Zghurskyi&#39; from dual union all
                    select &#39;Ґалаґан&#39;, &#39;Galagan&#39; from dual union all
                    select &#39;Ґорґани&#39;, &#39;Gorgany&#39; from dual union all
                    select &#39;Донецьк&#39;, &#39;Donetsk&#39; from dual union all
                    select &#39;Дмитро&#39;, &#39;Dmytro&#39; from dual union all
                    select &#39;Рівне&#39;, &#39;Rivne&#39; from dual union all
                    select &#39;Олег&#39;, &#39;Oleh&#39; from dual union all
                    select &#39;Есмань&#39;, &#39;Esman&#39; from dual union all
                    select &#39;Єнакієве&#39;, &#39;Yenakiieve&#39; from dual union all
                    select &#39;Гаєвич&#39;, &#39;Haievych&#39; from dual union all
                    select &#39;Короп&#39;&#39;є&#39;, &#39;Koropie&#39; from dual union all
                    select &#39;Житомир&#39;, &#39;Zhytomyr&#39; from dual union all
                    select &#39;Жанна&#39;, &#39;Zhanna&#39; from dual union all
                    select &#39;Жежелів&#39;, &#39;Zhezheliv&#39; from dual union all
                    select &#39;Закарпаття&#39;, &#39;Zakarpattia&#39; from dual union all
                    select &#39;Казимирчук&#39;, &#39;Kazymyrchuk&#39; from dual union all
                    select &#39;Медвин&#39;, &#39;Medvyn&#39; from dual union all
                    select &#39;Михайленко&#39;, &#39;Mykhailenko&#39; from dual union all
                    select &#39;Іванків&#39;, &#39;Ivankiv&#39; from dual union all
                    select &#39;Іващенко&#39;, &#39;Ivashchenko&#39; from dual union all
                    select &#39;Їжакевич&#39;, &#39;Yizhakevych&#39; from dual union all
                    select &#39;Кадиївка&#39;, &#39;Kadyivka&#39; from dual union all
                    select &#39;Мар&#39;&#39;їне&#39;, &#39;Marine&#39; from dual union all
                    select &#39;Йосипівка&#39;, &#39;Yosypivka&#39; from dual union all
                    select &#39;Стрий&#39;, &#39;Stryi&#39; from dual union all
                    select &#39;Олексій&#39;, &#39;Oleksii&#39; from dual union all
                    select &#39;Київ&#39;, &#39;Kyiv&#39; from dual union all
                    select &#39;Коваленко&#39;, &#39;Kovalenko&#39; from dual union all
                    select &#39;Лебедин&#39;, &#39;Lebedyn&#39; from dual union all
                    select &#39;Леонід&#39;, &#39;Leonid&#39; from dual union all
                    select &#39;Миколаїв&#39;, &#39;Mykolaiv&#39; from dual union all
                    select &#39;Маринич&#39;, &#39;Marynych&#39; from dual union all
                    select &#39;Ніжин&#39;, &#39;Nizhyn&#39; from dual union all
                    select &#39;Наталія&#39;, &#39;Nataliia&#39; from dual union all
                    select &#39;Одеса&#39;, &#39;Odesa&#39; from dual union all
                    select &#39;Онищенко&#39;, &#39;Onyshchenko&#39; from dual union all
                    select &#39;Полтава&#39;, &#39;Poltava&#39; from dual union all
                    select &#39;Петро&#39;, &#39;Petro&#39; from dual union all
                    select &#39;Решетилівка&#39;, &#39;Reshetylivka&#39; from dual union all
                    select &#39;Рибчинський&#39;, &#39;Rybchynskyi&#39; from dual union all
                    select &#39;Суми&#39;, &#39;Sumy&#39; from dual union all
                    select &#39;Соломія&#39;, &#39;Solomiia&#39; from dual union all
                    select &#39;Тернопіль&#39;, &#39;Ternopil&#39; from dual union all
                    select &#39;Троць&#39;, &#39;Trots&#39; from dual union all
                    select &#39;Ужгород&#39;, &#39;Uzhhorod&#39; from dual union all
                    select &#39;Уляна&#39;, &#39;Uliana&#39; from dual union all
                    select &#39;Фастів&#39;, &#39;Fastiv&#39; from dual union all
                    select &#39;Філіпчук&#39;, &#39;Filipchuk&#39; from dual union all
                    select &#39;Харків&#39;, &#39;Kharkiv&#39; from dual union all
                    select &#39;Христина&#39;, &#39;Khrystyna&#39; from dual union all
                    select &#39;Біла Церква&#39;, &#39;Bila Tserkva&#39; from dual union all
                    select &#39;Стеценко&#39;, &#39;Stetsenko&#39; from dual union all
                    select &#39;Чернівці&#39;, &#39;Chernivtsi&#39; from dual union all
                    select &#39;Шевченко&#39;, &#39;Shevchenko&#39; from dual union all
                    select &#39;Шостка&#39;, &#39;Shostka&#39; from dual union all
                    select &#39;Кишеньки&#39;, &#39;Kyshenky&#39; from dual union all
                    select &#39;Щербухи&#39;, &#39;Shcherbukhy&#39; from dual union all
                    select &#39;Гоща&#39;, &#39;Hoshcha&#39; from dual union all
                    select &#39;Гаращенко&#39;, &#39;Harashchenko&#39; from dual union all
                    select &#39;Юрій&#39;, &#39;Yurii&#39; from dual union all
                    select &#39;Корюківка&#39;, &#39;Koriukivka&#39; from dual union all
                    select &#39;Яготин&#39;, &#39;Yahotyn&#39; from dual union all
                    select &#39;Ярошенко&#39;, &#39;Yaroshenko&#39; from dual union all
                    select &#39;Костянтин&#39;, &#39;Kostiantyn&#39; from dual union all
                    select &#39;Знам&#39;&#39;янка&#39;, &#39;Znamianka&#39; from dual union all
                    select &#39;Феодосія&#39;, &#39;Feodosiia&#39; from dual union all
                    select &#39;Згорани&#39;, &#39;Zghorany&#39; from dual union all
                    select &#39;Розгон&#39;, &#39;Rozghon&#39; from dual )
select case fn_embossing_name(name_1) 
         when name_2 
         then &#39;TRUE&#39; 
         else &#39;FALSE&#39; 
       end status
     , name_1
     , name_2 
  from name_test
*/
is
  m_name varchar2(255);
  m_ukr varchar2(100) := q&#39;[АаБбВвГгҐґДдЕеЗзИиІіЙйКкЛлМмНнОоПпРрСсТтУуФфїCc -]&#39;;
  m_lat varchar2(100) := q&#39;[AaBbVvHhGgDdEeZzYyIiYiKkLlMmNnOoPpRrSsTtUuFfiCc -]&#39;;
  m_itm number;
  m_sym varchar2(1);
  m_res varchar2(255);
  m_pos number;
begin
  m_name := lower(p_name);
  m_name := replace(m_name, &#39;`&#39;, &#39;&#39;);
  m_name := replace(m_name, &#39;ь&#39;, &#39;&#39;);
  m_name := replace(m_name, &#39;&#39;&#39;&#39;, &#39;&#39;);
  m_name := replace(m_name, &#39;зг&#39;, &#39;зґг&#39;);
  m_name := replace(m_name, &#39;я&#39;, &#39;йа&#39;);
  m_name := replace(m_name, &#39;є&#39;, &#39;йе&#39;);
  m_name := replace(m_name, &#39;ю&#39;, &#39;йу&#39;);
  m_name := replace(m_name, &#39;ж&#39;, &#39;зг&#39;);
  m_name := replace(m_name, &#39;х&#39;, &#39;кг&#39;);
  m_name := replace(m_name, &#39;ц&#39;, &#39;тс&#39;);
  m_name := replace(m_name, &#39;щ&#39;, &#39;шч&#39;);
  m_name := replace(m_name, &#39;ч&#39;, &#39;cг&#39;);
  m_name := replace(m_name, &#39;ш&#39;, &#39;сг&#39;);
  m_name := initcap(m_name);
  m_name := replace(m_name, &#39;Ї&#39;, &#39;Иі&#39;);
  for m_itm in 1..length(m_name) loop
    m_sym := substr(m_name, m_itm, 1);
    m_pos := instr(m_ukr, m_sym);
    if m_pos &amp;gt; 0 then
      m_res := m_res || substr(m_lat, m_pos, 1);
    else
      m_res := m_res || &#39;?&#39;;
    end if;
    dbms_output.put_line(instr(m_ukr, m_sym));
  end loop;
  return m_res;
end;
&lt;/span&gt;&lt;/pre&gt;
&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://blog.kalinchyk.com/feeds/5226588999339391685/comments/default' title='Комментарии к сообщению'/><link rel='replies' type='text/html' href='http://blog.kalinchyk.com/2015/04/plsql.html#comment-form' title='Комментарии: 1'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8657487033851500757/posts/default/5226588999339391685'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8657487033851500757/posts/default/5226588999339391685'/><link rel='alternate' type='text/html' href='http://blog.kalinchyk.com/2015/04/plsql.html' title='PL/SQL. Транслитерация украинского языка'/><author><name>Unknown</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8657487033851500757.post-203354658960130122</id><published>2015-03-20T00:00:00.000+02:00</published><updated>2015-03-22T10:31:45.561+02:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="bi publisher"/><category scheme="http://www.blogger.com/atom/ns#" term="bip"/><category scheme="http://www.blogger.com/atom/ns#" term="cyrillic"/><category scheme="http://www.blogger.com/atom/ns#" term="oracle"/><title type='text'>Отчеты BI Publisher и шрифт Times New Roman (кириллица)</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
Столкнулся с необходимостью формировать отчеты в старой версии Oracle BI Publisher Enterprise (10.1.3.4.1) и сразу возникла сложность со шрифтам. Причем проблема возникала только при формировании отчета в формате pdf. Вместо правильных шрифтов статически указывался Alban WT J и вся кириллица смотрелась ужасно, стили не соответствовали шаблону - небыло выделения жирным и остальные странные артефакты.&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;b&gt;Решение:&lt;/b&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
Первым делом скопировать необходимые шрифты из windows (c:\windows\fonts\), например, Times New Roman, Arial и т.д. в директорию jre/lib/fonts (тут необходимо четко понимать, какой из jre использует ваш BIP, так например на нашей тестовой среде используется не родной).&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
Следующим шагом прописать группу шрифтов в конфигурационный файл (xdo.cfg). В зависимости от задачи - это может быть глобальный файл (расположен %BIP%/xmlp/XMLP/Admin/Configuration) или локальный для определенного отчета. Мой конфиг выглядит теперь так:&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;span style=&quot;font-size: x-small;&quot;&gt;
&lt;pre class=&quot;brush: xml&quot;&gt;&amp;lt;config version=&quot;1.0.0&quot; xmlns=&quot;http://xmlns.oracle.com/oxp/config/&quot;&amp;gt;

&amp;nbsp;&amp;nbsp; &amp;lt;properties&amp;gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;property name=&quot;pdf-compression&quot;&amp;gt;true&amp;lt;/property&amp;gt;
&amp;nbsp;&amp;nbsp; &amp;lt;/properties&amp;gt;
&amp;nbsp;&amp;nbsp; &amp;lt;fonts&amp;gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;font family=&quot;Arial&quot; style=&quot;normal&quot; weight=&quot;normal&quot;&amp;gt; 
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;truetype path=&quot;/arial.ttf&quot; /&amp;gt; 
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/font&amp;gt; 
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;font family=&quot;Arial&quot; style=&quot;italic&quot; weight=&quot;normal&quot;&amp;gt; 
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;truetype path=&quot;/ariali.ttf&quot; /&amp;gt; 
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/font&amp;gt; 
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;font family=&quot;Arial&quot; style=&quot;normal&quot; weight=&quot;bold&quot;&amp;gt; 
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;truetype path=&quot;/arialbd.ttf&quot; /&amp;gt; 
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/font&amp;gt; 
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;font family=&quot;Arial&quot; style=&quot;italic&quot; weight=&quot;bold&quot;&amp;gt; 
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;truetype path=&quot;/arialbi.ttf&quot; /&amp;gt; 
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/font&amp;gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; 

&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;font family=&quot;Times New Roman&quot; style=&quot;normal&quot; weight=&quot;normal&quot;&amp;gt; 
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;truetype path=&quot;/times.ttf&quot; /&amp;gt; 
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/font&amp;gt; 
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;font family=&quot;Times New Roman&quot; style=&quot;italic&quot; weight=&quot;normal&quot;&amp;gt; 
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;truetype path=&quot;/timesi.ttf&quot; /&amp;gt; 
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/font&amp;gt; 
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;font family=&quot;Times New Roman&quot; style=&quot;normal&quot; weight=&quot;bold&quot;&amp;gt; 
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;truetype path=&quot;/timesbd.ttf&quot; /&amp;gt; 
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/font&amp;gt; 
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;font family=&quot;Times New Roman&quot; style=&quot;italic&quot; weight=&quot;bold&quot;&amp;gt; 
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;truetype path=&quot;/timesbi.ttf&quot; /&amp;gt; 
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/font&amp;gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; 

&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;font family=&quot;Default&quot; style=&quot;normal&quot; weight=&quot;normal&quot;&amp;gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;truetype path=&quot;/times.ttf&quot; /&amp;gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/font&amp;gt;

&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;!--Font substitute setting (for PDFForm filling etc...) --&amp;gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;font-substitute name=&quot;MSGothic&quot;&amp;gt; 
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;truetype path=&quot;/msgothic.ttc&quot; ttcno=&quot;0&quot; /&amp;gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/font-substitute&amp;gt;&amp;nbsp; 
&amp;nbsp;&amp;nbsp; &amp;lt;/fonts&amp;gt;
&amp;lt;/config&amp;gt;&lt;/pre&gt;&lt;/span&gt;
&lt;/div&gt;
&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://blog.kalinchyk.com/feeds/203354658960130122/comments/default' title='Комментарии к сообщению'/><link rel='replies' type='text/html' href='http://blog.kalinchyk.com/2015/03/bi-publisher-times-new-roman.html#comment-form' title='Комментарии: 1'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8657487033851500757/posts/default/203354658960130122'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8657487033851500757/posts/default/203354658960130122'/><link rel='alternate' type='text/html' href='http://blog.kalinchyk.com/2015/03/bi-publisher-times-new-roman.html' title='Отчеты BI Publisher и шрифт Times New Roman (кириллица)'/><author><name>Unknown</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8657487033851500757.post-1262311646739325270</id><published>2015-03-11T00:00:00.000+02:00</published><updated>2015-03-11T00:00:05.819+02:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="a2048"/><category scheme="http://www.blogger.com/atom/ns#" term="codenjoy"/><category scheme="http://www.blogger.com/atom/ns#" term="python"/><category scheme="http://www.blogger.com/atom/ns#" term="websockets"/><category scheme="http://www.blogger.com/atom/ns#" term="алгоритм"/><category scheme="http://www.blogger.com/atom/ns#" term="бот"/><category scheme="http://www.blogger.com/atom/ns#" term="игра"/><title type='text'>CodenJoy. 2048</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
&lt;br /&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
В предыдущем посте я написал о посещении frameworksdays, на котором нас познакомили с проектом &lt;a href=&quot;http://www.codenjoy.com/&quot; target=&quot;_blank&quot;&gt;codenjoy&lt;/a&gt;. Очередные головоломки для разработчиков. В перечне задачек была предложена игра 2048 - суть задания написать алгоритм (бота), позволяющий набрать максимальное количество баллов из всех зарегистрированных участников.&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
Взаимодействие с сервером осуществляется посредством websoсket&#39;ов. Значит нет привязки к языку программирования - что не может не радовать.&amp;nbsp;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
Установил себе модуль https://pypi.python.org/pypi/websocket-client для работы с вебсокетами через python и начеркал примитивный алгоритм, который может прийти в голову - постоянно жмем кнопку вниз, когда строка (двумерный массив разложенный в строку) не изменилась от предыдущего действия, то нажимаем влево. В результате имеем следующий код:&lt;/div&gt;
&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;
&lt;pre class=&quot;brush: python&quot;&gt;import websocket

def on_message(ws, message):
    ws.send(&quot;LEFT&quot; if message == ws.last_message else &quot;DOWN&quot;)
    ws.last_message = message

if __name__ == &quot;__main__&quot;:
    ws = websocket.WebSocketApp( &quot;ws://tetrisj.jvmhost.net:12270/codenjoy-contest/ws?user=[user]&quot;
                               , on_message = on_message)
    ws.last_message = &quot;&quot;
    ws.run_forever()
&lt;/pre&gt;&lt;/span&gt;
&lt;br /&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;br /&gt;
Такой бот смог набрать&amp;nbsp;7938 и занять 3е место в рейтинге, к заметке - второе место имеет такое же количество баллов.&lt;/div&gt;
&lt;br /&gt;
Для сброса текущего счета (перерегистрация) клиента:&lt;br /&gt;
&lt;span style=&quot;font-size: x-small;&quot;&gt;curl http://codenjoy.com/codenjoy-contest/register -d &quot;name=[user]&amp;amp;password=[pass]&amp;amp;gameName=a2048&quot;&lt;/span&gt;&lt;br /&gt;
&lt;div&gt;
&lt;br /&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
Если будет возможность написать обновленного бота, который выйдет на первую строчку рейтинга, то обязательно выложу исходный код. И напоследок - советую всем попробовать свои силы в написании алгоритмов для подобных задачек.&lt;/div&gt;
&lt;span style=&quot;text-align: justify;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;
&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://blog.kalinchyk.com/feeds/1262311646739325270/comments/default' title='Комментарии к сообщению'/><link rel='replies' type='text/html' href='http://blog.kalinchyk.com/2015/03/codenjoy-2048.html#comment-form' title='Комментарии: 1'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8657487033851500757/posts/default/1262311646739325270'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8657487033851500757/posts/default/1262311646739325270'/><link rel='alternate' type='text/html' href='http://blog.kalinchyk.com/2015/03/codenjoy-2048.html' title='CodenJoy. 2048'/><author><name>Unknown</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8657487033851500757.post-1357229952124651033</id><published>2015-03-10T00:00:00.000+02:00</published><updated>2015-04-27T22:45:40.607+03:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="events"/><category scheme="http://www.blogger.com/atom/ns#" term="frameworksdays"/><category scheme="http://www.blogger.com/atom/ns#" term="fwdays"/><category scheme="http://www.blogger.com/atom/ns#" term="java"/><title type='text'>Java Frameworks Day 2015</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
7 марта посетил великолепный ивент &lt;a href=&quot;http://www.frameworksdays.com/&quot; target=&quot;_blank&quot;&gt;frameworksdays&lt;/a&gt; с тематиками для java разработчиков, хоть java не моя стихия, но было очень захватывающе. Спасибо большое организаторам за проведенное мероприятие и докладчикам за интересные презентации.&lt;/div&gt;
&lt;br /&gt;&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://blog.kalinchyk.com/feeds/1357229952124651033/comments/default' title='Комментарии к сообщению'/><link rel='replies' type='text/html' href='http://blog.kalinchyk.com/2015/03/java-frameworkdays-2015.html#comment-form' title='Комментарии: 0'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8657487033851500757/posts/default/1357229952124651033'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8657487033851500757/posts/default/1357229952124651033'/><link rel='alternate' type='text/html' href='http://blog.kalinchyk.com/2015/03/java-frameworkdays-2015.html' title='Java Frameworks Day 2015'/><author><name>Unknown</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8657487033851500757.post-8155219753641096579</id><published>2014-01-14T08:22:00.000+02:00</published><updated>2014-01-14T08:22:29.799+02:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="codility.com"/><category scheme="http://www.blogger.com/atom/ns#" term="lesson 5"/><category scheme="http://www.blogger.com/atom/ns#" term="python"/><category scheme="http://www.blogger.com/atom/ns#" term="train"/><category scheme="http://www.blogger.com/atom/ns#" term="very easy"/><title type='text'>Codility. Train. Brackets ★</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
&lt;div id=&quot;brinza-task-description&quot; style=&quot;font-family: Verdana, Arial; font-size: 12px;&quot;&gt;
&lt;div style=&quot;padding: 0px;&quot;&gt;
A string S consisting of N characters is considered to be&amp;nbsp;&lt;i&gt;properly nested&lt;/i&gt;&amp;nbsp;if any of the following conditions is true:&lt;/div&gt;
&lt;blockquote&gt;
&lt;ul style=&quot;list-style-type: none; margin: 10px; padding: 0px;&quot;&gt;
&lt;li style=&quot;list-style-type: disc;&quot;&gt;S is empty;&lt;/li&gt;
&lt;li style=&quot;list-style-type: disc;&quot;&gt;S has the form &quot;&lt;tt&gt;(U)&lt;/tt&gt;&quot; or &quot;&lt;tt&gt;[U]&lt;/tt&gt;&quot; or &quot;&lt;tt&gt;{U}&lt;/tt&gt;&quot; where U is a properly nested string;&lt;/li&gt;
&lt;li style=&quot;list-style-type: disc;&quot;&gt;S has the form &quot;&lt;tt&gt;VW&lt;/tt&gt;&quot; where V and W are properly nested strings.&lt;/li&gt;
&lt;/ul&gt;
&lt;/blockquote&gt;
&lt;div style=&quot;padding: 0px;&quot;&gt;
For example, the string &quot;&lt;tt&gt;{[()()]}&lt;/tt&gt;&quot; is properly nested but &quot;&lt;tt&gt;([)()]&lt;/tt&gt;&quot; is not.&lt;/div&gt;
&lt;div style=&quot;padding: 0px;&quot;&gt;
Write a function:&lt;/div&gt;
&lt;blockquote&gt;
&lt;div class=&quot;lang-c&quot; style=&quot;font-family: monospace; font-size: 9pt; padding: 0px;&quot;&gt;
&lt;tt&gt;int solution(char *S);&lt;/tt&gt;&lt;/div&gt;
&lt;/blockquote&gt;
&lt;blockquote&gt;
&lt;/blockquote&gt;
&lt;blockquote&gt;
&lt;/blockquote&gt;
&lt;blockquote&gt;
&lt;/blockquote&gt;
&lt;blockquote&gt;
&lt;/blockquote&gt;
&lt;blockquote&gt;
&lt;/blockquote&gt;
&lt;blockquote&gt;
&lt;/blockquote&gt;
&lt;blockquote&gt;
&lt;/blockquote&gt;
&lt;blockquote&gt;
&lt;/blockquote&gt;
&lt;blockquote&gt;
&lt;/blockquote&gt;
&lt;blockquote&gt;
&lt;/blockquote&gt;
&lt;blockquote&gt;
&lt;/blockquote&gt;
&lt;blockquote&gt;
&lt;/blockquote&gt;
&lt;blockquote&gt;
&lt;/blockquote&gt;
&lt;div style=&quot;padding: 0px;&quot;&gt;
that, given a string S consisting of N characters, returns 1 if S is properly nested and 0 otherwise.&lt;/div&gt;
&lt;div style=&quot;padding: 0px;&quot;&gt;
For example, given S = &quot;&lt;tt&gt;{[()()]}&lt;/tt&gt;&quot;, the function should return 1 and given S = &quot;&lt;tt&gt;([)()]&lt;/tt&gt;&quot;, the function should return 0, as explained above.&lt;/div&gt;
&lt;div style=&quot;padding: 0px;&quot;&gt;
Assume that:&lt;/div&gt;
&lt;blockquote&gt;
&lt;ul style=&quot;list-style-type: none; margin: 10px; padding: 0px;&quot;&gt;
&lt;li style=&quot;list-style-type: disc;&quot;&gt;N is an integer within the range [0..200,000];&lt;/li&gt;
&lt;li style=&quot;list-style-type: disc;&quot;&gt;string S consists only of the following characters: &quot;&lt;tt&gt;(&lt;/tt&gt;&quot;, &quot;&lt;tt&gt;{&lt;/tt&gt;&quot;, &quot;&lt;tt&gt;[&lt;/tt&gt;&quot;, &quot;&lt;tt&gt;]&lt;/tt&gt;&quot;, &quot;&lt;tt&gt;}&lt;/tt&gt;&quot; and/or &quot;&lt;tt&gt;)&lt;/tt&gt;&quot;.&lt;/li&gt;
&lt;/ul&gt;
&lt;/blockquote&gt;
&lt;div style=&quot;padding: 0px;&quot;&gt;
Complexity:&lt;/div&gt;
&lt;blockquote&gt;
&lt;ul style=&quot;list-style-type: none; margin: 10px; padding: 0px;&quot;&gt;
&lt;li style=&quot;list-style-type: disc;&quot;&gt;expected worst-case time complexity is O(N);&lt;/li&gt;
&lt;li style=&quot;list-style-type: disc;&quot;&gt;expected worst-case space complexity is O(N) (not counting the storage required for input arguments).&lt;/li&gt;
&lt;/ul&gt;
&lt;/blockquote&gt;
&lt;br /&gt;
&lt;a name=&#39;more&#39;&gt;&lt;/a&gt;&lt;br /&gt;
Solution:&lt;br /&gt;
&lt;/div&gt;
&lt;pre class=&quot;brush: python&quot;&gt;
from string import maketrans

def solution(S):
  b, t = [], maketrans(&#39;}])&#39;,&#39;{[(&#39;)
  for i in S:
    if i in &#39;{[(&#39;:
      b.append(i); continue
    if len(b) == 0 or \
      i.translate(t) != b.pop():
      return 0
  return 1 if len(b) == 0 else 0
&lt;/pre&gt;
&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://blog.kalinchyk.com/feeds/8155219753641096579/comments/default' title='Комментарии к сообщению'/><link rel='replies' type='text/html' href='http://blog.kalinchyk.com/2014/01/codility-train-brackets.html#comment-form' title='Комментарии: 1'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8657487033851500757/posts/default/8155219753641096579'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8657487033851500757/posts/default/8155219753641096579'/><link rel='alternate' type='text/html' href='http://blog.kalinchyk.com/2014/01/codility-train-brackets.html' title='Codility. Train. Brackets ★'/><author><name>Unknown</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8657487033851500757.post-78179131803679450</id><published>2014-01-13T00:00:00.002+02:00</published><updated>2014-01-13T17:47:46.157+02:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="codility.com"/><category scheme="http://www.blogger.com/atom/ns#" term="lesson 4"/><category scheme="http://www.blogger.com/atom/ns#" term="medium"/><category scheme="http://www.blogger.com/atom/ns#" term="python"/><category scheme="http://www.blogger.com/atom/ns#" term="train"/><title type='text'>Codility. Train. Number-of-disc-intersections ★★★</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
&lt;div id=&quot;brinza-task-description&quot; style=&quot;font-family: Verdana, Arial; font-size: 12px;&quot;&gt;
&lt;div style=&quot;padding: 0px;&quot;&gt;
Given an array A of N integers, we draw N discs in a 2D plane such that the I-th disc is centered on (0,I) and has a radius of A[I]. We say that the J-th disc and K-th disc intersect if J ≠ K and J-th and K-th discs have at least one common point.&lt;/div&gt;
&lt;div style=&quot;padding: 0px;&quot;&gt;
Write a function:&lt;/div&gt;
&lt;blockquote&gt;
&lt;/blockquote&gt;
&lt;blockquote&gt;
&lt;/blockquote&gt;
&lt;blockquote&gt;
&lt;/blockquote&gt;
&lt;blockquote&gt;
&lt;/blockquote&gt;
&lt;blockquote&gt;
&lt;/blockquote&gt;
&lt;blockquote&gt;
&lt;/blockquote&gt;
&lt;blockquote&gt;
&lt;/blockquote&gt;
&lt;blockquote&gt;
&lt;/blockquote&gt;
&lt;blockquote&gt;
&lt;/blockquote&gt;
&lt;blockquote&gt;
&lt;/blockquote&gt;
&lt;blockquote&gt;
&lt;div class=&quot;lang-py&quot; style=&quot;font-family: monospace; font-size: 9pt; padding: 0px;&quot;&gt;
&lt;tt&gt;def solution(A)&lt;/tt&gt;&lt;/div&gt;
&lt;/blockquote&gt;
&lt;blockquote&gt;
&lt;/blockquote&gt;
&lt;blockquote&gt;
&lt;/blockquote&gt;
&lt;blockquote&gt;
&lt;/blockquote&gt;
&lt;div style=&quot;padding: 0px;&quot;&gt;
that, given an array A describing N discs as explained above, returns the number of pairs of intersecting discs. For example, given N=6 and:&lt;/div&gt;
&lt;blockquote&gt;
&lt;div style=&quot;padding: 0px;&quot;&gt;
&lt;/div&gt;
&lt;pre&gt;&lt;tt&gt;A[0] = 1  A[1] = 5  A[2] = 2 
A[3] = 1  A[4] = 4  A[5] = 0  &lt;/tt&gt;&lt;/pre&gt;
&lt;div style=&quot;padding: 0px;&quot;&gt;
&lt;/div&gt;
&lt;/blockquote&gt;
&lt;div style=&quot;padding: 0px;&quot;&gt;
intersecting discs appear in eleven pairs of elements:&lt;/div&gt;
&lt;blockquote&gt;
&lt;ul style=&quot;list-style-type: none; margin: 10px; padding: 0px;&quot;&gt;
&lt;li style=&quot;list-style-type: disc;&quot;&gt;0 and 1,&lt;/li&gt;
&lt;li style=&quot;list-style-type: disc;&quot;&gt;0 and 2,&lt;/li&gt;
&lt;li style=&quot;list-style-type: disc;&quot;&gt;0 and 4,&lt;/li&gt;
&lt;li style=&quot;list-style-type: disc;&quot;&gt;1 and 2,&lt;/li&gt;
&lt;li style=&quot;list-style-type: disc;&quot;&gt;1 and 3,&lt;/li&gt;
&lt;li style=&quot;list-style-type: disc;&quot;&gt;1 and 4,&lt;/li&gt;
&lt;li style=&quot;list-style-type: disc;&quot;&gt;1 and 5,&lt;/li&gt;
&lt;li style=&quot;list-style-type: disc;&quot;&gt;2 and 3,&lt;/li&gt;
&lt;li style=&quot;list-style-type: disc;&quot;&gt;2 and 4,&lt;/li&gt;
&lt;li style=&quot;list-style-type: disc;&quot;&gt;3 and 4,&lt;/li&gt;
&lt;li style=&quot;list-style-type: disc;&quot;&gt;4 and 5.&lt;/li&gt;
&lt;/ul&gt;
&lt;/blockquote&gt;
&lt;div style=&quot;padding: 0px;&quot;&gt;
so the function should return 11.&lt;/div&gt;
&lt;div style=&quot;padding: 0px;&quot;&gt;
The function should return −1 if the number of intersecting pairs exceeds 10,000,000.&lt;/div&gt;
&lt;div style=&quot;padding: 0px;&quot;&gt;
Assume that:&lt;/div&gt;
&lt;blockquote&gt;
&lt;ul style=&quot;list-style-type: none; margin: 10px; padding: 0px;&quot;&gt;
&lt;li style=&quot;list-style-type: disc;&quot;&gt;N is an integer within the range [0..100,000];&lt;/li&gt;
&lt;li style=&quot;list-style-type: disc;&quot;&gt;each element of array A is an integer within the range [0..2147483647].&lt;/li&gt;
&lt;/ul&gt;
&lt;/blockquote&gt;
&lt;div style=&quot;padding: 0px;&quot;&gt;
Complexity:&lt;/div&gt;
&lt;blockquote&gt;
&lt;ul style=&quot;list-style-type: none; margin: 10px; padding: 0px;&quot;&gt;
&lt;li style=&quot;list-style-type: disc;&quot;&gt;expected worst-case time complexity is O(N*log(N));&lt;/li&gt;
&lt;li style=&quot;list-style-type: disc;&quot;&gt;expected worst-case space complexity is O(N), beyond input storage (not counting the storage required for input arguments).&lt;/li&gt;
&lt;/ul&gt;
&lt;/blockquote&gt;
&lt;div style=&quot;padding: 0px;&quot;&gt;
Elements of input arrays can be modified.&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;
&lt;a name=&#39;more&#39;&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;
Solution:&lt;/div&gt;
&lt;/div&gt;
&lt;pre class=&quot;brush: python&quot;&gt;
def solution(A):
  B, M = [], 0
  for i in xrange(len(A)):
    M += len(B) - binF(B, i - A[i])
    if M &gt; 10000000:
      return -1
    B.insert(binF(B, i + A[i]), i + A[i])
  return M

def binF(A, B):
  iF, iL = 0, len(A)
  if iL == 0 or \
    A[iL - 1] &lt; B: 
    return iL
  if A[0] &gt; B: 
    return iF

  while iF &lt; iL:
    iM = iF + (iL - iF) / 2
    if B &lt;= A[iM]:
      iL = iM
    else:
      iF = iM + 1
  return iF
&lt;/pre&gt;
&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://blog.kalinchyk.com/feeds/78179131803679450/comments/default' title='Комментарии к сообщению'/><link rel='replies' type='text/html' href='http://blog.kalinchyk.com/2014/01/codility-train-number-of-disc.html#comment-form' title='Комментарии: 0'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8657487033851500757/posts/default/78179131803679450'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8657487033851500757/posts/default/78179131803679450'/><link rel='alternate' type='text/html' href='http://blog.kalinchyk.com/2014/01/codility-train-number-of-disc.html' title='Codility. Train. Number-of-disc-intersections ★★★'/><author><name>Unknown</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8657487033851500757.post-7415699032902777130</id><published>2014-01-13T00:00:00.001+02:00</published><updated>2014-01-13T09:45:23.612+02:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="codility.com"/><category scheme="http://www.blogger.com/atom/ns#" term="easy"/><category scheme="http://www.blogger.com/atom/ns#" term="lesson 4"/><category scheme="http://www.blogger.com/atom/ns#" term="python"/><category scheme="http://www.blogger.com/atom/ns#" term="train"/><title type='text'>Codility. Train. Max-product-of-three ★★</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
&lt;div id=&quot;brinza-task-description&quot; style=&quot;font-family: Verdana, Arial; font-size: 12px;&quot;&gt;
&lt;div style=&quot;padding: 0px;&quot;&gt;
A non-empty zero-indexed array A consisting of N integers is given. The&amp;nbsp;&lt;i&gt;product&lt;/i&gt;&amp;nbsp;of triplet (P, Q, R) equates to A[P] * A[Q] * A[R] (0 ≤ P &amp;lt; Q &amp;lt; R &amp;lt; N).&lt;/div&gt;
&lt;div style=&quot;padding: 0px;&quot;&gt;
For example, array A such that:&lt;/div&gt;
&lt;div style=&quot;padding: 0px;&quot;&gt;
&lt;/div&gt;
&lt;pre&gt;&lt;tt&gt;  A[0] = -3
  A[1] = 1
  A[2] = 2
  A[3] = -2
  A[4] = 5
  A[5] = 6&lt;/tt&gt;&lt;/pre&gt;
&lt;div style=&quot;padding: 0px;&quot;&gt;
&lt;/div&gt;
&lt;div style=&quot;padding: 0px;&quot;&gt;
contains the following example triplets:&lt;/div&gt;
&lt;blockquote&gt;
&lt;ul style=&quot;list-style-type: none; margin: 10px; padding: 0px;&quot;&gt;
&lt;li style=&quot;list-style-type: disc;&quot;&gt;(0, 1, 2), product is −3 * 1 * 2 = −6&lt;/li&gt;
&lt;li style=&quot;list-style-type: disc;&quot;&gt;(1, 2, 4), product is 1 * 2 * 5 = 10&lt;/li&gt;
&lt;li style=&quot;list-style-type: disc;&quot;&gt;(2, 4, 5), product is 2 * 5 * 6 = 60&lt;/li&gt;
&lt;/ul&gt;
&lt;/blockquote&gt;
&lt;div style=&quot;padding: 0px;&quot;&gt;
Your goal is to find the maximal product of any triplet.&lt;/div&gt;
&lt;div style=&quot;padding: 0px;&quot;&gt;
Write a function:&lt;/div&gt;
&lt;blockquote&gt;
&lt;/blockquote&gt;
&lt;blockquote&gt;
&lt;/blockquote&gt;
&lt;blockquote&gt;
&lt;/blockquote&gt;
&lt;blockquote&gt;
&lt;/blockquote&gt;
&lt;blockquote&gt;
&lt;/blockquote&gt;
&lt;blockquote&gt;
&lt;/blockquote&gt;
&lt;blockquote&gt;
&lt;/blockquote&gt;
&lt;blockquote&gt;
&lt;/blockquote&gt;
&lt;blockquote&gt;
&lt;/blockquote&gt;
&lt;blockquote&gt;
&lt;/blockquote&gt;
&lt;blockquote&gt;
&lt;div class=&quot;lang-py&quot; style=&quot;font-family: monospace; font-size: 9pt; padding: 0px;&quot;&gt;
&lt;tt&gt;def solution(A)&lt;/tt&gt;&lt;/div&gt;
&lt;/blockquote&gt;
&lt;blockquote&gt;
&lt;/blockquote&gt;
&lt;blockquote&gt;
&lt;/blockquote&gt;
&lt;blockquote&gt;
&lt;/blockquote&gt;
&lt;div style=&quot;padding: 0px;&quot;&gt;
that, given a non-empty zero-indexed array A, returns the value of the maximal product of any triplet.&lt;/div&gt;
&lt;div style=&quot;padding: 0px;&quot;&gt;
For example, given array A such that:&lt;/div&gt;
&lt;div style=&quot;padding: 0px;&quot;&gt;
&lt;/div&gt;
&lt;pre&gt;&lt;tt&gt;  A[0] = -3
  A[1] = 1
  A[2] = 2
  A[3] = -2
  A[4] = 5
  A[5] = 6&lt;/tt&gt;&lt;/pre&gt;
&lt;div style=&quot;padding: 0px;&quot;&gt;
&lt;/div&gt;
&lt;div style=&quot;padding: 0px;&quot;&gt;
the function should return 60, as the product of triplet (2, 4, 5) is maximal.&lt;/div&gt;
&lt;div style=&quot;padding: 0px;&quot;&gt;
Assume that:&lt;/div&gt;
&lt;blockquote&gt;
&lt;ul style=&quot;list-style-type: none; margin: 10px; padding: 0px;&quot;&gt;
&lt;li style=&quot;list-style-type: disc;&quot;&gt;N is an integer within the range [3..100,000];&lt;/li&gt;
&lt;li style=&quot;list-style-type: disc;&quot;&gt;each element of array A is an integer within the range [−1,000..1,000].&lt;/li&gt;
&lt;/ul&gt;
&lt;/blockquote&gt;
&lt;div style=&quot;padding: 0px;&quot;&gt;
Complexity:&lt;/div&gt;
&lt;blockquote&gt;
&lt;ul style=&quot;list-style-type: none; margin: 10px; padding: 0px;&quot;&gt;
&lt;li style=&quot;list-style-type: disc;&quot;&gt;expected worst-case time complexity is O(N*log(N));&lt;/li&gt;
&lt;li style=&quot;list-style-type: disc;&quot;&gt;expected worst-case space complexity is O(1), beyond input storage (not counting the storage required for input arguments).&lt;/li&gt;
&lt;/ul&gt;
&lt;/blockquote&gt;
&lt;div style=&quot;padding: 0px;&quot;&gt;
Elements of input arrays can be modified.&lt;/div&gt;
&lt;div&gt;
&lt;a name=&#39;more&#39;&gt;&lt;/a&gt;&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
Solution:&lt;/div&gt;
&lt;/div&gt;
&lt;pre class=&quot;brush: python&quot;&gt;def solution(A):
   L, A = len(A), list(A); A.sort()
   return (lambda x, y: x if x &gt; y else y)\
   (A[L-1]*A[L-2]*A[L-3], A[0]*A[1]*A[L-1])&lt;/pre&gt;
&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://blog.kalinchyk.com/feeds/7415699032902777130/comments/default' title='Комментарии к сообщению'/><link rel='replies' type='text/html' href='http://blog.kalinchyk.com/2014/01/codility-train-max-product-of-three.html#comment-form' title='Комментарии: 0'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8657487033851500757/posts/default/7415699032902777130'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8657487033851500757/posts/default/7415699032902777130'/><link rel='alternate' type='text/html' href='http://blog.kalinchyk.com/2014/01/codility-train-max-product-of-three.html' title='Codility. Train. Max-product-of-three ★★'/><author><name>Unknown</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8657487033851500757.post-6115064209354952737</id><published>2014-01-13T00:00:00.000+02:00</published><updated>2014-01-13T09:44:54.557+02:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="codility.com"/><category scheme="http://www.blogger.com/atom/ns#" term="lesson 4"/><category scheme="http://www.blogger.com/atom/ns#" term="python"/><category scheme="http://www.blogger.com/atom/ns#" term="train"/><category scheme="http://www.blogger.com/atom/ns#" term="very easy"/><title type='text'>Codility. Train. Triangle ★</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
&lt;div id=&quot;brinza-task-description&quot; style=&quot;font-family: Verdana, Arial; font-size: 12px;&quot;&gt;
&lt;div style=&quot;padding: 0px;&quot;&gt;
A zero-indexed array A consisting of N integers is given. A triplet (P, Q, R) is&amp;nbsp;&lt;i&gt;triangular&lt;/i&gt;&amp;nbsp;if 0 ≤ P &amp;lt; Q &amp;lt; R &amp;lt; N and:&lt;/div&gt;
&lt;blockquote&gt;
&lt;ul style=&quot;list-style-type: none; margin: 10px; padding: 0px;&quot;&gt;
&lt;li style=&quot;list-style-type: disc;&quot;&gt;A[P] + A[Q] &amp;gt; A[R],&lt;/li&gt;
&lt;li style=&quot;list-style-type: disc;&quot;&gt;A[Q] + A[R] &amp;gt; A[P],&lt;/li&gt;
&lt;li style=&quot;list-style-type: disc;&quot;&gt;A[R] + A[P] &amp;gt; A[Q].&lt;/li&gt;
&lt;/ul&gt;
&lt;/blockquote&gt;
&lt;div style=&quot;padding: 0px;&quot;&gt;
For example, consider array A such that:&lt;/div&gt;
&lt;div style=&quot;padding: 0px;&quot;&gt;
&lt;/div&gt;
&lt;pre&gt;&lt;tt&gt;  A[0] = 10    A[1] = 2    A[2] = 5
  A[3] = 1     A[4] = 8    A[5] = 20&lt;/tt&gt;&lt;/pre&gt;
&lt;div style=&quot;padding: 0px;&quot;&gt;
&lt;/div&gt;
&lt;div style=&quot;padding: 0px;&quot;&gt;
Triplet (0, 2, 4) is triangular.&lt;/div&gt;
&lt;div style=&quot;padding: 0px;&quot;&gt;
Write a function:&lt;/div&gt;
&lt;blockquote&gt;
&lt;/blockquote&gt;
&lt;blockquote&gt;
&lt;/blockquote&gt;
&lt;blockquote&gt;
&lt;/blockquote&gt;
&lt;blockquote&gt;
&lt;/blockquote&gt;
&lt;blockquote&gt;
&lt;/blockquote&gt;
&lt;blockquote&gt;
&lt;/blockquote&gt;
&lt;blockquote&gt;
&lt;/blockquote&gt;
&lt;blockquote&gt;
&lt;/blockquote&gt;
&lt;blockquote&gt;
&lt;/blockquote&gt;
&lt;blockquote&gt;
&lt;/blockquote&gt;
&lt;blockquote&gt;
&lt;div class=&quot;lang-py&quot; style=&quot;font-family: monospace; font-size: 9pt; padding: 0px;&quot;&gt;
&lt;tt&gt;def solution(A)&lt;/tt&gt;&lt;/div&gt;
&lt;/blockquote&gt;
&lt;blockquote&gt;
&lt;/blockquote&gt;
&lt;blockquote&gt;
&lt;/blockquote&gt;
&lt;blockquote&gt;
&lt;/blockquote&gt;
&lt;div style=&quot;padding: 0px;&quot;&gt;
that, given a zero-indexed array A consisting of N integers, returns 1 if there exists a triangular triplet for this array and returns 0 otherwise. For example, given array A such that:&lt;/div&gt;
&lt;div style=&quot;padding: 0px;&quot;&gt;
&lt;/div&gt;
&lt;pre&gt;&lt;tt&gt;  A[0] = 10    A[1] = 2    A[2] = 5
  A[3] = 1     A[4] = 8    A[5] = 20&lt;/tt&gt;&lt;/pre&gt;
&lt;div style=&quot;padding: 0px;&quot;&gt;
&lt;/div&gt;
&lt;div style=&quot;padding: 0px;&quot;&gt;
the function should return 1, as explained above. Given array A such that:&lt;/div&gt;
&lt;div style=&quot;padding: 0px;&quot;&gt;
&lt;/div&gt;
&lt;pre&gt;&lt;tt&gt;  A[0] = 10    A[1] = 50    A[2] = 5
  A[3] = 1&lt;/tt&gt;&lt;/pre&gt;
&lt;div style=&quot;padding: 0px;&quot;&gt;
&lt;/div&gt;
&lt;div style=&quot;padding: 0px;&quot;&gt;
the function should return 0.&lt;/div&gt;
&lt;div style=&quot;padding: 0px;&quot;&gt;
Assume that:&lt;/div&gt;
&lt;blockquote&gt;
&lt;ul style=&quot;list-style-type: none; margin: 10px; padding: 0px;&quot;&gt;
&lt;li style=&quot;list-style-type: disc;&quot;&gt;N is an integer within the range [0..1,000,000];&lt;/li&gt;
&lt;li style=&quot;list-style-type: disc;&quot;&gt;each element of array A is an integer within the range [−2,147,483,648..2,147,483,647].&lt;/li&gt;
&lt;/ul&gt;
&lt;/blockquote&gt;
&lt;div style=&quot;padding: 0px;&quot;&gt;
Complexity:&lt;/div&gt;
&lt;blockquote&gt;
&lt;ul style=&quot;list-style-type: none; margin: 10px; padding: 0px;&quot;&gt;
&lt;li style=&quot;list-style-type: disc;&quot;&gt;expected worst-case time complexity is O(N*log(N));&lt;/li&gt;
&lt;li style=&quot;list-style-type: disc;&quot;&gt;expected worst-case space complexity is O(N), beyond input storage (not counting the storage required for input arguments).&lt;/li&gt;
&lt;/ul&gt;
&lt;/blockquote&gt;
&lt;div style=&quot;padding: 0px;&quot;&gt;
Elements of input arrays can be modified.&lt;/div&gt;
&lt;div&gt;
&lt;a name=&#39;more&#39;&gt;&lt;/a&gt;&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
Solution:&lt;/div&gt;
&lt;/div&gt;
&lt;pre class=&quot;brush: python&quot;&gt;def solution(A):
  A.sort()
  for i in xrange(len(A) - 2):
    P, Q, R = A[i], A[i + 1], A[i + 2]
    if P + Q &gt; R and Q + R &gt; P and R + P &gt; Q:
      return 1
  else:
    return 0&lt;/pre&gt;
&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://blog.kalinchyk.com/feeds/6115064209354952737/comments/default' title='Комментарии к сообщению'/><link rel='replies' type='text/html' href='http://blog.kalinchyk.com/2014/01/codility-train-triangle.html#comment-form' title='Комментарии: 0'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8657487033851500757/posts/default/6115064209354952737'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8657487033851500757/posts/default/6115064209354952737'/><link rel='alternate' type='text/html' href='http://blog.kalinchyk.com/2014/01/codility-train-triangle.html' title='Codility. Train. Triangle ★'/><author><name>Unknown</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8657487033851500757.post-6485797190126609826</id><published>2014-01-10T00:00:00.000+02:00</published><updated>2014-01-12T11:53:44.339+02:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="codility.com"/><category scheme="http://www.blogger.com/atom/ns#" term="lesson 3"/><category scheme="http://www.blogger.com/atom/ns#" term="medium"/><category scheme="http://www.blogger.com/atom/ns#" term="python"/><category scheme="http://www.blogger.com/atom/ns#" term="train"/><title type='text'>Codility. Train. Genomic-range-query ★★★</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
&lt;div id=&quot;brinza-task-description&quot; style=&quot;font-family: Verdana, Arial; font-size: 12px;&quot;&gt;
&lt;div style=&quot;padding: 0px;&quot;&gt;
A non-empty zero-indexed string S is given. String S consists of N characters from the set of upper-case English letters&amp;nbsp;&lt;tt&gt;A, C, G, T&lt;/tt&gt;.&lt;/div&gt;
&lt;div style=&quot;padding: 0px;&quot;&gt;
This string actually represents a DNA sequence, and the upper-case letters represent single nucleotides.&lt;/div&gt;
&lt;div style=&quot;padding: 0px;&quot;&gt;
You are also given non-empty zero-indexed arrays P and Q consisting of M integers. These arrays represent queries about minimal nucleotides. We represent the letters of string S as integers 1, 2, 3, 4 in arrays P and Q, where&amp;nbsp;&lt;tt&gt;A&lt;/tt&gt;&amp;nbsp;= 1,&amp;nbsp;&lt;tt&gt;C&lt;/tt&gt;&amp;nbsp;= 2,&amp;nbsp;&lt;tt&gt;G&lt;/tt&gt;&amp;nbsp;= 3,&amp;nbsp;&lt;tt&gt;T&lt;/tt&gt;&amp;nbsp;= 4, and we assume that&amp;nbsp;&lt;tt&gt;A &amp;lt; C &amp;lt; G &amp;lt; T&lt;/tt&gt;.&lt;/div&gt;
&lt;div style=&quot;padding: 0px;&quot;&gt;
Query K requires you to find the minimal nucleotide from the range (P[K], Q[K]), 0 ≤ P[i] ≤ Q[i] &amp;lt; N.&lt;/div&gt;
&lt;div style=&quot;padding: 0px;&quot;&gt;
For example, consider string S =&amp;nbsp;&lt;tt&gt;GACACCATA&lt;/tt&gt;&amp;nbsp;and arrays P, Q such that:&lt;/div&gt;
&lt;div style=&quot;padding: 0px;&quot;&gt;
&lt;/div&gt;
&lt;pre&gt;&lt;tt&gt;    P[0] = 0    Q[0] = 8
    P[1] = 0    Q[1] = 2
    P[2] = 4    Q[2] = 5
    P[3] = 7    Q[3] = 7&lt;/tt&gt;&lt;/pre&gt;
&lt;div style=&quot;padding: 0px;&quot;&gt;
&lt;/div&gt;
&lt;div style=&quot;padding: 0px;&quot;&gt;
The minimal nucleotides from these ranges are as follows:&lt;/div&gt;
&lt;blockquote&gt;
&lt;ul style=&quot;list-style-type: none; margin: 10px; padding: 0px;&quot;&gt;
&lt;li style=&quot;list-style-type: disc;&quot;&gt;(0, 8) is&amp;nbsp;&lt;tt&gt;A&lt;/tt&gt;&amp;nbsp;identified by 1,&lt;/li&gt;
&lt;li style=&quot;list-style-type: disc;&quot;&gt;(0, 2) is&amp;nbsp;&lt;tt&gt;A&lt;/tt&gt;&amp;nbsp;identified by 1,&lt;/li&gt;
&lt;li style=&quot;list-style-type: disc;&quot;&gt;(4, 5) is&amp;nbsp;&lt;tt&gt;C&lt;/tt&gt;&amp;nbsp;identified by 2,&lt;/li&gt;
&lt;li style=&quot;list-style-type: disc;&quot;&gt;(7, 7) is&amp;nbsp;&lt;tt&gt;T&lt;/tt&gt;&amp;nbsp;identified by 4.&lt;/li&gt;
&lt;/ul&gt;
&lt;/blockquote&gt;
&lt;blockquote&gt;
&lt;/blockquote&gt;
&lt;blockquote&gt;
&lt;/blockquote&gt;
&lt;div style=&quot;padding: 0px;&quot;&gt;
Write a function:&lt;/div&gt;
&lt;blockquote&gt;
&lt;/blockquote&gt;
&lt;blockquote&gt;
&lt;/blockquote&gt;
&lt;blockquote&gt;
&lt;/blockquote&gt;
&lt;blockquote&gt;
&lt;/blockquote&gt;
&lt;blockquote&gt;
&lt;/blockquote&gt;
&lt;blockquote&gt;
&lt;/blockquote&gt;
&lt;blockquote&gt;
&lt;/blockquote&gt;
&lt;blockquote&gt;
&lt;/blockquote&gt;
&lt;blockquote&gt;
&lt;/blockquote&gt;
&lt;blockquote&gt;
&lt;/blockquote&gt;
&lt;blockquote&gt;
&lt;div class=&quot;lang-py&quot; style=&quot;font-family: monospace; font-size: 9pt; padding: 0px;&quot;&gt;
&lt;tt&gt;def solution(S, P, Q)&lt;/tt&gt;&lt;/div&gt;
&lt;/blockquote&gt;
&lt;blockquote&gt;
&lt;/blockquote&gt;
&lt;blockquote&gt;
&lt;/blockquote&gt;
&lt;blockquote&gt;
&lt;/blockquote&gt;
&lt;div style=&quot;padding: 0px;&quot;&gt;
that, given a non-empty zero-indexed string S consisting of N characters and two non-empty zero-indexed arrays P and Q consisting of M integers, returns an array consisting of M characters specifying the consecutive answers to all queries.&lt;/div&gt;
&lt;div style=&quot;padding: 0px;&quot;&gt;
The sequence should be returned as:&lt;/div&gt;
&lt;blockquote&gt;
&lt;ul style=&quot;list-style-type: none; margin: 10px; padding: 0px;&quot;&gt;
&lt;li style=&quot;list-style-type: disc;&quot;&gt;a Results structure (in C), or&lt;/li&gt;
&lt;li style=&quot;list-style-type: disc;&quot;&gt;a vector of integers (in C++), or&lt;/li&gt;
&lt;li style=&quot;list-style-type: disc;&quot;&gt;a Results record (in Pascal), or&lt;/li&gt;
&lt;li style=&quot;list-style-type: disc;&quot;&gt;an array of integers (in any other programming language).&lt;/li&gt;
&lt;/ul&gt;
&lt;/blockquote&gt;
&lt;div style=&quot;padding: 0px;&quot;&gt;
For example, given the string S =&amp;nbsp;&lt;tt&gt;GACACCATA&lt;/tt&gt;&amp;nbsp;and arrays P, Q such that:&lt;/div&gt;
&lt;div style=&quot;padding: 0px;&quot;&gt;
&lt;/div&gt;
&lt;pre&gt;&lt;tt&gt;    P[0] = 0    Q[0] = 8
    P[1] = 0    Q[1] = 2
    P[2] = 4    Q[2] = 5
    P[3] = 7    Q[3] = 7&lt;/tt&gt;&lt;/pre&gt;
&lt;div style=&quot;padding: 0px;&quot;&gt;
&lt;/div&gt;
&lt;div style=&quot;padding: 0px;&quot;&gt;
the function should return the values [1, 1, 2, 4], as explained above.&lt;/div&gt;
&lt;div style=&quot;padding: 0px;&quot;&gt;
Assume that:&lt;/div&gt;
&lt;blockquote&gt;
&lt;ul style=&quot;list-style-type: none; margin: 10px; padding: 0px;&quot;&gt;
&lt;li style=&quot;list-style-type: disc;&quot;&gt;N is an integer within the range [1..100,000];&lt;/li&gt;
&lt;li style=&quot;list-style-type: disc;&quot;&gt;M is an integer within the range [1..50,000];&lt;/li&gt;
&lt;li style=&quot;list-style-type: disc;&quot;&gt;each element of array P, Q is an integer within the range [0..N − 1];&lt;/li&gt;
&lt;li style=&quot;list-style-type: disc;&quot;&gt;P[i] ≤ Q[i];&lt;/li&gt;
&lt;li style=&quot;list-style-type: disc;&quot;&gt;string S consists only of upper-case English letters&amp;nbsp;&lt;tt&gt;A, C, G, T&lt;/tt&gt;.&lt;/li&gt;
&lt;/ul&gt;
&lt;/blockquote&gt;
&lt;div style=&quot;padding: 0px;&quot;&gt;
Complexity:&lt;/div&gt;
&lt;blockquote&gt;
&lt;ul style=&quot;list-style-type: none; margin: 10px; padding: 0px;&quot;&gt;
&lt;li style=&quot;list-style-type: disc;&quot;&gt;expected worst-case time complexity is O(N+M);&lt;/li&gt;
&lt;li style=&quot;list-style-type: disc;&quot;&gt;expected worst-case space complexity is O(N), beyond input storage (not counting the storage required for input arguments).&lt;/li&gt;
&lt;/ul&gt;
&lt;/blockquote&gt;
&lt;div style=&quot;padding: 0px;&quot;&gt;
Elements of input arrays can be modified.&lt;/div&gt;
&lt;div&gt;
&lt;a name=&#39;more&#39;&gt;&lt;/a&gt;&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
Solution:&lt;/div&gt;
&lt;/div&gt;
&lt;pre class=&quot;brush: python&quot;&gt;def solution(S, P, Q):
  vMap = dict(A = 1, C = 2, G = 3, T = 4)
  vLst = dict(A =[], C =[], G =[], T =[])
  for i in xrange(len(S)):
    vLst[S[i]].append(i)
  for i in xrange(len(P)):
    for j in sorted(vLst):
      iF, iL = 0, len(vLst[j])
      if iL == iF or \
         vLst[j][iF] &gt; Q[i] or \
         vLst[j][iL - 1] &lt; P[i]:
        continue
      while iF &lt; iL:
        iM = iF + (iL - iF) / 2
        if P[i] &lt;= vLst[j][iM]:
          if vLst[j][iM] &lt;= Q[i]:
            P[i] = vMap[j]
            break
          iL = iM
        else:
          iF = iM + 1
      else:
        continue
      break
  return P&lt;/pre&gt;
&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://blog.kalinchyk.com/feeds/6485797190126609826/comments/default' title='Комментарии к сообщению'/><link rel='replies' type='text/html' href='http://blog.kalinchyk.com/2014/01/codility-train-genomic-range-query.html#comment-form' title='Комментарии: 0'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8657487033851500757/posts/default/6485797190126609826'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8657487033851500757/posts/default/6485797190126609826'/><link rel='alternate' type='text/html' href='http://blog.kalinchyk.com/2014/01/codility-train-genomic-range-query.html' title='Codility. Train. Genomic-range-query ★★★'/><author><name>Unknown</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8657487033851500757.post-3292355368873459176</id><published>2013-12-25T00:00:00.002+02:00</published><updated>2013-12-25T17:37:44.850+02:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="codility.com"/><category scheme="http://www.blogger.com/atom/ns#" term="easy"/><category scheme="http://www.blogger.com/atom/ns#" term="lesson 3"/><category scheme="http://www.blogger.com/atom/ns#" term="python"/><category scheme="http://www.blogger.com/atom/ns#" term="train"/><title type='text'>Codility. Train. Passing-cars ★★</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
&lt;div id=&quot;brinza-task-description&quot; style=&quot;font-family: Verdana, Arial; font-size: 12px;&quot;&gt;
&lt;div style=&quot;padding: 0px;&quot;&gt;
A non-empty zero-indexed array A consisting of N integers is given. The consecutive elements of array A represent consecutive cars on a road.&lt;/div&gt;
&lt;div style=&quot;padding: 0px;&quot;&gt;
Array A contains only 0s and/or 1s:&lt;/div&gt;
&lt;blockquote&gt;
&lt;ul style=&quot;list-style-type: none; margin: 10px; padding: 0px;&quot;&gt;
&lt;li style=&quot;list-style-type: disc;&quot;&gt;0 represents a car traveling east,&lt;/li&gt;
&lt;li style=&quot;list-style-type: disc;&quot;&gt;1 represents a car traveling west.&lt;/li&gt;
&lt;/ul&gt;
&lt;/blockquote&gt;
&lt;div style=&quot;padding: 0px;&quot;&gt;
The goal is to count passing cars. We say that a pair of cars (P, Q), where 0 ≤ P &amp;lt; Q &amp;lt; N, is passing when P is traveling to the east and Q is traveling to the west.&lt;/div&gt;
&lt;div style=&quot;padding: 0px;&quot;&gt;
For example, consider array A such that:&lt;/div&gt;
&lt;div style=&quot;padding: 0px;&quot;&gt;
&lt;/div&gt;
&lt;pre&gt;&lt;tt&gt;  A[0] = 0
  A[1] = 1
  A[2] = 0
  A[3] = 1
  A[4] = 1&lt;/tt&gt;&lt;/pre&gt;
&lt;div style=&quot;padding: 0px;&quot;&gt;
&lt;/div&gt;
&lt;div style=&quot;padding: 0px;&quot;&gt;
We have five pairs of passing cars: (0, 1), (0, 3), (0, 4), (2, 3), (2, 4).&lt;/div&gt;
&lt;div style=&quot;padding: 0px;&quot;&gt;
Write a function:&lt;/div&gt;
&lt;blockquote&gt;
&lt;/blockquote&gt;
&lt;blockquote&gt;
&lt;/blockquote&gt;
&lt;blockquote&gt;
&lt;/blockquote&gt;
&lt;blockquote&gt;
&lt;/blockquote&gt;
&lt;blockquote&gt;
&lt;/blockquote&gt;
&lt;blockquote&gt;
&lt;/blockquote&gt;
&lt;blockquote&gt;
&lt;/blockquote&gt;
&lt;blockquote&gt;
&lt;/blockquote&gt;
&lt;blockquote&gt;
&lt;/blockquote&gt;
&lt;blockquote&gt;
&lt;/blockquote&gt;
&lt;blockquote&gt;
&lt;div class=&quot;lang-py&quot; style=&quot;font-family: monospace; font-size: 9pt; padding: 0px;&quot;&gt;
&lt;tt&gt;def solution(A)&lt;/tt&gt;&lt;/div&gt;
&lt;/blockquote&gt;
&lt;blockquote&gt;
&lt;/blockquote&gt;
&lt;blockquote&gt;
&lt;/blockquote&gt;
&lt;blockquote&gt;
&lt;/blockquote&gt;
&lt;div style=&quot;padding: 0px;&quot;&gt;
that, given a non-empty zero-indexed array A of N integers, returns the number of passing cars.&lt;/div&gt;
&lt;div style=&quot;padding: 0px;&quot;&gt;
The function should return −1 if the number of passing cars exceeds 1,000,000,000.&lt;/div&gt;
&lt;div style=&quot;padding: 0px;&quot;&gt;
For example, given:&lt;/div&gt;
&lt;div style=&quot;padding: 0px;&quot;&gt;
&lt;/div&gt;
&lt;pre&gt;&lt;tt&gt;  A[0] = 0
  A[1] = 1
  A[2] = 0
  A[3] = 1
  A[4] = 1&lt;/tt&gt;&lt;/pre&gt;
&lt;div style=&quot;padding: 0px;&quot;&gt;
&lt;/div&gt;
&lt;div style=&quot;padding: 0px;&quot;&gt;
the function should return 5, as explained above.&lt;/div&gt;
&lt;div style=&quot;padding: 0px;&quot;&gt;
Assume that:&lt;/div&gt;
&lt;blockquote&gt;
&lt;ul style=&quot;list-style-type: none; margin: 10px; padding: 0px;&quot;&gt;
&lt;li style=&quot;list-style-type: disc;&quot;&gt;N is an integer within the range [1..100,000];&lt;/li&gt;
&lt;li style=&quot;list-style-type: disc;&quot;&gt;each element of array A is an integer within the range [0..1].&lt;/li&gt;
&lt;/ul&gt;
&lt;/blockquote&gt;
&lt;div style=&quot;padding: 0px;&quot;&gt;
Complexity:&lt;/div&gt;
&lt;blockquote&gt;
&lt;ul style=&quot;list-style-type: none; margin: 10px; padding: 0px;&quot;&gt;
&lt;li style=&quot;list-style-type: disc;&quot;&gt;expected worst-case time complexity is O(N);&lt;/li&gt;
&lt;li style=&quot;list-style-type: disc;&quot;&gt;expected worst-case space complexity is O(1), beyond input storage (not counting the storage required for input arguments).&lt;/li&gt;
&lt;/ul&gt;
&lt;/blockquote&gt;
&lt;div style=&quot;padding: 0px;&quot;&gt;
Elements of input arrays can be modified.&lt;/div&gt;
&lt;div&gt;&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;a name=&#39;more&#39;&gt;&lt;/a&gt;Solution:&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;pre class=&quot;brush: python&quot;&gt;def solution(A):
    c, z = 0, 0
    for i in A:
        if i == 0:
            z += 1
        else:
            c += z
            if c &amp;gt; 1000000000:
                return -1
    return c
&lt;/pre&gt;
&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://blog.kalinchyk.com/feeds/3292355368873459176/comments/default' title='Комментарии к сообщению'/><link rel='replies' type='text/html' href='http://blog.kalinchyk.com/2013/12/codility-train-passing-cars.html#comment-form' title='Комментарии: 0'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8657487033851500757/posts/default/3292355368873459176'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8657487033851500757/posts/default/3292355368873459176'/><link rel='alternate' type='text/html' href='http://blog.kalinchyk.com/2013/12/codility-train-passing-cars.html' title='Codility. Train. Passing-cars ★★'/><author><name>Unknown</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8657487033851500757.post-1883589940062856554</id><published>2013-12-25T00:00:00.001+02:00</published><updated>2013-12-25T15:41:36.474+02:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="codility.com"/><category scheme="http://www.blogger.com/atom/ns#" term="lesson 2"/><category scheme="http://www.blogger.com/atom/ns#" term="medium"/><category scheme="http://www.blogger.com/atom/ns#" term="python"/><category scheme="http://www.blogger.com/atom/ns#" term="train"/><title type='text'>Codility. Train. Max-Counters ★★★</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
&lt;div id=&quot;brinza-task-description&quot; style=&quot;font-family: Verdana, Arial; font-size: 12px;&quot;&gt;
&lt;div style=&quot;padding: 0px;&quot;&gt;
You are given N counters, initially set to 0, and you have two possible operations on them:&lt;/div&gt;
&lt;blockquote&gt;
&lt;ul style=&quot;list-style-type: none; margin: 10px; padding: 0px;&quot;&gt;
&lt;li style=&quot;list-style-type: disc;&quot;&gt;&lt;i&gt;increase(X)&lt;/i&gt;&amp;nbsp;− counter X is increased by 1,&lt;/li&gt;
&lt;li style=&quot;list-style-type: disc;&quot;&gt;&lt;i&gt;max_counter&lt;/i&gt;&amp;nbsp;− all counters are set to the maximum value of any counter.&lt;/li&gt;
&lt;/ul&gt;
&lt;/blockquote&gt;
&lt;div style=&quot;padding: 0px;&quot;&gt;
A non-empty zero-indexed array A of M integers is given. This array represents consecutive operations:&lt;/div&gt;
&lt;blockquote&gt;
&lt;ul style=&quot;list-style-type: none; margin: 10px; padding: 0px;&quot;&gt;
&lt;li style=&quot;list-style-type: disc;&quot;&gt;if A[K] = X, such that 1 ≤ X ≤ N, then operation K is increase(X),&lt;/li&gt;
&lt;li style=&quot;list-style-type: disc;&quot;&gt;if A[K] = N + 1 then operation K is max_counter.&lt;/li&gt;
&lt;/ul&gt;
&lt;/blockquote&gt;
&lt;div style=&quot;padding: 0px;&quot;&gt;
For example, given integer N = 5 and array A such that:&lt;/div&gt;
&lt;div style=&quot;padding: 0px;&quot;&gt;
&lt;/div&gt;
&lt;pre&gt;&lt;tt&gt;    A[0] = 3
    A[1] = 4
    A[2] = 4
    A[3] = 6
    A[4] = 1
    A[5] = 4
    A[6] = 4&lt;/tt&gt;&lt;/pre&gt;
&lt;div style=&quot;padding: 0px;&quot;&gt;
&lt;/div&gt;
&lt;div style=&quot;padding: 0px;&quot;&gt;
the values of the counters after each consecutive operation will be:&lt;/div&gt;
&lt;div style=&quot;padding: 0px;&quot;&gt;
&lt;/div&gt;
&lt;pre&gt;&lt;tt&gt;    (0, 0, 1, 0, 0)
    (0, 0, 1, 1, 0)
    (0, 0, 1, 2, 0)
    (2, 2, 2, 2, 2)
    (3, 2, 2, 2, 2)
    (3, 2, 2, 3, 2)
    (3, 2, 2, 4, 2)&lt;/tt&gt;&lt;/pre&gt;
&lt;div style=&quot;padding: 0px;&quot;&gt;
&lt;/div&gt;
&lt;div style=&quot;padding: 0px;&quot;&gt;
The goal is to calculate the value of every counter after all operations.&lt;/div&gt;
&lt;blockquote&gt;
&lt;/blockquote&gt;
&lt;blockquote&gt;
&lt;/blockquote&gt;
&lt;div style=&quot;padding: 0px;&quot;&gt;
Write a function:&lt;/div&gt;
&lt;blockquote&gt;
&lt;/blockquote&gt;
&lt;blockquote&gt;
&lt;/blockquote&gt;
&lt;blockquote&gt;
&lt;/blockquote&gt;
&lt;blockquote&gt;
&lt;/blockquote&gt;
&lt;blockquote&gt;
&lt;/blockquote&gt;
&lt;blockquote&gt;
&lt;/blockquote&gt;
&lt;blockquote&gt;
&lt;/blockquote&gt;
&lt;blockquote&gt;
&lt;/blockquote&gt;
&lt;blockquote&gt;
&lt;/blockquote&gt;
&lt;blockquote&gt;
&lt;/blockquote&gt;
&lt;blockquote&gt;
&lt;div class=&quot;lang-py&quot; style=&quot;font-family: monospace; font-size: 9pt; padding: 0px;&quot;&gt;
&lt;tt&gt;def solution(N, A)&lt;/tt&gt;&lt;/div&gt;
&lt;/blockquote&gt;
&lt;blockquote&gt;
&lt;/blockquote&gt;
&lt;blockquote&gt;
&lt;/blockquote&gt;
&lt;blockquote&gt;
&lt;/blockquote&gt;
&lt;div style=&quot;padding: 0px;&quot;&gt;
that, given an integer N and a non-empty zero-indexed array A consisting of M integers, returns a sequence of integers representing the values of the counters.&lt;/div&gt;
&lt;div style=&quot;padding: 0px;&quot;&gt;
The sequence should be returned as:&lt;/div&gt;
&lt;blockquote&gt;
&lt;ul style=&quot;list-style-type: none; margin: 10px; padding: 0px;&quot;&gt;
&lt;li style=&quot;list-style-type: disc;&quot;&gt;a structure Results (in C), or&lt;/li&gt;
&lt;li style=&quot;list-style-type: disc;&quot;&gt;a vector of integers (in C++), or&lt;/li&gt;
&lt;li style=&quot;list-style-type: disc;&quot;&gt;a record Results (in Pascal), or&lt;/li&gt;
&lt;li style=&quot;list-style-type: disc;&quot;&gt;an array of integers (in any other programming language).&lt;/li&gt;
&lt;/ul&gt;
&lt;/blockquote&gt;
&lt;div style=&quot;padding: 0px;&quot;&gt;
For example, given:&lt;/div&gt;
&lt;div style=&quot;padding: 0px;&quot;&gt;
&lt;/div&gt;
&lt;pre&gt;&lt;tt&gt;    A[0] = 3
    A[1] = 4
    A[2] = 4
    A[3] = 6
    A[4] = 1
    A[5] = 4
    A[6] = 4&lt;/tt&gt;&lt;/pre&gt;
&lt;div style=&quot;padding: 0px;&quot;&gt;
&lt;/div&gt;
&lt;div style=&quot;padding: 0px;&quot;&gt;
the function should return [3, 2, 2, 4, 2], as explained above.&lt;/div&gt;
&lt;div style=&quot;padding: 0px;&quot;&gt;
Assume that:&lt;/div&gt;
&lt;blockquote&gt;
&lt;ul style=&quot;list-style-type: none; margin: 10px; padding: 0px;&quot;&gt;
&lt;li style=&quot;list-style-type: disc;&quot;&gt;N and M are integers within the range [1..100,000];&lt;/li&gt;
&lt;li style=&quot;list-style-type: disc;&quot;&gt;each element of array A is an integer within the range [1..N + 1].&lt;/li&gt;
&lt;/ul&gt;
&lt;/blockquote&gt;
&lt;div style=&quot;padding: 0px;&quot;&gt;
Complexity:&lt;/div&gt;
&lt;blockquote&gt;
&lt;ul style=&quot;list-style-type: none; margin: 10px; padding: 0px;&quot;&gt;
&lt;li style=&quot;list-style-type: disc;&quot;&gt;expected worst-case time complexity is O(N+M);&lt;/li&gt;
&lt;li style=&quot;list-style-type: disc;&quot;&gt;expected worst-case space complexity is O(N), beyond input storage (not counting the storage required for input arguments).&lt;/li&gt;
&lt;/ul&gt;
&lt;/blockquote&gt;
&lt;div style=&quot;padding: 0px;&quot;&gt;
Elements of input arrays can be modified.&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&lt;a name=&#39;more&#39;&gt;&lt;/a&gt;Solution:&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;pre class=&quot;brush: python&quot;&gt;def solution(N, A):
    iMin, iMax = 0, 0
    iMas = [iMax] * N
    for i in A:
        if i == N + 1:
            iMin = iMax
        else:
            if iMas[i - 1] &amp;lt; iMin:
                iMas[i - 1] = iMin + 1
            else:
                iMas[i - 1] = iMas[i - 1] + 1
            if iMas[i - 1] &amp;gt; iMax:
                iMax = iMas[i - 1]
    for i in xrange(len(iMas)):
        if iMas[i] &amp;lt; iMin:
            iMas[i] = iMin
    return iMas
&lt;/pre&gt;
&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://blog.kalinchyk.com/feeds/1883589940062856554/comments/default' title='Комментарии к сообщению'/><link rel='replies' type='text/html' href='http://blog.kalinchyk.com/2013/12/codility-train-max-counters.html#comment-form' title='Комментарии: 0'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8657487033851500757/posts/default/1883589940062856554'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8657487033851500757/posts/default/1883589940062856554'/><link rel='alternate' type='text/html' href='http://blog.kalinchyk.com/2013/12/codility-train-max-counters.html' title='Codility. Train. Max-Counters ★★★'/><author><name>Unknown</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8657487033851500757.post-1747924888629698933</id><published>2013-12-25T00:00:00.000+02:00</published><updated>2013-12-25T13:17:28.370+02:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="codility.com"/><category scheme="http://www.blogger.com/atom/ns#" term="easy"/><category scheme="http://www.blogger.com/atom/ns#" term="lesson 2"/><category scheme="http://www.blogger.com/atom/ns#" term="python"/><category scheme="http://www.blogger.com/atom/ns#" term="train"/><title type='text'>Codility. Train. Frog-River-One ★★</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
&lt;div id=&quot;brinza-task-description&quot; style=&quot;font-family: Verdana, Arial; font-size: 12px;&quot;&gt;
&lt;div style=&quot;padding: 0px;&quot;&gt;
A small frog wants to get to the other side of a river. The frog is currently located at position 0, and wants to get to position X. Leaves fall from a tree onto the surface of the river.&lt;/div&gt;
&lt;div style=&quot;padding: 0px;&quot;&gt;
You are given a non-empty zero-indexed array A consisting of N integers representing the falling leaves. A[K] represents the position where one leaf falls at time K, measured in minutes.&lt;/div&gt;
&lt;div style=&quot;padding: 0px;&quot;&gt;
The goal is to find the earliest time when the frog can jump to the other side of the river. The frog can cross only when leaves appear at every position across the river from 1 to X.&lt;/div&gt;
&lt;div style=&quot;padding: 0px;&quot;&gt;
For example, you are given integer X = 5 and array A such that:&lt;/div&gt;
&lt;div style=&quot;padding: 0px;&quot;&gt;
&lt;/div&gt;
&lt;pre&gt;&lt;tt&gt;  A[0] = 1
  A[1] = 3
  A[2] = 1
  A[3] = 4
  A[4] = 2
  A[5] = 3
  A[6] = 5
  A[7] = 4&lt;/tt&gt;&lt;/pre&gt;
&lt;div style=&quot;padding: 0px;&quot;&gt;
&lt;/div&gt;
&lt;div style=&quot;padding: 0px;&quot;&gt;
In minute 6, a leaf falls into position 5. This is the earliest time when leaves appear in every position across the river.&lt;/div&gt;
&lt;div style=&quot;padding: 0px;&quot;&gt;
Write a function:&lt;/div&gt;
&lt;blockquote&gt;
&lt;/blockquote&gt;
&lt;blockquote&gt;
&lt;/blockquote&gt;
&lt;blockquote&gt;
&lt;/blockquote&gt;
&lt;blockquote&gt;
&lt;/blockquote&gt;
&lt;blockquote&gt;
&lt;/blockquote&gt;
&lt;blockquote&gt;
&lt;/blockquote&gt;
&lt;blockquote&gt;
&lt;/blockquote&gt;
&lt;blockquote&gt;
&lt;/blockquote&gt;
&lt;blockquote&gt;
&lt;/blockquote&gt;
&lt;blockquote&gt;
&lt;/blockquote&gt;
&lt;blockquote&gt;
&lt;div class=&quot;lang-py&quot; style=&quot;font-family: monospace; font-size: 9pt; padding: 0px;&quot;&gt;
&lt;tt&gt;def solution(X, A)&lt;/tt&gt;&lt;/div&gt;
&lt;/blockquote&gt;
&lt;blockquote&gt;
&lt;/blockquote&gt;
&lt;blockquote&gt;
&lt;/blockquote&gt;
&lt;blockquote&gt;
&lt;/blockquote&gt;
&lt;div style=&quot;padding: 0px;&quot;&gt;
that, given a non-empty zero-indexed array A consisting of N integers and integer X, returns the earliest time when the frog can jump to the other side of the river.&lt;/div&gt;
&lt;div style=&quot;padding: 0px;&quot;&gt;
If the frog is never able to jump to the other side of the river, the function should return −1.&lt;/div&gt;
&lt;div style=&quot;padding: 0px;&quot;&gt;
For example, given X = 5 and array A such that:&lt;/div&gt;
&lt;div style=&quot;padding: 0px;&quot;&gt;
&lt;/div&gt;
&lt;pre&gt;&lt;tt&gt;  A[0] = 1
  A[1] = 3
  A[2] = 1
  A[3] = 4
  A[4] = 2
  A[5] = 3
  A[6] = 5
  A[7] = 4&lt;/tt&gt;&lt;/pre&gt;
&lt;div style=&quot;padding: 0px;&quot;&gt;
&lt;/div&gt;
&lt;div style=&quot;padding: 0px;&quot;&gt;
the function should return 6, as explained above. Assume that:&lt;/div&gt;
&lt;blockquote&gt;
&lt;ul style=&quot;list-style-type: none; margin: 10px; padding: 0px;&quot;&gt;
&lt;li style=&quot;list-style-type: disc;&quot;&gt;N and X are integers within the range [1..100,000];&lt;/li&gt;
&lt;li style=&quot;list-style-type: disc;&quot;&gt;each element of array A is an integer within the range [1..X].&lt;/li&gt;
&lt;/ul&gt;
&lt;/blockquote&gt;
&lt;div style=&quot;padding: 0px;&quot;&gt;
Complexity:&lt;/div&gt;
&lt;blockquote&gt;
&lt;ul style=&quot;list-style-type: none; margin: 10px; padding: 0px;&quot;&gt;
&lt;li style=&quot;list-style-type: disc;&quot;&gt;expected worst-case time complexity is O(N);&lt;/li&gt;
&lt;li style=&quot;list-style-type: disc;&quot;&gt;expected worst-case space complexity is O(X), beyond input storage (not counting the storage required for input arguments).&lt;/li&gt;
&lt;/ul&gt;
&lt;/blockquote&gt;
&lt;div style=&quot;padding: 0px;&quot;&gt;
Elements of input arrays can be modified.&lt;/div&gt;
&lt;div&gt;&lt;br /&gt;
&lt;a name=&#39;more&#39;&gt;&lt;/a&gt;Solution:&lt;/div&gt;
&lt;br /&gt;
&lt;/div&gt;
&lt;pre class=&quot;brush: python&quot;&gt;def solution(X, A):
    j = set()
    for i in xrange(len(A)):
        if A[i] &lt;= X:
            j.add(A[i])
            if len(j) + 1 &gt; X: 
                return i
    return -1
&lt;/pre&gt;
&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://blog.kalinchyk.com/feeds/1747924888629698933/comments/default' title='Комментарии к сообщению'/><link rel='replies' type='text/html' href='http://blog.kalinchyk.com/2013/12/codility-train-frog-river-one.html#comment-form' title='Комментарии: 0'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8657487033851500757/posts/default/1747924888629698933'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8657487033851500757/posts/default/1747924888629698933'/><link rel='alternate' type='text/html' href='http://blog.kalinchyk.com/2013/12/codility-train-frog-river-one.html' title='Codility. Train. Frog-River-One ★★'/><author><name>Unknown</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8657487033851500757.post-3150646230934482678</id><published>2013-12-24T00:00:00.003+02:00</published><updated>2013-12-24T18:20:28.777+02:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="codility.com"/><category scheme="http://www.blogger.com/atom/ns#" term="lesson 2"/><category scheme="http://www.blogger.com/atom/ns#" term="python"/><category scheme="http://www.blogger.com/atom/ns#" term="train"/><category scheme="http://www.blogger.com/atom/ns#" term="very easy"/><title type='text'>Codility. Train. Perm-Check ★</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
&lt;div id=&quot;brinza-task-description&quot; style=&quot;font-family: Verdana, Arial; font-size: 12px;&quot;&gt;
&lt;div style=&quot;padding: 0px;&quot;&gt;
A non-empty zero-indexed array A consisting of N integers is given.&lt;/div&gt;
&lt;div style=&quot;padding: 0px;&quot;&gt;
A&amp;nbsp;&lt;i&gt;permutation&lt;/i&gt;&amp;nbsp;is a sequence containing each element from 1 to N once, and only once.&lt;/div&gt;
&lt;div style=&quot;padding: 0px;&quot;&gt;
For example, array A such that:&lt;/div&gt;
&lt;div style=&quot;padding: 0px;&quot;&gt;
&lt;/div&gt;
&lt;pre&gt;&lt;tt&gt;    A[0] = 4
    A[1] = 1
    A[2] = 3
    A[3] = 2&lt;/tt&gt;&lt;/pre&gt;
&lt;div style=&quot;padding: 0px;&quot;&gt;
&lt;/div&gt;
&lt;div style=&quot;padding: 0px;&quot;&gt;
is a permutation, but array A such that:&lt;/div&gt;
&lt;div style=&quot;padding: 0px;&quot;&gt;
&lt;/div&gt;
&lt;pre&gt;&lt;tt&gt;    A[0] = 4
    A[1] = 1
    A[2] = 3&lt;/tt&gt;&lt;/pre&gt;
&lt;div style=&quot;padding: 0px;&quot;&gt;
&lt;/div&gt;
&lt;div style=&quot;padding: 0px;&quot;&gt;
is not a permutation.&lt;/div&gt;
&lt;div style=&quot;padding: 0px;&quot;&gt;
The goal is to check whether array A is a permutation.&lt;/div&gt;
&lt;div style=&quot;padding: 0px;&quot;&gt;
Write a function:&lt;/div&gt;
&lt;blockquote&gt;
&lt;/blockquote&gt;
&lt;blockquote&gt;
&lt;/blockquote&gt;
&lt;blockquote&gt;
&lt;/blockquote&gt;
&lt;blockquote&gt;
&lt;/blockquote&gt;
&lt;blockquote&gt;
&lt;/blockquote&gt;
&lt;blockquote&gt;
&lt;/blockquote&gt;
&lt;blockquote&gt;
&lt;/blockquote&gt;
&lt;blockquote&gt;
&lt;/blockquote&gt;
&lt;blockquote&gt;
&lt;/blockquote&gt;
&lt;blockquote&gt;
&lt;/blockquote&gt;
&lt;blockquote&gt;
&lt;div class=&quot;lang-py&quot; style=&quot;font-family: monospace; font-size: 9pt; padding: 0px;&quot;&gt;
&lt;tt&gt;def solution(A)&lt;/tt&gt;&lt;/div&gt;
&lt;/blockquote&gt;
&lt;blockquote&gt;
&lt;/blockquote&gt;
&lt;blockquote&gt;
&lt;/blockquote&gt;
&lt;blockquote&gt;
&lt;/blockquote&gt;
&lt;div style=&quot;padding: 0px;&quot;&gt;
that, given a zero-indexed array A, returns 1 if array A is a permutation and 0 if it is not.&lt;/div&gt;
&lt;div style=&quot;padding: 0px;&quot;&gt;
For example, given array A such that:&lt;/div&gt;
&lt;div style=&quot;padding: 0px;&quot;&gt;
&lt;/div&gt;
&lt;pre&gt;&lt;tt&gt;    A[0] = 4
    A[1] = 1
    A[2] = 3
    A[3] = 2&lt;/tt&gt;&lt;/pre&gt;
&lt;div style=&quot;padding: 0px;&quot;&gt;
&lt;/div&gt;
&lt;div style=&quot;padding: 0px;&quot;&gt;
the function should return 1.&lt;/div&gt;
&lt;div style=&quot;padding: 0px;&quot;&gt;
Given array A such that:&lt;/div&gt;
&lt;div style=&quot;padding: 0px;&quot;&gt;
&lt;/div&gt;
&lt;pre&gt;&lt;tt&gt;    A[0] = 4
    A[1] = 1
    A[2] = 3&lt;/tt&gt;&lt;/pre&gt;
&lt;div style=&quot;padding: 0px;&quot;&gt;
&lt;/div&gt;
&lt;div style=&quot;padding: 0px;&quot;&gt;
the function should return 0.&lt;/div&gt;
&lt;div style=&quot;padding: 0px;&quot;&gt;
Assume that:&lt;/div&gt;
&lt;blockquote&gt;
&lt;ul style=&quot;list-style-type: none; margin: 10px; padding: 0px;&quot;&gt;
&lt;li style=&quot;list-style-type: disc;&quot;&gt;N is an integer within the range [1..100,000];&lt;/li&gt;
&lt;li style=&quot;list-style-type: disc;&quot;&gt;each element of array A is an integer within the range [1..1,000,000,000].&lt;/li&gt;
&lt;/ul&gt;
&lt;/blockquote&gt;
&lt;div style=&quot;padding: 0px;&quot;&gt;
Complexity:&lt;/div&gt;
&lt;blockquote&gt;
&lt;ul style=&quot;list-style-type: none; margin: 10px; padding: 0px;&quot;&gt;
&lt;li style=&quot;list-style-type: disc;&quot;&gt;expected worst-case time complexity is O(N);&lt;/li&gt;
&lt;li style=&quot;list-style-type: disc;&quot;&gt;expected worst-case space complexity is O(N), beyond input storage (not counting the storage required for input arguments).&lt;/li&gt;
&lt;/ul&gt;
&lt;/blockquote&gt;
&lt;div style=&quot;padding: 0px;&quot;&gt;
Elements of input arrays can be modified.&lt;/div&gt;
&lt;div&gt;
&lt;a name=&#39;more&#39;&gt;&lt;/a&gt;&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
Solution:&lt;/div&gt;
&lt;/div&gt;
&lt;pre class=&quot;brush: python&quot;&gt;def solution(A):
    A.sort(reverse=True)
    return 1 if A[0] == len(A) and len(set(A)) == len(A) else 0
&lt;/pre&gt;
&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://blog.kalinchyk.com/feeds/3150646230934482678/comments/default' title='Комментарии к сообщению'/><link rel='replies' type='text/html' href='http://blog.kalinchyk.com/2013/12/codility-train-perm-check.html#comment-form' title='Комментарии: 1'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8657487033851500757/posts/default/3150646230934482678'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8657487033851500757/posts/default/3150646230934482678'/><link rel='alternate' type='text/html' href='http://blog.kalinchyk.com/2013/12/codility-train-perm-check.html' title='Codility. Train. Perm-Check ★'/><author><name>Unknown</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8657487033851500757.post-639167504286741148</id><published>2013-12-24T00:00:00.002+02:00</published><updated>2013-12-24T16:04:45.001+02:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="codility.com"/><category scheme="http://www.blogger.com/atom/ns#" term="lesson 1"/><category scheme="http://www.blogger.com/atom/ns#" term="medium"/><category scheme="http://www.blogger.com/atom/ns#" term="python"/><category scheme="http://www.blogger.com/atom/ns#" term="train"/><title type='text'>Codility. Train. Tape-Equilibrium ★★★</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
&lt;div id=&quot;brinza-task-description&quot; style=&quot;font-family: Verdana, Arial; font-size: 12px;&quot;&gt;
&lt;div style=&quot;padding: 0px;&quot;&gt;
A non-empty zero-indexed array A consisting of N integers is given. Array A represents numbers on a tape.&lt;/div&gt;
&lt;div style=&quot;padding: 0px;&quot;&gt;
Any integer P, such that 0 &amp;lt; P &amp;lt; N, splits this tape into two non−empty parts: A[0], A[1], ..., A[P − 1] and A[P], A[P + 1], ..., A[N − 1].&lt;/div&gt;
&lt;div style=&quot;padding: 0px;&quot;&gt;
The&amp;nbsp;&lt;i&gt;difference&lt;/i&gt;&amp;nbsp;between the two parts is the value of: |(A[0] + A[1] + ... + A[P − 1]) − (A[P] + A[P + 1] + ... + A[N − 1])|&lt;/div&gt;
&lt;div style=&quot;padding: 0px;&quot;&gt;
In other words, it is the absolute difference between the sum of the first part and the sum of the second part.&lt;/div&gt;
&lt;div style=&quot;padding: 0px;&quot;&gt;
For example, consider array A such that:&lt;/div&gt;
&lt;div style=&quot;padding: 0px;&quot;&gt;
&lt;/div&gt;
&lt;pre&gt;&lt;tt&gt;  A[0] = 3
  A[1] = 1
  A[2] = 2
  A[3] = 4
  A[4] = 3&lt;/tt&gt;&lt;/pre&gt;
&lt;div style=&quot;padding: 0px;&quot;&gt;
&lt;/div&gt;
&lt;div style=&quot;padding: 0px;&quot;&gt;
We can split this tape in four places:&lt;/div&gt;
&lt;blockquote&gt;
&lt;ul style=&quot;list-style-type: none; margin: 10px; padding: 0px;&quot;&gt;
&lt;li style=&quot;list-style-type: disc;&quot;&gt;P = 1, difference = |3 − 10| = 7&amp;nbsp;&lt;/li&gt;
&lt;li style=&quot;list-style-type: disc;&quot;&gt;P = 2, difference = |4 − 9| = 5&amp;nbsp;&lt;/li&gt;
&lt;li style=&quot;list-style-type: disc;&quot;&gt;P = 3, difference = |6 − 7| = 1&amp;nbsp;&lt;/li&gt;
&lt;li style=&quot;list-style-type: disc;&quot;&gt;P = 4, difference = |10 − 3| = 7&amp;nbsp;&lt;/li&gt;
&lt;/ul&gt;
&lt;/blockquote&gt;
&lt;div style=&quot;padding: 0px;&quot;&gt;
Write a function:&lt;/div&gt;
&lt;blockquote&gt;
&lt;/blockquote&gt;
&lt;blockquote&gt;
&lt;/blockquote&gt;
&lt;blockquote&gt;
&lt;/blockquote&gt;
&lt;blockquote&gt;
&lt;/blockquote&gt;
&lt;blockquote&gt;
&lt;/blockquote&gt;
&lt;blockquote&gt;
&lt;/blockquote&gt;
&lt;blockquote&gt;
&lt;/blockquote&gt;
&lt;blockquote&gt;
&lt;/blockquote&gt;
&lt;blockquote&gt;
&lt;/blockquote&gt;
&lt;blockquote&gt;
&lt;/blockquote&gt;
&lt;blockquote&gt;
&lt;div class=&quot;lang-py&quot; style=&quot;font-family: monospace; font-size: 9pt; padding: 0px;&quot;&gt;
&lt;tt&gt;def solution(A)&lt;/tt&gt;&lt;/div&gt;
&lt;/blockquote&gt;
&lt;blockquote&gt;
&lt;/blockquote&gt;
&lt;blockquote&gt;
&lt;/blockquote&gt;
&lt;blockquote&gt;
&lt;/blockquote&gt;
&lt;div style=&quot;padding: 0px;&quot;&gt;
that, given a non-empty zero-indexed array A of N integers, returns the minimal difference that can be achieved.&lt;/div&gt;
&lt;div style=&quot;padding: 0px;&quot;&gt;
For example, given:&lt;/div&gt;
&lt;div style=&quot;padding: 0px;&quot;&gt;
&lt;/div&gt;
&lt;pre&gt;&lt;tt&gt;  A[0] = 3
  A[1] = 1
  A[2] = 2
  A[3] = 4
  A[4] = 3&lt;/tt&gt;&lt;/pre&gt;
&lt;div style=&quot;padding: 0px;&quot;&gt;
&lt;/div&gt;
&lt;div style=&quot;padding: 0px;&quot;&gt;
the function should return 1, as explained above.&lt;/div&gt;
&lt;div style=&quot;padding: 0px;&quot;&gt;
Assume that:&lt;/div&gt;
&lt;blockquote&gt;
&lt;ul style=&quot;list-style-type: none; margin: 10px; padding: 0px;&quot;&gt;
&lt;li style=&quot;list-style-type: disc;&quot;&gt;N is an integer within the range [2..100,000];&lt;/li&gt;
&lt;li style=&quot;list-style-type: disc;&quot;&gt;each element of array A is an integer within the range [−1,000..1,000].&lt;/li&gt;
&lt;/ul&gt;
&lt;/blockquote&gt;
&lt;div style=&quot;padding: 0px;&quot;&gt;
Complexity:&lt;/div&gt;
&lt;blockquote&gt;
&lt;ul style=&quot;list-style-type: none; margin: 10px; padding: 0px;&quot;&gt;
&lt;li style=&quot;list-style-type: disc;&quot;&gt;expected worst-case time complexity is O(N);&lt;/li&gt;
&lt;li style=&quot;list-style-type: disc;&quot;&gt;expected worst-case space complexity is O(N), beyond input storage (not counting the storage required for input arguments).&lt;/li&gt;
&lt;/ul&gt;
&lt;/blockquote&gt;
&lt;div style=&quot;padding: 0px;&quot;&gt;
Elements of input arrays can be modified.&lt;/div&gt;
&lt;div style=&quot;padding: 0px;&quot;&gt;
&lt;/div&gt;
&lt;div style=&quot;padding: 0px;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;a name=&#39;more&#39;&gt;&lt;/a&gt;Solution:&lt;br /&gt;
&lt;div style=&quot;padding: 0px;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;pre class=&quot;brush: python&quot;&gt;def solution(A):
  iMin, iTmp, i1st, i2nd = None, None, 0, sum(A)
  for i in range(len(A) - 1):
    i1st, i2nd = i1st + A[i], i2nd - A[i]
    iTmp = abs(i1st - i2nd)
    if iMin &amp;gt; iTmp or iMin == None:
      iMin = iTmp
  return iMin
&lt;/pre&gt;
&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://blog.kalinchyk.com/feeds/639167504286741148/comments/default' title='Комментарии к сообщению'/><link rel='replies' type='text/html' href='http://blog.kalinchyk.com/2013/12/codility-train-tape-equilibrium.html#comment-form' title='Комментарии: 0'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8657487033851500757/posts/default/639167504286741148'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8657487033851500757/posts/default/639167504286741148'/><link rel='alternate' type='text/html' href='http://blog.kalinchyk.com/2013/12/codility-train-tape-equilibrium.html' title='Codility. Train. Tape-Equilibrium ★★★'/><author><name>Unknown</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8657487033851500757.post-325288313925392411</id><published>2013-12-24T00:00:00.001+02:00</published><updated>2013-12-24T15:05:48.355+02:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="codility.com"/><category scheme="http://www.blogger.com/atom/ns#" term="easy"/><category scheme="http://www.blogger.com/atom/ns#" term="lesson 1"/><category scheme="http://www.blogger.com/atom/ns#" term="python"/><category scheme="http://www.blogger.com/atom/ns#" term="train"/><title type='text'>Codility. Train. Perm-Missing-Elem ★★</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
&lt;div id=&quot;brinza-task-description&quot;&gt;
&lt;div style=&quot;font-family: Verdana, Arial; font-size: 12px; padding: 0px;&quot;&gt;
A zero-indexed array A consisting of N different integers is given. The array contains integers in the range [1..(N + 1)], which means that exactly one element is missing.&lt;/div&gt;
&lt;div style=&quot;font-family: Verdana, Arial; font-size: 12px; padding: 0px;&quot;&gt;
Your goal is to find that missing element.&lt;/div&gt;
&lt;div style=&quot;font-family: Verdana, Arial; font-size: 12px; padding: 0px;&quot;&gt;
Write a function:&lt;/div&gt;
&lt;blockquote style=&quot;font-family: Verdana, Arial; font-size: 12px;&quot;&gt;
&lt;/blockquote&gt;
&lt;blockquote style=&quot;font-family: Verdana, Arial; font-size: 12px;&quot;&gt;
&lt;/blockquote&gt;
&lt;blockquote style=&quot;font-family: Verdana, Arial; font-size: 12px;&quot;&gt;
&lt;/blockquote&gt;
&lt;blockquote style=&quot;font-family: Verdana, Arial; font-size: 12px;&quot;&gt;
&lt;/blockquote&gt;
&lt;blockquote style=&quot;font-family: Verdana, Arial; font-size: 12px;&quot;&gt;
&lt;/blockquote&gt;
&lt;blockquote style=&quot;font-family: Verdana, Arial; font-size: 12px;&quot;&gt;
&lt;/blockquote&gt;
&lt;blockquote style=&quot;font-family: Verdana, Arial; font-size: 12px;&quot;&gt;
&lt;/blockquote&gt;
&lt;blockquote style=&quot;font-family: Verdana, Arial; font-size: 12px;&quot;&gt;
&lt;/blockquote&gt;
&lt;blockquote style=&quot;font-family: Verdana, Arial; font-size: 12px;&quot;&gt;
&lt;/blockquote&gt;
&lt;blockquote style=&quot;font-family: Verdana, Arial; font-size: 12px;&quot;&gt;
&lt;/blockquote&gt;
&lt;blockquote style=&quot;font-family: Verdana, Arial; font-size: 12px;&quot;&gt;
&lt;div class=&quot;lang-py&quot; style=&quot;font-family: monospace; font-size: 9pt; padding: 0px;&quot;&gt;
&lt;tt&gt;def solution(A)&lt;/tt&gt;&lt;/div&gt;
&lt;/blockquote&gt;
&lt;blockquote style=&quot;font-family: Verdana, Arial; font-size: 12px;&quot;&gt;
&lt;/blockquote&gt;
&lt;blockquote style=&quot;font-family: Verdana, Arial; font-size: 12px;&quot;&gt;
&lt;/blockquote&gt;
&lt;blockquote style=&quot;font-family: Verdana, Arial; font-size: 12px;&quot;&gt;
&lt;/blockquote&gt;
&lt;div style=&quot;font-family: Verdana, Arial; font-size: 12px; padding: 0px;&quot;&gt;
that, given a zero-indexed array A, returns the value of the missing element.&lt;/div&gt;
&lt;div style=&quot;font-family: Verdana, Arial; font-size: 12px; padding: 0px;&quot;&gt;
For example, given array A such that:&lt;/div&gt;
&lt;div style=&quot;font-family: Verdana, Arial; font-size: 12px; padding: 0px;&quot;&gt;
&lt;/div&gt;
&lt;pre style=&quot;font-family: Verdana, Arial; font-size: 12px;&quot;&gt;&lt;tt&gt;  A[0] = 2
  A[1] = 3
  A[2] = 1
  A[3] = 5&lt;/tt&gt;&lt;/pre&gt;
&lt;div style=&quot;font-family: Verdana, Arial; font-size: 12px; padding: 0px;&quot;&gt;
&lt;/div&gt;
&lt;div style=&quot;font-family: Verdana, Arial; font-size: 12px; padding: 0px;&quot;&gt;
the function should return 4, as it is the missing element.&lt;/div&gt;
&lt;div style=&quot;font-family: Verdana, Arial; font-size: 12px; padding: 0px;&quot;&gt;
Assume that:&lt;/div&gt;
&lt;blockquote style=&quot;font-family: Verdana, Arial; font-size: 12px;&quot;&gt;
&lt;ul style=&quot;list-style-type: none; margin: 10px; padding: 0px;&quot;&gt;
&lt;li style=&quot;list-style-type: disc;&quot;&gt;N is an integer within the range [0..100,000];&lt;/li&gt;
&lt;li style=&quot;list-style-type: disc;&quot;&gt;the elements of A are all distinct;&lt;/li&gt;
&lt;li style=&quot;list-style-type: disc;&quot;&gt;each element of array A is an integer within the range [1..(N + 1)].&lt;/li&gt;
&lt;/ul&gt;
&lt;/blockquote&gt;
&lt;div style=&quot;font-family: Verdana, Arial; font-size: 12px; padding: 0px;&quot;&gt;
Complexity:&lt;/div&gt;
&lt;blockquote style=&quot;font-family: Verdana, Arial; font-size: 12px;&quot;&gt;
&lt;ul style=&quot;list-style-type: none; margin: 10px; padding: 0px;&quot;&gt;
&lt;li style=&quot;list-style-type: disc;&quot;&gt;expected worst-case time complexity is O(N);&lt;/li&gt;
&lt;li style=&quot;list-style-type: disc;&quot;&gt;expected worst-case space complexity is O(1), beyond input storage (not counting the storage required for input arguments).&lt;/li&gt;
&lt;/ul&gt;
&lt;/blockquote&gt;
&lt;div style=&quot;font-family: Verdana, Arial; font-size: 12px; padding: 0px;&quot;&gt;
Elements of input arrays can be modified.&lt;/div&gt;
&lt;div style=&quot;font-family: Verdana, Arial; font-size: 12px; padding: 0px;&quot;&gt;
&lt;/div&gt;
&lt;a name=&#39;more&#39;&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;
&lt;div style=&quot;font-family: Verdana, Arial; font-size: 12px; padding: 0px;&quot;&gt;
Solution&lt;/div&gt;
&lt;pre class=&quot;brush: python&quot;&gt;def solution(A):
    j = 1
    A.sort()
    for i in A:
        if i != j:
            break
        j = j + 1
    return j
&lt;/pre&gt;
&lt;div style=&quot;font-family: Verdana, Arial; font-size: 12px;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://blog.kalinchyk.com/feeds/325288313925392411/comments/default' title='Комментарии к сообщению'/><link rel='replies' type='text/html' href='http://blog.kalinchyk.com/2013/12/codility-train-perm-missing-elem.html#comment-form' title='Комментарии: 6'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8657487033851500757/posts/default/325288313925392411'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8657487033851500757/posts/default/325288313925392411'/><link rel='alternate' type='text/html' href='http://blog.kalinchyk.com/2013/12/codility-train-perm-missing-elem.html' title='Codility. Train. Perm-Missing-Elem ★★'/><author><name>Unknown</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>6</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8657487033851500757.post-3065588850160473432</id><published>2013-12-24T00:00:00.000+02:00</published><updated>2013-12-24T14:51:56.531+02:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="codility.com"/><category scheme="http://www.blogger.com/atom/ns#" term="lesson 1"/><category scheme="http://www.blogger.com/atom/ns#" term="python"/><category scheme="http://www.blogger.com/atom/ns#" term="train"/><category scheme="http://www.blogger.com/atom/ns#" term="very easy"/><title type='text'>Codility. Train. Frog-Jmp ★</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
&lt;div style=&quot;font-family: Verdana, Arial; font-size: 12px; padding: 0px;&quot;&gt;
A small frog wants to get to the other side of the road. The frog is currently located at position X and wants to get to a position greater than or equal to Y. The small frog always jumps a fixed distance, D.&lt;/div&gt;
&lt;div style=&quot;font-family: Verdana, Arial; font-size: 12px; padding: 0px;&quot;&gt;
Count the minimal number of jumps that the small frog must perform to reach its target.&lt;/div&gt;
&lt;div style=&quot;font-family: Verdana, Arial; font-size: 12px; padding: 0px;&quot;&gt;
Write a function:&lt;/div&gt;
&lt;blockquote style=&quot;font-family: Verdana, Arial; font-size: 12px;&quot;&gt;
&lt;div class=&quot;lang-c&quot; style=&quot;font-family: monospace; font-size: 9pt; padding: 0px;&quot;&gt;
&lt;tt&gt;def solution(X, Y, D)&lt;/tt&gt;&lt;/div&gt;
&lt;/blockquote&gt;
&lt;blockquote style=&quot;font-family: Verdana, Arial; font-size: 12px;&quot;&gt;
&lt;/blockquote&gt;
&lt;blockquote style=&quot;font-family: Verdana, Arial; font-size: 12px;&quot;&gt;
&lt;/blockquote&gt;
&lt;blockquote style=&quot;font-family: Verdana, Arial; font-size: 12px;&quot;&gt;
&lt;/blockquote&gt;
&lt;blockquote style=&quot;font-family: Verdana, Arial; font-size: 12px;&quot;&gt;
&lt;/blockquote&gt;
&lt;blockquote style=&quot;font-family: Verdana, Arial; font-size: 12px;&quot;&gt;
&lt;/blockquote&gt;
&lt;blockquote style=&quot;font-family: Verdana, Arial; font-size: 12px;&quot;&gt;
&lt;/blockquote&gt;
&lt;blockquote style=&quot;font-family: Verdana, Arial; font-size: 12px;&quot;&gt;
&lt;/blockquote&gt;
&lt;blockquote style=&quot;font-family: Verdana, Arial; font-size: 12px;&quot;&gt;
&lt;/blockquote&gt;
&lt;blockquote style=&quot;font-family: Verdana, Arial; font-size: 12px;&quot;&gt;
&lt;/blockquote&gt;
&lt;blockquote style=&quot;font-family: Verdana, Arial; font-size: 12px;&quot;&gt;
&lt;/blockquote&gt;
&lt;blockquote style=&quot;font-family: Verdana, Arial; font-size: 12px;&quot;&gt;
&lt;/blockquote&gt;
&lt;blockquote style=&quot;font-family: Verdana, Arial; font-size: 12px;&quot;&gt;
&lt;/blockquote&gt;
&lt;blockquote style=&quot;font-family: Verdana, Arial; font-size: 12px;&quot;&gt;
&lt;/blockquote&gt;
&lt;div style=&quot;font-family: Verdana, Arial; font-size: 12px; padding: 0px;&quot;&gt;
that, given three integers X, Y and D, returns the minimal number of jumps from position X to a position equal to or greater than Y.&lt;/div&gt;
&lt;div style=&quot;font-family: Verdana, Arial; font-size: 12px; padding: 0px;&quot;&gt;
For example, given:&lt;/div&gt;
&lt;div style=&quot;font-family: Verdana, Arial; font-size: 12px; padding: 0px;&quot;&gt;
&lt;/div&gt;
&lt;pre style=&quot;font-size: 12px;&quot;&gt;&lt;tt&gt;  X = 10
  Y = 85
  D = 30&lt;/tt&gt;&lt;/pre&gt;
&lt;div style=&quot;font-family: Verdana, Arial; font-size: 12px; padding: 0px;&quot;&gt;
&lt;/div&gt;
&lt;div style=&quot;font-family: Verdana, Arial; font-size: 12px; padding: 0px;&quot;&gt;
the function should return 3, because the frog will be positioned as follows:&lt;/div&gt;
&lt;blockquote style=&quot;font-family: Verdana, Arial; font-size: 12px;&quot;&gt;
&lt;ul style=&quot;list-style-type: none; margin: 10px; padding: 0px;&quot;&gt;
&lt;li style=&quot;list-style-type: disc;&quot;&gt;after the first jump, at position 10 + 30 = 40&lt;/li&gt;
&lt;li style=&quot;list-style-type: disc;&quot;&gt;after the second jump, at position 10 + 30 + 30 = 70&lt;/li&gt;
&lt;li style=&quot;list-style-type: disc;&quot;&gt;after the third jump, at position 10 + 30 + 30 + 30 = 100&lt;/li&gt;
&lt;/ul&gt;
&lt;/blockquote&gt;
&lt;div style=&quot;font-family: Verdana, Arial; font-size: 12px; padding: 0px;&quot;&gt;
Assume that:&lt;/div&gt;
&lt;blockquote style=&quot;font-family: Verdana, Arial; font-size: 12px;&quot;&gt;
&lt;ul style=&quot;list-style-type: none; margin: 10px; padding: 0px;&quot;&gt;
&lt;li style=&quot;list-style-type: disc;&quot;&gt;X, Y and D are integers within the range [1..1,000,000,000];&lt;/li&gt;
&lt;li style=&quot;list-style-type: disc;&quot;&gt;X ≤ Y.&lt;/li&gt;
&lt;/ul&gt;
&lt;/blockquote&gt;
&lt;div style=&quot;font-size: 12px; padding: 0px;&quot;&gt;
&lt;span style=&quot;font-family: Verdana, sans-serif;&quot;&gt;Complexity:&lt;/span&gt;&lt;/div&gt;
&lt;blockquote&gt;
&lt;ul style=&quot;list-style-type: none; margin: 10px; padding: 0px;&quot;&gt;
&lt;li style=&quot;font-size: 12px; list-style-type: disc;&quot;&gt;&lt;span style=&quot;font-family: Verdana, sans-serif;&quot;&gt;expected worst-case time complexity is O(1);&lt;/span&gt;&lt;/li&gt;
&lt;li style=&quot;font-size: 12px; list-style-type: disc;&quot;&gt;&lt;span style=&quot;font-family: Verdana, sans-serif;&quot;&gt;expected worst-case space complexity is O(1).&lt;/span&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;/blockquote&gt;
&lt;br /&gt;
&lt;a name=&#39;more&#39;&gt;&lt;/a&gt;&lt;span style=&quot;font-family: Verdana, sans-serif; font-size: 12px;&quot;&gt;Solution:&lt;/span&gt;&lt;br /&gt;
&lt;pre class=&quot;brush: python&quot;&gt;import math
def solution(X, Y, D):
&amp;nbsp; &amp;nbsp; return int(math.ceil((Y-X)/float(D)))
&lt;/pre&gt;
&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://blog.kalinchyk.com/feeds/3065588850160473432/comments/default' title='Комментарии к сообщению'/><link rel='replies' type='text/html' href='http://blog.kalinchyk.com/2013/12/frog-jmp.html#comment-form' title='Комментарии: 2'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8657487033851500757/posts/default/3065588850160473432'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8657487033851500757/posts/default/3065588850160473432'/><link rel='alternate' type='text/html' href='http://blog.kalinchyk.com/2013/12/frog-jmp.html' title='Codility. Train. Frog-Jmp ★'/><author><name>Unknown</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>2</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8657487033851500757.post-7501925473384244981</id><published>2013-09-30T00:00:00.000+03:00</published><updated>2013-09-30T20:34:39.103+03:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="debug"/><category scheme="http://www.blogger.com/atom/ns#" term="jdeveloper"/><category scheme="http://www.blogger.com/atom/ns#" term="weblogic"/><title type='text'>WebLogic + JDeveloper = Remote Debugging</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
Иногда возникает необходимость проверить работу enterprise приложения на WebLogic сервере в debug-режиме.&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;/div&gt;
&lt;a name=&#39;more&#39;&gt;&lt;/a&gt;&lt;br /&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
Для этого необходимо перевести wls в данный режим, а делается это одной новой строкой в конфигурационном файле&amp;nbsp;$DOMAIN_HOME/bin/setDomainEnv.sh:&lt;/div&gt;
&lt;blockquote class=&quot;tr_bq&quot;&gt;
debugFlag=&quot;true&quot;&lt;/blockquote&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
После перезапускаем сервер приложений и приступаем к настройке проекта в jDeveloper.&amp;nbsp;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
1. &amp;nbsp;Правым кликом мыши на проекте вызываем меню и выбираем пункт &quot;Project Properties&quot; (либо двойной клик на проекте - откроется тоже самое окно настроек).&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
2. Слева, в дереве свойств, выбираем пункт &quot;Run/Debug/Profile&quot;. И щелкаем по кнопке &quot;Edit&quot;.&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
3. В открывшемся окне &quot;Edit Run Configuration ...&quot; для пункта &quot;Launch Settings&quot; устанавливаем галочку напротив элемента &quot;Remote Debugging&quot;.&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
4. В том же окне для пункта &quot;Tool Settings/Debugger/Remote&quot; у нас должны быть выставлены следующие параметры:&lt;/div&gt;
&lt;blockquote class=&quot;tr_bq&quot;&gt;
Protocol: &quot;Attach to JPDA&quot;&lt;br /&gt;Host: IP-адрес или имя сервера&lt;br /&gt;Port: порт, по умолчанию 8453&lt;/blockquote&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
5. Сохраняем настройки и можем теперь запускать приложение в debug-режиме.&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
6. Правой клавишей мыши щелкаем на проекте и выбираем в выпадающем меню пункт &quot;Start Remote Debugger&quot;. Подтверждаем наши намерения подключиться к Remote Debugger.&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
Вот и все. Устанавливаем точки останова в исходном коде вашего проекта и наслаждаетесь debug-режимом.&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
Примечание: пункт 6 данной инструкции не устанавливает приложение на weblogic-сервере поэтому deploy необходимо выполнить заранее.&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://blog.kalinchyk.com/feeds/7501925473384244981/comments/default' title='Комментарии к сообщению'/><link rel='replies' type='text/html' href='http://blog.kalinchyk.com/2013/09/weblogic-jdeveloper-remote-debugging.html#comment-form' title='Комментарии: 0'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8657487033851500757/posts/default/7501925473384244981'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8657487033851500757/posts/default/7501925473384244981'/><link rel='alternate' type='text/html' href='http://blog.kalinchyk.com/2013/09/weblogic-jdeveloper-remote-debugging.html' title='WebLogic + JDeveloper = Remote Debugging'/><author><name>Unknown</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8657487033851500757.post-1798879053562336277</id><published>2013-03-13T00:00:00.000+02:00</published><updated>2013-03-13T10:34:19.620+02:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="bom"/><category scheme="http://www.blogger.com/atom/ns#" term="utf8"/><category scheme="http://www.blogger.com/atom/ns#" term="vbs"/><category scheme="http://www.blogger.com/atom/ns#" term="wsdl"/><category scheme="http://www.blogger.com/atom/ns#" term="xsd"/><title type='text'>Удалить BOM маркер из UTF файлов</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
Многие продукты при работе с UTF файлами не корректно работают если присутствует на нем &lt;a href=&quot;http://ru.wikipedia.org/wiki/Byte_order_mark&quot; target=&quot;_blank&quot;&gt;BOM&lt;/a&gt; маркер. В моей работе частенько приходят файлы, сформированные из Microsoft Visual Studio с указанным префиксом. Для лечения сделал небольшой &lt;a href=&quot;http://ru.wikipedia.org/wiki/VBScript&quot; target=&quot;_blank&quot;&gt;VBScript&lt;/a&gt;:&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;blockquote class=&quot;tr_bq&quot;&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;span style=&quot;font-size: x-small;&quot;&gt;&#39; Removes the Byte Order Mark - BOM from a text file with UTF-8 encoding&lt;br /&gt;&#39; The BOM defines that the file was stored with an UTF-8 encoding.&lt;br /&gt;Public function RemoveBOM(filePath)&lt;br /&gt;&amp;nbsp; &#39; Create a reader and a writer&lt;br /&gt;&amp;nbsp; Dim writer,reader, fileSize&lt;br /&gt;&amp;nbsp; Set writer = CreateObject(&quot;Adodb.Stream&quot;)&lt;br /&gt;&amp;nbsp; Set reader = CreateObject(&quot;Adodb.Stream&quot;)&lt;br /&gt;&amp;nbsp; &#39; Load from the text file we just wrote&lt;br /&gt;&amp;nbsp; reader.Open&lt;br /&gt;&amp;nbsp; reader.LoadFromFile filePath&lt;br /&gt;&amp;nbsp; &#39; Copy all data from reader to writer, except the BOM&lt;br /&gt;&amp;nbsp; writer.Mode=3&lt;br /&gt;&amp;nbsp; writer.Type=1&lt;br /&gt;&amp;nbsp; writer.Open&lt;br /&gt;&amp;nbsp; reader.position=5&lt;br /&gt;&amp;nbsp; reader.copyto writer,-1&lt;br /&gt;&amp;nbsp; &#39; Overwrite file&lt;br /&gt;&amp;nbsp; writer.SaveToFile filePath,2&lt;br /&gt;&amp;nbsp; &#39; Return file name&lt;br /&gt;&amp;nbsp; RemoveBOM = filePath&lt;br /&gt;&amp;nbsp; &#39; Kill objects&lt;br /&gt;&amp;nbsp; Set writer = Nothing&lt;br /&gt;&amp;nbsp; Set reader = Nothing&lt;br /&gt;end Function&lt;br /&gt;&lt;br /&gt;Set objArgs = WScript.Arguments&lt;br /&gt;Set objFSO = CreateObject(&quot;Scripting.FileSystemObject&quot;)&lt;br /&gt;Set objFolder = objFSO.GetFolder(objArgs(0))&lt;br /&gt;Set colFiles = objFolder.Files&lt;br /&gt;For Each objFile in colFiles&lt;br /&gt;&amp;nbsp; RemoveBOM(objArgs(0) + &quot;\&quot; + objFile.Name)&lt;br /&gt;Next&lt;br /&gt;WScript.Echo &quot;Ok&quot;&lt;/span&gt;&lt;/div&gt;
&lt;/blockquote&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
Использовать просто - перетянуть папку, в которой живут неправильные файлы, на этот скрипт.
&lt;/div&gt;
&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://blog.kalinchyk.com/feeds/1798879053562336277/comments/default' title='Комментарии к сообщению'/><link rel='replies' type='text/html' href='http://blog.kalinchyk.com/2013/03/bom-utf.html#comment-form' title='Комментарии: 0'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8657487033851500757/posts/default/1798879053562336277'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8657487033851500757/posts/default/1798879053562336277'/><link rel='alternate' type='text/html' href='http://blog.kalinchyk.com/2013/03/bom-utf.html' title='Удалить BOM маркер из UTF файлов'/><author><name>Unknown</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8657487033851500757.post-7448107622634918991</id><published>2013-02-11T00:00:00.000+02:00</published><updated>2013-02-11T11:10:09.968+02:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="postgresql"/><category scheme="http://www.blogger.com/atom/ns#" term="SOA"/><category scheme="http://www.blogger.com/atom/ns#" term="weblogic"/><title type='text'>PostgreSQL &amp; WebLogic</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
Появилась задача в Oracle SOA Suite выбирать дополнительную информацию из СУБД PostgreSQL. Заглянув в настройки&amp;nbsp;создания нового JDBC-подключения для WebLogic сначала обрадовался когда в поле Database Type нашел пункт &quot;PostgreSQL&quot;. Но на этапе тестирования нового подключения получил ошибку - модуль org.postgresql.Driver не найден.&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
Ниже краткая инструкция, как добавить драйвер в WebLogic.&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;/div&gt;
&lt;a name=&#39;more&#39;&gt;&lt;/a&gt;&lt;br /&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
1. Идем на официальный сайт PostgreSQL за нашим драйвером:&lt;/div&gt;
&lt;blockquote class=&quot;tr_bq&quot;&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;a href=&quot;http://jdbc.postgresql.org/download.html&quot;&gt;http://jdbc.postgresql.org/download.html&lt;/a&gt;&lt;/div&gt;
&lt;/blockquote&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
2. В разделе &quot;Current Version&quot; выбираем драйвер jdbc4:&lt;/div&gt;
&lt;blockquote class=&quot;tr_bq&quot;&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;a href=&quot;http://jdbc.postgresql.org/download/postgresql-9.2-1002.jdbc4.jar&quot;&gt;Например, версия (на дату поста): postgresql-9.2-1002.jdbc4.jar&lt;/a&gt;&lt;/div&gt;
&lt;/blockquote&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
3. Копируем наш драйвер в директорию WebLogic:&lt;/div&gt;
&lt;blockquote class=&quot;tr_bq&quot;&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
/opt/oracle/product/Middleware/wlserver_10.3/server/lib&lt;/div&gt;
&lt;/blockquote&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
4. Устанавливаем необходимые права на файл:&lt;/div&gt;
&lt;blockquote class=&quot;tr_bq&quot;&gt;
$ chown oracle:oinstall postgresql-9.2-1002.jdbc4.jar&lt;br /&gt;$ chmod 750 postgresql-9.2-1002.jdbc4.jar&lt;/blockquote&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
5. Переходим в директорию:&lt;/div&gt;
&lt;blockquote class=&quot;tr_bq&quot;&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
/opt/oracle/product/Middleware/wlserver_10.3/common/bin&lt;/div&gt;
&lt;/blockquote&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
6. Открываем файл commEnv.sh на редактирования и находим раздел:&lt;/div&gt;
&lt;blockquote class=&quot;tr_bq&quot;&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;span style=&quot;font-size: xx-small;&quot;&gt;# set up WebLogic Server&#39;s class path&lt;br /&gt;WEBLOGIC_CLASSPATH=&quot;${JAVA_HOME}/lib/tools.jar${CLASSPATHSEP}${WL_HOME}/server/lib/weblogic_sp.jar${CLASSPATHSEP}${WL_HOME}/server/lib/weblogic.jar${CLASSPATHSEP}${FEATURES_DIR}/weblogic.server.modu&lt;br /&gt;les_10.3.6.0.jar${CLASSPATHSEP}${WL_HOME}/server/lib/webservices.jar${CLASSPATHSEP}${ANT_HOME}/lib/ant-all.jar${CLASSPATHSEP}${ANT_CONTRIB}/lib/ant-contrib.jar&quot;&lt;br /&gt;export WEBLOGIC_CLASSPATH&lt;/span&gt;&lt;/div&gt;
&lt;/blockquote&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
7. Дополняем строку объявления переменной WEBLOGIC_CLASSPATH:&lt;/div&gt;
&lt;blockquote class=&quot;tr_bq&quot;&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;span style=&quot;font-size: xx-small;&quot;&gt;${CLASSPATHSEP}${WL_HOME}/server/lib/postgresql-9.2-1002.jdbc4.jar&lt;/span&gt;&lt;/div&gt;
&lt;/blockquote&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
8. Сохраняем изменения и перезапускаем сервер WebLogic / Oracle SOA Suite.&lt;/div&gt;
&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://blog.kalinchyk.com/feeds/7448107622634918991/comments/default' title='Комментарии к сообщению'/><link rel='replies' type='text/html' href='http://blog.kalinchyk.com/2013/02/postgresql-weblogic.html#comment-form' title='Комментарии: 1'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8657487033851500757/posts/default/7448107622634918991'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8657487033851500757/posts/default/7448107622634918991'/><link rel='alternate' type='text/html' href='http://blog.kalinchyk.com/2013/02/postgresql-weblogic.html' title='PostgreSQL &amp; WebLogic'/><author><name>Unknown</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8657487033851500757.post-1794082515301013666</id><published>2012-10-03T00:00:00.000+03:00</published><updated>2014-05-29T11:46:20.181+03:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="hack"/><category scheme="http://www.blogger.com/atom/ns#" term="АБС Б2"/><title type='text'>Хаки АБС Б2</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
Узнал хак для АБС Б2, который очень полезен для тестирования и доработки функционала продукта. В рабочем окне необходимо нажать кнопку тильды &quot;~&quot;, в результате появится маленькое окошко для ввода текста. Вводим только один символ &quot;z&quot; и жмем Enter. Получаем волшебное окно &quot;Debug&quot;. Дальше уже все понятно.&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
Для активации данной возможности необходимо, чтобы в директории ADDINS был модуль Pb2Tracer.bpl и конфигурационный файл к нему Pb2Tracer.add.&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;/div&gt;
&lt;br /&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
Большое спасибо разработчикам!&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
П.С.: На продуктивной среде данную функцию включать не рекомендую! &lt;/div&gt;
&lt;br /&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
UPD: Содержимое файла Pb2Tracer.add&lt;br /&gt;
&lt;blockquote class=&quot;tr_bq&quot;&gt;
&lt;span style=&quot;font-size: x-small;&quot;&gt;&amp;lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot; standalone=&quot;yes&quot;?&amp;gt;&lt;br /&gt;&amp;lt;taskmap&amp;gt;&lt;br /&gt;&amp;lt;modulelist&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;module name=&quot;b2Tracer&quot; type=&quot;cs-plugin&quot; filename=&quot;ADDINS\Pb2Tracer.bpl&quot; load=&quot;startup&quot;/&amp;gt;&lt;br /&gt;&amp;lt;/modulelist&amp;gt;&lt;br /&gt;&amp;lt;tasklist/&amp;gt;&lt;br /&gt;&amp;lt;/taskmap&amp;gt; &lt;/span&gt;&lt;/blockquote&gt;
&lt;/div&gt;
&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://blog.kalinchyk.com/feeds/1794082515301013666/comments/default' title='Комментарии к сообщению'/><link rel='replies' type='text/html' href='http://blog.kalinchyk.com/2012/10/2.html#comment-form' title='Комментарии: 0'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8657487033851500757/posts/default/1794082515301013666'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8657487033851500757/posts/default/1794082515301013666'/><link rel='alternate' type='text/html' href='http://blog.kalinchyk.com/2012/10/2.html' title='Хаки АБС Б2'/><author><name>Unknown</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8657487033851500757.post-2445324682506222933</id><published>2012-07-23T00:00:00.000+03:00</published><updated>2012-07-23T09:32:00.747+03:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="ESB"/><category scheme="http://www.blogger.com/atom/ns#" term="SOA"/><category scheme="http://www.blogger.com/atom/ns#" term="Talend"/><category scheme="http://www.blogger.com/atom/ns#" term="TOS"/><title type='text'>Talend Open Studio for ESB. Установка.</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
Для установки и работы с Talend Open Studio необходимо в первую очередь позаботиться о наличии java machine на своей рабочей станции. Компания Talend рекомендует использовать Oracle JDK версии 1.6 (update 11 или выше). Для себя я решил оставить текущую версия, ранее установленный OpenJDK.&lt;/div&gt;
&lt;br /&gt;
&lt;span style=&quot;font-family: inherit;&quot;&gt;1. Идем скачивать дистрибутив с официального сайта компании Talend: &lt;a href=&quot;http://www.talend.com/products/open-studio-esb.php&quot;&gt;http://www.talend.com/products/open-studio-esb.php&lt;/a&gt;&lt;/span&gt;&lt;br /&gt;
&lt;blockquote class=&quot;tr_bq&quot;&gt;
&lt;span style=&quot;font-size: xx-small;&quot;&gt;(если нет желания заполнять анкету, то можно воспользоваться ниже приложенной ссылкой, она позволяет сразу начать закачку файла, но работает только для версии 5.1.1: &lt;a href=&quot;http://www.talend.com/downloads/download.php?version=tosesb_511&quot;&gt;http://www.talend.com/downloads/download.php?version=tosesb_511&lt;/a&gt;)&lt;/span&gt;&lt;/blockquote&gt;
&lt;br /&gt;
&lt;div style=&quot;text-align: -webkit-auto;&quot;&gt;
&lt;span style=&quot;white-space: pre-wrap;&quot;&gt;&lt;span style=&quot;font-family: inherit;&quot;&gt;2. Распаковываем полученный архив TOS_ESB в рабочую директорию, например сюда:&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;blockquote class=&quot;tr_bq&quot;&gt;
&lt;span style=&quot;white-space: pre-wrap;&quot;&gt;&lt;span style=&quot;font-family: inherit; font-size: xx-small;&quot;&gt;~/TOS_ESB&lt;/span&gt;&lt;/span&gt;&lt;/blockquote&gt;
&lt;div style=&quot;text-align: -webkit-auto;&quot;&gt;
&lt;span style=&quot;white-space: pre-wrap;&quot;&gt;&lt;span style=&quot;font-family: inherit;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: -webkit-auto;&quot;&gt;
&lt;span style=&quot;white-space: pre-wrap;&quot;&gt;Сразу же после установки Studio не запустилось, точнее падало из-за ошибки. В журнале нашел следующее стек сообщений:&lt;/span&gt;&lt;/div&gt;
&lt;blockquote class=&quot;tr_bq&quot;&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;span style=&quot;background-color: white; font-size: xx-small; white-space: pre-wrap;&quot;&gt;!MESSAGE Ошибка приложения&lt;/span&gt;&lt;/div&gt;
&lt;span style=&quot;white-space: pre-wrap;&quot;&gt;&lt;/span&gt;&lt;br /&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;span style=&quot;white-space: pre-wrap;&quot;&gt;&lt;span style=&quot;background-color: white; font-size: xx-small;&quot;&gt;!STACK 1&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;span style=&quot;white-space: pre-wrap;&quot;&gt;&lt;span style=&quot;font-size: xx-small;&quot;&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;span style=&quot;white-space: pre-wrap;&quot;&gt;&lt;span style=&quot;font-size: xx-small;&quot;&gt;&lt;span style=&quot;background-color: white;&quot;&gt;org.eclipse.swt.SWTError: No more handles [MOZILLA_FIVE_HOME=&#39;/usr/lib/xulrunner-addons&#39;] (java.lang.UnsatisfiedLinkError: Could not load SWT library. Reasons: &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;span style=&quot;white-space: pre-wrap;&quot;&gt;&lt;span style=&quot;font-size: xx-small;&quot;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;white-space: pre-wrap;&quot;&gt;&lt;/span&gt;&lt;br /&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;span style=&quot;white-space: pre-wrap;&quot;&gt;&lt;span style=&quot;background-color: white; font-size: xx-small;&quot;&gt;/home/TOS_ESB/Studio/configuration/org.eclipse.osgi/bundles/481/1/.cp/libswt-mozilla-gtk-3655.so: libxpcom.so: невозможно открыть разделяемый объектный файл: Нет такого файла или каталога &lt;/span&gt;&lt;span style=&quot;background-color: white; font-size: xx-small;&quot;&gt;no swt-mozilla-gtk in java.library.path &lt;/span&gt;&lt;span style=&quot;background-color: white; font-size: xx-small;&quot;&gt;/tmp/swtlib-32/libswt-mozilla-gtk-3655.so: libxpcom.so: невозможно открыть разделяемый объектный файл: Нет такого файла или каталога &lt;/span&gt;&lt;span style=&quot;background-color: white; font-size: xx-small;&quot;&gt;Can&#39;t load library: /tmp/swtlib-32/libswt-mozilla-gtk.so &lt;/span&gt;&lt;span style=&quot;background-color: white; font-size: xx-small;&quot;&gt;)&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;/blockquote&gt;
&lt;div style=&quot;text-align: -webkit-auto;&quot;&gt;
&lt;span style=&quot;white-space: pre-wrap;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;white-space: pre-wrap;&quot;&gt;Поэтому следующим этапом была установка недостающего компонента xulrunner. &lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: -webkit-auto;&quot;&gt;
&lt;span style=&quot;white-space: pre-wrap;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;span style=&quot;background-color: white; font-family: inherit; white-space: pre-wrap;&quot;&gt;3. Переходим на официальный сайт Mozilla и скачиваем архив с бинарными файлами. Ссылка: &lt;/span&gt;&lt;a href=&quot;https://ftp.mozilla.org/pub/mozilla.org/xulrunner/releases/1.9.2.19/runtimes/&quot; style=&quot;background-color: white; font-family: inherit; text-align: left;&quot;&gt;https://ftp.mozilla.org/pub/mozilla.org/xulrunner/releases/1.9.2.19/runtimes/&lt;/a&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: -webkit-auto;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
4. Извлекаем содержимое, полученного архива, например, в директорию: &lt;br /&gt;
&lt;blockquote class=&quot;tr_bq&quot;&gt;
&lt;span style=&quot;font-size: xx-small;&quot;&gt;~/TOS_ESB/xulrunner-1.9.2/&lt;/span&gt;&lt;/blockquote&gt;
&lt;br /&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
5. Открываем конфигурационный файл &lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;b&gt;~/TOS_ESB/Studio/TOS_ESB-linux-gtk-x86.ini&lt;/b&gt;&lt;/span&gt; и в конец документа добавляем строку, следующего вида:&lt;/div&gt;
&lt;blockquote class=&quot;tr_bq&quot;&gt;
&lt;span style=&quot;font-size: xx-small;&quot;&gt;-Dorg.eclipse.swt.browser.XULRunnerPath=~/TOS_ESB/xulrunner-1.9.2/&lt;/span&gt;&lt;/blockquote&gt;
&lt;br /&gt;
P.S.: Более поздняя версия xulrunner не подошла, ошибка в журнале выглядела так:&lt;br /&gt;
&lt;blockquote class=&quot;tr_bq&quot;&gt;
&lt;span style=&quot;font-size: xx-small;&quot;&gt;!MESSAGE Ошибка приложения&lt;br /&gt;!STACK 1&lt;br /&gt;org.eclipse.swt.SWTError: XPCOM error -2147467261&lt;/span&gt;&lt;/blockquote&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://blog.kalinchyk.com/feeds/2445324682506222933/comments/default' title='Комментарии к сообщению'/><link rel='replies' type='text/html' href='http://blog.kalinchyk.com/2012/07/talend-open-studio-for-esb.html#comment-form' title='Комментарии: 1'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8657487033851500757/posts/default/2445324682506222933'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8657487033851500757/posts/default/2445324682506222933'/><link rel='alternate' type='text/html' href='http://blog.kalinchyk.com/2012/07/talend-open-studio-for-esb.html' title='Talend Open Studio for ESB. Установка.'/><author><name>Unknown</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8657487033851500757.post-5489871240286044734</id><published>2012-01-06T00:00:00.000+02:00</published><updated>2012-01-06T12:05:38.612+02:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="жаба"/><category scheme="http://www.blogger.com/atom/ns#" term="наше творчество"/><category scheme="http://www.blogger.com/atom/ns#" term="рыцарь"/><title type='text'>Рыцарь VS ГипноЖаба</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgyxUYhMikcn1E1bXL9hTvRg7ckKU8X93KOXTO7xtyo2xqK9zxmN0VziBZgwm6bZskSM82OpP27UVHgA7gcAaSyE-C1FaVsHlxZJbg5fPP3L-exoKgTTTIjzZo2xlUFa5QNJk59LNz78AU/s1600/IMAG0116.jpg&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;300&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgyxUYhMikcn1E1bXL9hTvRg7ckKU8X93KOXTO7xtyo2xqK9zxmN0VziBZgwm6bZskSM82OpP27UVHgA7gcAaSyE-C1FaVsHlxZJbg5fPP3L-exoKgTTTIjzZo2xlUFa5QNJk59LNz78AU/s400/IMAG0116.jpg&quot; width=&quot;400&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj5pzOJisNdyAxJKir5zt87etsOAj4jYBduwCGceptIacPJcs1ildSKOgxeJtiiUoM9MdKeOwsiSmyw5Cc32v_lvpsvWYm9klxDPq6Hrb99qEGFg7lY-hgV7KM_kKjHKXQzzwYl11zlsmM/s1600/IMAG0117.jpg&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;400&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj5pzOJisNdyAxJKir5zt87etsOAj4jYBduwCGceptIacPJcs1ildSKOgxeJtiiUoM9MdKeOwsiSmyw5Cc32v_lvpsvWYm9klxDPq6Hrb99qEGFg7lY-hgV7KM_kKjHKXQzzwYl11zlsmM/s400/IMAG0117.jpg&quot; width=&quot;301&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://blog.kalinchyk.com/feeds/5489871240286044734/comments/default' title='Комментарии к сообщению'/><link rel='replies' type='text/html' href='http://blog.kalinchyk.com/2012/01/vs.html#comment-form' title='Комментарии: 1'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8657487033851500757/posts/default/5489871240286044734'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8657487033851500757/posts/default/5489871240286044734'/><link rel='alternate' type='text/html' href='http://blog.kalinchyk.com/2012/01/vs.html' title='Рыцарь VS ГипноЖаба'/><author><name>Unknown</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgyxUYhMikcn1E1bXL9hTvRg7ckKU8X93KOXTO7xtyo2xqK9zxmN0VziBZgwm6bZskSM82OpP27UVHgA7gcAaSyE-C1FaVsHlxZJbg5fPP3L-exoKgTTTIjzZo2xlUFa5QNJk59LNz78AU/s72-c/IMAG0116.jpg" height="72" width="72"/><thr:total>1</thr:total></entry></feed>