Fastest 3 out of 25 Horses Problem

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?


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.


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.


weblogic.home.dir=<OSB Home>/wlserver_10.3

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


<?xml version="1.0" encoding="windows-1252" ?>
<project name="ServiceControl" default="ServiceControl">
   <property file="./"/>
   <property file="./"/>
   <taskdef classname="" name="wlst">
         <pathelement location="${weblogic.lib.dir}/weblogic.jar"></pathelement>
   <target name="ServiceControl">
      <wlst filename="${service.script}" debug="true" failonerror="false"
            arguments="${wls.username} ${wls.password} ${wls.server} ${service.project} ${} ${service.action}">
            <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>

from import SessionManagementMBean
from 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 import Refs
from import CommonServiceConfigurationMBean
from java.lang import String
from com.bea.wli.monitoring import StatisticType
from com.bea.wli.config import Ref
from import Refs
from 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]
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)
print(String('Session was created ... ').concat(sessionName))

Get the ProxyServiceConfigurationMBean specific to our session

mbean = findService(String("ProxyServiceConfiguration.").concat(sessionName),'')

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"
else :
print "Enabling " + service +" has been completed"

Now commit (activate) the changes

sessionMBean.activateSession(sessionName, "disabled PS")

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:

  • Download and Install:
    1. Weblogic Server 10.3.6 <!! 12c would not work, Only 11g Release 2 !!>
    2. Web Center Portal
      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:
        2015-05-05_1724 2015-05-05_1725 2015-05-05_1726 2015-05-05_1726_001 2015-05-05_1727 2015-05-05_1729 2015-05-05_1729_001 2015-05-05_1729_002 2015-05-05_1729_003 2015-05-05_1730 2015-05-05_1730_001 2015-05-05_1731 2015-05-05_1731_001 2015-05-05_1809
  • Configure Domain Config:

    2015-05-05_1819_001 2015-05-05_1819_002

    2015-05-05_1822_002 2015-05-05_1822_003

How to install Weblogic Server 10.3.6

Follow the link: Weblogic Server 10.3.6

  • Accept the user agreement radio button. The link to download(Oracle WebLogic Server 11gR1 (10.3.6) ZIP Distribution) will be enabled.
    Note: You will be asked to login for the same.
  • click on the download link and the server jar file will be downloaded(wls1036_generic.jar)
  • Follow the complete steps mentioned here, or follow below steps:
    • Open CMD
    • Navigate to the directory where the file has been downloaded.
    • 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:
    • On the QuickStart links panel, select this link

      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';

Output :

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