Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 11 months ago.
Improve this question
How to do 50% of 120 in scala code..need proper syntax ,& runnable code for same.
Eg :
int k = (int)(120*(50.0f/100.0f));
This is in java need scala code for same.
The answer would be:
(120*(50.0f/100.0f)).toInt
Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 4 years ago.
Improve this question
lets suppose
al=['Al','2l','3l','4l','5l','6l','7l','8l','9l','jl','ql','kl']
af=['Af','2f','3f','4f','5f','6f','7f','8f','9f','jf','qf','kf']
ak=['Ak','2k','3k','4k','5k','6k','7k','8k','9k','jk','qk','kk']
an=['An','2n','3n','4n','5n','6n','7n','8n','9n','jn','qn','kn']
are array
let's suppose
there a two-person wait for random numbers to get
but they should not get the same word ( 3 outputs should be to 2 people from 4 arrays without repeating
)
Use Array#sample and then Enumerable#each_slice:
persons, cards = 2, 3
(al + af + ak + an).sample(persons * cards).each_slice(cards).to_a
#⇒ [["qk", "4l", "Ak"], ["6l", "8l", "5l"]]
Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 8 years ago.
Improve this question
I have this array:
a= [[1,2],[3,4],[1,2],[2,3],[2,3]]
How can I make user to enter an array element ex:[1,2] and it should take that element and return the number of times it is found in the array.
You have your array a and the user input (i1 and i2), all you have to do is:
a.count([i1, i2])
Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 8 years ago.
Improve this question
Using only five 3s and valid mathematical operations, how to get answer 31? Only digit 3 should be there and you can use 5 times (no more or less) to get the answer.
Would this work?
33 - 3 + 3/3
You can get to 31 with…
(3**3+(3/3))+3
Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 9 years ago.
Improve this question
I need to make a program that counts down from 10, displays a message, and then immediately after starts counting from 100 metres to 200 metres, and so on up to 100,000 metres. I can't figure out how to do the last part. This is the code I have so far.
10.downto(1) do|counter|
puts counter
sleep 1
end
puts "Blast off!"
If you mean in increments of 100, try this:
100.step(100_000, 100) {|c| puts c; sleep(0.5)}