Little Man Programming: Get Help Now

  • Thread starter Thread starter Matt3453
  • Start date Start date
  • Tags Tags
    Programming
Click For Summary

Discussion Overview

The discussion revolves around creating a Little Man program that accepts three user inputs and sorts them in order from largest to smallest. Participants are exploring programming concepts, specifically in the context of the Little Man Computer model, and are sharing code snippets and algorithms related to sorting.

Discussion Character

  • Exploratory
  • Technical explanation
  • Mathematical reasoning
  • Homework-related

Main Points Raised

  • One participant expresses a lack of knowledge about programming and seeks help to create a sorting program.
  • Another participant asks for clarification on the programming language, operating system, and resources being used.
  • A participant shares a code snippet that appears to find the largest number but questions how to modify it for sorting.
  • Several participants suggest a comparison-based approach to sorting, discussing how to exchange values to position the largest and smallest numbers correctly.
  • One participant shares a more detailed code snippet, indicating they have found the largest number and are now focused on sorting the remaining two.
  • A participant humorously comments on the completeness of the solution provided, suggesting it may inhibit the original poster's (OP's) independent thinking.
  • Another participant questions whether the previous solutions are flawed and seeks clarification on the term "OP."
  • One participant suggests looking into the "Bubble Sort" algorithm as a potential method for sorting the numbers.

Areas of Agreement / Disagreement

Participants are generally engaged in a collaborative exploration of programming techniques, but there is no consensus on a single solution or approach to the problem. Multiple methods for sorting are discussed, and some participants express uncertainty about the correctness of the proposed solutions.

Contextual Notes

Some code snippets provided may contain unresolved logical or syntactical issues, and there are references to specific algorithms that participants are encouraged to explore further. The discussion reflects varying levels of understanding and experience with programming concepts.

Who May Find This Useful

This discussion may be useful for individuals learning programming, particularly those interested in sorting algorithms and the Little Man Computer model.

Matt3453
Messages
5
Reaction score
0
Hello everyone,

New to the forums and I really need some help. I'm trying to create a little man program that would accept any three user inputs and return them in order from largest to smallest. I really have no clue where to start since I'm completely new to programming. Please help..
 
Physics news on Phys.org
Matt3453 said:
Hello everyone,

New to the forums and I really need some help. I'm trying to create a little man program that would accept any three user inputs and return them in order from largest to smallest. I really have no clue where to start since I'm completely new to programming. Please help..

Welcome to the PF. What language are you programming in? What OS and GUI and development system are you using? What is your textbook or online reference to the language?

We don't do your schoolwork for you here at the PF, but we can offer you some tutorial hints and questions to get you going.
 
Its Little Man and the textbook is by Englander, Computer Hardware and Systems Software. From what I understand, this is how to find the largest, but how does one go about modifying it to find them in order
00 : 901
01 : 397
02 : 901
03 : 398
04 : 901
05 : 399
06 : 297
07 : 810
08 : 597
09 : 611
10 : 599
11 : 298
12 : 815
13 : 598
14 : 616
15 : 599
16 : 902
17 : 000
97 : 000 DATA
98 : 000 DATA
99 : 000 DATA
 
Compare first with the second - if first is larger, exchange them. Compare second with third - if second is larger, exchange them. Not all are sorted yet, but at least the largest is in its final position...
 
Borek said:
Compare first with the second - if first is larger, exchange them. Compare second with third - if second is larger, exchange them. Not all are sorted yet, but at least the largest is in its final position...
Then compare the first with the second. If the second is smaller, exchange with the first. That should leave you with the smallest in the first position and the largest in the third position. The one whose value is between the smallest and largest is in the middle.
 
Does this seem right?

00 INP 901
01 STO 97 397
02 INP 901
03 STO 98 398
04 INP 901
05 STO 99 399
06 SUB 97 297
07 BRP 810
08 LDA 97 597
09 BR 611
10 LDA 99 599
11 SUB 98 298
12 BRP 815
13 LDA 98 598
14 BR 616
15 LDA 99 599
16 OUT 902 - Output as largest
17 LDA 98 398
18 SUB 97 297
19 BRP 826
20 LDA 97 597
21 BR 622
22 LDA 97 597
23 OUT 902 - Output as second largest
24 LDA 98 598
25 OUT 902 - Output as smallest
26 LDA 98 598
27 OUT 902 - Output as second largest
28 LDA 597
29 OUT 902 - Output as smallest30 LDA 98 598
31 SUB 99 299
32 BRP 839
33 LDA 99 599
34 BR 635
35 LDA 99 599
36 OUT 902 - Output as second largest
37 LDA 98 598
38 OUT 902 - Output as smallest
39 LDA 98 598
40 OUT 902 - Output as second largest
41 LDA 99 599
42 OUT 902 - Output as smallest
43 HLT 000

99 DAT 000
98 DAT 000
97 DAT 000

99 DAT 000
97 DAT 000
98 DAT 000
I already found the largest number, so all I have to do is sort the last two numbers.
 
Ah, there is nothing like to solve the question to the end, not leaving place for the OP to think on her/his own :-p
 
So, I don't understand? It's flawed somewhere? What's OP mean?
 
00 inp 901
01 sto 90 390
02 inp 901
03 sto 91 392
04 inp 901
05 sto 93 393
06 lda 90 590
07 sub 91 291
08 brp 812
09 lda 91 391
10 out 902
11 br 614
12 lda 90 390
13 out 902
14 lda 91 591
15 sub 92 292
16 brp 820
17 lda 92 392
18 out 902
19 br 622
20 lda 91 391
21 out 902
22 lda 90 590
23 sub 91 291
24 brp 829
25 lda 90 591
28 out 902
29 lda 91 590
30 out 902
31 hlt 000
 
  • #10
OP means Original Poster, that's you.
 
  • #11
Look for information in your book on "Bubble Sort". Find the algorithm described and compare this to the flow chart which your book should show.
 

Similar threads

  • · Replies 7 ·
Replies
7
Views
3K
  • · Replies 5 ·
Replies
5
Views
5K
  • · Replies 1 ·
Replies
1
Views
2K
  • · Replies 3 ·
Replies
3
Views
2K
  • · Replies 9 ·
Replies
9
Views
4K
  • · Replies 12 ·
Replies
12
Views
2K
  • · Replies 2 ·
Replies
2
Views
2K
Replies
6
Views
4K
Replies
9
Views
2K
  • · Replies 21 ·
Replies
21
Views
4K