4 kyu
T.T.T.#2: Equal to 24
371 of 1,008myjinxin2015
Description:
This is the simple version of Fastest Code : Equal to 24.
Task
A game I played when I was young: Draw 4 cards from playing cards, use + - * / and ()
to make the final results equal to 24.
You will coding in function equalTo24
. Function accept 4 parameters a b c d
(4 cards), value range is 1-13.
The result is a string such as "2*2*2*3"
,(4+2)*(5-1)
; If it is not possible to calculate the 24, please return "It's not possible!"
All four cards are to be used, only use three or two cards are incorrect; Use a card twice or more is incorrect too.
You just need to return one correct solution, don't need to find out all the possibilities.
Examples
equalTo24(1,2,3,4) // can return "(1+3)*(2+4)" or "1*2*3*4"
equalTo24(2,3,4,5) // can return "(5+3-2)*4" or "(3+4+5)*2"
equalTo24(3,4,5,6) // can return "(3-4+5)*6"
equalTo24(1,1,1,1) // should return "It's not possible!"
equalTo24(13,13,13,13) // should return "It's not possible!"
Puzzles
Games
Similar Kata:
Stats:
Created | May 30, 2016 |
Published | May 30, 2016 |
Warriors Trained | 4995 |
Total Skips | 1303 |
Total Code Submissions | 6606 |
Total Times Completed | 1008 |
JavaScript Completions | 371 |
CoffeeScript Completions | 10 |
Python Completions | 648 |
Total Stars | 260 |
% of votes with a positive feedback rating | 93% of 217 |
Total "Very Satisfied" Votes | 193 |
Total "Somewhat Satisfied" Votes | 19 |
Total "Not Satisfied" Votes | 5 |
Total Rank Assessments | 5 |
Average Assessed Rank | 4 kyu |
Highest Assessed Rank | 4 kyu |
Lowest Assessed Rank | 6 kyu |