Two Plus Two Publishing LLC
Two Plus Two Publishing LLC
 

Go Back   Two Plus Two Poker Forums > >

Notices

Programming Discussions about computer programming

Reply
 
Thread Tools Display Modes
Old 01-30-2015, 11:45 PM   #251
catsec
centurion
 
catsec's Avatar
 
Join Date: Apr 2014
Location: hunting shells
Posts: 178
Re: Programming homework and newbie help thread

ChrisV, daveT, and adios

Sorry for the delay in replying, I've been quite busy. Thank you all for the help, it is really appreciated!

ChrisV, it was I that screwed up the cipher text! I decrypted the original cipher text and saw that it had information about my university that I didn't want to post, so I replaced it. I think my efforts go to show that computers > humans when it comes to encrypting messages.

Cheers!
catsec is offline   Reply With Quote
Old 01-31-2015, 12:11 AM   #252
catsec
centurion
 
catsec's Avatar
 
Join Date: Apr 2014
Location: hunting shells
Posts: 178
Re: Programming homework and newbie help thread

Quote:
Originally Posted by daveT View Post

(to get the same result as ChrisV, you need to enter 23).


daveT,

That's interesting and strange. I don't understand why 23 is the value to successfully decrypt the cipher text instead of 3. How would I modify it to make it so a shift value of 3 successfully decrypts? I'm required to have 3 be the decrypting shift value.

Also, the assignment was originally instructed to be done in Java, and in the example my professor went over converting to ASCII in Java, but he also said we could use Python. I've tried running this code in Python3 after fixing the print syntax at the bottom and it fails with this error message. Any ideas?

Code:
cipherText = "FRQJUDWXODWLRKVBRXKDYHGHFOBSWHGWKHPHVVDJH"
shiftValue = input("Please enter an integer shift value from 1 to 26: ")

result = ""
for char in cipherText:
    result = result + chr(((ord(char) - 65 - shiftValue) % 26) + 65)  
print(result)
Quote:
Traceback (most recent call last):
File "C:\Users\IDC\Documents\Cryptography\CasesarCipher \TestFile.py", line 6, in <module>
result = result + chr(((ord(char) - 65 - shiftValue) % 26) + 65)
TypeError: unsupported operand type(s) for -: 'int' and 'str'

I have no idea what this means. And as an aside, I don't even want to ask what endianness is. I'm astounded at how easy some of you make programming look. It's tough in my opinion.
catsec is offline   Reply With Quote
Old 01-31-2015, 12:36 AM   #253
daveT
S.A.G.E. Master
 
daveT's Avatar
 
Join Date: Jun 2005
Location: La La Land
Posts: 23,159
Re: Programming homework and newbie help thread

catsec, you should consider using a pencil and paper when you don't understand how an algorithm works. Stepping through it leads to understanding.

The error you are receiving is pretty straight-forward. You are trying to subtract an integer and a string, which even Python won't let you do.

Endianess isn't too mysterious. It is how the computer "reads" byte-code, reading either left-to-right or right-to-left.
daveT is offline   Reply With Quote
Old 01-31-2015, 11:43 AM   #254
adios
Carpal \'Tunnel
 
Join Date: Sep 2002
Location: Russian Troll
Posts: 21,497
Re: Programming homework and newbie help thread

Endianness

You will seldom have to be concerned about this. Perhaps when processing byte streams from an external source.
adios is offline   Reply With Quote
Old 02-05-2015, 07:44 AM   #255
deleted23567
Guest
 
Posts: n/a
Re: Programming homework and newbie help thread

I have a problem in Visual Studio / C#:

We're working on building a movie Collection program, and I built a window, but something was wrong with the compability between it and the other stuff we'd built, so a group member told me to delete the repo-folder (my documents/source/repo) which I did, and cloned the repository we all share in VS...

However now I can't run the thing and I get this error:

"Visual Studio cannot start debugging because the debug target 'C:\Users\MyName\Source\Repos\GroupName\WindowsFor mApplication1\WindowsFormsApplication1\bin\Debug\F ilmApplication.exe' is missing. Please build the Project and retry, or set the OutputPath and AssemblyName properties appropriately to Point at the correct location for the target assembly"

