From 3f162287bb4e6d35c37f2808b89725c567225eca Mon Sep 17 00:00:00 2001 From: Hariiikrishnan Date: Sat, 14 Oct 2023 23:48:39 +0530 Subject: [PATCH 1/2] Friendship Percent Level Calculator --- FriendshipCalculator/algo.html | 35 +++++ FriendshipCalculator/globalStyles.css | 167 +++++++++++++++++++++++ FriendshipCalculator/index.html | 58 ++++++++ FriendshipCalculator/index.js | 183 ++++++++++++++++++++++++++ 4 files changed, 443 insertions(+) create mode 100644 FriendshipCalculator/algo.html create mode 100644 FriendshipCalculator/globalStyles.css create mode 100644 FriendshipCalculator/index.html create mode 100644 FriendshipCalculator/index.js diff --git a/FriendshipCalculator/algo.html b/FriendshipCalculator/algo.html new file mode 100644 index 000000000..7b51dcab2 --- /dev/null +++ b/FriendshipCalculator/algo.html @@ -0,0 +1,35 @@ + + + + + + Document + + + + + + + + + + +
+
+

How it Works ?

+

The Algorithm behind it!

+
    +
  • Write your and your friend's name and strike out the similar alphabets. For Eg:"Jack" , "Jane".
  • +
  • Store the count of similar alphabets sequentially. For Eg: alphabets:['J','J','a','a'], Sequence:[2,2]
  • +
  • Count the unique alphabets and store them in the same sequence as before. For Eg:alphabets:['c','k','n','e'], Sequence:[2,2,1,1,1,1]
  • +
  • Now add the first and last values from the sequence and store it. For Eg: 2+1 = 3
  • +
  • Now do the same for the 2nd character from the beginning and from the end in reverse. For Eg: 3 + ( 2 + 1).
  • +
  • Continue doing the same process until the sequence reaches its end. If the sequence length is odd, add the final value.
  • +
  • Now calculate the total count of the similar characters that we struck out earlier. For Eg:['J','a'] = 2
  • +
  • Multiply that count with the answer we calculated earlier by adding the sequence values.
  • +
