## Problem Statement

You have 25 horses, and you want to pick the fastest 3 horses out of those 25. Each race can have maximum of 5 horses at the same time. What is the minimum number of races required to find the 3 fastest horses without using a stopwatch?

## Solution

Let’s say that we have 5 races of 5 horses each, so each row in the table above represents a race.

 H1 H2 H3 H4 H5 H6 H7 H8 H9 H10 H11 H12 H13 H14 H15 H16 H17 H18 H19 H20 H21 H22 H23 H24 H25

Let each row represent a race.

Step 1: Perform 5 races of each set.

Result:

 1st 2nd 3rd 4th 5th H1 H2 H3 H4 H5 H6 H7 H8 H9 H10 H11 H12 H13 H14 H15 H16 H17 H18 H19 H20 H21 H22 H23 H24 H25

Step 2: Elimination by logical analysis:

• We can eliminate the slowest 2 horses in each group since those horses are definitely not in the top 3
• The 5 group leaders are not necessarily the 5 fastest horses, therefore race those 5 horses against each other (H1, H6, H11, H16, and H21) {Race 6}, Let’s say that the 3 fastest in that group are H1, H6, and H11 – automatically we can eliminate H16 and H21 since those 2 are definitely not in the top 3
• We can automatically eliminate all the horses that H16 and H21 competed against in the preliminary races as they were slower than H16 and H21
• We also know that H1 is the fastest horse in the group since he was the fastest horse out of the 5 group leaders
• if H6 and H11 are the 2nd and 3rd fastest in the group leaders, then we should be able to eliminate H8 since H6 raced against him and he was in 3rd place in that race
• We can also eliminate H12 and H13 since H11 was the 3rd fastest in the group leaders, and H12 and H13 were slower than H11
• This leaves us with the following horses to determine the 2nd and 3rd fastest horses:
 H2 H3 H6 H7 H11

Race the last Set {Race 7} to get the Top 2nd and 3rd racers with H1 as the fastest.

Total number of Races: 7

## Enable/Disable Proxy Service in OSB via ANT+Python

Below is the configurable code for developers to maintain an ant script to be able to control(Enable/Disable) Proxy Services via Ant Script.

Files:

WLSTbuild.properties
``` weblogic.home.dir=<OSB Home>/wlserver_10.3 weblogic.lib.dir=\${weblogic.home.dir}/server/lib ```

build.properties

```fmw.home=<OSB Middleware Home> wls.username =<Weblogic User Id> wls.password =<Weblogic Password> wls.server = t3://:<Weblogic Host>:<Weblogic Port> service.script=osb_enable_service.py service.project="<Project Name>/<Sub Project Name or 'ProxyServices' >" service.name =<Proxy Name> service.action = <disable/enable>```

build.xml

```<?xml version="1.0" encoding="windows-1252" ?>
<project name="ServiceControl" default="ServiceControl">
<property file="./build.properties"/>
<property file="./wlstbuild.properties"/>
<classpath>
<pathelement location="\${weblogic.lib.dir}/weblogic.jar"></pathelement>
</classpath>
<target name="ServiceControl">
<echo>\${weblogic.lib.dir}</echo>
<wlst filename="\${service.script}" debug="true" failonerror="false"
<classpath>
<pathelement location="\${weblogic.lib.dir}/weblogic.jar"></pathelement>
<pathelement location="\${fmw.home}/<OSB Installation Folder>/lib/sb-kernel-api.jar"></pathelement>
<pathelement location="\${fmw.home}/<OSB Installation Folder>/lib/sb-kernel-impl.jar"></pathelement>
<pathelement location="\${fmw.home}/<OSB Installation Folder>/lib/osb-coherence-client.jar"></pathelement>
</classpath>
</wlst>
</target>
</project>
```

