Giter Site home page Giter Site logo

josehu07 / guessing-game-collection Goto Github PK

View Code? Open in Web Editor NEW
0.0 1.0 0.0 38 KB

A collection of the number guessing game in different languages - weekly update ;)

License: MIT License

Python 44.38% Makefile 0.98% C 9.93% C++ 10.47% Julia 7.04% Rust 12.90% Shell 4.19% Go 10.11%

guessing-game-collection's Introduction

Guessing Game Collection

Languages Code-size

A collection of the number guessing game in different languages - weekly update ;)

Aimed to help me explore & touch new languages & technologies. Writing a simple game definitely cannot exploit the full advantages / disadvantages of a language, but should be a good start towards learning its pipeline of development and basic syntax.

Progress List

System programming languages:

  • C
  • C++
  • Rust
  • Go

Common scripting languages:

  • Python
  • Ruby
  • Julia
  • R

Java & its variants:

  • Java
  • Kotlin
  • Dart

Web scripting languages (with sample page in HTML/CSS):

  • JavaScript
  • TypeScript
  • PHP

Other app development:

  • Swift
  • Objective-C
  • C#

Lisp & its dialects:

  • Common Lisp
  • Scala
  • Scheme
  • Clojure

Erlang & its variants:

  • Erlang
  • Elixir

Assembly:

  • MIPS
  • RISC-V
  • x86
  • ARM
  • WebAssembly

Testing

Run the tester with Python3:

$ python3 test-all.py

This will give comprehensive tests for all language versions defined in test-all.py. Outputs will be strictly matched.

Expected Behavior

Normal behavior is a guessing game where the player tries to guess a random integer between 1 to 100.

Welcome to Guanzhou's guessing game!
Enter an int ∈ [1, 100], or 'q' to quit: 50
  Your guess is... Too large!
Enter an int ∈ [1, 100], or 'q' to quit: 25
  Your guess is... Too large!
Enter an int ∈ [1, 100], or 'q' to quit: 12
  Your guess is... Too large!
Enter an int ∈ [1, 100], or 'q' to quit: 6
  Your guess is... Too small!
Enter an int ∈ [1, 100], or 'q' to quit: 9
  Your guess is... Too large!
Enter an int ∈ [1, 100], or 'q' to quit: 7
  Your guess is... Too small!
Enter an int ∈ [1, 100], or 'q' to quit: 8
  Your guess is... Correct!
You win! Congrats ;)
<Game stats>
  You tried: 50 25 12 6 9 7 8
  In total 7 tries used.

Binary search should be the best strategy overall, but you can get lucky sometimes ;)

Robustness requirements under boundary conditions are defined as the following:

# Invalid input.
Enter an int ∈ [1, 100], or 'q' to quit: e
WARN: not a valid integer. Try again...

# Out-of-range input.
Enter an int ∈ [1, 100], or 'q' to quit: -141
WARN: valid input ∈ [1, 100]. Try again...

# Allow leading & trailing whitespaces.
Enter an int ∈ [1, 100], or 'q' to quit:   50 \t
  Your guess is... Too large!

# Empty input.
Enter an int ∈ [1, 100], or 'q' to quit:        # Directly display a new prompt.
Enter an int ∈ [1, 100], or 'q' to quit:

# Start with 'q'.
Enter an int ∈ [1, 100], or 'q' to quit: qewe   # Treat as quit signal as well.
Sad to see you go :(

All language versions must satisfy this specification.

guessing-game-collection's People

Contributors

josehu07 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.