I checked the Output path, and it's the same as for the others,\bin\debug\

Does anyone know how I can fix this, extremely irritating problem?

Thanks in advance,

nejo
  Reply With Quote
Old 02-05-2015, 07:51 AM   #256
deleted23567
Guest
 
Posts: n/a
Re: Programming homework and newbie help thread

Quote:
Originally Posted by nejo View Post
I have a problem in Visual Studio / C#:

We're working on building a movie Collection program, and I built a window, but something was wrong with the compability between it and the other stuff we'd built, so a group member told me to delete the repo-folder (my documents/source/repo) which I did, and cloned the repository we all share in VS...

However now I can't run the thing and I get this error:

"Visual Studio cannot start debugging because the debug target 'C:\Users\MyName\Source\Repos\GroupName\WindowsFor mApplication1\WindowsFormsApplication1\bin\Debug\F ilmApplication.exe' is missing. Please build the Project and retry, or set the OutputPath and AssemblyName properties appropriately to Point at the correct location for the target assembly"

I checked the Output path, and it's the same as for the others,\bin\debug\

Does anyone know how I can fix this, extremely irritating problem?

Thanks in advance,

nejo
Solved. The problem was that there was an error in the code, and that prevented the program from running and creating an .exe-file. I just put /* */ around the problem-code and was able to run the program.
  Reply With Quote
Old 02-05-2015, 08:24 AM   #257
catsec
centurion
 
catsec's Avatar
 
Join Date: Apr 2014
Location: hunting shells
Posts: 178
Re: Programming homework and newbie help thread

Hi all, I think I just realized something and wanted to make sure I was correct.

Am I correct in that a python program cannot possibly be closed source, as it is not compiled? Like for languages that must be compiled, when they are compiled into binary executable, you cannot read the source code without reverse engineering, and so such programs can be closed source if the producers choose to not publish the source code. This is not the case with python, so you cannot close source a python program.

Am I correct?
catsec is offline   Reply With Quote
Old 02-05-2015, 09:02 AM   #258
ChrisV
Carpal \'Tunnel
 
ChrisV's Avatar
 
Join Date: Jul 2004
Location: Adelaide, Australia
Posts: 40,283
Re: Programming homework and newbie help thread

No. For instance, a python program can be executed via a webservice.
ChrisV is offline   Reply With Quote
Old 02-05-2015, 02:25 PM   #259
Mr.mmmKay
Drugs are bad...
 
Mr.mmmKay's Avatar
 
Join Date: May 2011
Location: Treat your womenfolk with care
Posts: 16,216
Re: Programming homework and newbie help thread

and there are packages which can turn your code into an executable binary
Mr.mmmKay is offline   Reply With Quote
Old 02-05-2015, 10:22 PM   #260
daveT
S.A.G.E. Master
 
daveT's Avatar
 
Join Date: Jun 2005
Location: La La Land
Posts: 23,159
Re: Programming homework and newbie help thread

You can compile python to .pyc files, which certainly aren't human readable.
daveT is offline   Reply With Quote
Old 02-06-2015, 01:55 AM   #261
catsec
centurion
 
catsec's Avatar
 
Join Date: Apr 2014
Location: hunting shells
Posts: 178
Re: Programming homework and newbie help thread

Rats! Even though I knew those things, I failed to consider them. Thanks all!
catsec is offline   Reply With Quote
Old 02-06-2015, 12:27 PM   #262
Alobar
Born Ready
 
Alobar's Avatar
 
Join Date: Nov 2003
Location: 3rd turtle from the bottom
Posts: 41,296
Re: Programming homework and newbie help thread

I thought you could decompile most languages back to their original code? At least in the case of Java and Python, which is why on android for instance (which is written in java) your code is run through a program that obfuscates it, which while not making it impossible to get the original code, makes it harder. I also thought Python was supposed to be relatively easy to reverse engineer? Is that not correct, or am I totally misunderstanding what you guys mean
Alobar is offline   Reply With Quote
Old 02-06-2015, 11:15 PM   #263
daveT
S.A.G.E. Master
 
daveT's Avatar
 
