• Log InLog In
  • Register
Liquid`
Team Liquid Liquipedia
EDT 18:10
CEST 00:10
KST 07:10
  • Home
  • Forum
  • Calendar
  • Streams
  • Liquipedia
  • Features
  • Store
  • EPT
  • TL+
  • StarCraft 2
  • Brood War
  • Smash
  • Heroes
  • Counter-Strike
  • Overwatch
  • Liquibet
  • Fantasy StarCraft
  • TLPD
  • StarCraft 2
  • Brood War
  • Blogs
Forum Sidebar
Events/Features
News
Featured News
[ASL21] Ro24 Preview Pt2: News Flash10[ASL21] Ro24 Preview Pt1: New Chaos0Team Liquid Map Contest #22 - Presented by Monster Energy18ByuL: The Forgotten Master of ZvT30Behind the Blue - Team Liquid History Book20
Community News
GSL CK: More events planned pending crowdfunding0Weekly Cups (May 30-Apr 5): herO, Clem, SHIN win0[BSL22] RO32 Group Stage3Weekly Cups (March 23-29): herO takes triple6Aligulac acquired by REPLAYMAN.com/Stego Research8
StarCraft 2
General
Weekly Cups (May 30-Apr 5): herO, Clem, SHIN win Rongyi Cup S3 - Preview & Info Team Liquid Map Contest #22 - Presented by Monster Energy Blizzard Classic Cup @ BlizzCon 2026 - $100k prize pool What mix of new & old maps do you want in the next ladder pool? (SC2)
Tourneys
$5,000 WardiTV TLMC tournament - Presented by Monster Energy GSL CK: More events planned pending crowdfunding Sparkling Tuna Cup - Weekly Open Tournament RSL Season 4 announced for March-April StarCraft Evolution League (SC Evo Biweekly)
Strategy
Custom Maps
[M] (2) Frigid Storage Publishing has been re-enabled! [Feb 24th 2026]
External Content
The PondCast: SC2 News & Results Mutation # 520 Moving Fees Mutation # 519 Inner Power Mutation # 518 Radiation Zone
Brood War
General
ASL21 General Discussion Pros React To: JaeDong vs Queen [BSL22] RO32 Group Stage so ive been playing broodwar for a week straight. Gypsy to Korea
Tourneys
[Megathread] Daily Proleagues [ASL21] Ro24 Group F Escore Tournament StarCraft Season 2 [ASL21] Ro24 Group E
Strategy
What's the deal with APM & what's its true value Fighting Spirit mining rates Simple Questions, Simple Answers
Other Games
General Games
Nintendo Switch Thread Stormgate/Frost Giant Megathread Starcraft Tabletop Miniature Game General RTS Discussion Thread Darkest Dungeon
Dota 2
The Story of Wings Gaming Official 'what is Dota anymore' discussion
League of Legends
G2 just beat GenG in First stand
Heroes of the Storm
Simple Questions, Simple Answers Heroes of the Storm 2.0
Hearthstone
Deck construction bug Heroes of StarCraft mini-set
TL Mafia
Mafia Game Mode Feedback/Ideas TL Mafia Community Thread Five o'clock TL Mafia
Community
General
US Politics Mega-thread The Chess Thread Russo-Ukrainian War Thread NASA and the Private Sector Things Aren’t Peaceful in Palestine
Fan Clubs
The IdrA Fan Club
Media & Entertainment
[Manga] One Piece [Req][Books] Good Fantasy/SciFi books Movie Discussion!
Sports
2024 - 2026 Football Thread Formula 1 Discussion Cricket [SPORT] Tokyo Olympics 2021 Thread General nutrition recommendations
World Cup 2022
Tech Support
[G] How to Block Livestream Ads
TL Community
The Automated Ban List
Blogs
Loot Boxes—Emotions, And Why…
TrAiDoS
Broowar part 2
qwaykee
Funny Nicknames
LUCKY_NOOB
Iranian anarchists: organize…
XenOsky
FS++
Kraekkling
ASL S21 English Commentary…
namkraft
Electronics
mantequilla
Customize Sidebar...

Website Feedback

Closed Threads



Active: 1253 users

The Big Programming Thread - Page 870

Forum Index > General Forum
Post a Reply
Prev 1 868 869 870 871 872 1032 Next
Thread Rules
1. This is not a "do my homework for me" thread. If you have specific questions, ask, but don't post an assignment or homework problem and expect an exact solution.
2. No recruiting for your cockamamie projects (you won't replace facebook with 3 dudes you found on the internet and $20)
3. If you can't articulate why a language is bad, don't start slinging shit about it. Just remember that nothing is worse than making CSS IE6 compatible.
4. Use [code] tags to format code blocks.
Deleted User 3420
Profile Blog Joined May 2003
24492 Posts
April 07 2017 13:32 GMT
#17381
the repeating part must be floor of n/3 length
Acrofales
Profile Joined August 2010
Spain18255 Posts
April 07 2017 13:35 GMT
#17382
On April 07 2017 22:32 travis wrote:
the repeating part must be floor of n/3 length

Exactly floor(n/3) length? Or at most floor(n/3) length? Or at least floor(n/3) length?
Deleted User 3420
Profile Blog Joined May 2003
24492 Posts
April 07 2017 13:37 GMT
#17383
On April 07 2017 22:35 Acrofales wrote:
Show nested quote +
On April 07 2017 22:32 travis wrote:
the repeating part must be floor of n/3 length

Exactly floor(n/3) length? Or at most floor(n/3) length? Or at least floor(n/3) length?


exactly
Acrofales
Profile Joined August 2010
Spain18255 Posts
Last Edited: 2017-04-07 13:42:20
April 07 2017 13:39 GMT
#17384
On April 07 2017 22:37 travis wrote:
Show nested quote +
On April 07 2017 22:35 Acrofales wrote:
On April 07 2017 22:32 travis wrote:
the repeating part must be floor of n/3 length

Exactly floor(n/3) length? Or at most floor(n/3) length? Or at least floor(n/3) length?


exactly

Ok. Then the only thing you had wrong was that x = floor(n/3) and not floor(n/2).

And don't forget the simplification: you have 3^(ceil(2n/3)) combinations
Deleted User 3420
Profile Blog Joined May 2003
24492 Posts
April 07 2017 13:53 GMT
#17385
Oh yeah, my bad on the floor typo

thank you

these are relatively easy questions compared to what I expect to find on the homework hehe
but it's good to know my thinking for the simpler stuff is right
Deleted User 3420
Profile Blog Joined May 2003
24492 Posts
Last Edited: 2017-04-07 18:11:37
April 07 2017 16:16 GMT
#17386
ok, here goes
first check on my assembly code

please be gentle, I have no idea what I am doing. I feel like our instruction was really disjointed so I have no idea what I am doing. I am mostly guessing based on example code.

+ Show Spoiler +


1 irmovl $0, %esi #Hold current number of iterations in for loop in esi
2 irmovl $20, %eax #Hold total iterations in eax
3
4 irmovl MyArray, %edx #Hold array start address in edx
5
6
7 ForLoopOne:
8
9 #check if esi is 20
10 subl %esi, %eax #check if subtraction = 0
11 je EndForLoopOne
12
13
14
15 rdchr %ebx #Ask for char input, store it in ebx
16
17 #check if character is newline (10)
18 irmovl $10, %eax #temporarily put 10 (newline value) into eax
19 subl %ebx, %eax #check if subtraction = 0
20 je EndForLoopOne
21
22
23 irmovl $20, %eax #Put 20 back in eax
24 mrmovl %ebx, 0(%edx) #Move ebx into the array at address edx
25
26 irmovl $4, %edi #Put 4 into %edi
27 addl %edi, %edx #Move edx to next array index
28 irmovl $1, %ebx #put 1 into ebx
29 addl %ebx, %esi #Increment esi by increment amount (1)
30 jmp ForLoopOne
31
32
33 EndForLoopOne:
34
35
36 halt
37
38 MyArray: #Declaring array of size 20
39 .long 0
40 .long 0
41 .long 0
42 .long 0
43 .long 0
44 .long 0
45 .long 0
46 .long 0
47 .long 0
48 .long 0
49 .long 0
50 .long 0
51 .long 0
52 .long 0
53 .long 0
54 .long 0
55 .long 0
56 .long 0
57 .long 0
58 .long 0



Please disregarding the line numbers. They come with how I get my source (since the files are on a remote server). It'd be a pain to remove them.

The idea with this code is that I want to have an array of size 20, and read characters in a for loop and store them into the array. If we are given a newline, the for loop ends. If we fill our array, the loop ends.

There will be more to it, but I wanted to make sure I fixed up any misunderstandings before I continue.

edit: do I need to use rmmovl to assign the value into my array? That's not in our examples anywhere so I was guessing before but I found this online.

edit2: you can't do an add between an integer and a register? It has to be between 2 registers? That is annoying.

edit3: well, it's not looping. it's just asking for input once and going straight through to the halt.

edit4: ok it looks like my problem has to do with me reading characters, not ints

edit5: ok this code is all wrong. I realized that it was making me hit enter each time, and the user should be able to put in an entire string all at once

edit6: okay nevermind, it actually is working. for some reason i was being a dumb idiot and hitting enter after entering the first character, rather than just typing my string in..
phar
Profile Joined August 2011
United States1080 Posts
Last Edited: 2017-04-07 18:53:13
April 07 2017 18:52 GMT
#17387
On April 08 2017 01:16 travis wrote:

Please disregarding the line numbers. They come with how I get my source (since the files are on a remote server). It'd be a pain to remove them.



sed 's/^....//'



On April 08 2017 01:16 travis wrote:
edit2: you can't do an add between an integer and a register? It has to be between 2 registers? That is annoying.


This depends entirely on the assembly language. For example MIPS assembly I think supports an add that lets you add a register to a given value directly (though it's been awhile, so I may be fuzzy on that).

But actually, if you think about the underlying hardware, restricting add to two registers makes some sense. Underneath, an add operation is done by a physical bit of hardware on the chip (called an ALU). It can, for example, add two integers - say 32 bit integers for a 32 bit ALU. It has to get those integers from some input signal - in order to add it's gotta get the bits on the wire from somewhere. Generally that somewhere is coming from a register. If you have an immediate add operation that works on a register + constant, you have to physically load that constant somewhere to send the signal to the ALU - so at the end of the day it's going into something like a register anyways.

So basically you either have:

Register1 signal -> ALU
Register2 signal -> ALU -> Add them together

(This is an assembly language that only allows add between two registers)

Or you have

Register1 signal -> ALU
Some constant from your instruction code -> load it into what is essentially a hidden register -> send signal -> ALU -> Add them together

(This is an assembly language that supports add between register + constant)


Certain assembly languages just cut the shit and make you do the register loading yourself instead of having extra hardware to hold your hand there.


Again though, been awhile, so this may not be the clearest/most accurate explanation.
Who after all is today speaking about the destruction of the Armenians?
Deleted User 3420
Profile Blog Joined May 2003
24492 Posts
April 07 2017 20:41 GMT
#17388
I hate the way the professor insists we write comments

We have to write comments tabbed over on the right side to correspond to our code on our left

but i'd rather write the comments on top since it'd make it easier to write the comments first, and then write code that does what the comment I wrote says
raNazUra
Profile Joined December 2012
United States10 Posts
Last Edited: 2017-04-08 00:45:50
April 08 2017 00:45 GMT
#17389
If any of you enjoy coding competitions (although they're really more like algorithms competitions), Google's annual one started a couple of hours ago (code.google.com). The qualification round is the next 24 hours. I always enjoy it, so figured I'd share.
Speak the truth, even if your voice shakes
Zocat
Profile Joined April 2010
Germany2229 Posts
Last Edited: 2017-04-08 02:14:07
April 08 2017 02:10 GMT
#17390
On April 08 2017 01:16 travis wrote:
I hate the way the professor insists we write comments

We have to write comments tabbed over on the right side to correspond to our code on our left

but i'd rather write the comments on top since it'd make it easier to write the comments first, and then write code that does what the comment I wrote says


Its just preference. Do what you want. (and if you get graded - do what gets you the best grade).
Deleted User 3420
Profile Blog Joined May 2003
24492 Posts
April 08 2017 15:26 GMT
#17391
first assembly program complete. it determines whether or not an input string is a palindrome. feels good for it to work, lol

2 more to go
Shield
Profile Blog Joined August 2009
Bulgaria4824 Posts
April 08 2017 20:59 GMT
#17392
People still write assembly? Someone has too much patience.
WarSame
Profile Blog Joined February 2010
Canada1950 Posts
April 08 2017 23:15 GMT
#17393
Assembly is extremely good for learning how everything works under the hood. It is also still required in some jobs(compilers, I think).
Can it be I stayed away too long? Did you miss these rhymes while I was gone?
Deleted User 3420
Profile Blog Joined May 2003
24492 Posts
Last Edited: 2017-04-09 20:26:32
April 08 2017 23:23 GMT
#17394
2nd program was easier than the first

I think im actually finding this easier to do than C, lol
just have to be careful and plan ahead

edit: finished my assignment about a week ahead of time
all 3 programs work, I feel amazing, lol
Shield
Profile Blog Joined August 2009
Bulgaria4824 Posts
April 09 2017 16:51 GMT
#17395
If you find Assembly easier than C, I think you've got it backwards. :D
Thaniri
Profile Blog Joined March 2011
1264 Posts
Last Edited: 2017-04-11 03:09:40
April 11 2017 02:59 GMT
#17396
https://github.com/ch00kles/ATM/blob/master/src/ca/bcit/comp2613/a00657642/wow/Wow.java

CTRL+F to "bonus question"

Couldn't this be solved by adding up the levels of all the characters, then subtracting that number from the sum of all numbers 1-85 inclusive?

Short example of numbers between 1-5 inclusive:
1 + 2 + 3 + 4 + 5 = 15
{3, 2, 5, 1}
3 + 2 + 5 + 1 = 11
15 - 11 = 4
Therefore 4 is the missing level

I have no idea what this guy was trying in his assignment.

edit: and my solution is O(N) because even though I have two loops they are not a loop within a loop?
Hanh
Profile Joined June 2016
146 Posts
April 11 2017 05:20 GMT
#17397
On April 11 2017 11:59 Thaniri wrote:
https://github.com/ch00kles/ATM/blob/master/src/ca/bcit/comp2613/a00657642/wow/Wow.java

CTRL+F to "bonus question"

Couldn't this be solved by adding up the levels of all the characters, then subtracting that number from the sum of all numbers 1-85 inclusive?

Short example of numbers between 1-5 inclusive:
1 + 2 + 3 + 4 + 5 = 15
{3, 2, 5, 1}
3 + 2 + 5 + 1 = 11
15 - 11 = 4
Therefore 4 is the missing level

I have no idea what this guy was trying in his assignment.

edit: and my solution is O(N) because even though I have two loops they are not a loop within a loop?


You don't need to loop to compute the first sum. It's 85*86/2
CorsairHero
Profile Joined December 2008
Canada9491 Posts
Last Edited: 2017-04-11 05:31:40
April 11 2017 05:30 GMT
#17398
for you c experts:
int i = 4;
i++ & printf("%d\n", i);

I compiled with gcc which gave me a different result than expected...
any insight?
© Current year.
Nesserev
Profile Blog Joined January 2011
Belgium2760 Posts
Last Edited: 2017-04-11 05:46:22
April 11 2017 05:44 GMT
#17399
--- Nuked ---
beg
Profile Blog Joined May 2010
991 Posts
Last Edited: 2017-04-11 05:59:33
April 11 2017 05:48 GMT
#17400
On April 11 2017 14:30 CorsairHero wrote:
for you c experts:
int i = 4;
i++ & printf("%d\n", i);

I compiled with gcc which gave me a different result than expected...
any insight?

What did you think the & does? I think it's trying to do "bitwise and" here.
(Just guessing. Definitely not an expert ).
Prev 1 868 869 870 871 872 1032 Next
Please log in or register to reply.
Live Events Refresh
Next event in 1h 50m
[ Submit Event ]
Live Streams
Refresh
StarCraft 2
CosmosSc2 15
StarCraft: Brood War
Calm 2344
ggaemo 105
Artosis 85
910 26
Sexy 21
NaDa 10
Dota 2
monkeys_forever337
capcasts25
League of Legends
JimRising 296
Counter-Strike
Coldzera 1598
Super Smash Bros
hungrybox295
AZ_Axe78
Other Games
summit1g16517
Grubby2940
shahzam518
FrodaN510
Liquid`Hasu139
ToD139
Sick94
Mew2King58
ViBE43
ROOTCatZ36
minikerr6
Organizations
StarCraft 2
Blizzard YouTube
StarCraft: Brood War
BSLTrovo
sctven
[ Show 19 non-featured ]
StarCraft 2
• RyuSc2 29
• musti20045 26
• davetesta25
• OhrlRock 1
• IndyKCrew
• sooper7s
• AfreecaTV YouTube
• intothetv
• Kozan
• LaughNgamezSOOP
• Migwel
StarCraft: Brood War
• RayReign 37
• STPLYoutube
• ZZZeroYoutube
• BSLYoutube
Dota 2
• WagamamaTV1098
League of Legends
• Doublelift3787
Other Games
• imaqtpie1272
• Scarra1009
Upcoming Events
PiGosaur Cup
1h 50m
Replay Cast
10h 50m
Kung Fu Cup
12h 50m
Replay Cast
1d 1h
The PondCast
1d 11h
CranKy Ducklings
2 days
WardiTV Team League
2 days
Replay Cast
3 days
CranKy Ducklings
3 days
WardiTV Team League
3 days
[ Show More ]
uThermal 2v2 Circuit
3 days
BSL
3 days
Sparkling Tuna Cup
4 days
WardiTV Team League
4 days
BSL
4 days
Replay Cast
5 days
Replay Cast
5 days
Wardi Open
5 days
GSL
6 days
Liquipedia Results

