Jump to content
Phishing Emails & YouTube Messages - Fake Giveaway Read more... ×
Search In
  • More options...
Find results that contain...
Find results in...
fletch to 99

The under 100 line challenge!

Recommended Posts

YouTube competition winner generator, paste YouTube video link in and click generate.

 

All commenters will be recorded and get one entry each (excludes replies) and then one of those users gets randomly picked as the winner - https://gist.github.com/Cirx08/9ccbdce2d21cabefa472#file-random-youtube-winner


--

Link to post
Share on other sites
Posted · Original PosterOP

I've made another program :) -- A local screen snapper that can be bound to run when a hotkey is pressed (for use with my blackwidow)

 

https://gist.github.com/fletchto99/5788659


There are 10 types of people in this world, those who can read binary and those who can't.

There are 10 types of people in this world, those who can read hexadecimal and F the rest.

~Fletch

Link to post
Share on other sites

 

 

 
------------{asks user for number}-------------
print("type a number")
      local input = tonumber(io.read())
 
----------{split number into digits within a table}-----------
 
 local Digit = {tonumber(string.sub(input, 1, 1)), tonumber(string.sub(input, 2, 2)), tonumber(string.sub(input, 3, 3))}
local length = string.len(input)
 
--------------{convert to number}--------------
     local lengthNumber = tonumber(length)
-----------{writing out the number}------------
 
if lengthNumber == 1 then
if tonumber(input) == 1 then
io.write("One\n")
end
 
if tonumber(input) == 2 then
io.write("Two\n")
end
 
if tonumber(input) == 3 then
io.write("Three\n")
end
 
if tonumber(input) == 4 then
io.write("Four\n")
end
 
if tonumber(input) == 5 then
io.write("Five\n")
end
 
if tonumber(input) == 6 then
io.write("Six\n")
end
 
if tonumber(input) == 7 then
io.write("Seven\n")
end
 
if tonumber(input) == 8 then
io.write("Eight\n")
end
 
if tonumber(input) == 9 then
io.write("Nine\n")
end
end
 
if (lengthNumber == 2 and Digit[1] == 1) then
 
 
if Digit[2] == 0 then
io.write("Ten\n")
end
 
if Digit[2] == 1 then
io.write("Eleven\n")
end
 
if Digit[2] == 2 then
io.write("Twelve\n")
end
 
if Digit[2] == 3 then
io.write("Thirteen\n")
end
 
if Digit[2] == 4 then
io.write("Fourteen\n")
end
 
if Digit[2] == 5 then
io.write("Fifteen\n")
end
 
if Digit[2] == 6 then
io.write("Sixteen\n")
end
 
if Digit[2] == 7 then
io.write("Seventeen\n")
end
 
if Digit[2] == 8 then
io.write("Eighteen\n")
end
 
if Digit[2] == 9 then
io.write("Nineteen\n")
end
 
end
 
 
 
if (lengthNumber == 2 and Digit[1] == 2) then
 
io.write("Twenty")
 
if Digit[2] == 1 then
io.write("One\n")
end
 
if Digit[2] == 2 then
io.write("Two\n")
end
 
if Digit[2] == 3 then
io.write("Three\n")
end
 
if Digit[2] == 4 then
io.write("Four\n")
end
 
if Digit[2] == 5 then
io.write("Five\n")
end
 
if Digit[2] == 6 then
io.write("Six\n")
end
 
if Digit[2] == 7 then
io.write("Seven\n")
end
 
if Digit[2] == 8 then
io.write("Eight\n")
end
 
if Digit[2] == 9 then
io.write("Nine\n")
end
 
end
 

LUA

 

this is my first real world application program, however it is not finished it only accepts integers 1-29., it probably could be under 100 lines, but i like to make my code readable. had trouble with the if, else, elseif and a few other small mistakes, but my friend Austin helped me out like the good friend that he is

 

please for the love of god, but it in the:

here!

