₦airaland Forum

Welcome, Guest: RegisterLoginWith GoogleTrendingRecentNew

Stats: 3,325,035 members, 8,420,011 topics. Date: Thursday, 04 June 2026 at 09:26 AM

Toggle theme

JFOD's Posts

Nairaland ForumJFOD's ProfileJFOD's Posts

1 2 3 4 5 6 7 8 9 10 (of 14 pages)

ProgrammingRe: Thread For Nairaland Algorithm Questions by JFOD: 1:21am On Jan 20, 2021
Brukx:
Almost complete but the main function is accepting arguments outside 4 and 7
Yes, it is . However it's not going to do anything

Maybe I don't really understand, what should happen if something other than 4 or 7 is passed?
ProgrammingRe: Thread For Nairaland Algorithm Questions by JFOD: 12:39am On Jan 20, 2021
Brukx:
I'm seeing 3 functions here. Where is the main function ? I'm also not seeing any point where user input is requested.
user_input = input()

paired_num = {'7':4, '4':7}
#checks if the number is 7, returns True if it is
def is_7(y):
return '7'==y

def is_4(y):
return '4'==y

def main_func(x):
seven = is_7(x)
four = is_4(x)
while seven or four:
return paired_num[x]
break

print(main_func(user_input))

Note: I worked with strings because python takes user input as strings and I don't want to do type conversion cox that will break it if a non digit character is passed.

What do you think? Good enough?

Modified

I skipped the user input part in the first post because I felt it wasn't necessary
ProgrammingRe: Thread For Nairaland Algorithm Questions by JFOD:
Brukx:
Lemme just drop this here

Question
Write a function that takes user input. The input must be either 7 or 4. If the input is 4, the function should return 7. If the input is 7, the function should return 4. Do not use if or else statements. Do not use exceptions.
Create a dictionary/object
Use 7 as a key and 4 has a value (vice versa)
Create a function that will take one argument
Return the dictionary index using the argument that was passed.

Python implementation

Unamed_variable= {7:4,4:7}

def dont_use_if(x):
return Unamed_variable[x]

This should work

Modified:

Some measures are not put in place
Example: it should only accept either 4 or 7

While loop comes to mind but I feel that's not a good idea.

def is_7(y):
return y == 7


def is_4(y):
return y == 4

Then add this to the first function

a = is_7(x)
b = is_4(x)

while a or b:
return unamed_variabele[x]
break

This should work fine
ProgrammingRe: Javascript by JFOD: 8:35am On Jan 16, 2021
manando1:
Hi can someone please help me with JavaScript that do the following , For Example: If User clicked the button one time, the value should increase from 0 to 1 and then if clicked again, then the value should be 1 to 2. And the greatest amount of numbers be placed on top of the table automatically . My current code isn't functioning accordingly

Thanks
I can really explain well due to my little knowledge on the subject matter.

Create a function that increments a counter whenever it's called and couple it with the onclick stuff.

Is the table on the webpage?

If yes, you can look up how to display variables on web pages (template engines (ejs and co I think).

There might be a simple/other way to go about this.
ProgrammingRe: People Are Fraustrating Here On Nairaland by JFOD: 8:08pm On Jan 15, 2021
cixak95211:
@JFOD You're kinda correct, yea.
So I basically asked him to find similarities between "sentences' and not "individual words". Thus, it accounts that you need to give consideration to punctuation marks and spaces, typical of a complete English language expression. Its an approximate 78%. or 77.777777777% if you want to be precise.
Have been very busy with work and unable to read a post for more than 2 mins.
Saw the algo, very impressive although you can instantly tell it's not so efficient.
Is it possible for you share more problems like this?

And if I may ask, do you work in Tech?

I'll like to connect, I feel I can learn a lot from you
ProgrammingRe: People Are Fraustrating Here On Nairaland by JFOD: 7:57pm On Jan 15, 2021
SapphireYj:
I quickly put the code together,but idealy,if I had the time,I would have tested the code more. I disagree regarding the space,it is important.One of the sentences had 3 spaces while the other had four. I agree with you on the dot,however,implementing regex for searching for punctuations like . , ; : ? etc and comparing them between sentences will require me to write a lot more code than i was willing to. My main target was to compare only the words provided, and since those words have a fullstop each, i didn't see the need to write code to handle them since they cancel each other out.If the spaces are the same,i wouldn't have bothered implementing code for handling spaces.
Alright, do you use JS in your job? Or it's a side thing ? If I may ask

If yes, What's the role?
ProgrammingRe: Why The Error? by JFOD: 10:29am On Jan 15, 2021
Tarvel:
Sorry, I just spotted my mistake, there's a parenthesis before 'car brand: '

I've been on this for almost 2 days.
Out of curiosity

Why are you adding two list together?

Is there a reason why you're not using the "Append" method?
ProgrammingRe: People Are Fraustrating Here On Nairaland by JFOD:
SapphireYj:
I got 76%. My code is below:

const findsimilar = (str,str1)=>{
if(str.length<str1.length){
let placeHolder = str
str = str1
str1 = placeHolder
}
const sp = str.match(/\s/g).length
const sp1 = str1.match(/\s/g).length
const spaceSimilarity = sp1/sp
if(str.includes(str1)){
const arr = str.split(' ')
const arr1 = str1.split(' ')
const wordCount = arr.join('').length
const unsimilarVals = arr.reduce((acc,val,i)=>{
if(arr1.includes(val)){
arr1.splice(i,1,'')
return acc + ''

}
else{
return acc + val
}
},'')

const wordSimilarity = (wordCount - unsimilarVals.length)/wordCount
const similarity = ((spaceSimilarity + wordSimilarity)/2).toFixed(2)
return `${similarity*100}%`
}
else{
return '0%'
}
}
console.log(findsimilar('You still never blow reach','You still never blow'))

I just quickly put this together for fun.I didnt use internet or stack overflow.It will be interesting to see your implementation and how you got 78%.Thanks.
Hello SapphireYj, can you explain this if you don't mind

How to find similarities between two sentences

Thank you

EDITED

(3/4 + 22-5/22 ) / 2 = 0.76

It took me a while to understand because it's in JS. Your code doesn't work well (it returns 0) if the '.' is added and if one should pass different things (it breaks sometimes).

I think the dot is important and the space won't be considered. That will give us

A total of 23 characters and an unsimilar/extra characters of 5 , if I'm to go by your calculation

23- 5/ 23 = 0.78 appr.

404Dev ,cixak95211 is this correct?

If no, what's the correct answer?
ProgrammingRe: Bulk Ethereum For Sale! 400naira/$ by JFOD: 7:18pm On Jan 09, 2021
OP don't vex oo

This looks fishy , the price is too low for someone that wants to sell bulk.

I'm not saying anything, I'm just saying it doesn't feel right.

I am not calling you a ripper

1 2 3 4 5 6 7 8 9 10 (of 14 pages)