Skip to content

Commit 3f96e31

Browse files
authored
Merge pull request ashutosh97#1 from ashutosh97/master
updating my fork
2 parents f1e9b90 + f033ff2 commit 3f96e31

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

54 files changed

+1356
-0
lines changed

.DS_Store

12 KB
Binary file not shown.

Acronym/instructions.txt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
Acronym
2+
Convert a phrase to its acronym.
3+
4+
Techies love their TLA (Three Letter Acronyms)!
5+
6+
Help generate some jargon by writing a program that converts a long name like Portable Network Graphics to its acronym (PNG).

Acronym/ruby_solution.rb

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
def abbreviate(string)
2+
string_arr = string.scan(/\b\w/)
3+
string_arr.join.upcase
4+
end
5+
6+
7+
# begin
8+
# >> abbreviate("Portable Network Graphics")
9+
# => "PNG"
10+
# >> abbreviate("Ruby on Rails")
11+
# => "ROR"
12+
# >> abbreviate("GNU Image Manipulation Program")
13+
# => "GIMP"

AnagramChecking/anagram_checking.py

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
# Python3 program to check if two strings are anagram of each other
2+
3+
def are_anagram(s1, s2):
4+
""" Check if two strings are anagram of each other.
5+
6+
Apply XOR to all characters of both strings. If the final value is 0, then
7+
there is an even occurence of all characters, ie the two strings are
8+
anagram. Otherwise, there are not anagram.
9+
10+
Args:
11+
s1 (str): First string
12+
s2 (str): Second string
13+
14+
Returns:
15+
bool: True if the two strings are anagram of each other, otherwise False
16+
"""
17+
# Two strings with different sizes can not be anagram of each other
18+
if len(s1) != len(s2):
19+
return False
20+
21+
# Apply XOR to all characters of both strings
22+
xor_value = 0
23+
for c1, c2 in zip(s1, s2):
24+
xor_value = xor_value ^ ord(c1)
25+
xor_value = xor_value ^ ord(c2)
26+
27+
return not bool(xor_value)
28+
29+
def main():
30+
""" Driver code """
31+
s1 = 'listen'
32+
s2 = 'silent'
33+
s3 = 'hacktoberfest'
34+
print('{} / {} -> {}'.format(s1, s2, are_anagram(s1, s2)))
35+
print('{} / {} -> {}'.format(s1, s3, are_anagram(s1, s3)))
36+
print('{} / {} -> {}'.format(s2, s3, are_anagram(s2, s3)))
37+
38+
if __name__=='__main__':
39+
main()

AnagramChecking/anagram_checking.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
Anagram checking
2+
3+
Write a function that check whether two given strings are anagram of each other. An anagram is a word or phrase formed by rearranging the letters of a different word or phrase using all the original letters exactly once. An optimized solution should have a O(n) time complexity and O(1) space complexity.
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
Write a function that counts how many different ways you can make change for an amount of money, given an array of coin denominations. For example, there are 3 ways to give change for 4 if you have coins with denomination 1 and 2:
2+
3+
1+1+1+1, 1+1+2, 2+2.
4+
The order of coins does not matter:
5+
6+
1+1+2 == 2+1+1
7+
Also, assume that you have an infinite amount of coins.
8+
9+
Your function should take an amount to change and an array of unique denominations for the coins:
10+
11+
countChange(4, [1,2]) // => 3
12+
countChange(10, [5,2,3]) // => 4
13+
countChange(11, [5,7]) // => 0
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
let countChange = function(money, coins) {
2+
if (coins.length === 0) {
3+
return 0;
4+
}
5+
6+
coins = coins.slice(0).sort();
7+
let result = 0,
8+
largestCoin = coins.pop(),
9+
maxCount = 0;
10+
let maxRemain = money % largestCoin;
11+
12+
if (maxRemain === 0) {
13+
result++;
14+
maxCount = money / largestCoin - 1;
15+
} else {
16+
maxCount = (money - maxRemain) / largestCoin;
17+
}
18+
19+
for (let i = maxCount; i >= 0; i--) {
20+
result += countChange(money - largestCoin * i, coins);
21+
}
22+
23+
return result;
24+
}

FANCY/problem.txt

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
Chef was reading some quotes by great people. Now, he is interested in classifying all the fancy quotes he knows. He thinks that all fancy quotes which contain the word "not" are Real Fancy; quotes that do not contain it are regularly fancy.
2+
3+
You are given some quotes. For each quote, you need to tell Chef if it is Real Fancy or just regularly fancy.
4+
5+
Input
6+
The first line of the input contains a single integer T denoting the number of test cases. The description of T test cases follows.
7+
The first and only line of each test case contains a single string S denoting a quote.
8+
9+
Output
10+
For each test case, print a single line containing the string "Real Fancy" or "regularly fancy" (without quotes).
11+
12+
Constraints
13+
1≤T≤50
14+
1≤|S|≤100
15+
each character of S is either a lowercase English letter or a space
16+
17+
Subtasks
18+
Subtask #1 (100 points): original constraints
19+
20+
Example Input
21+
2
22+
i do not have any fancy quotes
23+
when nothing goes right go left
24+
25+
Example Output
26+
Real Fancy
27+
regularly fancy
28+
29+
Explanation
30+
Example case 1: "i do not have any fancy quotes"
31+
32+
Example case 2: The word "not" does not appear in the given quote.

FANCY/solution.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
# cook your dish here
2+
x=int(input())
3+
p=0
4+
flag=0
5+
while(p<x):
6+
s=str(input())
7+
s=s.split(" ")
8+
for i in range(len(s)):
9+
if(s[i]=='not'):
10+
print("Real Fancy")
11+
flag=1
12+
break
13+
if(flag==0):
14+
print("regularly fancy")
15+
flag=0
16+
p=p+1

Fizz Buzz/dart_solution.dart

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
main() {
2+
for (int i = 1; i <= 100; i++) {
3+
if (i % 15 == 0) {
4+
print('fizzbuzz');
5+
} else if (i % 5 == 0) {
6+
print('buzz');
7+
} else if (i % 3 == 0) {
8+
print('fizz');
9+
} else {
10+
print(i);
11+
}
12+
}
13+
}

0 commit comments

Comments
 (0)