I believe these questions should yield the same answer:
(The question is "what are the odds of throwing at least two 1's with 3 dice")
https://www.wolframalpha.com/input/?i=1%2C1+on+3+6-sided+dice
(solution: 15/216)
and
https://www.wolframalpha.com/input/?i=at+least+two+1+on+3+6-sided+dice
(solution: 16/216)
It seems the first does not seem take into account 1,1,1 as solution. Perhaps it interprets the question as exactly two ones. But when showing the example roll on the bottom and pressing reroll, it does show up as a solution. This seems like a bug.
Can anyone shed some light on this?
---- UPDATE ----
So the bug boils down to:
When asking WolframAlpha the question:
"What are the odds of rolling exactly two 1's (and no more) with 5 dice?" (https://www.wolframalpha.com/input/?i=1%2C1+on+3+6-sided+dice)
The solution: 15/216 is correct, but the example box below shows 1,1,1 as possible result (press reroll a couple of times). This is especially unclear when you throw 5 dice and seeing 1,1,1,4,1 as valid result. It's very unclear if it interprets as exactly 1,1 or at least 1,1.
As #paxdiablo pointed out, Wolfram Alpha answers https://www.wolframalpha.com/input/?i=exactly+two+1+on+3+6-sided+dice with the same probability, but without the bug (1,1,1 does not show up as valid answer).
I would suggest that it is interpreting 1,1 on 3 6-sided dice as exactly two 1's, not at least two. That discounts the 1,1,1 solution which explains the disparity:
1 1 2-5 (5)
1 2-5 1 (5)
2-5 1 1 (5)
----
(15)
1 1 1 (1)
----
(16)
That gels with the precise probability given of 5/72 (15/216).
As to why it's putting forward 1,1,1 when you throw the dice, I would say that is a a bug if it's meant to agree with the input. That certainly appears to be the case as it always has the 1,1 at the start.
Interestingly enough, the two 1 on 3 6-sided dice query generates the same probability but, after trying 50 dice rolls, the 1,1,1 combo never appeared. Perhaps the natural language processing is different between the two different areas.
As an aside, I have submitted feedback to Wolfram Alpha to see what they say about it. If they ever get back to me, I'll post the response here.
Update 1: Standard form letter response has been received, so hopefully a further response will come shortly:
We appreciate your feedback regarding Wolfram|Alpha. The issue you reported has been passed along to our development team for review. Thank you for helping us improve Wolfram|Alpha.
Related
We have a matrix of questions with 12 field label variable (resources) and options for this matrix are - Strongly disagree -to strongly agree. I want develop next question based on "Strongly agree answer' and asking participants to rank those variable/sources.
'The final set of questions relate to return to work resources the MDT team may have offered while you were still in the recovery unit. Please indicate how much you agree with the following statements.'
1 Help with CV
2 Apply funding .....
3
......
12 Adaptive equipment
For the following question - is it possible to pull out variables/ resources that participant choose as strongly agreed and ask them to rank them 1 to 5.
Thanks,
JM
If I understand correctly, you have a matrix of 12 fields with strongly agree to strongly disagree, and for each of those that are marked strongly agree, you want to have the respondent rank them from 1 through to 5.
What you can do is have another matrix field that asks respondents to select a choice between 1 and 5 for each of the 12 statements in the first matrix. Then, for each statement in the second matrix, add branching logic to only show it if the corresponding statement in the first matrix was strongly agree. Finally, set the matrix to 'Ranking'; this will only allow a single response per column (in addition to only a single response per row). This will mean a user may only have one 1, one 2, etc.,
Here's what that looks like in the designer:
However, there are problems with this. First, there is nothing to prevent someone selecting strongly agree to more than 5 choices, meaning there will be statements that cannot be ranked. Maybe this is good; maybe you only want them to be able to rank 5 and the way to handle that is to only provide 5 columns to rank. Here's a screenshot of a record with 6 statements to rank. Notice the last cannot be ranked or it will displace another statement's ranking:
The reverse is also true, if someone answers strongly agree to less than 5 statements, they will still see 5 columns to rank the less than 5 statements, so you might have 1, 2, 3, or it might be 1, 3, 4. This screenshot shows three statements being ranked, leaving two rank positions unfilled.
The problem is that the number of choices in a ranking matrix field cannot grow or shrink depending on the number of statements in it.
This is my first post on Stack Overflow, so please excuse my mistakes if I'm doing something wrong.
Ok so I'm trying to find an algorithm/function/something that can calculate how many times I have to do the same type of shuffle of 52 playing cards to get back to where I started.
The specific shuffle I'm using goes like this:
-You will have two piles.
-You have the deck with the back facing up. (Lets call this pile 1)
-You will now alternate between putting a card in the back of pile 1 Example: Let's say you have 4 cards in a pile, back facing up, going from 4 closest to the ground and 1 closest to the sky (Their order is 4,3,2,1. You take card 1 and put it beneath card 4 mening card 1 is now closest to the ground and card 4 is second closest, order is now 1,4,3,2. and putting one in pile 2. -Pile 2 will "stack downwards" meaning you will always put the new card at the bottom of that pile. (Back always facing up)
-The first card will always get put at the back of pile 1.
-Repeat this process until all cards are in pile 2.
-Now take pile 2 and do the exact same thing you just did.
My question is: How many times do I have to repeat this process until I get back where I started?
Side notes:
- If this is a common way of shuffling cards and there already is a solution, please let me know.
- I'm still new to math and coding so if writing up an equation/algorithm/code for this is really easy then don't laugh at me pls ;<.
- Sorry if I'm asking this at the wrong place, I don't know how all this works.
- English isn't my main language and I'm not a native speaker either so please excuse any bad grammar and/or other grammatical errors.
I do however have a code that does all of this (Link here) but I'm unsure if it's the most effective way to do it, and it hasn't given a result yet so I don't even know if it works. If you wan't to give tips or suggestions on how to change it then please do, I would really appreciate it. It's done in scratch however because I can't write in any other languages... sorry...
Thanks in advance.
Any fixed shuffle is equivalent to a permutation; what you want to know is the order of that permutation. This can be computed by decomposing the permutation into cycles and then computing the least common multiple of the cycle lengths.
I'm not able to properly understand your algorithm, but here's an example of shuffling 8 elements and then finding the number of times that shuffle needs to be repeated to get back to an unshuffled state.
Suppose the sequence starts as 1,2,3,4,5,6,7,8 and after one shuffle, it's 3,1,4,5,2,8,7,6.
The number 1 goes to position 2, then 2 goes to position 5, then 5 goes to position 4, then 4 goes to position 3, then 3 goes to position 1. So the first cycle is (1 2 5 4 3).
The number 6 goes to position 8, then 8 goes to position 6. So the next cycle is (6 8).
The number 7 stays in position 7, so this is a trivial cycle (7).
The lengths of the cycles are 5, 2 and 1, so the least common multiple is 10. This shuffle takes 10 iterations to get back to the intitial state.
If you don't mind sitting down with pen and paper for a while, you should be able to follow this procedure for your own shuffling algorithm.
I don't know if this is the right section... but here goes:
Last weeks contest on interviewstreet (Code Sprint 3) had a problem called bowling. (10 pin bowling, N frames). The point is to count the number of ways to score M points by playing N frames.
Problem Statement is here: http://pastebin.com/cyeLML8U
I'm pretty sure I've solved the problem using 2 dimensional DP. However, I get the 3rd sample data wrong (1 Frame, 25 points). The sample answer is 1, however I get 6.
This is their explanation of the sample answer:
For the third case, there is only 1 way. Score a strike in the first frame, score another strike with the first extra ball, and an additional 5 with the second extra ball.
However, can't you score a strike in the first (and only) frame, then score any of the following in the subsequent extra frames?
10 5
9 6
8 7
7 8
6 9
5 10
I can't wrap my head around why "1" is the right answer.... I've looked on wikipedia for the rules too.
Their answer is probably right, and I'm probably overlooking something REALLY obvious. Can anyone tell me what's wrong with my answer?
You cannot get 9 pins with the first extra ball and then 6 pins with the second extra ball because there is only 1 pin left standing when you bowl the second extra ball.
But if you don't get a strike on the second ball, you only have the opportunity to "pick up the spare." That is, you only get 10 pins. So if you get a strike on the first ball and then 9 pins on the second ball, the most you can get on the third ball is 1.
The way I read it, your answer is technically correct, but I don't think the question was asked correctly.
Within the constraints as set out in the link in your question, I can't see what's wrong with your solution. In real life, the pins won't actually be reset unless you've knocked them all down or have bowled twice (or both), so - as others have said - the only way you can score 25 from a 1 ball frame in real life is strike, strike, 5.
Basically, the question didn't give you the correct constraints. I don't think it's valid to say you got the answer wrong, because the question was poorly phrased.
I am stuck on this problem for quite a while, it is basically reverse engineering bulls and cow game.
Read more here: http://rosettacode.org/wiki/Bulls_and_cows
I am not able to develop a logic for the problem given below, if you can think of a solving approach please comment the same.
Problem Statement:
Given few clue words(of form ABCD/DBCA etc) and the number of cows and bulls for each word,program
should be able to work out the actual word by evaluating the given clue words and generate the output secret word.
TEST CASES:
Input:
4
DBCC 0 2
CDAB 2 1
CAAD 1 2
CDDA 2 0
Output:
BDAA
The idea is to reduce the space of possible solutions. Before you start, all 4^4 combinations are possible. After you read the first clue [DBCC 0 2 ], you can eliminate a number of possible solutions, in this particular example you can eliminate all states which have a D in the first place, all which have a B in the second place and so on. Just eliminate all possible solutions which do not "fit" the current clue.
Do this with each clue, until only one solution is left. Another interesting problem of course is how to generate good clue patterns.
The way I did it is:
1. Generate all possible words, put them in a list (array)
2. Randomly select one of them (first question)and ask for clues
3. Take the answer (let's say it is 2,1)
4. Start comparing that question with
first, second, ..., to the last word from the list
5. if they give the same clue: count them, plac
EDIT: Just to make sure someone is not breaking their head on the problem... I am not looking for the best optimal algorithm. Some heuristic that makes sense is fine.
I made a previous attempt at formulating this and realized I did not do a great job at it so I removed that question. I have taken another shot at formulating my problem. Please feel free to provide any constructive criticism that can help me improve this.
Input:
N people
k announcements that I can make
Distance that my voice can be heard (say 5 meters) i.e. I may decide to announce or not depending on the number of people within these 5 meters
Goal:
Maximize the total number of people who have heard my k announcements and (optionally) minimize the time in which I can finish announcing all k announcements
Constraints:
Once a person hears my announcement, he is be removed from the total i.e. if he had heard my first announcement, I do not count him even if he hears my second announcement
I can see the same person as well as the same set of people within my proximity
Example:
Let us consider 10 people numbered from 1 to 10 and the following pattern of arrival:
Time slot 1: 1 (payoff = 1)
Time slot 2: 2 3 4 5 (payoff = 4)
Time slot 3: 5 6 7 8 (payoff = 4 if no announcement was made previously in time slot 2, 3 if an announcement was made in time slot 2)
Time slot 4: 9 10 (payoff = 2)
and I am given 2 announcements to make. Now if I were an oracle, I would choose time slots 2 and time slots 3 because then 7 people would have heard (because 5 already heard my announcement in Time slot 2, I do not consider him anymore). I am looking for an online algorithm that will help me make these decisions on whether or not to make an announcement and if so based on what factors. Does anyone have any ideas on what algorithms can be used to solve this or a simpler version of this problem?
There should be an approach relying upon a max-flow algorithm. In essence, you're trying to push the maximum amount of messages from start->end. Though it would be multidimensional, you could have a super-sink, which connects to each value of t, then have each value of t connect to the people you can reach at this time and then have a super-sink. This way, you simply have to compute a max-flow (with the added constraint of no more than k shouts, which should be solvable with a bit of dynamic programming). It's a terrifically dirty way to solve it, but it should get the job done deterministically and without the use of heuristics.
I don't know that there is really a way to solve this or an algorithm to do it the way you have formulated it.
It seems like basically you are trying to reach the maximum number of people with exactly 2 announcements. But without knowing any information about the groups of people in advance, you can't really make any kind of intelligent decision about whether or not to use your first announcement. Your second one at least has the benefit of knowing when not to be used (i.e. if the group has no new members then you can know its not worth wasting the announcement). But it still has basically the same problem.
The only real way to solve this is to use knowledge about the type of data or the desired outcome to make guesses. If you know that groups average 100 people with a standard deviation of 10, then you could just refuse to announce if less than 90 people are present. Or, if you know you need to reach at least 100 people with two announcements, you could choose never to announce to less than 50 at once. Obviously those approaches risk never announcing at all if the actual data does not meet what you would expect. But that's always going to be a risk, since you could get 1 person in the first group and then 0 in all of the rest, no matter what you do.
Or, you could try more clearly defining the problem, I have a hard time figuring out how to relate this to computers.
Lets start my trying to solve the simplest possible variant of the problem: Lets assume N people and K timeslots, but only one possible announcement. Lets also assume that each person will only ever stay for one timeslot and that each person who hasn't yet shown up has an equally probable chance of showing up at any future timeslot.
Given these simplifications, at each timeslot you look at the payoff of announcing at the current timeslot and compare to the chance of a future timeslot having a higher payoff, eg, lets assume 4 people 3 timeslots:
Timeslot 1: Person 1 shows up, so you know you could get a payoff of 1 by announcing, but then you have 3 people to show up in 2 remaining timeslots, so at least one of those timeslots is guaranteed to have 2 people, so don't announce..
So at each timeslot, you can calculate the chance that a later timeslot will have a higher payoff than the current by treating the remaining (N) people and (K) timeslots as being N independent random numbers each from 1..k, and calculate the chance of at least one value k being hit more than or equal to the current-payoff times. (Similar to the Birthday problem, but for more than 1 collision) and then you need to decide hwo much to discount based on expected variances. (bird in the hand, etc)
Generalization of this solution to the original problem is left as an exercise for the reader.