• Log InLog In
  • Register
Liquid`
Team Liquid Liquipedia
EDT 04:43
CEST 10:43
KST 17:43
  • 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 Tall6HomeStory 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
Flash Announces Hiatus From ASL41Weekly Cups (June 23-29): Reynor in world title form?12FEL Cracov 2025 (July 27) - $8000 live event16Esports World Cup 2025 - Final Player Roster16Weekly Cups (June 16-22): Clem strikes back1
StarCraft 2
General
Statistics for vetoed/disliked maps Esports World Cup 2025 - Final Player Roster The SCII GOAT: A statistical Evaluation How does the number of casters affect your enjoyment of esports? Weekly Cups (June 23-29): Reynor in world title form?
Tourneys
RSL: Revival, a new crowdfunded tournament series [GSL 2025] Code S: Season 2 - Semi Finals & Finals $5,100+ SEL Season 2 Championship (SC: Evo) FEL Cracov 2025 (July 27) - $8000 live event HomeStory Cup 27 (June 27-29)
Strategy
How did i lose this ZvP, whats the proper response Simple Questions Simple Answers
Custom Maps
[UMS] Zillion Zerglings
External Content
Mutation # 480 Moths to the Flame Mutation # 479 Worn Out Welcome Mutation # 478 Instant Karma Mutation # 477 Slow and Steady
Brood War
General
Player “Jedi” cheat on CSL Help: rep cant save Flash Announces Hiatus From ASL [ASL19] Finals Recap: Standing Tall BGH Auto Balance -> http://bghmmr.eu/
Tourneys
[Megathread] Daily Proleagues [BSL20] GosuLeague RO16 - Tue & Wed 20:00+CET The Casual Games of the Week Thread [BSL20] ProLeague LB Final - Saturday 20:00 CET
Strategy
Simple Questions, Simple Answers I am doing this better than progamers do.
Other Games
General Games
Stormgate/Frost Giant Megathread Nintendo Switch Thread 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 Things Aren’t Peaceful in Palestine Trading/Investing Thread The Games Industry And ATVI
Fan Clubs
SKT1 Classic Fan Club! Maru Fan Club
Media & Entertainment
Anime Discussion Thread [Manga] One Piece [\m/] Heavy Metal Thread Korean Music Discussion
Sports
2024 - 2025 Football Thread NBA General Discussion Formula 1 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
from making sc maps to makin…
Husyelt
Blog #2
tankgirl
Game Sound vs. Music: The Im…
TrAiDoS
StarCraft improvement
iopq
Heero Yuy & the Tax…
KrillinFromwales
Trip to the Zoo
micronesia
Customize Sidebar...

Website Feedback

Closed Threads



Active: 558 users

The Big Programming Thread - Page 869

Forum Index > General Forum
Post a Reply
Prev 1 867 868 869 870 871 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.
dsyxelic
Profile Joined May 2010
United States1417 Posts
Last Edited: 2017-04-05 06:20:35
April 05 2017 06:10 GMT
#17361
x2-x1 btw!

or for general cases |x1-x2| but this problem said x2 must be larger

anyways as you said, k1 is getting closer to k2 each iteration by v1-v2 steps. so the gap continuously closes by a certain amount. Because v1>v2, kangaroo 1 will eventually outpace kangaroo 2.

ex. lim->infinity (v1p+x1)/(v2p+x2) = v1/v2, p=number of iterations
since v1>v2, kangaroo1 always outpaces kangaroo2 in regards to infinity
(sorry if I'm explaining the math in a bad way I'm honestly not a math guy)

SO, all we need to do is check if the gap eventually reaches 0 for the overlap.
since the difference of x1 and x2 is the starting gap we need to cover, and the difference of v1 and v2 is how much that gap decreases by, we just need to see if they divide evenly. If they do, we know that the gap ends up at 0 at some point.

Hope that made sense. I'm also very sad that there is probably so many more efficient ways to solve this. I might look at this more tomorrow unless someone smart can explain a better solution so I can just learn from that.

edit:

nvm I passed the last test case.

all I had to do was check for more of the bad inputs in the beginning. I guess that last test case was just checking for that. So this is actually one of the optimal ways?
TL/SKT
frogmelter
Profile Blog Joined April 2009
United States971 Posts
April 05 2017 06:44 GMT
#17362
Apologies for the typo. Hopefully I didn't mislead anyone. Edited.

This solution is O(1). There isn't an efficiency class faster than this.
TL+ Member
dsyxelic
Profile Joined May 2010
United States1417 Posts
April 05 2017 06:53 GMT
#17363
On April 05 2017 15:44 frogmelter wrote:
Apologies for the typo. Hopefully I didn't mislead anyone. Edited.

This solution is O(1). There isn't an efficiency class faster than this.


yeah you're right its crazy how i've been conditioned by these questions to just assume i can't get the optimal algorithm on first go
TL/SKT
Wrath
Profile Blog Joined July 2014
3174 Posts
April 05 2017 06:54 GMT
#17364
Thanks guys!

When I wrote the equation first time I was stuck on p as I really did not know what it actually indicates.

Now all make sense. By solving: v2p+x2 = v1p+x1 -> we get that p = x2-x1/v1-v2

since p as @dsyxelic said stands for number of iterations, it must be an integer value. Otherwise it means they won't meet at all.

MysteryMeat1
Profile Blog Joined June 2011
United States3291 Posts
April 05 2017 18:17 GMT
#17365
I'm working on a python project, where a user uploads an excel sheet and it generates a powerpoint. Right now it only works on my machine and I want to package it and distribute it. However If I use py2app it seems like everytime I want to use new data I have to repackage the app. What is a better way of doing this?

I was thinking of using flask and heroku but im a novice to python
"Cause ya know, Style before victory." -The greatest mafia player alive
Prillan
Profile Joined August 2011
Sweden350 Posts
April 05 2017 19:46 GMT
#17366
On April 06 2017 03:17 MysteryMeat1 wrote:
I'm working on a python project, where a user uploads an excel sheet and it generates a powerpoint. Right now it only works on my machine and I want to package it and distribute it. However If I use py2app it seems like everytime I want to use new data I have to repackage the app. What is a better way of doing this?

I was thinking of using flask and heroku but im a novice to python

If that's the case you're probably doing something wrong. Also, what are users uploading the document to if you're not running a web server?
TheBB's sidekick, aligulac.com | "Reality is frequently inaccurate." - Douglas Adams
Nesserev
Profile Blog Joined January 2011
Belgium2760 Posts
April 06 2017 09:32 GMT
#17367
--- Nuked ---
Acrofales
Profile Joined August 2010
Spain17969 Posts
April 06 2017 09:43 GMT
#17368
On April 06 2017 18:32 Nesserev wrote:
Yeah, py2app, py2exe, PyInstaller, cx_Freeze, etc. should be used for generating and distributing standalone executables (.exe) targeting end users, but are a bad fit/unnecessary in almost any other situation, especially for a web server where you have control over your own environment.

@MysteryMeat1 If you're new to this, maybe you should check out pythonanywhere.com instead of Heroku. I've never used Heroku, but the setup seems a bit more complicated/steep compared to pythonanywhere.com, which I've used, and is really easy to use.

Honestly, there's a basic thought problem at the very beginning here. Heroku isn't an alternative to py2app. It's an alternative to AWS, Azure, etc.

It's still not clear to me whether mysterymeat is interested in making a standalone app or a web app. In the former, it's not py2app that is failing him, but the way in which he inputs the spreadsheet (hardcoded?!) In the latter, he should study the various options for hosting his app. But they are entirely different kettles of fish.
MysteryMeat1
Profile Blog Joined June 2011
United States3291 Posts
Last Edited: 2017-04-06 15:46:27
April 06 2017 15:38 GMT
#17369
On April 06 2017 04:46 Prillan wrote:
Show nested quote +
On April 06 2017 03:17 MysteryMeat1 wrote:
I'm working on a python project, where a user uploads an excel sheet and it generates a powerpoint. Right now it only works on my machine and I want to package it and distribute it. However If I use py2app it seems like everytime I want to use new data I have to repackage the app. What is a better way of doing this?

I was thinking of using flask and heroku but im a novice to python

If that's the case you're probably doing something wrong. Also, what are users uploading the document to if you're not running a web server?


Right now the only user is me. I have the script in the same directory as the excel file so it just grabs it and runs it. However when I package the exe its not grabbing the excel file. Did I just set it up wrong?

On April 06 2017 18:43 Acrofales wrote:
Show nested quote +
On April 06 2017 18:32 Nesserev wrote:
Yeah, py2app, py2exe, PyInstaller, cx_Freeze, etc. should be used for generating and distributing standalone executables (.exe) targeting end users, but are a bad fit/unnecessary in almost any other situation, especially for a web server where you have control over your own environment.

@MysteryMeat1 If you're new to this, maybe you should check out pythonanywhere.com instead of Heroku. I've never used Heroku, but the setup seems a bit more complicated/steep compared to pythonanywhere.com, which I've used, and is really easy to use.

Honestly, there's a basic thought problem at the very beginning here. Heroku isn't an alternative to py2app. It's an alternative to AWS, Azure, etc.

It's still not clear to me whether mysterymeat is interested in making a standalone app or a web app. In the former, it's not py2app that is failing him, but the way in which he inputs the spreadsheet (hardcoded?!) In the latter, he should study the various options for hosting his app. But they are entirely different kettles of fish.


I'm interested in whatever's easier. If the data in the excel sheet is constantly changing it seems like a standalone app isn't the correct solution? Unless I missed out on a way to select the excel file in the app.

Right now its just wb = load_workbook(filename.xlss)

The preference for the standalone app was that I could just have people download the exe and not have to look into web hosting
"Cause ya know, Style before victory." -The greatest mafia player alive
Acrofales
Profile Joined August 2010
Spain17969 Posts
Last Edited: 2017-04-06 16:45:09
April 06 2017 16:42 GMT
#17370
On April 07 2017 00:38 MysteryMeat1 wrote:
Show nested quote +
On April 06 2017 04:46 Prillan wrote:
On April 06 2017 03:17 MysteryMeat1 wrote:
I'm working on a python project, where a user uploads an excel sheet and it generates a powerpoint. Right now it only works on my machine and I want to package it and distribute it. However If I use py2app it seems like everytime I want to use new data I have to repackage the app. What is a better way of doing this?

I was thinking of using flask and heroku but im a novice to python

If that's the case you're probably doing something wrong. Also, what are users uploading the document to if you're not running a web server?


Right now the only user is me. I have the script in the same directory as the excel file so it just grabs it and runs it. However when I package the exe its not grabbing the excel file. Did I just set it up wrong?

Show nested quote +
On April 06 2017 18:43 Acrofales wrote:
On April 06 2017 18:32 Nesserev wrote:
Yeah, py2app, py2exe, PyInstaller, cx_Freeze, etc. should be used for generating and distributing standalone executables (.exe) targeting end users, but are a bad fit/unnecessary in almost any other situation, especially for a web server where you have control over your own environment.

@MysteryMeat1 If you're new to this, maybe you should check out pythonanywhere.com instead of Heroku. I've never used Heroku, but the setup seems a bit more complicated/steep compared to pythonanywhere.com, which I've used, and is really easy to use.

Honestly, there's a basic thought problem at the very beginning here. Heroku isn't an alternative to py2app. It's an alternative to AWS, Azure, etc.

It's still not clear to me whether mysterymeat is interested in making a standalone app or a web app. In the former, it's not py2app that is failing him, but the way in which he inputs the spreadsheet (hardcoded?!) In the latter, he should study the various options for hosting his app. But they are entirely different kettles of fish.


I'm interested in whatever's easier. If the data in the excel sheet is constantly changing it seems like a standalone app isn't the correct solution? Unless I missed out on a way to select the excel file in the app.

Right now its just wb = load_workbook(filename.xlss)

The preference for the standalone app was that I could just have people download the exe and not have to look into web hosting

You'll want to use some type of input. The most basic form would be:


filename = input("Enter your filename: ")
try:
wb = load_workbook(filename)
except:
print("Problem loading file", filename, "Please make sure you entered a valid Excel file")
exit(1)


Or as a command line argument: https://www.tutorialspoint.com/python/python_command_line_arguments.htm
Deleted User 3420
Profile Blog Joined May 2003
24492 Posts
April 06 2017 19:48 GMT
#17371
It's assembly time in my current programming class. For the current project we have to convert a couple different C programs to assembly.

I am sure I will need help from you guys
MysteryMeat1
Profile Blog Joined June 2011
United States3291 Posts
April 06 2017 19:53 GMT
#17372
I switched it to using the tKinter library, allowing the user to select the excel file that they want. I want it to be as easy as possible for someone who doesn't have any experience with coding.
"Cause ya know, Style before victory." -The greatest mafia player alive
tofucake
Profile Blog Joined October 2009
Hyrule19029 Posts
April 06 2017 20:20 GMT
#17373
On April 07 2017 04:48 travis wrote:
It's assembly time in my current programming class. For the current project we have to convert a couple different C programs to assembly.

I am sure I will need help from you guys

Which assembly?
Liquipediaasante sana squash banana
Deleted User 3420
Profile Blog Joined May 2003
24492 Posts
April 06 2017 22:35 GMT
#17374
On April 07 2017 05:20 tofucake wrote:
Show nested quote +
On April 07 2017 04:48 travis wrote:
It's assembly time in my current programming class. For the current project we have to convert a couple different C programs to assembly.

I am sure I will need help from you guys

Which assembly?


I don't know the differences. Does "Y86" answer that question?
Blitzkrieg0
Profile Blog Joined August 2010
United States13132 Posts
Last Edited: 2017-04-06 22:44:32
April 06 2017 22:40 GMT
#17375
On April 07 2017 07:35 travis wrote:
Show nested quote +
On April 07 2017 05:20 tofucake wrote:
On April 07 2017 04:48 travis wrote:
It's assembly time in my current programming class. For the current project we have to convert a couple different C programs to assembly.

I am sure I will need help from you guys

Which assembly?


I don't know the differences. Does "Y86" answer that question?


x86 but yes. There's a bit more to it than that depending on what generation of intel processor you're running it on as well.

How strict is the grading on these assignments? Are you limited to a certain number of instructions?
I'll always be your shadow and veil your eyes from states of ain soph aur.
Deleted User 3420
Profile Blog Joined May 2003
24492 Posts
Last Edited: 2017-04-06 22:51:46
April 06 2017 22:50 GMT
#17376
85% of the grade is just making the program have the same output for tests as the corresponding C program

10% is for style

5% is for code efficiency

the only limit i see on instruction use is that if we are calling a function we must use call and not jmp
Hanh
Profile Joined June 2016
146 Posts
April 07 2017 01:30 GMT
#17377
gcc -S anyone?
Deleted User 3420
Profile Blog Joined May 2003
24492 Posts
Last Edited: 2017-04-07 01:54:27
April 07 2017 01:53 GMT
#17378
we've already been informed that we will horribly fail the tests if we try to do that

(I have no idea why, prof may have mentioned why but I can't remember the reasons)
Deleted User 3420
Profile Blog Joined May 2003
24492 Posts
Last Edited: 2017-04-07 13:09:41
April 07 2017 13:07 GMT
#17379
want to verify my understanding of combinatorics

the question i am given is that of "three-peat" combinations

we have an alphabet: {a, b, c}

We have words that are "threepeats", such that every n-size word word begins and ends with the same 3(floor of n/3) letters in the same order. For example, a threepeat word is "abcbbaabc", or "aabbcaa".

Why it's called a "threepeat" when the repeated sequence isn't necessarily 3 is beyond me.

Anyways we are asked for the total combinations of words possible for given n-lengths.

I want to verify that the way I solve this is with

x= [floor of (n/2)] (the size of the repeated segment)
y = n - 2x (the size of the middle segment)

then do 3^x * 3^y
Acrofales
Profile Joined August 2010
Spain17969 Posts
Last Edited: 2017-04-07 13:31:19
April 07 2017 13:27 GMT
#17380
I think I am understanding this correctly if I say the repeating part can be between 1 and floor(n/2) length, correct? If that's so, the formula is wrong:

Firstly, I am assuming the middle bit can only be in the same alphabet of 3 letters. Then the middle bit doesn't have y^x combinations, but 3^y. This gives you 3^x * 3^y = 3^(x + y) = 3^(n - x) possible combinations. This makes perfect sense, right. Because the only part you restrict is the final part with length x, which has to be exactly the same as the first x characters. So you have complete freedom over the first n-x characters, which can be chosen from your alphabet of 3 letters.

However, you're also forgetting to sum them: you have repeating parts of 1 letter, of 2 letters, of ... floor(n/2) letters, all of which have 3^(n-i) possible combinations. So to get all combinations, you have to do \Sum_{i=1}^{floor(n/2)} 3^(n - i).

But even then, you still have a problem with replacement in some corner cases. Consider for instance: Let n=6, and the sentence be aaaaaa. This is counted 3 times under the above system: once for the repeated seqence aaa (x=3, y=0), once for the repeated sequence aa (x=2, y=2) and once for the repeated sequence a (x=1, y=4)

I will leave it as an exercise for you how you can solve this.

E: you ninja edited a fix in there. So you already caught the first bit (but not the simplification or the rest).
Prev 1 867 868 869 870 871 1031 Next
Please log in or register to reply.
Live Events Refresh
Next event in 1h 17m
[ Submit Event ]
Live Streams
Refresh
StarCraft 2
Nina 129
StarCraft: Brood War
Sea 2697
ToSsGirL 733
BeSt 558
actioN 348
Killer 200
GoRush 109
Nal_rA 99
JulyZerg 60
Shinee 53
Mong 36
[ Show more ]
Sharp 27
Noble 23
sSak 14
Bale 8
Sacsri 3
Dota 2
BananaSlamJamma377
XcaliburYe276
League of Legends
JimRising 481
Counter-Strike
shoxiejesuss854
Stewie2K679
Super Smash Bros
Mew2King174
Heroes of the Storm
Khaldor139
Other Games
shahzam1293
ceh9635
Happy288
rGuardiaN73
SortOf17
DeMusliM10
Organizations
Other Games
gamesdonequick846
StarCraft 2
Blizzard YouTube
StarCraft: Brood War
BSLTrovo
sctven
[ Show 15 non-featured ]
StarCraft 2
• Berry_CruncH363
• OhrlRock 50
• LUISG 13
• AfreecaTV YouTube
• intothetv
• Kozan
• IndyKCrew
• LaughNgamezSOOP
• Migwel
• sooper7s
StarCraft: Brood War
• BSLYoutube
• STPLYoutube
• ZZZeroYoutube
Dota 2
• lizZardDota2116
League of Legends
• Stunt698
Upcoming Events
The PondCast
1h 17m
RSL Revival
1h 17m
ByuN vs Classic
Clem vs Cham
WardiTV European League
7h 17m
ByuN vs NightPhoenix
HeRoMaRinE vs HiGhDrA
Krystianer vs sebesdes
MaxPax vs Babymarine
SKillous vs Mixu
ShoWTimE vs MaNa
Replay Cast
15h 17m
RSL Revival
1d 1h
herO vs SHIN
Reynor vs Cure
WardiTV European League
1d 7h
Scarlett vs Percival
Jumy vs ArT
YoungYakov vs Shameless
uThermal vs Fjant
Nicoract vs goblin
Harstem vs Gerald
FEL
1d 7h
Korean StarCraft League
1d 18h
CranKy Ducklings
2 days
RSL Revival
2 days
[ Show More ]
FEL
2 days
Sparkling Tuna Cup
3 days
RSL Revival
3 days
FEL
3 days
BSL: ProLeague
3 days
Dewalt vs Bonyth
Replay Cast
4 days
Replay Cast
5 days
The PondCast
6 days
Replay Cast
6 days
Liquipedia Results

Completed

Proleague 2025-06-28
HSC XXVII
Heroes 10 EU

Ongoing

JPL Season 2
BSL 2v2 Season 3
BSL Season 20
Acropolis #3
KCM Race Survival 2025 Season 2
CSL 17: 2025 SUMMER
Copa Latinoamericana 4
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
YaLLa Compass Qatar 2025

Upcoming

CSLPRO Last Chance 2025
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.