• Log InLog In
  • Register
Liquid`
Team Liquid Liquipedia
EDT 18:15
CEST 00:15
KST 07:15
  • 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
[ASL19] Finals Recap: Standing Tall10HomeStory Cup 27 - Info & Preview18Classic wins Code S Season 2 (2025)16Code S RO4 & Finals Preview: herO, Rogue, Classic, GuMiho0TL Team Map Contest #5: Presented by Monster Energy6
Community News
Weekly Cups (June 30 - July 6): Classic Doubles2[BSL20] Non-Korean Championship 4x BSL + 4x China9Flash Announces Hiatus From ASL66Weekly Cups (June 23-29): Reynor in world title form?14FEL Cracov 2025 (July 27) - $8000 live event22
StarCraft 2
General
The GOAT ranking of GOAT rankings The SCII GOAT: A statistical Evaluation Weekly Cups (June 23-29): Reynor in world title form? Weekly Cups (June 30 - July 6): Classic Doubles Program: SC2 / XSplit / OBS Scene Switcher
Tourneys
RSL: Revival, a new crowdfunded tournament series FEL Cracov 2025 (July 27) - $8000 live event Sparkling Tuna Cup - Weekly Open Tournament WardiTV Mondays Korean Starcraft League Week 77
Strategy
How did i lose this ZvP, whats the proper response Simple Questions Simple Answers
Custom Maps
[UMS] Zillion Zerglings
External Content
Mutation # 481 Fear and Lava Mutation # 480 Moths to the Flame Mutation # 479 Worn Out Welcome Mutation # 478 Instant Karma
Brood War
General
BGH Auto Balance -> http://bghmmr.eu/ ASL20 Preliminary Maps [ASL19] Finals Recap: Standing Tall SC uni coach streams logging into betting site Flash Announces Hiatus From ASL
Tourneys
[BSL20] Non-Korean Championship 4x BSL + 4x China [BSL20] Grand Finals - Sunday 20:00 CET CSL Xiamen International Invitational The Casual Games of the Week Thread
Strategy
Simple Questions, Simple Answers I am doing this better than progamers do.
Other Games
General Games
Nintendo Switch Thread Stormgate/Frost Giant Megathread Path of Exile What do you want from future RTS games? Beyond All Reason
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
Heroes of StarCraft mini-set
TL Mafia
TL Mafia Community Thread Vanilla Mini Mafia
Community
General
Russo-Ukrainian War Thread US Politics Mega-thread Stop Killing Games - European Citizens Initiative Summer Games Done Quick 2024! Summer Games Done Quick 2025!
Fan Clubs
SKT1 Classic Fan Club! Maru Fan Club
Media & Entertainment
Anime Discussion Thread [Manga] One Piece [\m/] Heavy Metal Thread
Sports
Formula 1 Discussion 2024 - 2025 Football Thread NBA General Discussion TeamLiquid Health and Fitness Initiative For 2023 NHL Playoffs 2024
World Cup 2022
Tech Support
Computer Build, Upgrade & Buying Resource Thread
TL Community
The Automated Ban List
Blogs
Culture Clash in Video Games…
TrAiDoS
from making sc maps to makin…
Husyelt
Blog #2
tankgirl
StarCraft improvement
iopq
Trip to the Zoo
micronesia
Customize Sidebar...

Website Feedback

Closed Threads



Active: 644 users

The Big Programming Thread - Page 870

Forum Index > General Forum
Post a Reply
Prev 1 868 869 870 871 872 1031 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
Spain17971 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
Spain17971 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 1031 Next
Please log in or register to reply.
Live Events Refresh
Next event in 1h 46m
[ Submit Event ]
Live Streams
Refresh
StarCraft 2
RotterdaM 728
ProTech67
ROOTCatZ 56
Livibee 53
JuggernautJason32
UpATreeSC 1
StarCraft: Brood War
Artosis 240
Rock 24
MaD[AoV]14
Stormgate
Nathanias73
Dota 2
NeuroSwarm51
League of Legends
Grubby4548
Counter-Strike
Fnx 2254
taco 746
Stewie2K688
flusha402
sgares146
Super Smash Bros
PPMD146
Mew2King84
Heroes of the Storm
Liquid`Hasu569
Other Games
summit1g7854
tarik_tv2375
fl0m700
mouzStarbuck293
ZombieGrub59
Maynarde17
Organizations
Other Games
gamesdonequick49954
BasetradeTV29
StarCraft 2
Blizzard YouTube
StarCraft: Brood War
BSLTrovo
sctven
[ Show 22 non-featured ]
StarCraft 2
• kabyraGe 268
• musti20045 36
• davetesta33
• IndyKCrew
• sooper7s
• Migwel
• AfreecaTV YouTube
• LaughNgamezSOOP
• intothetv
• Kozan
StarCraft: Brood War
• 80smullet 31
• Eskiya23 20
• STPLYoutube
• ZZZeroYoutube
• BSLYoutube
Stormgate
• mYiSmile10
Dota 2
• masondota2985
League of Legends
• Jankos2288
• TFBlade1022
Other Games
• imaqtpie1968
• Shiphtur533
• WagamamaTV222
Upcoming Events
Replay Cast
1h 46m
Sparkling Tuna Cup
11h 46m
WardiTV European League
17h 46m
MaNa vs sebesdes
Mixu vs Fjant
ByuN vs HeRoMaRinE
ShoWTimE vs goblin
Gerald vs Babymarine
Krystianer vs YoungYakov
PiGosaur Monday
1d 1h
The PondCast
1d 11h
WardiTV European League
1d 13h
Jumy vs NightPhoenix
Percival vs Nicoract
ArT vs HiGhDrA
MaxPax vs Harstem
Scarlett vs Shameless
SKillous vs uThermal
uThermal 2v2 Circuit
1d 17h
Replay Cast
2 days
RSL Revival
2 days
ByuN vs SHIN
Clem vs Reynor
Replay Cast
3 days
[ Show More ]
RSL Revival
3 days
Classic vs Cure
FEL
3 days
RSL Revival
4 days
FEL
4 days
FEL
4 days
CSO Cup
4 days
BSL20 Non-Korean Champi…
4 days
Bonyth vs QiaoGege
Dewalt vs Fengzi
Hawk vs Zhanhun
Sziky vs Mihu
Mihu vs QiaoGege
Zhanhun vs Sziky
Fengzi vs Hawk
Sparkling Tuna Cup
5 days
RSL Revival
5 days
FEL
5 days
BSL20 Non-Korean Champi…
5 days
Bonyth vs Dewalt
QiaoGege vs Dewalt
Hawk vs Bonyth
Sziky vs Fengzi
Mihu vs Zhanhun
QiaoGege vs Zhanhun
Fengzi vs Mihu
Liquipedia Results

