Jump to content

The under 100 line challenge!

fletch to 99

I made this today, as I had convert a butt-ton of CSS-Hex-Value Colours to CSS-RGB-Value Colours. And this is exactly what it does. It's quite ugly in my opinion but I didn't have much time. It can also only convert end-of-line colours, but I'm planning on making it more useful. C# is probably also a little overkill to use here.

    using System;    using System.Collections.Generic;    using System.Linq;    using System.Text;    using System.Threading.Tasks;    using System.IO;    using System.Text.RegularExpressions;         namespace csscolourchanger    {        class Program        {            static void Main(string[] args)            {                while (true)                {                    Console.Write("Drag file to replace hex values in: ");                    string path = @Console.ReadLine(); ;                         string[] readText = File.ReadAllLines(path);                    char[] readTextLine;                         for (int i = 0; i <= readText.Length - 1; i++)                    {                        readTextLine = readText[i].ToString().ToCharArray();                        for (int j = 0; j <= readTextLine.Length - 1; j++)                        {                            if (readTextLine.Contains('#'))                            {                                if (readTextLine[j] == '#' &&                                    (IsHex(readTextLine[j + 1]) == true &&                                    IsHex(readTextLine[j + 2]) == true &&                                    IsHex(readTextLine[j + 3]) == true                                    ))                                {                                    if (readTextLine[j + 4] == ';')                                    {                                        readText[i] = Regex.Replace(readText[i], "#.*?;", "rgb(" +                                        Convert.ToInt32((readTextLine[j + 1]).ToString() + (readTextLine[j + 1]).ToString(), 16) +                                        "," +                                        Convert.ToInt32((readTextLine[j + 2]).ToString() + (readTextLine[j + 2]).ToString(), 16) +                                        "," +                                        Convert.ToInt32((readTextLine[j + 3]).ToString() + (readTextLine[j + 3]).ToString(), 16) +                                        ");");                                    }                                    else if (IsHex(readTextLine[j + 4]) == true &&                                   IsHex(readTextLine[j + 5]) == true &&                                   IsHex(readTextLine[j + 6]) == true &&                                   readTextLine[j + 7] == ';')                                    {                                        readText[i] = Regex.Replace(readText[i], "#.*?;", "rgb(" +                                        Convert.ToInt32((readTextLine[j + 1]).ToString() + (readTextLine[j + 2]).ToString(), 16) +                                        "," +                                        Convert.ToInt32((readTextLine[j + 3]).ToString() + (readTextLine[j + 4]).ToString(), 16) +                                        "," +                                        Convert.ToInt32((readTextLine[j + 5]).ToString() + (readTextLine[j + 6]).ToString(), 16) +                                        ");");                                    }                                }                            }                        }                    }                    foreach (string s in readText)                    {                        Console.WriteLine(s);                    }                    File.WriteAllLines(path, readText);                    Console.WriteLine("Successfully completed");                    Console.ReadKey();                }            }                 public static bool IsHex(char c)            {                if ('0' <= c && c <= '9') return true;                if ('a' <= c && c <= 'f') return true;                if ('A' <= c && c <= 'F') return true;                return false;            }        }    }

btw I use arch

Link to comment
Share on other sites

Link to post
Share on other sites

Magic 8-Ball written in 54 lines of Python (3). It could certainly be shorter I but then it'd have poor style and that's unacceptable. Also, I'm horrible at picking variable names.  :)

 

EDIT (07 November 2014): Random now picks from the list/array rather than generating a number and then pulling the corresponding element. This is much better, I'm not sure what I was thinking when I originally made this. :huh:

import randomimport sys  another = Truewhile another:    question = input("Ask the Magic 8-Ball anything!\n")     if question == "Exit" or question == "exit":        print("Goodbye.")        sys.exit()     outcomes = [        "It is certain.",        "It is decidedly so.",        "Without a doubt.",        "Yes definitely.",        "You may rely on it.",        "As I see it, yes.",        "Most likely.",        "Outlook good.",        "Yes.",        "Signs point to yes.",        "Reply hazy try again.",        "Ask again later.",        "Better not tell you now.",        "Cannot predict now.",        "Concentrate and ask again.",        "Don't count on it.",        "My reply is no.",        "My sources say no.",        "Outlook not so good.",        "Very doubtful."    ]     print(random.choice(outcomes))     passed = False    while passed is False:        again = str(input("Would you like to ask another question?(Y/n) "))         if again.lower() == "yes" or again.lower() == "y":            another = True            passed = True            print("-----------------------")        elif again.lower() == "no" or again.lower() == "n":            another = False            passed = True            print("Goodbye.")        else:            print("Eh, what now?")            passed = False

"Unix was not designed to stop you from doing stupid things, because that would also stop you from doing clever things." - Doug Gwyn

Link to comment
Share on other sites

Link to post
Share on other sites

