Received a submission adjacent to this pseudocode in a PR yesterday from the guy we hired with a Comp. Sci. Master's Degree. FML.
πŸ‘︎ 565
πŸ’¬︎
πŸ‘€︎ u/Haimeh
πŸ“…︎ Oct 14 2021
🚨︎ report
Dynamic Programming for 0/1 Knapsack Pseudocode

looking for someone to help me continue my iterations in a question:

W=12

i) 1 2 3 4 Wi) 3 2 8 6 Vi) 2 4 3 5

im not sure how to continue after i find the V[i,w]=max{Vi+V[i-1,W-Wi] {V[i-1,W]

πŸ‘︎ 2
πŸ’¬︎
πŸ‘€︎ u/freckelsandhun
πŸ“…︎ Jan 19 2022
🚨︎ report
what programming language resembles pseudocode the most?

What programming language resembles pseudocode the most and has minimal complexity just like pseudocode?

πŸ‘︎ 5
πŸ’¬︎
πŸ‘€︎ u/backafterban2
πŸ“…︎ Jan 07 2022
🚨︎ report
[2021 day 19 part 2][pseudocode] speeding up computation from O(n^2) to O(n)

I noticed that most solutions in the day 19 megathread used an O(n^2) algorithm for determining the maximum Manhattan distance between any two scanners. Of course, this is perfectly fine - the bulk of your runtime is going to be spent on an O(n^2) (or worse) search during part 1 for which scanners overlap in order to compute the scanner coordinates in the first place, so not optimizing part 2 won't make any huge difference to your overall time. But if you are trying to squeeze out every last microsecond of computer time, this tutorial shows pseudocode of how to do it.

The naive approach visits every pair of points, to track a running maximum (that is, n*(n-1)/2 computations of Manhattan distance):

ans = 0
for s1 in scanners:
  for s2 in scanners:
    if s1 != s2:
      dist = abs(s1.x - s2.x) + abs(s1.y - s2.y) + abs(s1.z - s2.z)
      ans = max(ans, dist)

But if you think of abs(a - b) in terms of max(+(a - b), -(a - b)), we can rewrite the 3-D Manhattan distance as a maximum of 2^(3) sums:

dist = max(+ (s1.x - s2.x) + (s1.y - s2.y) + (s1.z - s2.z),
           + (s1.x - s2.x) + (s1.y - s2.y) - (s1.z - s2.z),
           + (s1.x - s2.x) - (s1.y - s2.y) + (s1.z - s2.z),
           + (s1.x - s2.x) - (s1.y - s2.y) - (s1.z - s2.z),
           - (s1.x - s2.x) + (s1.y - s2.y) + (s1.z - s2.z),
           - (s1.x - s2.x) + (s1.y - s2.y) - (s1.z - s2.z),
           - (s1.x - s2.x) - (s1.y - s2.y) + (s1.z - s2.z),
           - (s1.x - s2.x) - (s1.y - s2.y) - (s1.z - s2.z))

Then we can rearrange the terms in each summation, to group all the s1 contributions on the left and s2 contributions on the right:

dist = max(+ (s1.x + s1.y + s1.z) - (s2.x + s2.y + s2.z),
           + (s1.x + s1.y - s1.z) - (s2.x + s2.y - s2.z),
           + (s1.x - s1.y + s1.z) - (s2.x - s2.y + s2.z),
           + (s1.x - s1.y - s1.z) - (s2.x - s2.y - s2.z),
           - (s1.x - s1.y - s1.z) + (s2.x - s2.y - s2.z),
           - (s1.x - s1.y + s1.z) + (s2.x - s2.y + s2.z),
           - (s1.x + s1.y - s1.z) + (s2.x + s2.y - s2.z),
           - (s1.x + s1.y + s1.z) + (s2.x + s2.y + s2.z))

Next, we can observe that although we are computing the maximum of 8 computations, we can pair up those computations. For example, the first and eighth terms involve the same two quantities (the sum of all s1 components, and the sum of all s2 components); for a paired term, we will get a maximum if the s1 contr

... keep reading on reddit ➑

πŸ‘︎ 21
πŸ’¬︎
πŸ‘€︎ u/e_blake
πŸ“…︎ Jan 07 2022
🚨︎ report
What is the syntax to initialise an array in Pseudocode?

Is there a specific syntax I have to follow or can I just do

INPUT ArrayName[i]

?

Thanks!

πŸ‘︎ 3
πŸ’¬︎
πŸ‘€︎ u/Proman28610
πŸ“…︎ Jan 03 2022
🚨︎ report
CMV: Introductory computer programming teachers need to stop assigning Pseudocode problems.

I work online as a computer science tutor and I've been seeing a trend lately where students' first exposure to programming is not via Java or Python or any other real language, but rather via Pseudocode.

My students' first ever assignments remotely related to programming are typically to design various calculator programs in this Pseudocode. One example would be:

> Grade Calculator
>
> In this course you will have to complete a total of six tasks: three homework assignments altogether worth 40% of your grade, two mid-term exams each worth 15% of your grade, and one final exam worth 30% of your grade.
>   > Write a program which takes as input a student's name and the percent score he/she received (0-100 points) for each of these six tasks of the course. Calculate what this student's overall percentage grade is for the course, as well as the letter-grade he/she received (90-100 is an A, 80-89 is a B, 70-79 is a C, 60-69 is a D, and anything below 60 is an F). Finally, display as output the student's name, the percentage grade, and the letter grade that was calculated.

  • I haven't copied this example from anywhere. To avoid pointing blame at any particular school, I made up this assignment to be somewhat representative of what I see.

The problem is, these students have absolutely no concept of what "input" and "output" are, nor any concept of what variables are. They've never seen a console application before and so can't begin to imagine what this program would look like.

Sometimes, my students are terrible at math as well. Some of them don't even understand how percentages work (these are adult university students!), let alone how to calculate weighted averages, but that's another matter.

If this were an actual coding assignment, this would be no problem. I could introduce students to "Hello, world", how print() or System.out.println() can make a computer print out lines of text, how Python or Java understands math operations, exactly what variables are (which takes a lot more time to teach than you'd think!), and finally what it means for a program to be interactive & read input from you. This takes at least a full hour one-on-one to do properly, but it works well when students can see their programs do things.

By the end of my tutoring sessions on coding, even the.. ahem... "difficult" students at least have some idea as to how to proceed. They have something to work with.

With only Pseudocode though, ther

... keep reading on reddit ➑

πŸ‘︎ 15
πŸ’¬︎
πŸ‘€︎ u/Cybyss
πŸ“…︎ Nov 09 2021
🚨︎ report
Wanted to see how the latest Ghidra 10.0.3 and IDA Pro 7.5 compared when it came to their decompiler's pseudocode. I made a simple C++ console executable and threw it in each to see. reddit.com/gallery/qgbllg
πŸ‘︎ 53
πŸ’¬︎
πŸ‘€︎ u/Mr_Voltiac
πŸ“…︎ Oct 26 2021
🚨︎ report
Quick Structural Question with pseudocode

Just to be clear, I'm asking about structure here not syntax.

In this scenario there would be hundreds of villagers and dozens of professions to choose from. The idea would be that when you make this villager a farmer it sets Villager15Profession = Farmer

The function below with all the villagers loaded up with all these IF statements would run every second.

This seems simple, but very inefficient. Is there another way you'd structure how this is setup?

Just looking for big picture ideas here.

Villager15
If Villager15Profession = Lumberjack
	Wood  + Villager15LumberjackSkill 
	Villager15LumberjackSkill  + .01
	Villager15Exhaustion  + .1
If Villager15Profession = Stonecutter
	Stone + Villager15StonecutterSkill
	Villager15StonecutterSkill + .01
	Villager15Exhaustion  + .1
If Villager15Profession = Farmer
	Stone + Villager15FarmerSkill
	Villager15FarmerSkill + 0.01
	Villager15Exhaustion + 0.1
ELSE 
    Villager15Exhaustion - 0.2
πŸ‘︎ 5
πŸ’¬︎
πŸ‘€︎ u/Yangoose
πŸ“…︎ Dec 14 2021
🚨︎ report
Experiencing "code paralysis" with C. Can't translate pseudocode to actual code.

I'm a second year uni CS student and I am doing terribly in my course on Systems programming, which uses C for the functional assignments. I've read the FAQ and I realize my issue would be resolved if I just knew more C, but alas, I hit a glass wall. I want to know if this is a normal thing to experience, and how I can better solve this issue. I experience paralysis (inability to translate logic to actual code) with other languages too, but a lot less (I use mainly python and java).

I was doing alright when pointers were introduced, and when structures were introduced. But when combining everything, and having a multilayered approach with 10+ different .C files, I get overwhelmed.

For context, the task is to use dynamically allocated structures (or unions) and a singly linked list to simulate a printer (print jobs represented by nodes in a queue). There's obviously lots of small twists but that's the overall gist. I can implement the structures (that's not rocket science) and some of the basic pointer concepts, but I am completely lost when it comes to complex pointer manipulation, memory management, and getting all the separate functions to work together. This was the last assignment of the course, and plenty of hints were given. Pseudocode for the functions were given out for free, basically the whole program was given out, just in logical steps.

Again, is this a major red flag for my programming foundations? If so, is this something I can fix? For reference, I can solve a few leetcode mediums in java, so I don't think I'm completely lost, but my inability to adapt to C is a bit worrying.

Thanks and sorry if this isn't a good question.

πŸ‘︎ 23
πŸ’¬︎
πŸ‘€︎ u/zotorofan
πŸ“…︎ Dec 03 2021
🚨︎ report
[0478/22 COMPUTER SCIENCE] Can someone help me find the solution to this program in Visual Basic also the pseudocode will be appreciated. reddit.com/gallery/r8qriv
πŸ‘︎ 6
πŸ’¬︎
πŸ‘€︎ u/Soubhagya12
πŸ“…︎ Dec 04 2021
🚨︎ report
Any extensive resources like this? (Python compared to pseudocode)

Hi, recently I stumbled upon a Khan Academy article[1] that showed this interesting but very short table that compares how a concept is expressed in pseudocode with how it could be/is implemented with Python:

Concept Pseudocode Python
Assignment a ← expression a = expression
Equality a = b a == b
Inequality a β‰  b a != b
Repetition REPEAT n TIMES for i in range(n):
Repetition REPEAT UNTIL (condition) while condition:
List index list[1] is first item list[0] is first item

It looked quite useful to me (note that i'm a beginner in coding overall), beyond being just some refresher/reinforcement. I imagined all kinds of coding concepts being presented with a (hopefully) self-explanatory pseudocode example and a comprehensive Python implementation, ordered from simplest to most complex. Does something like this exist anywhere? Thanks.

πŸ‘︎ 2
πŸ’¬︎
πŸ“…︎ Dec 28 2021
🚨︎ report
Do programmers actually use Flowcharts/Pseudocode when planning a project?
πŸ‘︎ 245
πŸ’¬︎
πŸ‘€︎ u/vis2x
πŸ“…︎ Sep 01 2021
🚨︎ report
Suggested pseudocode to reverse this operation?

I have a bitwise operation which essentially extracts n bits from the t-th LSB in an unsigned int x of size 32 bits. It's pseudocode as follows :

extractBits (unsigned int x, int n, int t)
{ 
   unsigned int mask = ((1<<n)-1)<<t;
   final = x & mask;
}

I am now supposed to think of a function which is the reverse of this function. I cannot seem to come up with a pseudocode for such a function however. Any suggestions or help please? Thank you.

πŸ‘︎ 3
πŸ’¬︎
πŸ‘€︎ u/Averyn00
πŸ“…︎ Nov 11 2021
🚨︎ report
Hoe often is pseudocode used in the real world?

How often do you use pseudocode on your projects or at work? I have never actually learned how to use pseudocode, and wondering if it would help me make my programs easier to write. Is pseudocode really that helpful?

πŸ‘︎ 27
πŸ’¬︎
πŸ‘€︎ u/soggymuffinz
πŸ“…︎ Nov 04 2021
🚨︎ report
Pseudocode, does it have rules or can there be offsets from certain rules?

So we started learning algorithms and pseudocode for the algorithms but idk what pseudocode is it. In the lecture it's said its pascaloid-like but we are doing everything in C and C#. For instance we declare variables like:

x:integer

y:integer

...

for loops are weird they are written like.

for i=5;+1;10 so this in c would be for(i=5;i<10;i++) i think or its <=10 not sure.

Input and output are simple like:

input x

output y

What's this pseudocode and can I just write simple C language? It's weird, what if I can write it in an another way but the professor will not accept that way?

πŸ‘︎ 2
πŸ’¬︎
πŸ‘€︎ u/Ethereallie13
πŸ“…︎ Nov 16 2021
🚨︎ report
I am wondering what this even does. I have an assignment where J have to figure what this displays and I am clueless. This is supposed to be pseudocode btw.
πŸ‘︎ 29
πŸ’¬︎
πŸ‘€︎ u/benji_the_ginger
πŸ“…︎ Sep 24 2021
🚨︎ report
Computer science. Short algorithms questions. Pseudocode. NOW.

Looking for someone knowledgeable in algorithms and pseudo code. Vouches please. It’s due in 4 hrs. Short questions. DM me.

πŸ‘︎ 7
πŸ’¬︎
πŸ‘€︎ u/eguerr
πŸ“…︎ Nov 20 2021
🚨︎ report
SuperNoob - Is there a great source to grasp if, then and else? (Pseudocode)

Hi there.
I started school in web programming just over 2 weeks ago. Obviously still doing pseudocode. I'm having trouble with if, then and else.

I have a "paper" coming up Monday, for example. In our pseudocode, I can't determine whether the absence of "else" won't move onto the next "if". I don't even know if that's clear.

Any help would be appreciated. Thanks and cheers.

πŸ‘︎ 2
πŸ’¬︎
πŸ“…︎ Dec 03 2021
🚨︎ report
Here’s a simple pseudocode for the monkeys somehow developing this game to fix the car show bug

if game status == loading

for cars in garage

x = 0 // int going through the garage array assuming you’re using one

if (car(x).car show timer value == expired)

car(x).car show timer value = 0/whatever you use for available shit

car(x).car show is available = true

x = x + 1

else

x = x + 1

It’s a temporary fix but since you’re taking literal months (I doubt you’re trying) please just add something similar to this. It’s an absolute joke you’re getting paid for developing this game.

πŸ‘︎ 5
πŸ’¬︎
πŸ‘€︎ u/NepuNeptuneNep
πŸ“…︎ Oct 07 2021
🚨︎ report
Pseudocode release of the algo I live on
Get brokerage.Acct
If brokerage.Acct &gt;3m
Define buyingPower(0.25) == onePosition
If onePosition == &gt;0
then at_open(buy, onePosition == "SPY") 
    &amp;&amp; (buy, onePosition == "QQQ") 
    &amp;&amp; (buy, onePosition == "ARKK") 
    &amp;&amp; (buy, onePosition == "MO or DIAX or someOilStock")
Set sell.Conditions == null //because 
    //taxes; sell manually if you need to
If time is "December"
Then set sell.Conditions == TaxLossHarvest
Then in January GOTO "def buyingPower(0.25)"

Successfully initializing the brokerage.Acct subroutine so it doesn't fail on the if statement is the hardest part. The best way I know past it was to join FAANG or other Big Tech between 2014-2017 and not sell your RSUs until initializing this algo.

This account produces QQQ-like returns with smaller drawdowns, higher Sharpe and Sortinos, and a much higher cash yield of about 3%.

πŸ‘︎ 84
πŸ’¬︎
πŸ‘€︎ u/n00body333
πŸ“…︎ Aug 02 2021
🚨︎ report
Pseudocode In Exams (Compsci)

When answering algorithm questions, is there a specific syntax you must use when writing pseudocode? Do they accept syntax from different languages? I'm not very farmiliar with the IB psuedocode standard. For example, can I write a for loop this way:

>for (int i = 0; i < 10; i++) {
>
>print("hi");
>
>}

or this way:

>for i in range 10:
>
>print("hi")

or must I write it this way (ie IB psuedocode from answer key):

>loop for i from 0 to 10
>
>output "hi"
>
>end loop

πŸ‘︎ 5
πŸ’¬︎
πŸ‘€︎ u/tupiV
πŸ“…︎ Oct 26 2021
🚨︎ report
[College Programming Logic: Pseudocode] Did I do this right??πŸ˜… reddit.com/gallery/pe05co
πŸ‘︎ 20
πŸ’¬︎
πŸ‘€︎ u/Alousygod
πŸ“…︎ Aug 29 2021
🚨︎ report
Pseudocode for minimax with transposition table

Man, transposition tables are so complex for me. For my search program I've gotten the ab pruning and move ordering, which means that the only one left for me is the transposition table. I'm not exactly sure how to implement this, and I can't find any good resources for this. So, can someone please provide me pseudocode for minimax search with a transposition table? Thank you very much.

πŸ‘︎ 4
πŸ’¬︎
πŸ‘€︎ u/Kermanium294
πŸ“…︎ Oct 20 2021
🚨︎ report
do we need to learn structured english and pseudocode and flowcharts , or just one of them for computer science 9618 as level.
πŸ‘︎ 2
πŸ’¬︎
πŸ‘€︎ u/420koolaidman
πŸ“…︎ Oct 05 2021
🚨︎ report

Please note that this site uses cookies to personalise content and adverts, to provide social media features, and to analyse web traffic. Click here for more information.