7 kyu
Simple Fun #367: Flip Cards
Loading description...
Puzzles
Games
View
This comment has been reported as {{ abuseKindText }}.
Show
This comment has been hidden. You can view it now .
This comment can not be viewed.
- |
- Reply
- Edit
- View Solution
- Expand 1 Reply Expand {{ comments?.length }} replies
- Collapse
- Spoiler
- Remove
- Remove comment & replies
- Report
{{ fetchSolutionsError }}
-
-
Your rendered github-flavored markdown will appear here.
-
Label this discussion...
-
No Label
Keep the comment unlabeled if none of the below applies.
-
Issue
Use the issue label when reporting problems with the kata.
Be sure to explain the problem clearly and include the steps to reproduce. -
Suggestion
Use the suggestion label if you have feedback on how this kata can be improved.
-
Question
Use the question label if you have questions and/or need help solving the kata.
Don't forget to mention the language you're using, and mark as having spoiler if you include your solution.
-
No Label
- Cancel
Commenting is not allowed on this discussion
You cannot view this solution
There is no solution to show
Please sign in or sign up to leave a comment.
Seven cards are placed on a table. Each card has an O on one side and an X on the opposite side. Three of the cards have the X side facing up, and the other four have the O side facing up, however you can't see which cards are which. Your task is to divide the cards into 2 piles that each contain an equal number of cards with an X facing up. Although you cannot see the cards, you are allowed to flip each card or leave it as it is. The cards are labelled "C1" through "C7". Return an array containing two subarrays which, between the two of them, contain all seven cards, either as they are (i.e. "C3") or flipped (i.e. "C3.flip").
This is a puzzle more than a programming challenge. If you are confused, I would advise experimenting by dividing the cards into two piles of varying sizes, and working through the possibilities for what the end results will be by flipping different amounts of cards, keeping in mind that you don't know which side is originally facing up on each card.
Very fascinating Kata, thanks myjinxin2015!
Am i supposed to code something for this? I don't see any way to manipulate or view any of the data, all i seem to be able to change are the Cx/Cx.flip returns, however without the ability to see what each represents there is no way to code a proper solution to "attempt" this kata. probably just going to skip it and see if this involves some for of "breaking" the tests.
It's hard to give an explanation or hint ;-) You can take these seven cards as a 7 bit binary number, 3 bits are 1, 4 bits are 0. such as 1110000, 0000111, etc. Your goal is to flip some bits, so that the result has same numbers of 1 in two groups. Tips: you should flip an odd number of cards. If you flip even number of cards in any case, the numbers of 1 still be a odd number. And obviously, flip 1 or 7 cards are not good choices.
I tried but I don't understand what is needed in this kata, I really don't want to skip it but I think requirements need more clarification.
Approved