Join Date: Jun 2005
Location: La La Land
Posts: 23,159
Re: Programming homework and newbie help thread

A .jar file is really a .zip file. You can "decompile" a .jar file using 7zip, which gives you clean source and folder tree back.

It seems kind of a given that if you can compile to something, you can decompile.

first hit for "decompile python" http://stackoverflow.com/questions/8...python-2-7-pyc
daveT is offline   Reply With Quote
Old 02-07-2015, 01:19 AM   #264
adios
Carpal \'Tunnel
 
Join Date: Sep 2002
Location: Russian Troll
Posts: 21,497
Re: Programming homework and newbie help thread

Quote:
Originally Posted by daveT View Post
A .jar file is really a .zip file. You can "decompile" a .jar file using 7zip, which gives you clean source and folder tree back.

It seems kind of a given that if you can compile to something, you can decompile.

first hit for "decompile python" http://stackoverflow.com/questions/8...python-2-7-pyc
I have my doubts about optimized C and C++ code.
adios is offline   Reply With Quote
Old 02-08-2015, 12:15 PM   #265
sthief09
Josh.
 
Join Date: Feb 2004
Posts: 20,654
Re: Programming homework and newbie help thread

highly recommend going through this if anyone is interested in data analysis/manipulation: https://www.youtube.com/watch?v=w26x-z-BdWQ
sthief09 is offline   Reply With Quote
Old 02-11-2015, 06:01 AM   #266
TheHoss
journeyman
 
TheHoss's Avatar
 
Join Date: Jul 2005
Posts: 313
Re: Programming homework and newbie help thread

following a quick guide to get acquainted with Powershell, and for some reason i can't get the "less" and "more" commands to work (using Windows 7).

i save a text file (ex13.txt) to C:\Users\Myname\temp\

type "less ex13.txt" but get the error

Quote:
The term 'less' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelli
ng of the name, or if a path was included, verify that the path is correct and try again.
At line:1 char:5
+ less <<<< ex13.txt
+ CategoryInfo : ObjectNotFound: (less:String) [], CommandNotFoundException
+ FullyQualifiedErrorId : CommandNotFoundException
well, idk what that's all about :S i tried it both as empty text file and with some words although i think that shouldn't matter.
TheHoss is offline   Reply With Quote
Old 02-11-2015, 09:34 AM   #267
adios
Carpal \'Tunnel
 
Join Date: Sep 2002
Location: Russian Troll
Posts: 21,497
Re: Programming homework and newbie help thread

Quote:
Originally Posted by TheHoss View Post
following a quick guide to get acquainted with Powershell, and for some reason i can't get the "less" and "more" commands to work (using Windows 7).

i save a text file (ex13.txt) to C:\Users\Myname\temp\

type "less ex13.txt" but get the error



well, idk what that's all about :S i tried it both as empty text file and with some words although i think that shouldn't matter.
Not a Powershell expert. Looked at your guide and it appears that it lists Unix commands that are implemented with Powershell aliases. I'm guessing that less doesn't have a Powershell alias.
adios is offline   Reply With Quote
Old 02-11-2015, 12:00 PM   #268
Alobar
Born Ready
 
Alobar's Avatar
 
Join Date: Nov 2003
Location: 3rd turtle from the bottom
Posts: 41,296
Re: Programming homework and newbie help thread

less and more work in powershell. That said I have no idea why you are getting that error.
Alobar is offline   Reply With Quote
Old 02-11-2015, 03:01 PM   #269
CyberShark93
veteran
 
CyberShark93's Avatar
 
Join Date: Dec 2013
Location: strangling the golden goose
Posts: 3,226
Re: Programming homework and newbie help thread

hi, i'm supposed to do this in python

a).Write a function that takes input a,b,c and finds the solution to a^x=b(mod c)
b). use the function u wrote in part a to solve 34091202317940^x = 46461034929471 (mod 61704897745301)

i tried just doing it iteratively by simply doing accumulator*a n times until accumulator = b(mod c) then returning n, however this function overflows for part b, since the numbers are just too big, so i was wondering is there a smarter way to do this?(perhaps some theorem that i need to use?)
CyberShark93 is offline   Reply With Quote
Old 02-11-2015, 09:19 PM   #270
adios
Carpal \'Tunnel
 
