Need help writing an Algorithm for an ocr challenge? (A lvl Computer Science)

Watch
Csman123
Badges: 0
Rep:
?
#1
Report Thread starter 4 years ago
#1
Hi,

I am having problem writing a pseudocode for a challenge question on the OCR challenges document.

Question Below!!!!

""" A thief has managed to find out the four digits for an online PIN code, but doesn’t know the correct sequence needed to hack into the account. Design and write a program that displays all the possible combinations for any four numerical digits entered by the user. The program should avoid displaying the same combination more than once.

"""

Any helps appreciated. Thanks.
0
reply
Kevin De Bruyne
Badges: 21
Rep:
?
#2
Report 4 years ago
#2
(Original post by Csman123)
Hi,

I am having problem writing a pseudocode for a challenge question on the OCR challenges document.

Question Below!!!!

""" A thief has managed to find out the four digits for an online PIN code, but doesn’t know the correct sequence needed to hack into the account. Design and write a program that displays all the possible combinations for any four numerical digits entered by the user. The program should avoid displaying the same combination more than once.

"""

Any helps appreciated. Thanks.
Input a,b,c,d which are not necessarily unique.

Generate all the combinations and sort them in order..


<rest for you to work out>

Good luck
0
reply
Csman123
Badges: 0
Rep:
?
#3
Report Thread starter 4 years ago
#3
(Original post by Kevin De Bruyne)
Input a,b,c,d which are not necessarily unique.

Generate all the combinations and sort them in order..


<rest for you to work out>

Good luck
That would only give the lowest to highest and highest to lowest. I also want other possible combinations.

For example: if i had to find the possible combinations of 4537. If i apply your method i will only get 4357 and 3457.
0
reply
Kevin De Bruyne
Badges: 21
Rep:
?
#4
Report 4 years ago
#4
(Original post by Csman123)
That would only give the lowest to highest and highest to lowest. I also want other possible combinations.

For example: if i had to find the possible combinations of 4537. If i apply your method i will only get 4357 and 3457.
Note that I did not give a complete method but with what I've given, I disagree with what you've said - I included a line that says 'generate all combinations'
0
reply
Csman123
Badges: 0
Rep:
?
#5
Report Thread starter 4 years ago
#5
(Original post by Kevin De Bruyne)
Note that I did not give a complete method but with what I've given, I disagree with what you've said - I included a line that says 'generate all combinations'
I would be so grateful, if you can write me an understandable pesudocode.

Thanks.
0
reply
Kevin De Bruyne
Badges: 21
Rep:
?
#6
Report 4 years ago
#6
(Original post by Csman123)
I would be so grateful, if you can write me an understandable pesudocode.

Thanks.
Then you would not be able to reproduce one in the exam.

I've given you a conceptual start (kind of in pseudocode.. pretty much..) and you understand that, from what I have written, there are all the possible combinations of the 4 numbers sorted in order and now you just need to finish it off...

Happy to answer any questions but not prepared to do any work for you - it's against the ethos of the study help forum and also not good for your own learning.
2
reply
Csman123
Badges: 0
Rep:
?
#7
Report Thread starter 4 years ago
#7
(Original post by Kevin De Bruyne)
Then you would not be able to reproduce one in the exam.

I've given you a conceptual start (kind of in pseudocode.. pretty much..) and you understand that, from what I have written, there are all the possible combinations of the 4 numbers sorted in order and now you just need to finish it off...

Happy to answer any questions but not prepared to do any work for you - it's against the ethos of the study help forum and also not good for your own learning.
Thanks for your reply. Using inbuilt functions in VB. Net I have managed to create a program that works fine. However I am not sure how to write that into pseudocode. Can I state in the pesudocode that I've made use of inbuilt functions, and is that allowed?

Thanks.
0
reply
JickDee
Badges: 13
Rep:
?
#8
Report 4 years ago
#8
you could use a recursive algorithm that takes an input array (called arr) containing the digits and an optional input string called s.

rough pseudocode for the algorithm
display(arr, s):
if arr is empty:
print(s)

else:
for i in arr:
display(arr with i removed, s+i)


you could also use dynamic programming (memoisation) to make this more efficient
1
reply
X

Quick Reply

Attached files
Write a reply...
Reply
new posts
Back
to top
Latest
My Feed

See more of what you like on
The Student Room

You can personalise what you see on TSR. Tell us a little about yourself to get started.

Personalise

Who is winning Euro 2020

France (85)
26.15%
England (109)
33.54%
Belgium (27)
8.31%
Germany (38)
11.69%
Spain (6)
1.85%
Italy (32)
9.85%
Netherlands (10)
3.08%
Other (Tell us who) (18)
5.54%

Watched Threads

View All
Latest
My Feed