Completed

BSL Season 20
HSC XXVII
Heroes 10 EU

Ongoing

JPL Season 2
BSL 2v2 Season 3
Acropolis #3
KCM Race Survival 2025 Season 2
CSL 17: 2025 SUMMER
Copa Latinoamericana 4
Jiahua Invitational
Championship of Russia 2025
RSL Revival: Season 1
Murky Cup #2
BLAST.tv Austin Major 2025
ESL Impact League Season 7
IEM Dallas 2025
PGL Astana 2025
Asian Champions League '25
BLAST Rivals Spring 2025
MESA Nomadic Masters
CCT Season 2 Global Finals
IEM Melbourne 2025

Upcoming

2025 ACS Season 2: Qualifier
CSLPRO Last Chance 2025
CSL Xiamen Invitational
2025 ACS Season 2
CSLPRO Chat StarLAN 3
K-Championship
uThermal 2v2 Main Event
SEL Season 2 Championship
FEL Cracov 2025
Esports World Cup 2025
StarSeries Fall 2025
FISSURE Playground #2
BLAST Open Fall 2025
BLAST Open Fall Qual
Esports World Cup 2025
BLAST Bounty Fall 2025
BLAST Bounty Fall Qual
IEM Cologne 2025
FISSURE Playground #1
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 © 2025 TLnet. All Rights Reserved.