Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # Ruby
- print "\nInput #1 -- "
- inputA = gets.chomp
- print "\nInput #2 -- "
- inputB = gets.chomp
- if inputA.downcase.delete(' ').chars.sort == inputB.downcase.delete(' ').chars.sort
- puts "\nOutput -- \"#{inputA}\" can be formed using \"#{inputB}\"!"
- else
- puts "\nOutput -- \"#{inputA}\" cannot be formed using \"#{inputB}\"!"
- end
- # PHP
- =begin
- <?php
- $a = htmlentities($_GET['a']);
- $b = htmlentities($_GET['b']);
- $inputA = str_replace(" ", "", strtolower($a));
- $inputB = str_replace(" ", "", strtolower($b));
- if(isset($a, $b))
- {if(count_chars($inputA, 1)===count_chars($inputB, 1)){echo "$a can be formed using $b.";}
- else {echo "$a is can't be formed using $b.";}}
- ?>
- =end
- # JavaScript
- =begin
- function check(inputA, inputB)
- {if (inputA.toLowerCase().replace(/[^a-z\d]/g,'').split('').sort().join('')===inputB.toLowerCase().replace(/[^a-z\d]/g,'').split('').sort().join('')){return '"'+inputA+'" can be formed using "'+inputB+'"';}
- else {return '"'+inputA+'" can\'t be formed using '+inputB+'"';}}
- userInputA = prompt("Input #1 ~");
- userInputB = prompt("Input #2 ~");
- document.write(check(userInputA, userInputB));
- =end
- # Python (Tonmoy Ahmed Dhrubo's Solution)
- =begin
- input1 = raw_input('\n1st input >> ')
- input2 = raw_input('\n2nd input >> ')
- string1 = input1.lower()
- string2 = input2.lower()
- string1 = string1.replace(' ', '')
- string2 = string2.replace(' ', '')
- list1 = sorted(list(string1))
- list2 = sorted(list(string2))
- if list1 == list2:
- print('\n[+] ((%s)) can be formed using ((%s))') % (input1, input2)
- print('\nThanks for the challenge')
- print('\nRegards , Tonmoy Ahmed Dhrubo')
- else:
- print('\n[+] ((%s)) can NOT be formed using ((%s))') % (input1, input2)
- print('\nThanks for the challenge')
- print('\nRegards , Tonmoy Ahmed Dhrubo')
- =end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement