• Log InLog In
  • Register
Liquid`
Team Liquid Liquipedia
EST 08:42
CET 14:42
KST 22:42
  • 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
Behind the Blue - Team Liquid History Book15Clem wins HomeStory Cup 289HomeStory Cup 28 - Info & Preview13Rongyi Cup S3 - Preview & Info8herO wins SC2 All-Star Invitational14
Community News
ACS replaced by "ASL Season Open" - Starts 21/0222LiuLi Cup: 2025 Grand Finals (Feb 10-16)26Weekly Cups (Feb 2-8): Classic, Solar, MaxPax win2Nexon's StarCraft game could be FPS, led by UMS maker10PIG STY FESTIVAL 7.0! (19 Feb - 1 Mar)14
StarCraft 2
General
How do you think the 5.0.15 balance patch (Oct 2025) for StarCraft II has affected the game? Nexon's StarCraft game could be FPS, led by UMS maker Terran Scanner Sweep Behind the Blue - Team Liquid History Book Weekly Cups (Jan 12-18): herO, MaxPax, Solar win
Tourneys
Sparkling Tuna Cup - Weekly Open Tournament RSL Season 4 announced for March-April PIG STY FESTIVAL 7.0! (19 Feb - 1 Mar) LiuLi Cup: 2025 Grand Finals (Feb 10-16) RSL Revival: Season 4 Korea Qualifier (Feb 14)
Strategy
Custom Maps
Map Editor closed ? [A] Starcraft Sound Mod
External Content
The PondCast: SC2 News & Results Mutation # 512 Overclocked Mutation # 511 Temple of Rebirth Mutation # 510 Safety Violation
Brood War
General
ACS replaced by "ASL Season Open" - Starts 21/02 Which units you wish saw more use in the game? StarCraft player reflex TE scores [ASL21] Potential Map Candidates Gypsy to Korea
Tourneys
Escore Tournament StarCraft Season 1 [Megathread] Daily Proleagues Small VOD Thread 2.0 KCM Race Survival 2026 Season 1
Strategy
Fighting Spirit mining rates Zealot bombing is no longer popular? Simple Questions, Simple Answers Current Meta
Other Games
General Games
Path of Exile Nintendo Switch Thread Diablo 2 thread Battle Aces/David Kim RTS Megathread ZeroSpace Megathread
Dota 2
Official 'what is Dota anymore' discussion
League of Legends
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
TL Mafia Community Thread Mafia Game Mode Feedback/Ideas Vanilla Mini Mafia
Community
General
US Politics Mega-thread Ask and answer stupid questions here! Things Aren’t Peaceful in Palestine European Politico-economics QA Mega-thread The Games Industry And ATVI
Fan Clubs
The IdrA Fan Club The herO Fan Club!
Media & Entertainment
[Req][Books] Good Fantasy/SciFi books [Manga] One Piece Anime Discussion Thread
Sports
2024 - 2026 Football Thread
World Cup 2022
Tech Support
TL Community
The Automated Ban List
Blogs
The Search For Meaning in Vi…
TrAiDoS
My 2025 Magic: The Gathering…
DARKING
Life Update and thoughts.
FuDDx
How do archons sleep?
8882
StarCraft improvement
iopq
Customize Sidebar...

Website Feedback

Closed Threads



Active: 2067 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
Spain18215 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
Spain18215 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
LiuLi Cup
11:00
2025 Grand Finals Playoffs
Serral vs RogueLIVE!
Reynor vs TBD
Maru vs TBD
RotterdaM2043
ComeBackTV 1224
PiGStarcraft691
IndyStarCraft 402
Rex289
BRAT_OK 242
3DClanTV 83
IntoTheiNu 30
Liquipedia
Sparkling Tuna Cup
10:00
Weekly #119
ByuN vs KrystianerLIVE!
CranKy Ducklings133
LiquipediaDiscussion
[ Submit Event ]
Live Streams
Refresh
StarCraft 2
RotterdaM 2043
PiGStarcraft691
IndyStarCraft 402
Rex 289
BRAT_OK 242
EmSc Tv 40
StarCraft: Brood War
Britney 33561
Rain 3719
Sea 2378
Flash 2060
firebathero 1497
actioN 975
Stork 757
EffOrt 559
Soma 446
Mini 438
[ Show more ]
Rush 282
Shuttle 274
ggaemo 154
Hyun 133
Sharp 123
Last 119
JYJ 79
Sea.KH 48
Backho 47
Movie 46
ToSsGirL 38
sorry 28
sSak 25
IntoTheRainbow 19
JulyZerg 18
soO 18
yabsab 14
GoRush 13
Yoon 12
NotJumperer 11
Shine 11
HiyA 10
Icarus 8
zelot 8
Terrorterran 8
Sacsri 7
SilentControl 7
Noble 6
Bonyth 0
Dota 2
Dendi2412
XcaliburYe680
XaKoH 661
febbydoto21
Counter-Strike
fl0m2803
x6flipin613
Super Smash Bros
Mew2King95
Heroes of the Storm
Khaldor245
Other Games
singsing3289
B2W.Neo1145
Liquid`RaSZi994
Happy224
crisheroes220
KnowMe37
MindelVK9
Organizations
Counter-Strike
PGL31669
StarCraft 2
EmSc Tv 40
EmSc2Tv 40
Blizzard YouTube
StarCraft: Brood War
BSLTrovo
sctven
[ Show 18 non-featured ]
StarCraft 2
• Berry_CruncH167
• Adnapsc2 5
• IndyKCrew
• sooper7s
• Migwel
• AfreecaTV YouTube
• LaughNgamezSOOP
• intothetv
• Kozan
StarCraft: Brood War
• FirePhoenix7
• ZZZeroYoutube
• STPLYoutube
• BSLYoutube
Dota 2
• WagamamaTV191
• lizZardDota2161
League of Legends
• Nemesis4501
• Jankos2866
• Stunt573
Upcoming Events
Ladder Legends
4h 19m
Replay Cast
10h 19m
Replay Cast
19h 19m
Wardi Open
22h 19m
Monday Night Weeklies
1d 3h
OSC
1d 10h
WardiTV Winter Champion…
1d 22h
PiGosaur Cup
2 days
Replay Cast
2 days
WardiTV Winter Champion…
2 days
[ Show More ]
Replay Cast
3 days
PiG Sty Festival
3 days
The PondCast
3 days
KCM Race Survival
3 days
WardiTV Winter Champion…
3 days
Replay Cast
4 days
PiG Sty Festival
4 days
Epic.LAN
4 days
Replay Cast
5 days
PiG Sty Festival
5 days
CranKy Ducklings
5 days
Epic.LAN
5 days
Replay Cast
6 days
PiG Sty Festival
6 days
Sparkling Tuna Cup
6 days
Liquipedia Results

Completed

Proleague 2026-02-14
Rongyi Cup S3
Underdog Cup #3

Ongoing

KCM Race Survival 2026 Season 1
LiuLi Cup: 2025 Grand Finals
Nations Cup 2026
PGL Cluj-Napoca 2026
IEM Kraków 2026
BLAST Bounty Winter 2026
BLAST Bounty Winter Qual
eXTREMESLAND 2025
SL Budapest Major 2025

Upcoming

Escore Tournament S1: King of Kings
[S:21] ASL SEASON OPEN 1st Round
[S:21] ASL SEASON OPEN 1st Round Qualifier
[S:21] ASL SEASON OPEN 2nd Round
[S:21] ASL SEASON OPEN 2nd Round Qualifier
Acropolis #4
IPSL Spring 2026
HSC XXIX
uThermal 2v2 2026 Main Event
Bellum Gens Elite Stara Zagora 2026
RSL Revival: Season 4
WardiTV Winter 2026
BLAST Rivals Spring 2026
CCT Season 3 Global Finals
FISSURE Playground #3
IEM Rio 2026
PGL Bucharest 2026
Stake Ranked Episode 1
BLAST Open Spring 2026
ESL Pro League Season 23
ESL Pro League Season 23
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.