• Log InLog In
  • Register
Liquid`
Team Liquid Liquipedia
EST 08:52
CET 14:52
KST 22:52
  • 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
TL.net Map Contest #21: Winners10Intel X Team Liquid Seoul event: Showmatches and Meet the Pros10[ASL20] Finals Preview: Arrival13TL.net Map Contest #21: Voting12[ASL20] Ro4 Preview: Descent11
Community News
StarCraft, SC2, HotS, WC3, Returning to Blizzcon!33$5,000+ WardiTV 2025 Championship6[BSL21] RO32 Group Stage4Weekly Cups (Oct 26-Nov 2): Liquid, Clem, Solar win; LAN in Philly2Weekly Cups (Oct 20-26): MaxPax, Clem, Creator win10
StarCraft 2
General
Mech is the composition that needs teleportation t TL.net Map Contest #21: Winners Weekly Cups (Oct 20-26): MaxPax, Clem, Creator win RotterdaM "Serral is the GOAT, and it's not close" 5.0.15 Patch Balance Hotfix (2025-10-8)
Tourneys
Constellation Cup - Main Event - Stellar Fest $5,000+ WardiTV 2025 Championship Sparkling Tuna Cup - Weekly Open Tournament Merivale 8 Open - LAN - Stellar Fest Sea Duckling Open (Global, Bronze-Diamond)
Strategy
Custom Maps
Map Editor closed ?
External Content
Mutation # 498 Wheel of Misfortune|Cradle of Death Mutation # 497 Battle Haredened Mutation # 496 Endless Infection Mutation # 495 Rest In Peace
Brood War
General
[ASL20] Ask the mapmakers — Drop your questions BW General Discussion [BSL21] RO32 Group Stage BGH Auto Balance -> http://bghmmr.eu/ SnOw's ASL S20 Finals Review
Tourneys
[Megathread] Daily Proleagues [ASL20] Grand Finals [BSL21] RO32 Group B - Sunday 21:00 CET [BSL21] RO32 Group A - Saturday 21:00 CET
Strategy
Current Meta PvZ map balance How to stay on top of macro? Soma's 9 hatch build from ASL Game 2
Other Games
General Games
Nintendo Switch Thread Stormgate/Frost Giant Megathread Path of Exile Should offensive tower rushing be viable in RTS games? Dawn of War IV
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 SPIRED by.ASL Mafia {211640}
Community
General
US Politics Mega-thread Russo-Ukrainian War Thread Things Aren’t Peaceful in Palestine YouTube Thread Dating: How's your luck?
Fan Clubs
White-Ra Fan Club The herO Fan Club!
Media & Entertainment
[Manga] One Piece Anime Discussion Thread Movie Discussion! Korean Music Discussion Series you have seen recently...
Sports
2024 - 2026 Football Thread NBA General Discussion MLB/Baseball 2023 TeamLiquid Health and Fitness Initiative For 2023 Formula 1 Discussion
World Cup 2022
Tech Support
SC2 Client Relocalization [Change SC2 Language] Linksys AE2500 USB WIFI keeps disconnecting Computer Build, Upgrade & Buying Resource Thread
TL Community
The Automated Ban List Recent Gifted Posts
Blogs
Coffee x Performance in Espo…
TrAiDoS
Saturation point
Uldridge
DnB/metal remix FFO Mick Go…
ImbaTosS
Why we need SC3
Hildegard
Reality "theory" prov…
perfectspheres
Our Last Hope in th…
KrillinFromwales
Customize Sidebar...

Website Feedback

Closed Threads



Active: 1421 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
Spain18110 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
Spain18110 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
CranKy Ducklings
10:00
Sea Duckling Open #140
CranKy Ducklings79
LiquipediaDiscussion
[ Submit Event ]
Live Streams
Refresh
StarCraft 2
RotterdaM 198
Railgan 42
Creator 14
StarCraft: Brood War
Sea 6694
Horang2 4040
GuemChi 1668
Jaedong 862
actioN 292
Mini 259
BeSt 247
Killer 230
Soma 220
EffOrt 210
[ Show more ]
Rush 169
Mind 92
Hyun 87
Bonyth 72
ToSsGirL 69
Backho 61
sas.Sziky 33
JYJ28
PianO 27
zelot 24
Aegong 14
soO 12
Terrorterran 10
Sacsri 9
sorry 9
HiyA 8
Dota 2
Gorgc6041
singsing2210
qojqva1772
Dendi596
XcaliburYe214
BananaSlamJamma90
Heroes of the Storm
Khaldor209
Other Games
B2W.Neo1194
Lowko261
Sick244
Fuzer 193
Hui .112
XaKoH 95
nookyyy 54
MindelVK19
Organizations
StarCraft 2
WardiTV622
Counter-Strike
PGL242
StarCraft 2
Blizzard YouTube
StarCraft: Brood War
BSLTrovo
sctven
[ Show 14 non-featured ]
StarCraft 2
• StrangeGG 67
• AfreecaTV YouTube
• intothetv
• Kozan
• IndyKCrew
• LaughNgamezSOOP
• Migwel
• sooper7s
StarCraft: Brood War
• BSLYoutube
• STPLYoutube
• ZZZeroYoutube
Dota 2
• C_a_k_e 2050
League of Legends
• Stunt703
• HappyZerGling113
Upcoming Events
IPSL
4h 8m
dxtr13 vs OldBoy
Napoleon vs Doodle
LAN Event
4h 8m
Lambo vs Clem
Scarlett vs TriGGeR
ByuN vs TBD
Zoun vs TBD
BSL 21
6h 8m
Gosudark vs Kyrie
Gypsy vs OyAji
UltrA vs Radley
Dandy vs Ptak
Replay Cast
9h 8m
Sparkling Tuna Cup
20h 8m
WardiTV Korean Royale
22h 8m
LAN Event
1d 1h
IPSL
1d 4h
JDConan vs WIZARD
WolFix vs Cross
BSL 21
1d 6h
spx vs rasowy
HBO vs KameZerg
Cross vs Razz
dxtr13 vs ZZZero
Replay Cast
1d 19h
[ Show More ]
Wardi Open
1d 22h
WardiTV Korean Royale
2 days
Replay Cast
3 days
Kung Fu Cup
3 days
Classic vs Solar
herO vs Cure
Reynor vs GuMiho
ByuN vs ShoWTimE
Tenacious Turtle Tussle
4 days
The PondCast
4 days
RSL Revival
4 days
Solar vs Zoun
MaxPax vs Bunny
Kung Fu Cup
4 days
WardiTV Korean Royale
4 days
RSL Revival
5 days
Classic vs Creator
Cure vs TriGGeR
Kung Fu Cup
5 days
CranKy Ducklings
6 days
RSL Revival
6 days
herO vs Gerald
ByuN vs SHIN
Kung Fu Cup
6 days
Liquipedia Results

Completed

BSL 21 Points
SC4ALL: StarCraft II
Eternal Conflict S1

Ongoing

C-Race Season 1
IPSL Winter 2025-26
KCM Race Survival 2025 Season 4
SOOP Univ League 2025
YSL S2
BSL Season 21
Stellar Fest: Constellation Cup
IEM Chengdu 2025
PGL Masters Bucharest 2025
Thunderpick World Champ.
CS Asia Championships 2025
ESL Pro League S22
StarSeries Fall 2025
FISSURE Playground #2
BLAST Open Fall 2025
BLAST Open Fall Qual

Upcoming

SLON Tour Season 2
BSL 21 Non-Korean Championship
Acropolis #4
IPSL Spring 2026
HSC XXVIII
RSL Offline Finals
WardiTV 2025
RSL Revival: Season 3
META Madness #9
BLAST Bounty Winter 2026: Closed Qualifier
eXTREMESLAND 2025
ESL Impact League Season 8
SL Budapest Major 2025
BLAST Rivals Fall 2025
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.