Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Assignment solution #3

Open
wants to merge 11 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
48 changes: 48 additions & 0 deletions Match 02/submissions/yashvardhan.singhsomvanshi.min.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
function uniq(str,n){
var index = 0;
for (var i = 0; i < n; i++){ var j;
for (j = 0; j < i; j++){if (str[i] == str[j])
{break;}
}
if (j == i)
{ str[index++] = str[i];}
}
return str.join("").slice(str, index);}
var str = ` when i find myself in times of trouble
mother mary comes to me
speaking words of wisdom, let it be
and in my hour of darkness
she is standing right in front of me
speaking words of wisdom, let it be
let it be, let it be
let it be, let it be
whisper words of wisdom, let it be
and when the broken-hearted people
living in the world agree
there will be an answer, let it be
for though they may be parted
there is still a chance that they will see
there will be an answer, let it be
let it be, let it be
let it be, let it be
yeah, there will be an answer, let it be
let it be, let it be
let it be, let it be
whisper words of wisdom, let it be
let it be, let it be
ah, let it be, yeah, let it be
whisper words of wisdom, let it be
and when the night is cloudy
there is still a light that shines on me
shine on until tomorrow, let it be
i wake up to the sound of music,
mother mary comes to me
speaking words of wisdom, let it be
let it be, let it be
let it be, yeah, let it be
oh, there will be an answer, let it be
let it be, let it be
let it be, yeah, let it be
whisper words of wisdom, let it be`.split(" ");
var n = str.length;
document.write(uniq(str, n));
8 changes: 8 additions & 0 deletions Match 03/submissions/yashvardhan.singhsomvanshi.min.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
const sort_string=(word)=>(word.split("").sort((i,j)=>i.charCodeAt()-j.charCodeAt())).join();
function check(word)
{
for(const letter of word)
{if(letter.toUpperCase().charCodeAt()<65 || letter.toUpperCase().charCodeAt()>90)
{ return false;}}
return true;}
const solution=(a, b)=> (check(a) && check(b))?sort_string(a)==sort_string(b):false;