+ Try it out +
+
+ + \ No newline at end of file diff --git a/FriendshipCalculator/globalStyles.css b/FriendshipCalculator/globalStyles.css new file mode 100644 index 000000000..41c032fc6 --- /dev/null +++ b/FriendshipCalculator/globalStyles.css @@ -0,0 +1,167 @@ +* { + margin: 0; + padding: 0; + text-align: center; + font-family: 'Tilt Neon', sans-serif; +} + +a{ + text-decoration: none; +} +section { + /* padding: 30px; */ + height: 100vh; + width: 100%; + display: flex; + flex-direction: column; + justify-content: space-evenly; + align-items: center; + background: #f2709c; + color: white; + /* fallback for old browsers */ + background: -webkit-linear-gradient(to right, #ff9472, #f2709c); + /* Chrome 10-25, Safari 5.1-6 */ + background: linear-gradient(to right, #ff9472, #f2709c); + /* W3C, IE 10+/ Edge, Firefox 16+, Chrome 26+, Opera 12+, Safari 7+ */ + +} + +section .header { + padding: 20px; +} + +.form { + justify-content: space-evenly; + height: 70vh; +} + +.form, +.header { + display: flex; + /* justify-content: center; */ + flex-direction: column; + align-items: center; +} + +.form, +.header h5 { + font-size: 1.5rem; + margin: 10px; + width: 70%; +} + +section .form h1 { + font-size: 2.8rem; +} + +.inputs { + width: 70%; + display: flex; + justify-content: space-evenly; + flex-wrap: wrap; +} + +.inputs input { + margin: 5px; + font-size: 1.5rem; + font-weight: 700; + border: none; + color: white; + padding: 20px 40px; + border-radius: 6px; + background-color: rgb(255 255 255 / 42%); + /* background-color: #f2709c; */ + box-shadow: 3px 3px 100px 5px rgb(222 175 255); + transition: transform 0.1s linear; + /* box-shadow: 3px 3px 100px 15px rgb(255 255 255); */ +} +.inputs input:focus-visible{ + outline: solid white 2px; + transform: scale(1.1); +} +.inputs input::placeholder { + color: white; + font-weight: 500; +} + +button.pre-animation { + opacity: 0; + max-height: 0; +} + +button { + /* transition: all 1s; */ + max-height: 300px; + + padding: 10px; + width: 200px; + border-radius: 10px; + font-size: 1.5rem; + font-weight: 900; + border: solid 3px #f2709c; + transition: all 0.3s linear; +} +button:hover{ + background-color: #f2709c; + color: white; + border: solid 2px white; +} +.show { + visibility: visible !important; + /* display: inline!important; */ +} +.footer{ + display: flex; + justify-content: center; + align-items: center; +} +.footer a,.footer p{ + color: white; + margin:5px; + font-size: 1.1rem; +} +.footer p a{ + color: rgb(71, 71, 255); + font-weight: 700; +} +ul li{ + text-align: left; +} +.algo{ + padding: 30px; + height: 100vh; + display: flex; + flex-direction: column; + align-items: center; + justify-content: space-evenly; + +} +.algo ul li{ + font-size: 1.2rem; +} +.algo .btn{ + background-color: #f2709c; + border: solid white 1px; + padding: 10px; + width: 100px; + border-radius: 4px; + transition: all 0.1s linear; + color:white; +} +.algo .btn:hover{ + background-color: #d03f6f; + color: rgba(255, 255, 255, 0.744); +} + +@media (min-width:320px) and (max-width:680px){ + .form, +.header h5 { + font-size: 1.3rem; + /* margin: 10px; */ + width: 100%; +} +.inputs input { + padding: 10px 15px; + font-size: 1.2rem; +} +} \ No newline at end of file diff --git a/FriendshipCalculator/index.html b/FriendshipCalculator/index.html new file mode 100644 index 000000000..23bcc4085 --- /dev/null +++ b/FriendshipCalculator/index.html @@ -0,0 +1,58 @@ + + + + + + + Friendship % Calculator + + + + + + + + + + + + +
+
+
+

+ Friendship Calci +

+
It's all about my School days Friendship % Calculator which we used to kill time.. Sooo NOSTALGIC ! +
+
+ +

Let's Play Yours!

+
+ + +
+ + + + + + +
+
+ + + + + + \ No newline at end of file diff --git a/FriendshipCalculator/index.js b/FriendshipCalculator/index.js new file mode 100644 index 000000000..768279b0f --- /dev/null +++ b/FriendshipCalculator/index.js @@ -0,0 +1,183 @@ + + + + + + +function calculate(){ + + +var name = document.getElementById("name1").value.toLowerCase(); +var name2 = document.getElementById("name2").value.toLowerCase(); +console.log(name); + +// let name = "hari".toLowerCase(); +// let name2 = "naruto".toLowerCase(); + + + +let array = name.split(""); +array.push(...name2.split("")); +console.log(array); +let finalLetters = []; +let equaledchar = { + value : [], + index : [], +} +let scoreSequence = []; +let ansSequence =[]; +let ans = 0 ; + + +for(i=0;i + equaledchar.index.indexOf(item) === index); + +console.log(finalLetters); +console.log(equaledchar); +console.log(equaledchar.index); + +// equaledchar.index.sort(); +equaledchar.index.sort(function(a, b){return a - b}); +console.log(equaledchar.index); + +for(i=0;i 100){ + ans=100; + }else{ + // console.log(((sequence.length)/2)); + if( (sequence.length % 2) === 0 ){ + if(i<= ((sequence.length-1)/2)){ + + ansSequence.push(sequence[i] + (sequence[(sequence.length-1) - i] )); + // console.log((sequence[i]) + (sequence[(sequence.length-1) - i] )); + ans += (sequence[i]) + (sequence[(sequence.length-1) - i] ); + } + }else{ + + if(i=== Math.round(((sequence.length- 1 )/2))) + { + // console.log(sequence[Math.round((sequence.length/2))]); + ansSequence.push(sequence[Math.round((sequence.length/2))]); + // console.log(ansSequence); + ans += sequence[Math.round((sequence.length/2))]; + // console.log(sequence[Math.round((sequence.length/2))]); + // console.log("%th e") + }else{ + // console.log("here"); + + // console.log(sequence[i] + (sequence[(sequence.length-1) - i] )); + ansSequence.push(sequence[i] + (sequence[(sequence.length-1) - i] )); + ans += (sequence[i]) + (sequence[(sequence.length-1) - i] ); + + + + } + + + + } + + + } +} + + ansSequence.splice(0,ansSequence.length/2); + + console.log(ansSequence.length) + + // console.log(Math.round(((sequence.length- 1 )/2))); +} + + +console.log(ansSequence); +const noOfRepeaters = Math.round((equaledchar.index.length-1)/2); +console.log(noOfRepeaters); +console.log(ans); +console.log(ans*noOfRepeaters); + +var resultTag = document.getElementsByClassName("result")[0]; +var resultBtn = document.getElementsByClassName("btn")[0]; +console.log(resultTag) +resultTag.classList.add("show"); +resultBtn.classList.add('pre-animation'); +if(ans*noOfRepeaters === 0){ + resultBtn.innerHTML = "Oops!"; +} +else if(ans*noOfRepeaters < 100){ + resultBtn.innerHTML = ans*noOfRepeaters + "%"; +}else{ + resultBtn.innerHTML = 100 + "%"; + console.log("Perusu") +} + +setTimeout(function(){ + resultBtn.classList.remove('pre-animation'); +},100) +} +// Steps +// 1. Count the total characters in the two string. +// 2. Store the individual characters in an array. +// 3. Count the repeated characters in the array. +// 4. Store the repeated characters reoeat values in a seperate array. +// 5. + From d5c720a3f2aa65eaf0d750c4d871ea4bb710eed9 Mon Sep 17 00:00:00 2001 From: Hariiikrishnan Date: Mon, 16 Oct 2023 20:35:01 +0530 Subject: [PATCH 2/2] changed the directory issue --- FriendshipCalculator/{ => Hariiikrishnan}/algo.html | 0 FriendshipCalculator/{ => Hariiikrishnan}/globalStyles.css | 0 FriendshipCalculator/{ => Hariiikrishnan}/index.html | 0 FriendshipCalculator/{ => Hariiikrishnan}/index.js | 0 4 files changed, 0 insertions(+), 0 deletions(-) rename FriendshipCalculator/{ => Hariiikrishnan}/algo.html (100%) rename FriendshipCalculator/{ => Hariiikrishnan}/globalStyles.css (100%) rename FriendshipCalculator/{ => Hariiikrishnan}/index.html (100%) rename FriendshipCalculator/{ => Hariiikrishnan}/index.js (100%) diff --git a/FriendshipCalculator/algo.html b/FriendshipCalculator/Hariiikrishnan/algo.html similarity index 100% rename from FriendshipCalculator/algo.html rename to FriendshipCalculator/Hariiikrishnan/algo.html diff --git a/FriendshipCalculator/globalStyles.css b/FriendshipCalculator/Hariiikrishnan/globalStyles.css similarity index 100% rename from FriendshipCalculator/globalStyles.css rename to FriendshipCalculator/Hariiikrishnan/globalStyles.css diff --git a/FriendshipCalculator/index.html b/FriendshipCalculator/Hariiikrishnan/index.html similarity index 100% rename from FriendshipCalculator/index.html rename to FriendshipCalculator/Hariiikrishnan/index.html diff --git a/FriendshipCalculator/index.js b/FriendshipCalculator/Hariiikrishnan/index.js similarity index 100% rename from FriendshipCalculator/index.js rename to FriendshipCalculator/Hariiikrishnan/index.js