Best regards Zahlio,
Unity asset developer - Game developer (http://playsurvive.com) - Computer Science student

Link to post
Share on other sites

I find it useful to know the first X prime numbers, especially for doing Project Euler competitions. Here's how to get prime numbers using the Sieve of Eratosthenes, and an example to add up the first million prime numbers.

 

https://gist.github.com/danialgoodwin/5789439

 

(And there are many great things done with AutoHotKey that I really enjoy)

Link to post
Share on other sites
Posted · Original PosterOP

I find it useful to know the first X prime numbers, especially for doing Project Euler competitions. Here's how to get prime numbers using the Sieve of Eratosthenes, and an example to add up the first million prime numbers.

 

https://gist.github.com/danialgoodwin/5789439

 

(And there are many great things done with AutoHotKey that I really enjoy)

 

I recall having to do something similar to this in my programming class this year.


There are 10 types of people in this world, those who can read binary and those who can't.

There are 10 types of people in this world, those who can read hexadecimal and F the rest.

~Fletch

Link to post
Share on other sites

My simple python calculator.

https://gist.github.com/MrSchrodingersCat/5790332

print "Simple Calculator v1.0.0"def calc():    x = int(raw_input("Enter first number: "))    y = int(raw_input("Enter second number: "))    type = str.lower(raw_input("(A)dd, (S)ubtract, (M)ultiply, (D)ivide: "))    if type != "a" and type != "s" and type != "m" and type != "d":        print ("Invalid command.")        calc();    else:        if type == "a":            print ("The result is '" + str(x+y) + "'")        elif type == "s":            print ("The result is '" + str(x-y) + "'")        elif type == "m":            print ("The result is '" + str(x*y) + "'")        elif type == "d":            print ("The result is '" + str(float(x)/float(y)) + "'")                   if str.lower (raw_input("Restart? (y/n)"))== "y":            calc();        else:            exit([0])calc();

ASUS Maximus VII Hero || Intel i7-4790k || ASUS STRIX GTX 970 || Mushkin Blackline 4x4gb (16gb) 1600mhz || ADATA SX900 128gb SSD || 4 Random HDD's (1.5TB Total) || CM Storm Scout II || Enermax NAXN 80+ Bronze 650w || Corsair H100i || Windows 7 Home

Link to post
Share on other sites

What's up, new guy here. Heard about this on the Live Stream.

 

Here's a bunch of small scripts that I wrote for the purpose of making my life easier. :)

Most aren't even exhaustive. And they're not really end-user friendly, but UIs for this can be easily done! lol

By the way, some of them exceed 100 lines, but take out the comments and line breaks and you've get yerself a 100- lines codebit.

 

Link Getter - Give it a link, and a domain, and you get a list of all URLs with that domain in the linked page

FFXIII-2 Hands of Time Puzzle Solver - I had made a web ui for this, but I just realized my University took down all user pages, meh!

IEEE 754 "Converter" - Not really a converter, just shows you the bit values of a single precision floating point.

Simple Weighted Graph Djikstra's Shortest Path - This is actually a terrible and inefficient implementation of Dijkstra's SP algorithm on a weighted graph, but it's hanging around in my pastebin so why not. :P

Multi-threaded PGM Mandelbrot "renderer" - This is about 100 lines without the comments. Creates a pgm file with a mandelbrot drawn onto it, using the given amount of threads. 

 

Now, here's a question for anyone who's curious about low level stuff.

Why does this code...

#include <stdio.h> int main(int argc, char ** argv){ float f1 = 0.041;float f2 = 0.04;f2 += 0.001; if ( f1 == f2 ) printf("%f and %f are the same!", f1, f2);else printf("%f and %f are different! :(", f1, f2); printf("\n");return 0;}

Produce this output: 0.041000 and 0.041000 are different! :(

?

I often ask this to my computer architectures students, to watch them gasp. lol (Hint: read about IEEE 754)


Want to solve problems? Check this out.

Link to post
Share on other sites
Posted · Original PosterOP

What's up, new guy here. Heard about this on the Live Stream.

 

Here's a bunch of small scripts that I wrote for the purpose of making my life easier. :)

Most aren't even exhaustive. And they're not really end-user friendly, but UIs for this can be easily done! lol

By the way, some of them exceed 100 lines, but take out the comments and line breaks and you've get yerself a 100- lines codebit.

 

Link Getter - Give it a link, and a domain, and you get a list of all URLs with that domain in the linked page

FFXIII-2 Hands of Time Puzzle Solver - I had made a web ui for this, but I just realized my University took down all user pages, meh!

IEEE 754 "Converter" - Not really a converter, just shows you the bit values of a single precision floating point.

Simple Weighted Graph Djikstra's Shortest Path - This is actually a terrible and inefficient implementation of Dijkstra's SP algorithm on a weighted graph, but it's hanging around in my pastebin so why not. :P

Multi-threaded PGM Mandelbrot "renderer" - This is about 100 lines without the comments. Creates a pgm file with a mandelbrot drawn onto it, using the given amount of threads. 

 

Now, here's a question for anyone who's curious about low level stuff.

Why does this code...

#include <stdio.h> int main(int argc, char ** argv){ float f1 = 0.041;float f2 = 0.04;f2 += 0.001; if ( f1 == f2 ) printf("%f and %f are the same!", f1, f2);else printf("%f and %f are different! :(", f1, f2); printf("\n");return 0;}

Produce this output: 0.041000 and 0.041000 are different! :(

?

I often ask this to my computer architectures students, to watch them gasp. lol (Hint: read about IEEE 754)

 

This specific one doesn't occur in java. But I have encountered this issue in java before when doing

double input = 5.59;System.out.println("Output: " + (input % 2));

Expecting 1.59 but getting 1.589999999. I believe it has something to do with floating point accuracy, although I never looked into it. Its because it cant represent some numbers accurately or something. Feel free to correct me where I'm wrong :)


There are 10 types of people in this world, those who can read binary and those who can't.

There are 10 types of people in this world, those who can read hexadecimal and F the rest.

~Fletch

Link to post
Share on other sites

This specific one doesn't occur in java. But I have encountered this issue in java before when doing

double input = 5.59;System.out.println("Output: " + (input % 2));

Expecting 1.59 but getting 1.589999999. I believe it has something to do with floating point accuracy, although I never looked into it. Its because it cant represent some numbers accurately or something. Feel free to correct me where I'm wrong :)

 

Anywhere IEEE 754 is used, that error will happen. The JVM uses IEEE 754. You're using double precision floating point while testing it in Java probably. This is how to correctly port that to Java.

float f1 = 0.041f;float f2 = 0.04f;f2 += 0.001f;if ( f1 == f2 ) System.out.printf("%f and %f are the same!", f1, f2);else System.out.printf("%f and %f are different! :(", f1, f2); 

 

With double precision something like this should produce the same output:

double f1 = 0.041;double f2 = 0.03;f2 += 0.011;if ( f1 == f2 ) System.out.printf("%f and %f are the same!", f1, f2);else System.out.printf("%f and %f are different! :(", f1, f2); 

 

And yes, it has to do with floating point accuracy. That doesn't explain much though! It's fun to learn, look it up if low-level is interesting to you. ;)


Want to solve problems? Check this out.

Link to post
Share on other sites
Posted · Original PosterOP

Anywhere IEEE 754 is used, that error will happen. The JVM uses IEEE 754. You're using double precision floating point while testing it in Java probably. This is how to correctly port that to Java.

float f1 = 0.041f;float f2 = 0.04f;f2 += 0.001f;if ( f1 == f2 ) System.out.printf("%f and %f are the same!", f1, f2);else System.out.printf("%f and %f are different! :(", f1, f2); 

With double precision something like this should produce the same output:

double f1 = 0.041;double f2 = 0.03;f2 += 0.011;if ( f1 == f2 ) System.out.printf("%f and %f are the same!", f1, f2);else System.out.printf("%f and %f are different! :(", f1, f2); 

And yes, it has to do with floating point accuracy. That doesn't explain much though! It's fun to learn, look it up if low-level is interesting to you. ;)

I can't seem to replicate it.

 

bf647e8df5dc5a0a0e6bb01468cbf5ba.png

 

 

However I do get this

 

9272b3dbd77ef7e4b8e6311496c1090e.png


There are 10 types of people in this world, those who can read binary and those who can't.

There are 10 types of people in this world, those who can read hexadecimal and F the rest.

~Fletch

Link to post
Share on other sites

I can't seem to replicate it.

 

bf647e8df5dc5a0a0e6bb01468cbf5ba.png

 

Remove the "f" in the double precision variables. f is for single precision.

Take a closer look at the examples.


Want to solve problems? Check this out.

Link to post
Share on other sites
Posted · Original PosterOP

You used the double precision values with the single precision code. Double check the codebits. First one is for single precision (values are the same as the C code), second is for double precision.

 

EDIT: You changed the picture. :P Remove the "f" in the double precision variables.

 

Still saying they are the same... Also can you give me a rundown on why this occurs? :)


