Git Product home page Git Product logo

soshisoai's Introduction

Problem

A group of male and female participants give three choices.

# soshisoai.txt
A:c,b,a
B:a,b,d
C:a,c,b
D:d,a,c
a:A,C,D
b:D,A,B
c:B,A,C
d:D,C,A

Male A's first choice is c, the second one is b and the third choice is a from the female group.

Desired outputs.

A-c
B-b
C-a
D-d

If the first choice of male and female participants are the same it creates a pair. If there are no matches in the first choices, then you need to use the second chices etc.

Some inputs may not be valid.

  • it may have a wrong person who does not exist.
  • it may have the same person's name.
  • it may have no choice.
  • it may have only the first choice.

The following is another input.

# soshisoai2.txt
A:c,a,b
B:c,f,a
C:f,c,b
D:d,d,d
E:
F:e,c,a
a:A,D,F
b:C,B,A
c:D,A,C
d:A,A,B
e:C,A,E
f:D,B,A

Test

Run tests.

rspec -c soshisoai1_spec.rb
rspec -c soshisoai2_spec.rb

Run with the first example.

ruby findpartner.rb

This gives the following result.

cA
bB
aC
dD

Run with the second text.

ruby findpartner2.rb

This gives the following result.

cA
fB
aF

soshisoai's People

Watchers

James Cloos avatar Junichi Ito avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.