this post was submitted on 14 Apr 2024
328 points (94.1% liked)

linuxmemes

20453 readers
147 users here now

I use Arch btw


Sister communities:

Community rules

  1. Follow the site-wide rules and code of conduct
  2. Be civil
  3. Post Linux-related content
  4. No recent reposts

Please report posts and comments that break these rules!

founded 1 year ago
MODERATORS
 
you are viewing a single comment's thread
view the rest of the comments
[โ€“] [email protected] 29 points 4 months ago (1 children)

I would just write down the steps I would take, just some psudocode. It doesn't have to work, it just has to make sense in the style of the language you're talking about.

import random library  
import any GUI/display libraries required for the outcome desired

build array of integers [1..52] (or 0..51 if you're being fancy)
for loop 1..1000
       select random number A 1..52 (or 0..51 if you used that above)
       select random number B 1..52 (or 0..51 if you used that above)
       swap elements in the array A and B
pop first two elements from array
decode at display time what the two numbers represent in terms of playing cards

If the test requires more than that, then they're crazy. The syntax doesn't matter, just that you can logic yourself through the problem.
You can use the IDE, google, or whatever to fill in the specifics. If you wanted me to do that in literally any programming language, once the psudocode is done, you just spend an hour or so looking up the details.

[โ€“] [email protected] 10 points 4 months ago

If you wanted me to do that in literally any programming language, once the psudocode is done, you just spend an hour or so looking up the details.

In some cases, you can even use an AI chatbot as a "pseudocode compiler". Just tell it to translate your pseudocode to an actual language. I've done it for shell scripts a couple of times, works surprisingly well. Not that I would do this at a job interview haha.