There are 10 types of people in this world, those who can read binary and those who can't.

There are 10 types of people in this world, those who can read hexadecimal and F the rest.

~Fletch

Link to post
Share on other sites

Still saying they are the same... Also can you give me a rundown on why this occurs? :)

For it to say they are the same, then you tested the wrong code (maybe you confused some values). Try literally copy-pasting my snippets.

You had me question myself there, since I hadn't tested the code. lol Here and here.

 

It's hard to give you a rundown if you don't know the standard. But it has to do with floating point arithmetic using this standard.

The final mantissa bit might differ for certain limit values, while a real representation of the value "looks the same".

 

So, essentially they're different at a binary level (bitwise), but end up with the same decimal representation.


Want to solve problems? Check this out.

Link to post
Share on other sites
Posted · Original PosterOP

For it to say they are the same, then you tested the wrong code (maybe you confused some values). Try literally copy-pasting my snippets.

You had me question myself there, since I hadn't tested the code. lol Here and here.

 

It's hard to give you a rundown if you don't know the standard. But it has to do with floating point arithmetic using this standard.

The final mantissa bit might differ for certain limit values, while a real representation of the value "looks the same".

 

So, essentially they're different at a binary level (bitwise), but end up with the same decimal representation.

I found my issue lol. Very stupid mistake (i didn't c/p your snippet, I just rewrote it)

 

622df10236e7e54490f4c1b7ea621770.png

 

Both output the same thing xD -- Sorry for that, also how can they be different at a binary level but not a decimal level? Like why wouldn't the decimal representation be off? Sorry for my noobieness I've never looked into this issue and everything I found on google seemed quite advanced. Although I did find this: http://stackoverflow.com/questions/2100490/floating-point-inaccuracy-examples/2100502#2100502


There are 10 types of people in this world, those who can read binary and those who can't.

There are 10 types of people in this world, those who can read hexadecimal and F the rest.

~Fletch

Link to post
Share on other sites

Written a long time ago, when needing numbers converting to float, double and int (handy for getting the hex values to modify flash cookie values)

#include <stdio.h>#include <string.h>#include <stdlib.h>#include <float.h>#include <limits.h>#include <math.h>int main() {	char line[1024];	int *bits;	int bits2;	double val;	float val2;	fgets(line, 1024, stdin);	val2 = atof(line);	val = val2;	bits2 = *((int*)&val2);	bits = (int*)&val;	printf("Float: %f\nHex: 0x%X\n", val2, bits2);	printf("Double: %f\nHex: 0x%08X%08X\n", val2, bits[1], bits[0]);	printf("Int: %d\nHex: 0x%08X\n", (int)val2, (int)val2);	return 1;}

0b10111010 10101101 11110000 00001101

Link to post
Share on other sites

Well, I made an ATM that asks the USER to deposit withdraw or view balance and does more cool stuff. But its 200 lines...lol 

I made it in QBasic


There are 10 types of people in this world, those who understand binary, and those who don't.

Link to post
Share on other sites

semi colons are the best. you could put pretty much anything in just one line.


Intel 4770k   -   Corsair Vengeance Pro CL9 16gb 1866mhz   -   Corsair Air 540   -   Gentle Typhoon AP45   -   Corsair ax1200i   -   Razer Death Adder 2013   -   Filco Majestouch 2   -   Crucial m4 256gb ssd   -   1TB Western Digital Black   -   Asus Maximus vi Formula   -   Bitspower matte black fittings   -   Black Ice sr1 240mm and 360mm Radiators   -   Swiftech mcp655   -   EK x-res pump top   -   Promochill Advanced lrt 3/8 5/8 bloodshed red tubing   -   swiftech apogee hd cpu block   -   Asus pb278q 1440p monitor   -   Razer Carcharas Headphones   -   Razer Vespula Hard Mouse Pad   -   Arctic Silver 5 TIM   -   Sapphire r9-290x   -   Ek-fc R9-290x Waterblock and Backplate

Link to post
Share on other sites

Julia set render.

Again debatable over "is it useful?". My program has its uses, and is just cool anyway. I mean, who doesn't like fractals? :)

I had to do a bit of white space culling to get it under 100 lines, but it fits, also as its Uni work I had to use their library. Though, If I hadn't it would still only be ~110 lines.

 

Using a private, non-crawl-able gist because uni work is always subject to plagiarism checks even if It is still my own work. 

https://gist.github.com/lutzee/2d0b5037b75763d4f6ec

 

Some samples from it. 

IvMxAkT.png

SJIIbjQ.png

VvWiC5M.png


Arch Linux on Samsung 840 EVO 120GB: Startup finished in 1.334s (kernel) + 224ms (userspace) = 1.559s | U mad windoze..?

Link to post
Share on other sites

Made this lil VBScript back in high school. Useful? Nope! But it sure kept me entertained xD

MsgBOX "Terminate script in Task Manager for free ice-cream"DoSet WshShell = WScript.CreateObject("WScript.Shell")For i = 0 to 5 WshShell.SendKeys "{NUMLOCK}" WScript.Sleep 15 WshShell.SendKeys "{CAPSLOCK}" WScript.Sleep 15 WshShell.SendKeys "{SCROLLLOCK}" WScript.Sleep 25  Nextloop

 Coolermaster HAF 932 | Intel i7 4770k  | Corsair H100i | 16GB 1600Mhz Corsair Vengeance | PowerColor 7970 | Asus Sabertooth Z87 | Corsair HX650 | Dell U2713HM , U2312HM


Samsung 840 Pro 128gb|  9tb Storage |  CMStorm Quickfire rapid (Cherry Blue) | SteelSeries Sensei RAW | SteelSeries Siberia | Logitech G51| Xonar DX| Sennheiser HD518|


~Duck Duck Goose!~

Link to post
Share on other sites

Knew i had this lying around : P

 

I don't know how to code, but i did come up with this! So useful, i know.

<html><head><title>My Script</title><script type="text/javascript">	alert("Hello world!");</script></head><body></body></html>

Stuff I have I like: Moto G - Superlux HD681 Evo - Monoprice 9927

90% of what I say is sarcasm.

Link to post
Share on other sites

I found my issue lol. Very stupid mistake (i didn't c/p your snippet, I just rewrote it)

 

622df10236e7e54490f4c1b7ea621770.png

 

Both output the same thing xD -- Sorry for that, also how can they be different at a binary level but not a decimal level? Like why wouldn't the decimal representation be off? Sorry for my noobieness I've never looked into this issue and everything I found on google seemed quite advanced. Although I did find this: http://stackoverflow.com/questions/2100490/floating-point-inaccuracy-examples/2100502#2100502

 

OK. Good looking out. It's a start. Here's a quick rundown of how a floating point value is represented with IEEE 754 (let's see single precision, double is similar). I'll try not to be confusing.

A single precision floating point is 4 bytes, which makes it a 32-bit representation. The general representation of a floating point is scientific notation in the form of (-1)signal * 1.mantissa * 2exp.

Remember that a bit may hold 0 or 1.

 

The bit distribution is as follows:

[s][eeeeeeee][mmmmmmmmmmmmmmmmmmmmmmm]

 

[s] - Represents the signal of the number (0 is positive, 1 is negative). 1 bit

[eeeeeeee] - Exponent portion of the number. This is calculated with a -127 excess (we'll see what this means below). 8 bits (can represent a number as high as 28-1 = 255)

[mmmmmmmmmmmmmmmmmmmmmmm] - The mantissa portion of the number. This is the fractional part of your real number. 23 bits

 

Let's take a look at an example:

[0] [01101000] [10101010100001101000010]

 

First of all, it is clear that this is a positive number (the signal bit is 0).

Next up, the exponent has a value of 01101000, which means that it represents 104 in decimal1. The reason for the -127 excess, is so that you can represent numbers in [-127,128]. This way it is possible to represent negative and positive exponents (for really big and really small numbers).

So this exponent is in fact 104-127 = -23.

 

Finally, the mantissa (the troublemaker). Conversion is (naturally) done this way. I assume you know your math and understand why we're using negative exponents. :P

Right to left, -1 to -n. So, in this case:

1*2-1 + 0*2-2 + .... + 0*2-22 = 0.666115.

 

As I mentioned previously, the general form of this standard is (-1)signal * 1.mantissa * 2exp. So my example number effectively represents 1.666115 * 2-23, which is roughly 1.986 * 10-7.

That is a simple explanation of how you would convert FP to decimal. Now, consider the following 2 representations:

 

0 01111010 01001111110111110011110 = 0.041 (this is the result of assigning this value to a variable)

+       -5                      0.312

 

0 01111010 01001111110111110011101 = 1.3118778 * 2-50.04099618125 ~= 0.041 (this is the result of adding 0.001 to a variable with 0.04)

+       -5                     0.3118778

 

The reason why this approximation is done, is pretty well explained in point 3 of that link you found. The final mantissa bits are approximations, rather than precise numerics (the only numbers that you can represent precisely are numbers which can be represented by fractions with a 2n denominator).

Now, if you are curious and want to understand why that's the result of this sum, go check out how to calculate floating point arithmetic. Also, a quick Google search brought this up.

 

Good luck! 

 

TL;DR: Never use floating point values for arithmetic when you'll need to compare them. This is why any (decent) programming teacher will tell you never to use floating point variables to handle things like bank balances. Most of them don't know why, but it's still good advice. :)

 

________________________________________________________________________________

1 - If you don't know how to convert from binary to decimal, a simple way is to sum powers of 2 from left to right, counting only the ones with a 1. So the first bit is worth 1, the next is 2, then 4, etc. 

So in this case 01101000 is 8+32+64 = 104. The general form is, in this case, 011010002 = 0*20 + 0*21 + 0*22 + 1*23 + 0*24 + 1*25 + 1*26 + 0*27 = 0+0+0+8+0+32+64+0 = 10410


Want to solve problems? Check this out.

Link to post
Share on other sites

If we can vote for pieces of software not found in this forum, the single scripts for Playonlinux tend to be 80-90 lines and makes me able to play skyrim on linux and stuff. Seems pretty useful to me.


Stuff I have I like: Moto G - Superlux HD681 Evo - Monoprice 9927

90% of what I say is sarcasm.

Link to post
Share on other sites

This is a Python program I wrote which calculates prime numbers within a specified range, gets a bit laggy at 15,000+ though as the loop is cycling 15,000+ times per number...

y=int(input("Enter the start of the range."))a=int(input("Enter the end of the range."))if y<2:    y=2for x in range (y,a):    c=0    z=x+1    for loop in range (0,x):        z=z-1        y=x%z        if y==0:            c=c+1        if c>2:            x=0    if c<=2:        print(x) 

| Cooler Master HAF 912 Plus | MSI P67A-G45 | i5 2500K @ 4.2GHz |  Coolermaster Hyper 212 Plus | EVGA GTX 670 FTW Edition 2GB | 8GB (2X4GB) Mushkin Blackline @ 1600MHz | 256GB OCZ Vertex 4 SSD | 1TB Western Digital Caviar Green | Corsair 600CX V2 | Windows 7 64-bit |

Link to post
Share on other sites

I made a Python command line version of Deal or No Deal in exactly 100 lines.

 

Download a executable version here. Just extract all the files in the zip and run DealOrNoDeal.exe from console. Unfortunately in the end of the game there is no pause and the window closes. I will work on fixing that.

http://filesmelt.com/dl/deal_or_no_deal.7z

 

 
6eyb2yX.jpg
 


from colorama import Fore, Back, Stylefrom termcolor import coloredimport colorama, random, os, syscolorama.init()values = [ 0.01, 1, 5, 10, 25, 50, 75, 100, 200, 300, 400, 		    500, 750, 1000, 5000, 10000, 25000, 50000, 75000, 		    100000, 200000, 300000, 400000, 500000, 750000, 1000000 ]			cases = []choice = 0round = 1class Case:	def __init__(self, number, value):		self.number = number		self.value = value		self.active = True		def print_cases(x):	os.system('cls')	print('')	for i in range(0, 13):		if not values[i] == 0:			a = ' $' + ' '*( 5 - len(str(values[i]))) + str(values[i]) + ' '		else:			a = ' '*8		if not values[i + 13] == 0:			b = ' $' + ' '*( 8 - len(str(values[i+13]))) + str(values[i+13]) + ' '		else:			b = ' '*11		print( '\t\t\t' + colored(a, 'grey', 'on_yellow') + '  ' + colored(b, 'grey', 'on_yellow'), end='')		if i == 6:			print('\tYour Case', end='')		if i == 7 and not choice == 0:			print( '\t' + colored('  ' + str(choice) + ' '*(4-len(str(choice))), 'grey', 'on_yellow'), end='' )		print('')	print('\n')		for i in range(0, 26):		if(x[i].active):			print( colored('  ' + str(x[i].number) + ' '*(4-len(str(x[i].number))), 'grey', 'on_yellow'), end='\t')		else:			print(colored('      ', 'grey', 'on_yellow'), end='\t')		if( i == 19):			print('\n\n\t\t', end='')		elif( i == 9):			print('\n')			def setup_cases():	r = list(values)	random.shuffle(r)	for i in range(0,26):		cases.append( Case( i + 1 , r[i] ) )		def get_offer():	total, a = 0, 0	for x in cases:		if x.number == choice or x.active:			a += 1			total += x.value	return int((total/a) * (round/10))setup_cases()print_cases(cases)while choice < 1 or choice > 26:	choice = int(input('\n\nChoose a case (1 - 26): '))for x in cases:	if x.number == choice:		x.active = Falseprint_cases(cases)while round < 10:	p = 7 - round	if p < 1: p = 1	for i in range(0, p):		print('\nPick ' + str(p) + ' cases this round')		x = 0		while x < 1 or x > 26 or not cases[x-1].active:			x = int(input('\n' + str(i + 1) + ': '))		for j in cases:			if j.number == x:				print('Case ' + str(x) + ': ' + str(j.value))				values[values.index(j.value)] = 0				j.active = False		input('Press Enter to continue...')		print_cases(cases)	print('\nThe bank offers ' + str(get_offer()))	d = input('Deal or No Deal? ')	if d.lower() == 'deal':		print ('Congratulations! You\'ve won $' + str(get_offer()))		sys.exit(0)	input('Press Enter to continue...')	print_cases(cases)	round += 1	for x in cases:	if x.active and not x.number == choice: val = x.valueprint('\n\nThe last case contained $' + str(val) + '\nCongratulations! You stuck with your case and won $' + str(cases[choice-1].value))
Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Buy VPN

×