osb_enable_service.py
``` from com.bea.wli.sb.management.configuration import SessionManagementMBean from com.bea.wli.sb.management.configuration import ALSBConfigurationMBean from com.bea.wli.config import Ref from java.lang import String from com.bea.wli.monitoring import StatisticType from com.bea.wli.config import Ref from com.bea.wli.sb.util import Refs from com.bea.wli.sb.management.configuration import CommonServiceConfigurationMBean from java.lang import String from com.bea.wli.monitoring import StatisticType from com.bea.wli.config import Ref from com.bea.wli.sb.util import Refs from com.bea.wli.sb.management.configuration import CommonServiceConfigurationMBean adminUser = sys.argv[1] adminPassword = sys.argv[2] adminUrl = sys.argv[3] project = sys.argv[4] service = sys.argv[5] action = sys.argv[6] connect(adminUser,adminPassword,adminUrl) domainRuntime() print('WLST Connected')```

``` Create a session name sessionName = String("SessionScript"+Long(System.currentTimeMillis()).toString()) print('... after session. Session is: ', sessionName) Get the session MBean and create a session sessionMBean = findService(SessionManagementMBean.NAME,SessionManagementMBean.TYPE) print('SessionMBean is: ', sessionMBean) sessionMBean.createSession(sessionName) print(String('Session was created ... ').concat(sessionName)) Get the ProxyServiceConfigurationMBean specific to our session mbean = findService(String("ProxyServiceConfiguration.").concat(sessionName),'com.bea.wli.sb.management.configuration.ProxyServiceConfigurationMBean') Creates a reference to a folder and 'ProxyServices' is a folder in the project and 'ProxyServices' is a folder in the project projectName = Refs.makeParentRef(project + '/') proxyRef = Refs.makeProxyRef(projectName, service) if action == 'disable' : print "Disabling " + service +" has been completed" mbean.disableService(proxyRef) else : print "Enabling " + service +" has been completed" mbean.enableService(proxyRef) Now commit (activate) the changes ```

```sessionMBean.activateSession(sessionName, "disabled PS") print disconnect() exit() ```

Place all files in a single folder.

From CMD, Navigate to folder and just call ant

Verify from OSB Portal, the service will be in disabled/enabled format in Operational Settings Tab.

## How to install Web Center Portal

Installing Oracle Web Center Portal has the following steps:

1. Weblogic Server 10.3.6 <!! 12c would not work, Only 11g Release 2 !!>
2. Web Center Portal
F
ollow the complete steps or follow the wizard as shown:

*Please Note: Weblogic option will not be available if the Server version mentioned in the previous step is not 10.3.6. 12c will not work

3. Database XE(Optional. install only if you dont have database already installed)
4. RCU
• In CMD, Open file

• Follow the below steps to install RCU:
• Configure Domain Config:

## How to install Weblogic Server 10.3.6

• Open CMD
• Run the following command as Admin

java -jar wls1036_generic.jar

• On Welcome, click the Next button.
• On Choose Middleware Home Directory. select option

Create a new Middleware Home

click the Next button

• On Register for Security Updates, enter email id, and unselect the security updates checkbox. This will disable update information.

Click the Next button
• Select Typical install on Choose Install Type Screen and keep clicking next for default options as shown:

Click on Done.
• Domain Configuration(Quick Start) will open:

Getting started with WebLogic Server 10.3.6

• Follow the wizard as shown below:

Enter domain related details

• Your weblogic server is now installed.

## How to fill a increasing values in a column of a table?

How to fill a increasing values in a column of a table?

Lets assume we have a table
Table name : test

 Name Value Yogesh 0 Yogesh 0 Yogesh 0 Yogesh 0 Yogesh 0 Suresh 0 Suresh 0

Requirement : to insert 1, 2, 3 …. corresponding to values Yogesh

Query to Update :

`create sequence seq start with 1 increment by 1;update test set Value=seq.nextval where Name='Yogesh';commit;`

Output :

 Name Value Yogesh 1 Yogesh 2 Yogesh 3 Yogesh 4 Yogesh 5 Suresh 0 Suresh 0