C# Minecraft Server Query Method:

        public string Name { get; private set; }        public string Version { get; private set; }        public string Map { get; private set; }        public int NumPlayers { get; private set; }        public int MaxPlayers { get; private set; }        public string[] Players { get; private set; }        public void MinecraftQuery(IPAddress ip, int port)        {            using (UdpClient udp = new UdpClient())            {                IPEndPoint ep = new IPEndPoint(ip, port);                byte[] request =                {                    0xFE, 0xFD,         // Magic                    09,                 // Type                    00, 00, 00, 01      // Session ID                };                byte[] response;                udp.Client.SendTimeout = 5000;                udp.Client.ReceiveTimeout = 5000;                udp.Connect(ep);                udp.Send(request, 7);                if ((response = udp.Receive(ref ep)) != null)                {                    request[2] = 00;                                                                                                        // Type                    udp.Send(request                        .Concat(BitConverter.GetBytes(Int32.Parse(Encoding.UTF8.GetString(response, 5, response.Length - 6))).Reverse())    // Challenge                        .Concat(new byte[4])                                                                                                // Padding                        .ToArray(), 15);                    if ((response = udp.Receive(ref ep)) != null)                    {                        string[] split = Encoding.UTF8.GetString(response, 16, response.Length - 18).Split('\0');                        this.Name = split[1];                        this.Version = split[7];                        this.Map = split[11];                        this.NumPlayers = Int32.Parse(split[13]);                        this.MaxPlayers = Int32.Parse(split[15]);                        this.Players = split.Skip(23).ToArray();                    }                }            }        }

I'm kinda new to C# so any suggestions to improve my code would be greatly appreciated. :)

So that operates a minecraft server? Like Bukkit?

Looking for a Programming Project take a look here!

http://linustechtips.com/main/topic/407332-looking-for-a-project-idea-start-here/

Link to comment
Share on other sites

Link to post
Share on other sites

This is a C# class which you can use to solve a system of 3 equations (with 3 variables), using Gaussian elimination. You could also use it to do some other 3x4 matrix stuff, but IDK  :unsure:

 

Examples which I have tested so far have worked, if anyone can find a bug tell me! ;)

 

I am using row major order, just fill the matrix with 

AugMatrix3 m = new AugMatrix3(); //fills the matrix with 0sm.set(row, collumn, a_value);
using System;namespace gauss_elimination{    class AugMatrix3    {        private float[][] m = new float[3][];        public AugMatrix3(float[][] m) //constructors        {            m[0] = new float[4]{m[0][0], m[0][1], m[0][2], m[0][3]};            m[1] = new float[4]{m[0][0], m[0][1], m[0][2], m[0][3]};            m[2] = new float[4]{m[0][0], m[0][1], m[0][2], m[0][3]};        }        public AugMatrix3()        {            m[0] = new float[4] { 0, 0, 0, 0 };            m[1] = new float[4] { 0, 0, 0, 0 };            m[2] = new float[4] { 0, 0, 0, 0 };        }        public float get(int r, int c)        {            return m[r][c];        }        public void set(int r, int c, float value)        {            m[r][c] = value;        }        // row operations        public void rowopAdd(int r1, int r2)        {            for (int c = 0; c < 4; c++)            {                m[r1][c] += m[r2][c];            }        }        public void rowopSub(int r1, int r2){            for (int c = 0; c < 4; c++)            {                m[r1][c] -= m[r2][c];            }        }        public void rowopMult(int r, float n){            for (int c = 0; c < 4; c++)            {                m[r][c] *= n;            }        }        public void rowopDiv(int r, float n){            for (int c = 0; c < 4; c++)            {                m[r][c] /= n;            }        }        public void rowopSwap(int r1, int r2){            float[] A = m[r1];            m[r1] = m[r2];            m[r2] = A;        }        public float[] solve()        {            float x, y, z;            //change to upper triangular form            if (m[2][0] != 0)            {                rowopDiv(2, m[2][0] / m[0][0]);                rowopSub(2, 0);            }            if (m[1][0] != 0)            {                rowopDiv(1, m[1][0] / m[0][0]);                rowopSub(1, 0);            }            if (m[2][1] != 0)            {                rowopDiv(2, m[2][1] / m[1][1]);                rowopSub(2, 1);            }            if (m[2][2] != 0)            // get the coefficients            {                z = m[2][3] / m[2][2];                if (m[1][3] + (m[1][1] * -z) != 0)                {                    y = (m[1][3] - z * m[1][2])/m[1][1];                    if (m[0][3] + (m[0][2] * -z) + (m[0][1] * -y) != 0)                    {                        x = (m[0][3] - y * m[0][1] - z * m[0][2]) / m[0][0];                        return new float[3] { x, y, z }; //final values                    }                }            }            return null;            // inconsistent or infinite solutions.        }    }}  

Link to comment
Share on other sites

Link to post
Share on other sites

I've got something coming in that I'm really proud of (No nice code or anything) but it took me over 20 hours I think. (100 lines of code have never taken me this long)  :P But it was well worth it. I can't post it today, I've got to make sure my professor accepts it tomorrow, then I can post it (all kinds of no plagiarism rules and such)

 

To be continued....

Build log "Whiplash" : http://linustechtips.com/main/topic/158477-the-hero/

Whiplash: 4790k@4,4Ghz|Maximus VII Hero|4x4Gb Red/Black HyperX fury 1866Mhz|R9 290 Tri-X|Modded 450D|Sleeved cables on a M12II evo 850W|M500 480Gb| BenQ XL2411T@144Hz

Laptop: 4700MQ|16Gb@1600Mhz|Quadro 1100M|1080P|128Gb SSD|500Gb 7200RPM hdd

Link to comment
Share on other sites

Link to post
Share on other sites

Here it is, its a (very basic) brainf*ck interpreter. The program that is in the current string is Mandelbrot. (brainf*ck program by Erik Bosman)

.data	string: .asciz "A simple brainfuck interpreter\nBy Dorian de Koning\n"	brainfuck: .asciz"+++++++++++++[->++>>>+++++>++>+<<<<<<]>>>>>++++++>--->>>>>>>>>>+++++++++++++++[[>>>>>>>>>]+[<<<<<<<<<]>>>>>>>>>-]+[>>>>>>>>[-]>]<<<<<<<<<[<<<<<<<<<]>>>>>>>>[-]+<<<<<<<+++++[-[->>>>>>>>>+<<<<<<<<<]>>>>>>>>>]>>>>>>>+>>>>>>>>>>>>>>>>>>>>>>>>>>>+<<<<<<<<<<<<<<<<<[<<<<<<<<<]>>>[-]+[>>>>>>[>>>>>>>[-]>>]<<<<<<<<<[<<<<<<<<<]>>>>>>>[-]+<<<<<<++++[-[->>>>>>>>>+<<<<<<<<<]>>>>>>>>>]>>>>>>+<<<<<<+++++++[-[->>>>>>>>>+<<<<<<<<<]>>>>>>>>>]>>>>>>+<<<<<<<<<<<<<<<<[<<<<<<<<<]>>>[[-]>>>>>>[>>>>>>>[-<<<<<<+>>>>>>]<<<<<<[->>>>>>+<<+<<<+<]>>>>>>>>]<<<<<<<<<[<<<<<<<<<]>>>>>>>>>[>>>>>>>>[-<<<<<<<+>>>>>>>]<<<<<<<[->>>>>>>+<<+<<<+<<]>>>>>>>>]<<<<<<<<<[<<<<<<<<<]>>>>>>>[-<<<<<<<+>>>>>>>]<<<<<<<[->>>>>>>+<<+<<<<<]>>>>>>>>>+++++++++++++++[[>>>>>>>>>]+>[-]>[-]>[-]>[-]>[-]>[-]>[-]>[-]>[-]<<<<<<<<<[<<<<<<<<<]>>>>>>>>>-]+[>+>>>>>>>>]<<<<<<<<<[<<<<<<<<<]>>>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>>>>>>>>>>>>>>>>-<<<<<<[<<<<<<<<<]]>>>]"	outformat: .asciz "%c"	informat: .asciz "%c"	pointer: .space 1024.text.global main# Printing the program intromain:	movq $0, %rax	movq $string, %rdi	call printf# Setting up values in registers	movq 	$0, %rcx		# Setup charpointer	movq 	$pointer, %rbx		# Move adress of pointer in %rbxloop:	movq 	$brainfuck, %rdi	# Move adress of brainfuck into rax	movq 	(%rdi,%rcx,), %rax	# Move the char at the charpointer in rdi	call parse			# Calling parse	jmp 	loop################################################## Parsing the current caracter			##################################################parse:	cmpb $0x3c, %al		# Set flags, 0x3c = "<"	(ascii)	je dpointer		# Jump to decrement pointer	cmpb $0x3e, %al		# Set flags, 0x3e = ">" (ascii) 	je ipointer		# Jump to increment pointer	cmpb $0x2b, %al		# Set flags, 0x3b = "+" (ascii) 	je ivalue		# Jump to increment	cmpb $0x2d, %al		# Set flags, 0x3d = "-" (ascii) 	je dvalue		# Jump to decrement	cmpb $0x2e, %al		# Set flags, 0x2e = "." (ascii) 	je output		# Jump to output	cmpb $0x2c, %al		# Set flags, 0x3e = "," (ascii) 	je input		# Jump to input	cmpb $0x5b, %al		# Set flags, 0x3e = "[" (ascii) 	je jumpf		# Jump to jump forward	cmpb $0x5d, %al		# Set flags, 0x3e = "]" (ascii) 	je jumpb		# Jump to jump back 	cmpb $0x00, %al	je exit	ret# Executed if char is <dpointer:movq $brainfuck, %rdinextdpointer:	incq %rcx		# Increment charpointer	subq $8, %rbx		# Lower pointer with 8	movq (%rdi, %rcx,),%rax	# Load character at charpointer in rax	cmpb $0x3c, %al		# Check if next char is a <	je nextdpointer		# If next is < loop again	ret			# Return	# Executed if char is >ipointer:	movq $brainfuck, %rdi	# Move brainfuck in rdinextip:	incq %rcx		# Increment charpointer	addq $8, %rbx		# Adding one to the pointer	movq (%rdi, %rcx,),%rax	# Move char at charpointer in rax	cmpb $0x3e, %al		# Compare flags >, rax	je ipointer		# Loop again if char at charpinter is >	ret			# Return# Executed if char is +ivalue:	movq $brainfuck, %rdi	# Move branfuck in rdi	movq $0, %r9		# Set r9 to 0nextplus:	incq %rcx		# Increment the charpointer	incq %r9		# Increment r9	movq (%rdi, %rcx,), %rax# Move the char at charpointer in rax	cmpb $0x2b, %al		# Set compare flags, char at pointer,al	je nextplus		# If char at charpointer is + loop 	addq %r9, (%rbx)	# Adding the amount of +'s in a row to the pointer	ret			# Return# Executed if char is -dvalue:	movq $brainfuck, %rdi	# Move brainfuck in rdi	movq $0, %r9		# put 0 in r9nextmin:incq %rcx		# Increment the charpointer	incq %r9		# Increment r9	movq (%rdi, %rcx), %rax # Move the char at charpointer in rax	cmpb $0x2d, %al		# Setup compare flags -,al	je nextmin		# If next char is - loop again	subq %r9, (%rbx)	# Decrementing the value at the pointer	ret			# Return# Executed if char isoutput:	pushq %rcx	movq $0, %rax		# Mov $0 in rax	movq $outformat, %rdi	# Outformat adress in rdi	movq (%rbx), %rsi	# Mov Rbx in first print par	call printf		# Calling printf	popq %rcx	incq %rcx	ret# Executed if char is ,input:	pushq %rbp              # Move base pointer to stack        movq %rsp, %rbp         # Copy stack pointer to base pointer	pushq %rcx        subq $8, %rsp           # Reserve stack space        leaq -8(%rbp), %rsi     # Load adress        movq $informat, %rdi # Move the first parameter        movq $0, %rax           # Specify scanf memory storage adress        call scanf              #	movq -8(%rbp),  %rsi	# Second argument, the number	movq %rsi, (%rbx)	popq %rcx	incq %rcx	movq %rbp, %rsp         # Clear local variables from stack        popq %rbp               # Restore base pointer	ret# Executed if char is [jumpf:	movq $1, %r9		# Move 1 in r9 (the bracketcounter)	cmpq $0, (%rbx)		# Setup compare flags	je checkn		# Jump to search for next bracket if the value at the pointer is 0	incq %rcx		# If pointer!=0 increment the charpointer	ret			# And returncheckn:	incq %rcx		# Increment charpointer	movq (%rdi, %rcx,), %rax# load next char in %rax	cmpb $0x5b, %al		# Check if char is [	jne notopen		# If it is not jump notopen	incq %r9		# Else increment r9notopen:cmpb $0x5d, %al		# Check if char is ]	jne checkn		# Loop again if the char=!]	decq %r9		# If char=] Decrement r9	cmpq $0, %r9		# If the char is a closing bracket set compare flags 0,r9 (bracketcounter)	jne checkn		# If r9=!0 loop again	ret			# return to main# Executed if char is }jumpb:	movq $1, %r9		# Move 1 in r9 (the bracketcounter)	cmpq $0, (%rbx)		# Setup compare flags	jne checkp		# If the value at the pointer is not 0 search for matching bracket	incq %rcx		# Increment the charpointer	ret			# Returncheckp:	decq %rcx		# Decrement charpointer	movq (%rdi, %rcx,), %rax# Move the char at the charpointer in rax	cmpb $0x5d, %al		# Setup compare flags	jne notclose		# If char=!] jump to notclose	incq %r9		# Increment the bracketcounternotclose:	cmpb $0x5b, %al		# Setup flags	jne checkp		# If char=![ loop again	decq %r9		# Decrement r9	cmpq $0, %r9		# Setup flags	jne checkp		# if r9 =! 0 loop again	incq %rcx		# Increment charpointer (Select char after matching bracket)	ret			# Return to main\

Its not exactly under a 100 lines (I've a less optimized version under 100 lines) but its close to it...

Build log "Whiplash" : http://linustechtips.com/main/topic/158477-the-hero/

Whiplash: 4790k@4,4Ghz|Maximus VII Hero|4x4Gb Red/Black HyperX fury 1866Mhz|R9 290 Tri-X|Modded 450D|Sleeved cables on a M12II evo 850W|M500 480Gb| BenQ XL2411T@144Hz

Laptop: 4700MQ|16Gb@1600Mhz|Quadro 1100M|1080P|128Gb SSD|500Gb 7200RPM hdd

Link to comment
Share on other sites

Link to post
Share on other sites

Here it is, its a (very basic) brainf*ck interpreter. The program that is in the current string is Mandelbrot.

.data	string: .asciz "A simple brainfuck interpreter\nBy Dorian de Koning\n"	brainfuck: .asciz"+++++++++++++[->++>>>+++++>++>+<<<<<<]>>>>>++++++>--->>>>>>>>>>+++++++++++++++[[>>>>>>>>>]+[<<<<<<<<<]>>>>>>>>>-]+[>>>>>>>>[-]>]<<<<<<<<<[<<<<<<<<<]>>>>>>>>[-]+<<<<<<<+++++[-[->>>>>>>>>+<<<<<<<<<]>>>>>>>>>]>>>>>>>+>>>>>>>>>>>>>>>>>>>>>>>>>>>+<<<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<<[>[-]<->>>>>>>>[-<<<<<<<<+>[<->-<<+>>]<[->+<]>>>>>>>>]<<<<<<<[->>>>>>>+<<<<<<<]<+<<<<<<<<<]>+++++[-[->>>>>>>>>+<<<<<<<<<]>>>>>>>>>]>>>>>+>>>>>>>>>>>>>>>>>>>>>>>>>>>+<<<<<<[<<<<<<<<<]>>>>>>>>>[>>>>>>[-<<<<<<->>>>>>]+<<<<<<[->>>>>>->>[-<<<<<<<<+>>>>>>>>]<<<<<<<<[->>>>>>>>+<<<<<<<<<<<<<<<<<[<<<<<<<<<]>>>>[-]+>>>>>[>>>>>>>>>]>+<]]+>>>>>>>>[-<<<<<<<<->>>>>>>>]+<<<<<<<<[->>>>>>>>-<<[-<<<<<<+>>>>>>]<<<<<<[->>>>>>+<<<<<<<<<<<<<<<[<<<<<<<<<]>>>[-]+>>>>>>[>>>>>>>>>]>[-]+<]]+>[-<[>>>>>>>>>]<<<<<<<<]>>>>>>>>]<<<<<<<<<[<<<<<<<<<]>>>>[-]<<<+++++[-[->>>>>>>>>+<<<<<<<<<]>>>>>>>>>]>>>>>->>>>>>>>>>>>>>>>>>>>>>>>>>>-<<<<<<[<<<<<<<<<]]>>>]"	outformat: .asciz "%c"	informat: .asciz "%c"	pointer: .space 1024.text.global main# Printing the program intromain:	movq $0, %rax	movq $string, %rdi	call printf# Setting up values in registers	movq 	$0, %rcx		# Setup charpointer	movq 	$pointer, %rbx		# Move adress of pointer in %rbxloop:	movq 	$brainfuck, %rdi	# Move adress of brainfuck into rax	movq 	(%rdi,%rcx,), %rax	# Move the char at the charpointer in rdi	call parse			# Calling parse	jmp 	loop################################################## Parsing the current caracter			##################################################parse:	cmpb $0x3c, %al		# Set flags, 0x3c = "<"	(ascii)	je dpointer		# Jump to decrement pointer	cmpb $0x3e, %al		# Set flags, 0x3e = ">" (ascii) 	je ipointer		# Jump to increment pointer	cmpb $0x2b, %al		# Set flags, 0x3b = "+" (ascii) 	je ivalue		# Jump to increment	cmpb $0x2d, %al		# Set flags, 0x3d = "-" (ascii) 	je dvalue		# Jump to decrement	cmpb $0x2e, %al		# Set flags, 0x2e = "." (ascii) 	je output		# Jump to output	cmpb $0x2c, %al		# Set flags, 0x3e = "," (ascii) 	je input		# Jump to input	cmpb $0x5b, %al		# Set flags, 0x3e = "[" (ascii) 	je jumpf		# Jump to jump forward	cmpb $0x5d, %al		# Set flags, 0x3e = "]" (ascii) 	je jumpb		# Jump to jump back 	cmpb $0x00, %al	je exit	ret# Executed if char is <dpointer:movq $brainfuck, %rdinextdpointer:	incq %rcx		# Increment charpointer	subq $8, %rbx		# Lower pointer with 8	movq (%rdi, %rcx,),%rax	# Load character at charpointer in rax	cmpb $0x3c, %al		# Check if next char is a <	je nextdpointer		# If next is < loop again	ret			# Return	# Executed if char is >ipointer:	movq $brainfuck, %rdi	# Move brainfuck in rdinextip:	incq %rcx		# Increment charpointer	addq $8, %rbx		# Adding one to the pointer	movq (%rdi, %rcx,),%rax	# Move char at charpointer in rax	cmpb $0x3e, %al		# Compare flags >, rax	je ipointer		# Loop again if char at charpinter is >	ret			# Return# Executed if char is +ivalue:	movq $brainfuck, %rdi	# Move branfuck in rdi	movq $0, %r9		# Set r9 to 0nextplus:	incq %rcx		# Increment the charpointer	incq %r9		# Increment r9	movq (%rdi, %rcx,), %rax# Move the char at charpointer in rax	cmpb $0x2b, %al		# Set compare flags, char at pointer,al	je nextplus		# If char at charpointer is + loop 	addq %r9, (%rbx)	# Adding the amount of +'s in a row to the pointer	ret			# Return# Executed if char is -dvalue:	movq $brainfuck, %rdi	# Move brainfuck in rdi	movq $0, %r9		# put 0 in r9nextmin:incq %rcx		# Increment the charpointer	incq %r9		# Increment r9	movq (%rdi, %rcx), %rax # Move the char at charpointer in rax	cmpb $0x2d, %al		# Setup compare flags -,al	je nextmin		# If next char is - loop again	subq %r9, (%rbx)	# Decrementing the value at the pointer	ret			# Return# Executed if char isoutput:	pushq %rcx	movq $0, %rax		# Mov $0 in rax	movq $outformat, %rdi	# Outformat adress in rdi	movq (%rbx), %rsi	# Mov Rbx in first print par	call printf		# Calling printf	popq %rcx	incq %rcx	ret# Executed if char is ,input:	pushq %rbp              # Move base pointer to stack        movq %rsp, %rbp         # Copy stack pointer to base pointer	pushq %rcx        subq $8, %rsp           # Reserve stack space        leaq -8(%rbp), %rsi     # Load adress        movq $informat, %rdi # Move the first parameter        movq $0, %rax           # Specify scanf memory storage adress        call scanf              #	movq -8(%rbp),  %rsi	# Second argument, the number	movq %rsi, (%rbx)	popq %rcx	incq %rcx	movq %rbp, %rsp         # Clear local variables from stack        popq %rbp               # Restore base pointer	ret# Executed if char is [jumpf:	movq $1, %r9		# Move 1 in r9 (the bracketcounter)	cmpq $0, (%rbx)		# Setup compare flags	je checkn		# Jump to search for next bracket if the value at the pointer is 0	incq %rcx		# If pointer!=0 increment the charpointer	ret			# And returncheckn:	incq %rcx		# Increment charpointer	movq (%rdi, %rcx,), %rax# load next char in %rax	cmpb $0x5b, %al		# Check if char is [	jne notopen		# If it is not jump notopen	incq %r9		# Else increment r9notopen:cmpb $0x5d, %al		# Check if char is ]	jne checkn		# Loop again if the char=!]	decq %r9		# If char=] Decrement r9	cmpq $0, %r9		# If the char is a closing bracket set compare flags 0,r9 (bracketcounter)	jne checkn		# If r9=!0 loop again	ret			# return to main# Executed if char is }jumpb:	movq $1, %r9		# Move 1 in r9 (the bracketcounter)	cmpq $0, (%rbx)		# Setup compare flags	jne checkp		# If the value at the pointer is not 0 search for matching bracket	incq %rcx		# Increment the charpointer	ret			# Returncheckp:	decq %rcx		# Decrement charpointer	movq (%rdi, %rcx,), %rax# Move the char at the charpointer in rax	cmpb $0x5d, %al		# Setup compare flags	jne notclose		# If char=!] jump to notclose	incq %r9		# Increment the bracketcounternotclose:	cmpb $0x5b, %al		# Setup flags	jne checkp		# If char=![ loop again	decq %r9		# Decrement r9	cmpq $0, %r9		# Setup flags	jne checkp		# if r9 =! 0 loop again	incq %rcx		# Increment charpointer (Select char after matching bracket)	ret			# Return to main\

Its not exactly under a 100 lines (I've a less optimized version under 100 lines) but its close to it...

Could you give a input / output example?

Looking for a Programming Project take a look here!

http://linustechtips.com/main/topic/407332-looking-for-a-project-idea-start-here/

Link to comment
Share on other sites

Link to post
Share on other sites

Could you give a input / output example?

There is no input on runtime, you just paste the brainfuck code that has to be interpreted in the brainfuck assembler directive. However it wouldn't take a lot of effort to make the program read from a specified file (but that was not a requirement so I didn't bother also that would have made it a lot slower, read below) The output will be the output of the brainfuck program. In this case (there is a brainfuck program for printing a ascii mantelbrot written by Erik Bosman) there will be a mantelbrot printed in ascii. 

(Something like this) but in ascii ofcourse.

Mandel_zoom_00_mandelbrot_set.jpg

But you can put any (valid) brainfuck program in there. Just to make clear there was a little context about who could make the fastest brainfuck interpreter. I finished 8th of the 18th, but as you can see I made this thing really basic and try optimizing it to hard I just went for the bonus points you could get by making a interpreter. From the 250 (maybe a little less if, there are some dropped out) I believe 17 took the challenge and wrote one, I finished 8th out of those 17th. (the fastest was 25x faster than mine) but those to guys took a total different approach, they just wrote a program to convert the brainf*ck to assembly and executed the assembly. However mine was also around 20 times faster then the slowest... :P

Build log "Whiplash" : http://linustechtips.com/main/topic/158477-the-hero/

Whiplash: 4790k@4,4Ghz|Maximus VII Hero|4x4Gb Red/Black HyperX fury 1866Mhz|R9 290 Tri-X|Modded 450D|Sleeved cables on a M12II evo 850W|M500 480Gb| BenQ XL2411T@144Hz

Laptop: 4700MQ|16Gb@1600Mhz|Quadro 1100M|1080P|128Gb SSD|500Gb 7200RPM hdd

Link to comment
Share on other sites

Link to post
Share on other sites

@[member='Echo'] offTitle Numbers to Binarysetlocal EnableDelayedExpansion:begginingset errorlevel=0set "x=1"set "inp="clsset /p inp=Enter a number to be converted to binary:if not defined inp goto begginingSET "var="&for /f "delims=0123456789" %%i in ("%inp%") do set "var=%%i"if defined var (goto beggining) else (echo.)if %inp% GEQ 2147483647 goto begginingset "x=0"set "a=1"set "b=0"set "c=0"set "d=0"set "e="set "f=1":topset "b=%inp%"goto tryagain:fixset /a "a*=2"set /a "f+=1":tryagainset /a "c=%b%-(2*%a%)"if %c% LSS 0 goto dothematshgoto fix:dothematshset /a "c=%b%-%a%"if %c% LSS 0 set "d=0"if %c% GTR -1 set "d=1"if %c% GTR -1 set "b=%c%"set /a "a=%a%/2"set "e=%e%%d%"set /a "f-=1"if %f% LSS 1 goto donegoto dothematsh:doneecho %e% pause >nulgoto beggining

Simple batch converter for converting a Number into Binary Digits.

It works until the number ((2^32)/2)-1  (2147483647) due to Windows Limitations.

But it only accepts numbers up to ((2^32)/2)-2 due to Error Checking

A riddle wrapped in an enigma , shot to the moon and made in China

Link to comment
Share on other sites

Link to post
Share on other sites

So that operates a minecraft server? Like Bukkit?

 

It queries a Minecraft server.

 

I have another one for Source Engine games. :P

~meOw! Σ:3

Link to comment
Share on other sites

Link to post
Share on other sites

Random Pass Generator in Javascript

<!DOCTYPE html><html>     <head>          <!--           Program Name: Random Password Generator          Purpose: Generates a random password with a desired length          Author: Cornelius Froese          Date Last Modified: 3-Nov-2014          -->          <title> Random Password Generator </title>          <script type="text/javascript">			               // Determines the final randomized password               function determinePassword(passLength) {                    for (var index = 0; index < passLength; index++) {                    randomPos = Math.floor(Math.random() * possibleCharacter.length);                    finalPassword += possibleCharacter[randomPos];                    }                    // Returns the final random password                    return finalPassword;               }			          </script>     </head>          <body>		<script type="text/javascript">				     var finalPassword = "";	// Final password to be input by program		     var passwordLength;	// Length of the desired password		     var possibleCharacter = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";	// All possible characters		     var randomPos;	// Random position determined in the separate function		     var BR = "<br/>";		     // Welcomes the user		     document.write("Welcome to the random password generator" + BR);					     // Prompts the user for the length of the password they desire		     passwordLength = prompt("What is your desired password length?", "");		     passwordLength = parseInt(passwordLength);					     // Calls the function and is returned with the final password		     determinePassword(passwordLength);				     // Writes out the final password to the user		     document.write(finalPassword);	              </script>       </body></html>
Link to comment
Share on other sites

Link to post
Share on other sites

My first legit Java program other than a CS lab, Its a Guessing game so its pretty fun to play, need to work on the difficulty by tweaking the amount of allowed guesses, but it works.

package guessinggame;import java.util.Scanner;public class GuessingGame {    public static void main(String[] args) {        Scanner scan = new Scanner(System.in);        int number, max, guesses = 0, maxGuesses;        System.out.println("Guessing game\n=============");        while(true) {            while(true) {                System.out.print("Would you like to play on easy, " +                        "medium, hard or extreme? ");                String answer = scan.nextLine();                if (answer.equalsIgnoreCase("easy")) {                    max = 10;                    maxGuesses = 5;                     break;                }                else if (answer.equalsIgnoreCase("medium")) {                    max = 50;                    maxGuesses = 10;                    break;                }                 else if (answer.equalsIgnoreCase("hard")) {                    max = 100;                    maxGuesses = 25;                    break;                }                else if (answer.equalsIgnoreCase("extreme")) {                    max = 1000;                    maxGuesses = 50;                    break;                }                else System.out.println("That's not a difficulty");            }            int randNumber = (int) ((Math.random() * max) + 1);            System.out.printf("I'm thinking of a number between 1" +                    " and %d: ",max);            while(maxGuesses>0) {                while(!scan.hasNextInt()) {                    String userEntered = scan.next();                    System.out.printf("%s is not a number, Please" +                            " re-enter: ",userEntered);                }                number = scan.nextInt();                scan.nextLine();                guesses++;                if (number == randNumber) {                    System.out.printf("The number %d is what I was thinking!" +                            " Good job, it only took you" +                            " %d guesses!\n",number,guesses);                    break;                }                else {                    if (number>max||number<1)                        System.out.printf("%d is not in the correct" +                                " range\n",number);                    else if (number > randNumber)                        System.out.printf("%d is too high. ",number);                    else if (number < randNumber)                        System.out.printf("%d is too low. ",number);                    maxGuesses--;                    if (maxGuesses > 0) {                        System.out.printf("You have %d guesses" +                                " left\n",maxGuesses);                        System.out.print("Guess again: ");                    }                    else System.out.println("Sorry, you ran out of guesses!");                }            }            guesses = 0;            while(true) {                System.out.print("Would you like to play again?(Yes/No)? ");                String answer = scan.nextLine();                if (answer.equalsIgnoreCase("yes")) break;                if (answer.equalsIgnoreCase("no")) System.exit(0);                else System.out.println("That is not a valid answer");            }        }    } }
Link to comment
Share on other sites

Link to post
Share on other sites

from Tkinter import *import mathwindow =Tk()window.minsize(500,500)window.maxsize(500,500)Label(window,text='Orbital Mechanics Calculator\nV = Sqrt(G*M*(2/r-1/a))\n Enter everything except Velocity').place(x=175,y=20)G = 6.673*10**-11def calc():    pc = pchoice.get()    if pc =="Kerbin":        M=5.2915793*10**22        rp= 600000    elif pc=='Eve':        M=1.2244127*10**23        rp=700000    elif pc=='Duna':        M=4.5154812*10**21        rp=320000    elif pc=='Moho':        M=2.5263617*10**21        rp=250000    #M=float(Mass.get())    #rp =float(RadoP.get())    r = 2/((float(Rad.get())*1000)+rp)    a = 1/((((float(Apo.get())*1000)+rp)+((float(Peri.get())*1000)+rp))/2)    Theta = r-a    Velocity = G*M*Theta    Velocity = math.sqrt(Velocity)    Vel.delete(0,END)    Vel.insert(0,Velocity)    Label(window,text='Periapsis (km)').place(x=100,y=75)Peri = Entry(window)Peri.place(x=100,y=100)Apo=Entry(window)Apo.place(x=240,y=100)Label(window,text='Apoapsis (km)').place(x=240,y=75)Vel =Entry(window)Vel.place(x=100,y=175)Label(window,text='Velocity (m/s)').place(x=100,y=150)Rad = Entry(window)Rad.place(x=240,y=175)Label(window,text='Radius of desired posistion (km)').place(x=240,y=150)pchoice = StringVar(window)pchoice.set('Kerbin')Planets = ['Kerbin','Eve','Duna','Moho','Dres','Eeloo','Jool']Pmenu = OptionMenu(window, pchoice, *Planets)Pmenu.place(x=100,y=250)#RadoP= Entry(window)#RadoP.place(x=100,y=250)#RadoP.insert(0,6371000)#Label(window,text='Radius of planet\n (Core to Surface (m))').place(x=100,y=210)#Mass= Entry(window)#Mass.place(x=240,y=250)#Label(window,text='Mass of body (kg)').place(x=240,y=225)#Mass.insert(0,5.972*10**24)derp=Button(window,text='Calculate',command=calc)derp.place(x=100,y=300)window.mainloop()

Almost finished Velocity Calculator for Kerbal Space Program, just need to add in the mass and radius of jool,dres and eleoo. Will probs build this into a more complicated program that will be a lot more useful i.e calculate phase angles for transfer burns and compare orbit velocities for a Delta V value. Also commented out manual input of mass and radius of the body the object you're orbiting. 

Link to comment
Share on other sites

Link to post
Share on other sites

Koch's snowflake: right now it's setup to draw the sixth order fractal

JIwrlWr.png

#include <cairomm/context.h>#include <cmath>#include <gtkmm/application.h>#include <gtkmm/drawingarea.h>#include <gtkmm/window.h>#include <utility>const double PI = 3.14159265359; class SnowflakeArea : public Gtk::DrawingArea {public:   SnowflakeArea() {}   virtual ~SnowflakeArea() {} protected:   //Override default signal handler:   virtual bool on_draw(const Cairo::RefPtr<Cairo::Context>& cr);};  static std::pair<double,double>drawFractalLine(const Cairo::RefPtr<Cairo::Context>& cr,                std::pair<double, double> pt,                double r, double theta, int order){   double x0 = pt.first;   double y0 = pt.second;    if (order == 0) {      cr->move_to(x0, y0);      double x1 = x0 + r*cos(theta);      double y1 = y0 + r*sin(theta);      cr->line_to(x1, y1);      return std::make_pair(x1, y1);   } else {      pt = drawFractalLine(cr, pt, r/3, theta, order-1);      pt = drawFractalLine(cr, pt, r/3, theta+PI/3, order-1);      pt = drawFractalLine(cr, pt, r/3, theta-PI/3, order-1);      pt = drawFractalLine(cr, pt, r/3, theta, order-1);       return pt;   }}  bool SnowflakeArea::on_draw(const Cairo::RefPtr<Cairo::Context>& cr){   Gtk::Allocation allocation = get_allocation();   const int width  = allocation.get_width();   const int height = allocation.get_height();   const int SIZE = width/1.5;    double xc = width/2;   double yc = height/2;    // now draw the fractal   cr->set_line_width(1.0);   cr->set_source_rgb(0.7, 0.0, 0.0);    std::pair<double, double> pt(xc-SIZE/2, yc + sqrt(3.0)*SIZE/6);    int order = 6;    pt = drawFractalLine(cr, pt, SIZE, 0, order);   pt = drawFractalLine(cr, pt, SIZE, -2*PI/3, order);   pt = drawFractalLine(cr, pt, SIZE, +2*PI/3, order);   cr->stroke();    return true;}  int main(int argc, char** argv){   Glib::RefPtr<Gtk::Application> app =       Gtk::Application::create(argc, argv, "org.gtkmm.example");    Gtk::Window win;   win.set_title("Koch's Snowflake");   win.set_default_size(1000, 1000);    SnowflakeArea area;   win.add(area);   area.show();    return app->run(win);}

Change the value "order" to N in the SnowflakeArea::on_draw method to draw the N+1st iteration. Yeah, I know it should be in a private member set by the constructor but I just hacked this real quick and lazy. Compiled it with g++ using the GTKMM library in Ubuntu 12.04. 

Link to comment
Share on other sites

Link to post
Share on other sites

  • 2 weeks later...

Very rough console class I wrote for another program I am working on and learning. Supports basic plugins but needs more work for production use.

package pw.jtl.SteamyDreams.console;import java.util.ArrayList;import java.util.Scanner;import pw.jtl.SteamyDreams.console.commands.ExitCommand;import pw.jtl.SteamyDreams.console.commands.HelpCommand;import pw.jtl.SteamyDreams.console.commands.TestCommand;public class MainConsole {	ArrayList<ConsoleCommand> cmdArray = new ArrayList<ConsoleCommand>();	Scanner s = new Scanner(System.in);	private boolean command = false;			public void Console()	{		while (true)		{		System.out.print("SteamyDreams> ");		String x = s.nextLine();		for (ConsoleCommand object : cmdArray)		{			if (x.equals(object.commandName()))			{				command  = true;				object.runCommand();						}									}		if (!command)		{		System.out.println("Invalid command");		}	  }	}				public void addClasses() {	 cmdArray.add(new TestCommand());	 cmdArray.add(new HelpCommand(this.cmdArray));	 cmdArray.add(new ExitCommand());			}		}
Link to comment
Share on other sites

Link to post
Share on other sites

I made a 30ish line calculator a while ago, not sure what happened to it though.

Link to comment
Share on other sites

Link to post
Share on other sites

#include <iostream>#include <string>#include <ctime>using namespace std;void game(){	string usersAnswer, choice, winner;	int cpuChoice;	cout << "Rock, paper or scissors?" <<endl;	cin >> usersAnswer;	while (usersAnswer != "rock" &&  usersAnswer != "Rock" && usersAnswer != "paper" && usersAnswer != "Paper"&& usersAnswer != "scissors" && usersAnswer != "Scissors")	{		cout<<endl;		cout << "You must enter either rock, paper or scissors!" <<endl;		cout << "Please enter a valid input" <<endl;		cin >> usersAnswer;	}	cout<<endl;	long seed=time(NULL);	srand(seed);	cpuChoice = (rand()%3+1);	switch (cpuChoice)	{	case 1:		choice="rock";		if (usersAnswer == "paper")		{			cout << "You win! the cpu had " << choice <<endl;		}		else if (usersAnswer =="rock")		{			cout << "Nobody wins! the cpu had " << choice <<endl;		}		else		{			cout << "You lose! the cpu had " << choice <<endl;		}		break;	case 2:		choice="paper";		if (usersAnswer == "scissors")		{			cout << "You win! the cpu had " << choice <<endl;		}		else if (usersAnswer =="paper")		{			cout << "Nobody wins! the cpu had " << choice <<endl;		}		else		{			cout << "You lose! the cpu had " << choice <<endl;		}		break;	case 3:		choice="scissors";		if (usersAnswer == "rock")		{			cout << "You win! the cpu had " << choice <<endl;		}		else if (usersAnswer =="scissors")		{			cout << "Nobody wins! the cpu had " << choice <<endl;		}		else		{			cout << "You lose! the cpu had " << choice <<endl;		}		break;	}}int main(){	game();	cout<<endl;	return 0;}
Rock, paper scissors game I made last night before bed :P

Shouldn't there be a simpler way to do this rather than using a bunch of cases?

Link to comment
Share on other sites

Link to post
Share on other sites

Well, this topic kinda inspired me this morning to write a Brainf*ck interpreter in C++  :)

#include <iostream>using namespace std;int exec();char		 data[268435456]; // 256 MB of memory (RAM)char		*d; // data and pointerconst char	*p; // program and pointerint main(int argc, char* argv[]){	d = data;	p = "<INSERT BRAINFUCK PROGRAM HERE>";	exec();	return 0;}int exec(){	while (*p) { // while in the program		// Execute the instruction		if (*p == '>') { // increase the data pointer			if ((int)d == 268435456) {				cout << "\nERROR: PROGRAM VIOLATES UPPER MEMORY BOUNDS.\n";				return 1;			}			d++;		}		else if (*p == '<') { // decrease the data pointer			if ((int)d == 0) {				cout << "\nERROR: PROGRAM VIOLATES LOWER MEMORY BOUNDS.\n";				return 2;			}			d--;		}		else if (*p == '+') { // increase the value of the data at the pointer			if ((*d) == 255) {				cout << "\nERROR: PROGRAM VIOLATES UPPER VALUE BOUNDS.\n";				return 3;			}			(*d)++;		}		else if (*p == '-') { // decrease the value of the data at the pointer			if ((*d) == 0) {				cout << "\nERROR: PROGRAM VIOLATES LOWER VALUE BOUNDS.\n";				return 4;			}			(*d)--;		}		else if (*p == '.') { // print the ASCII character of the data at the pointer			cout << *d;		}		else if (*p == ',') { // read a single ASCII character into the data at the pointer			cin >> *d;		}		else if (*p == '[') { // begin of the loop; find the matching closing bracket if the value at the pointer equals 0			int openBrackets = 1;			if (*d == 0) { // the value at the pointer equals 0				do {					p++; // increase the program pointer to the next instruction					if (*p == '[') { // increase the amount of open brackets - this takes care of nested loops						openBrackets++;					}					else if (*p == ']') { // decrease the amount of open brackets						openBrackets--;					}				} while (openBrackets != 0); // loop until the amount of open brackets is 0			}		}		else if (*p == ']') { // end of loop; find the matching opening bracket to move the program pointer to the begin of the loop			int openBrackets = 0; // the amount of open brackets is unknown, but 0 is our baseline			do {				if (*p == '[') { // increase the amount of open brackets - this takes care of nested loops					openBrackets++;				}				else if (*p == ']') { // decrease the amount of open brackets					openBrackets--;				}				p--; // decrease the program pointer to go to the previous instruction			} while (openBrackets != 0); // after opening and closing brackets, this is 0 once the matching opening bracket was found		}		// Increase the program pointer		p++;	}	return 0;}
Link to comment
Share on other sites

Link to post
Share on other sites

I like the idea in this thread. However, I think it would be more interesting to have specific challenges. E.g., Sudoku solver in under 100 lines. OR, let's all collaborate and do something awesome.

Link to comment
Share on other sites

Link to post
Share on other sites

For every Linux User out there

This Progamm downloads all Wallpapers on: http://pichost.me/

#!/bin/shi="1271890"lower=$ifor y in {1..99}; do  mkdir "${y}"  cd "${y}"  j=$i  while wget -c http://p1.pichost.me/i/$y/$j.jpg && [[ -s $j.jpg ]]; do     if [ "$lower" = "$j" ]; then      break    fi    j=$[$j-1]    for n in {1..100}; do      if wget http://p1.pichost.me/i/$y/$j.jpg && [[ -s $j.jpg ]]; then         break      else        rm $j.jpg        j=$[$j-1]      fi      if [ "$lower" = "$j" ]; then        break      fi    done  done  while wget -c http://p1.pichost.me/i/$y/$i.jpg && [[ -s $i.jpg ]]; do     lower=$i    i=$[$i+1]    for n in {1..100}; do      if wget http://p1.pichost.me/i/$y/$i.jpg && [[ -s $i.jpg ]]; then         break      else        rm $i.jpg        i=$[$i+1]      fi    done  done   cd ..done

This works also for downloading Podcasts, and other stuff that is nummerated.

I used this to download german Potcasts.

Optimizations are welcome, probibly check if the filesize is greater than 10kb after every wget. But i don't know how, jet.

i am not a native speaker of the english language

[spoiler=My Rig: ]CPU: i7-3770k@Stock | Ram: 3x4GB@1600Mhz | Graka: 660TI@Stock | Storage: 250GB 840Evo, 1x1TB,2x2TB,2x640GB,1x500GB (JBOD) + NAS: DLINK DNS-320 2x3TB Raid1

 
Link to comment
Share on other sites

Link to post
Share on other sites

 

Well, this topic kinda inspired me this morning to write a Brainf*ck interpreter in C++  :)

-snip-

I like your style, no do it in assembly  :D

 

 

I like the idea in this thread. However, I think it would be more interesting to have specific challenges. E.g., Sudoku solver in under 100 lines. OR, let's all collaborate and do something awesome.

Checkout the program solving thread(s)!

Build log "Whiplash" : http://linustechtips.com/main/topic/158477-the-hero/

Whiplash: 4790k@4,4Ghz|Maximus VII Hero|4x4Gb Red/Black HyperX fury 1866Mhz|R9 290 Tri-X|Modded 450D|Sleeved cables on a M12II evo 850W|M500 480Gb| BenQ XL2411T@144Hz

Laptop: 4700MQ|16Gb@1600Mhz|Quadro 1100M|1080P|128Gb SSD|500Gb 7200RPM hdd

Link to comment
Share on other sites

Link to post
Share on other sites

I like your style, no do it in assembly  :D

 

 

Checkout the program solving thread(s)!

I'm new here. Can you point me in that direction? 

Link to comment
Share on other sites

Link to post
Share on other sites

However, I think it would be more interesting to have specific challenges. E.g., Sudoku solver in under 100 lines.

I was a bit bored so here's a sudoku solver

def backtrack(board,pos=0):    if pos == 81:        return True        for index in range(pos,81):        if board[index] == '.':            rowStart = index // 9 * 9            row = board[rowStart:rowStart+9]            col = board[index % 9:81:9]            squareStart = (rowStart // 27 * 27) + (index % 9 // 3 * 3)            square = board[squareStart:squareStart+3] + board[squareStart+9:squareStart+12] + board[squareStart+18:squareStart+21]            for i in set(['1','2','3','4','5','6','7','8','9']) - set(row + col + square):                board[index] = i                if backtrack(board,index+1):                    return True            board[index] = '.'            return False        elif index == 80:            return True           return False            if __name__ == "__main__":    board = list(''.join([input() for i in range(9)]))    print('\r\n'.join([''.join(board[i:i+9]) for i in range(0,81,9)])) if backtrack(board) else print('Unable to find a solution.')

Edit: cleaned it up a bit, now with 15 less lines of code!

 

1474412270.2748842

Link to comment
Share on other sites

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


×