Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7653005
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T11:54:57+00:00 2026-05-31T11:54:57+00:00

t = [ [ [[Armando, P],[Dave, S]], [[Richard, R],[Michael, S]], ], [ [[Allen, S],[Omer,

  • 0
t = [
       [
         [["Armando", "P"],["Dave", "S"]],
         [["Richard", "R"],["Michael", "S"]],
       ],
       [
         [["Allen", "S"],["Omer", "P"]],
         [["David E.", "R"], ["Richard X.", "P"]]
       ]
    ]

def rps_game_winner(game)
    raise WrongNumberOfPlayersError unless game.length == 2
    if (game[0][1] =~ /[r]/i && game[1][1] =~ /[s]/i) || (game[0][1] =~ /[s]/i && game[1][1] =~ /[p]/i) || (game[0][1] =~ /[p]/i && game[1][1] =~ /[r]/i)
        return game[0]
    elsif (game[0][1] =~ /[r]/i && game[1][1] =~ /[p]/i) || (game[0][1] =~ /[s]/i && game[1][1] =~ /[r]/i) || (game[0][1] =~ /[p]/i && game[1][1] =~ /[s]/i)
        return game[1]
    elsif game[0][1] == game[1][1]
        return game[0]
    else
        raise NoSuchStrategyError.new
    end
end

def rps_tournament_winner(t)
   t.each do |pair|
    yield pair
   end  
end

rps_tournament_winner(t) { |x| rps_game_winner(x)  }

So the error I am getting is: NoSuchStrategyError: NoSuchStrategyError – which means that the yield is passing a value to the block and that is being passed to my method rps_game_winner and it is evaluating something and giving that error – per the method.

But it’s not evaluating it properly….because it should be looking at Armando and Dave and returning a winner, then it should go back and continue look at the next pair and return the winner, etc.

P.S. When I do puts pair, I see the right values – and I have tested rps_game_winner method on one single pair and it works fine. It’s just iterating over multiple pairs is giving me an issue with the passing of control back and forth.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-31T11:54:58+00:00Added an answer on May 31, 2026 at 11:54 am

    Are you sure your t is correct?
    Seems to me like it should be something like this:

    t = [
          [["Armando", "P"],["Dave", "S"]],
          [["Richard", "R"],["Michael", "S"]],
          [["Allen", "S"],["Omer", "P"]],
          [["David E.", "R"], ["Richard X.", "P"]]
        ]
    

    I assume Armando plays Dave in the first game.
    Richard plays Michael etc.

    In your code [[“Armando”, “P”],[“Dave”, “S”]] plays [[“Allen”, “S”],[“Omer”, “P”]]. So when your rps_game_winner checks for game[0][1] it actually returns [“Dave”, “S”]. Not P.

    edit1:
    if you want to do the set-logic you speak of you need to modify rps_tournament_winner like so:

    def rps_tournament_winner(t)
       t.each do |pair|
        pair.each do |g|
          puts 'winner:', yield(g)
        end
       end  
    end
    

    edit2:
    made my own implementation. take from it what you will. but it does what you want it to do.
    https://github.com/SpoBo/rock-paper-scissors

    you basicaly need to keep track of the winners and let the winners play against themselves. my implementation allows for any number of players to play against each other. the only problem my implementation has is that a player always plays the same hand and as soon as 2 players with the same hands meet the game will become unpredictable. so it needs some modifications to handle this.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

def rps_tournament_winner(tournament) for i in 0..1 do if tournament[i][1].is_a? Array then rps_tournament_winner(tournament[i]) else tournament=rps_game_winner(tournament)
Maybe is a silly questiion, but I haven't found a solution to what I
Background, I'm running a Zend Framework application. Trying to squeeze the most performance out
I want to use the system command in a bash shell script. Being more
So, say I have an array that looks like this: t = [ [
I have my sample XML file: <?xml version=1.0 encoding=utf-8 ?> <contacts> <contact contactId=2> <firstName>Barney</firstName>
The Application_Error event is being raised in my application with a HttpException. Inside the
I'm trying to put these buttons inside my GridView: $extraButtons = array( 'class'=>'CButtonColumn', updateButtonLabel
I am trying to get my debug.keystore md5 key so I can get the
After searching quite a bit in the Internet for a solution I decided to

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.