Join Date: Sep 2002
Location: Russian Troll
Posts: 21,497
Re: Programming homework and newbie help thread

Quote:
Originally Posted by CyberShark93 View Post
hi, i'm supposed to do this in python

a).Write a function that takes input a,b,c and finds the solution to a^x=b(mod c)
b). use the function u wrote in part a to solve 34091202317940^x = 46461034929471 (mod 61704897745301)

i tried just doing it iteratively by simply doing accumulator*a n times until accumulator = b(mod c) then returning n, however this function overflows for part b, since the numbers are just too big, so i was wondering is there a smarter way to do this?(perhaps some theorem that i need to use?)
I assume you are Python 2.7. The number is greater than 32 bits. Not an expert on Python, just a guess. If so start from there.
adios is offline   Reply With Quote
Old 02-11-2015, 09:39 PM   #271
CyberShark93
veteran
 
CyberShark93's Avatar
 
Join Date: Dec 2013
Location: strangling the golden goose
Posts: 3,226
Re: Programming homework and newbie help thread

Quote:
Originally Posted by adios View Post
I assume you are Python 2.7. The number is greater than 32 bits. Not an expert on Python, just a guess. If so start from there.
i managed to solve the overflow problem, but i found out that doing it iteratively is simply too slow for large inputs, i was wondering if there is a way where i can be clever and skip over a lot of cases where i don't need to test?
CyberShark93 is offline   Reply With Quote
Old 02-11-2015, 10:08 PM   #272
econophile
Carpal \'Tunnel
 
econophile's Avatar
 
Join Date: Jul 2005
Location: (X'X)^(-1)X'Y
Posts: 11,319
Re: Programming homework and newbie help thread

Quote:
Originally Posted by CyberShark93 View Post
hi, i'm supposed to do this in python

a).Write a function that takes input a,b,c and finds the solution to a^x=b(mod c)
b). use the function u wrote in part a to solve 34091202317940^x = 46461034929471 (mod 61704897745301)

i tried just doing it iteratively by simply doing accumulator*a n times until accumulator = b(mod c) then returning n, however this function overflows for part b, since the numbers are just too big, so i was wondering is there a smarter way to do this?(perhaps some theorem that i need to use?)
have you tried taking logs of both sides?
econophile is offline   Reply With Quote
Old 02-11-2015, 10:39 PM   #273
CyberShark93
veteran
 
CyberShark93's Avatar
 
Join Date: Dec 2013
Location: strangling the golden goose
Posts: 3,226
Re: Programming homework and newbie help thread

Quote:
Originally Posted by econophile View Post
have you tried taking logs of both sides?
i think we require integer solutions to the congruence a^x = b (mod c)
taking log will give us the solution to a^x=b, however x is not necessarily an integer in that case
CyberShark93 is offline   Reply With Quote
Old 02-11-2015, 10:44 PM   #274
Alobar
Born Ready
 
Alobar's Avatar
 
Join Date: Nov 2003
Location: 3rd turtle from the bottom
Posts: 41,296
Re: Programming homework and newbie help thread

I think I remember a project euler problem like this, sadly Id learn how to do something like this and now I completely forget all the number theory stuff I learned to do them
Alobar is offline   Reply With Quote
Old 02-12-2015, 12:35 AM   #275
daveT
S.A.G.E. Master
 
daveT's Avatar
 
Join Date: Jun 2005
Location: La La Land
Posts: 23,159
Re: Programming homework and newbie help thread

Quote:
Originally Posted by CyberShark93 View Post
i managed to solve the overflow problem, but i found out that doing it iteratively is simply too slow for large inputs, i was wondering if there is a way where i can be clever and skip over a lot of cases where i don't need to test?
You could probably use successive approximation.
daveT is offline   Reply With Quote

Reply
      

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off


Forum Jump


All times are GMT -4. The time now is 01:59 AM.


Powered by vBulletin®
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
Copyright © 2008-2017, Two Plus Two Interactive
 
 
Poker Players - Streaming Live Online