Completed

CSL Elite League 2026
RSL Revival: Season 4
NationLESS Cup

Ongoing

BSL Season 22
ASL Season 21
CSL 2026 SPRING (S20)
StarCraft2 Community Team League 2026 Spring
Nations Cup 2026
PGL Bucharest 2026
Stake Ranked Episode 1
BLAST Open Spring 2026
ESL Pro League S23 Finals
ESL Pro League S23 Stage 1&2
PGL Cluj-Napoca 2026
IEM Kraków 2026
BLAST Bounty Winter 2026

Upcoming

Escore Tournament S2: W2
IPSL Spring 2026
Escore Tournament S2: W3
Acropolis #4
BSL 22 Non-Korean Championship
CSLAN 4
Kung Fu Cup 2026 Grand Finals
HSC XXIX
uThermal 2v2 2026 Main Event
RSL Revival: Season 5
IEM Cologne Major 2026
Stake Ranked Episode 2
CS Asia Championships 2026
Asian Champions League 2026
IEM Atlanta 2026
PGL Astana 2026
BLAST Rivals Spring 2026
CCT Season 3 Global Finals
IEM Rio 2026
TLPD

1. ByuN
2. TY
3. Dark
4. Solar
5. Stats
6. Nerchio
7. sOs
8. soO
9. INnoVation
10. Elazer
1. Rain
2. Flash
3. EffOrt
4. Last
5. Bisu
6. Soulkey
7. Mini
8. Sharp
Sidebar Settings...

Advertising | Privacy Policy | Terms Of Use | Contact Us

Original banner artwork: Jim Warren
The contents of this webpage are copyright © 2026 TLnet. All Rights Reserved.