• Log InLog In
  • Register
Liquid`
Team Liquid Liquipedia
EDT 05:41
CEST 11:41
KST 18:41
  • 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
Team TLMC #5 - Finalists & Open Tournaments0[ASL20] Ro16 Preview Pt2: Turbulence10Classic Games #3: Rogue vs Serral at BlizzCon9[ASL20] Ro16 Preview Pt1: Ascent10Maestros of the Game: Week 1/Play-in Preview12
Community News
BSL 2025 Warsaw LAN + Legends Showmatch0Weekly Cups (Sept 8-14): herO & MaxPax split cups4WardiTV TL Team Map Contest #5 Tournaments1SC4ALL $6,000 Open LAN in Philadelphia8Weekly Cups (Sept 1-7): MaxPax rebounds & Clem saga continues29
StarCraft 2
General
#1: Maru - Greatest Players of All Time Weekly Cups (Sept 8-14): herO & MaxPax split cups Team Liquid Map Contest #21 - Presented by Monster Energy SpeCial on The Tasteless Podcast Team TLMC #5 - Finalists & Open Tournaments
Tourneys
Maestros of The Game—$20k event w/ live finals in Paris Sparkling Tuna Cup - Weekly Open Tournament SC4ALL $6,000 Open LAN in Philadelphia WardiTV TL Team Map Contest #5 Tournaments RSL: Revival, a new crowdfunded tournament series
Strategy
Custom Maps
External Content
Mutation # 491 Night Drive Mutation # 490 Masters of Midnight Mutation # 489 Bannable Offense Mutation # 488 What Goes Around
Brood War
General
Soulkey on ASL S20 ASL TICKET LIVE help! :D BW General Discussion NaDa's Body A cwal.gg Extension - Easily keep track of anyone
Tourneys
[ASL20] Ro16 Group D [ASL20] Ro16 Group C [Megathread] Daily Proleagues BSL 2025 Warsaw LAN + Legends Showmatch
Strategy
Simple Questions, Simple Answers Muta micro map competition Fighting Spirit mining rates [G] Mineral Boosting
Other Games
General Games
Stormgate/Frost Giant Megathread Nintendo Switch Thread Path of Exile Borderlands 3 General RTS Discussion Thread
Dota 2
Official 'what is Dota anymore' discussion LiquidDota to reintegrate into TL.net
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
Community
General
US Politics Mega-thread Canadian Politics Mega-thread Things Aren’t Peaceful in Palestine Russo-Ukrainian War Thread UK Politics Mega-thread
Fan Clubs
The Happy Fan Club!
Media & Entertainment
Movie Discussion! [Manga] One Piece Anime Discussion Thread
Sports
2024 - 2026 Football Thread Formula 1 Discussion MLB/Baseball 2023
World Cup 2022
Tech Support
Linksys AE2500 USB WIFI keeps disconnecting Computer Build, Upgrade & Buying Resource Thread High temperatures on bridge(s)
TL Community
BarCraft in Tokyo Japan for ASL Season5 Final The Automated Ban List
Blogs
I <=> 9
KrillinFromwales
The Personality of a Spender…
TrAiDoS
A very expensive lesson on ma…
Garnet
hello world
radishsoup
Lemme tell you a thing o…
JoinTheRain
RTS Design in Hypercoven
a11
Evil Gacha Games and the…
ffswowsucks
Customize Sidebar...

Website Feedback

Closed Threads



Active: 1590 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
Spain18050 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
Spain18050 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 19m
[ Submit Event ]
Live Streams
Refresh
StarCraft 2
Rex 1
StarCraft: Brood War
Calm 5699
Bisu 731
Hyuk 162
HiyA 96
Hyun 96
sorry 86
ToSsGirL 84
Dewaltoss 82
Pusan 77
Light 74
[ Show more ]
Soma 60
actioN 56
Mini 49
ZerO 32
BeSt 30
Liquid`Ret 29
Nal_rA 28
soO 27
Sharp 24
Rush 19
Free 16
SilentControl 10
Dota 2
singsing1260
XcaliburYe206
boxi98170
League of Legends
JimRising 381
Counter-Strike
olofmeister1583
shoxiejesuss598
allub166
Other Games
XaKoH 143
NeuroSwarm80
Trikslyr15
Organizations
StarCraft: Brood War
lovetv 593
Other Games
gamesdonequick587
StarCraft 2
Blizzard YouTube
StarCraft: Brood War
BSLTrovo
sctven
[ Show 14 non-featured ]
StarCraft 2
• AfreecaTV YouTube
• intothetv
• Kozan
• IndyKCrew
• LaughNgamezSOOP
• Migwel
• sooper7s
StarCraft: Brood War
• iopq 1
• BSLYoutube
• STPLYoutube
• ZZZeroYoutube
League of Legends
• Jankos1421
• Stunt679
Other Games
• WagamamaTV81
Upcoming Events
RSL Revival
19m
Maru vs Reynor
Cure vs TriGGeR
Rex1
Map Test Tournament
1h 19m
The PondCast
3h 19m
RSL Revival
1d
Zoun vs Classic
Korean StarCraft League
1d 17h
BSL Open LAN 2025 - War…
1d 22h
RSL Revival
2 days
BSL Open LAN 2025 - War…
2 days
RSL Revival
3 days
Online Event
3 days
[ Show More ]
Wardi Open
4 days
Monday Night Weeklies
4 days
Sparkling Tuna Cup
5 days
LiuLi Cup
6 days
Liquipedia Results

Completed

Proleague 2025-09-10
Chzzk MurlocKing SC1 vs SC2 Cup #2
HCC Europe

Ongoing

BSL 20 Team Wars
KCM Race Survival 2025 Season 3
BSL 21 Points
ASL Season 20
CSL 2025 AUTUMN (S18)
LASL Season 20
RSL Revival: Season 2
Maestros of the Game
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

Upcoming

2025 Chongqing Offline CUP
BSL World Championship of Poland 2025
IPSL Winter 2025-26
BSL Season 21
SC4ALL: Brood War
BSL 21 Team A
Stellar Fest
SC4ALL: StarCraft II
EC S1
ESL Impact League Season 8
SL Budapest Major 2025
BLAST Rivals Fall 2025
IEM Chengdu 2025
PGL Masters Bucharest 2025
MESA Nomadic Masters Fall
Thunderpick World Champ.
CS Asia Championships 2025
ESL Pro League S22
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.