Compare commits
No commits in common. "4256c77217416f77eae090e84327a1c2a6b1cc82" and "3dd52a9c70e74d00da0d22a8babe92b1fe1ceb99" have entirely different histories.
4256c77217
...
3dd52a9c70
1
.gitignore
vendored
1
.gitignore
vendored
@ -1,3 +1,2 @@
|
|||||||
# Ignore builds
|
# Ignore builds
|
||||||
bin/
|
bin/
|
||||||
*.o
|
|
||||||
|
17
Makefile
17
Makefile
@ -21,11 +21,8 @@
|
|||||||
# distribution.
|
# distribution.
|
||||||
|
|
||||||
# Compilers
|
# Compilers
|
||||||
ASM=as
|
|
||||||
CC=gcc
|
CC=gcc
|
||||||
CXX=g++
|
CXX=g++
|
||||||
LD=ld
|
|
||||||
FTR=gfortran
|
|
||||||
JAVAC=javac
|
JAVAC=javac
|
||||||
|
|
||||||
# Other commands
|
# Other commands
|
||||||
@ -34,13 +31,7 @@ RM=rm -rf
|
|||||||
# Directories
|
# Directories
|
||||||
BINDIR=bin
|
BINDIR=bin
|
||||||
|
|
||||||
all: x86-64asm c cpp fortran java
|
all: c cpp java
|
||||||
|
|
||||||
x86-64asm:
|
|
||||||
mkdir -p $(BINDIR)
|
|
||||||
$(ASM) -o src/main-x86_64.o src/main-x86_64.asm
|
|
||||||
$(LD) -dynamic-linker /lib64/ld-linux-x86-64.so.2 -o \
|
|
||||||
$(BINDIR)/doublesgame-x86_64asm src/main-x86_64.o -lc
|
|
||||||
|
|
||||||
c:
|
c:
|
||||||
mkdir -p $(BINDIR)
|
mkdir -p $(BINDIR)
|
||||||
@ -50,14 +41,10 @@ cpp:
|
|||||||
mkdir -p $(BINDIR)
|
mkdir -p $(BINDIR)
|
||||||
$(CXX) src/Main.cpp -o $(BINDIR)/doublesgame-cpp
|
$(CXX) src/Main.cpp -o $(BINDIR)/doublesgame-cpp
|
||||||
|
|
||||||
fortran:
|
|
||||||
mkdir -p $(BINDIR)
|
|
||||||
$(FTR) src/main.f -o $(BINDIR)/doublesgame-f
|
|
||||||
|
|
||||||
java:
|
java:
|
||||||
mkdir -p $(BINDIR)
|
mkdir -p $(BINDIR)
|
||||||
$(JAVAC) src/DoublesGame.java -d $(BINDIR)
|
$(JAVAC) src/DoublesGame.java -d $(BINDIR)
|
||||||
|
|
||||||
.PHONY: clean
|
.PHONY: clean
|
||||||
clean:
|
clean:
|
||||||
$(RM) src/*.o
|
$(RM) $(BINDIR)
|
||||||
|
@ -6,11 +6,7 @@ Currently DoublesGame exists in the following languages:
|
|||||||
- Bash
|
- Bash
|
||||||
- C
|
- C
|
||||||
- C++
|
- C++
|
||||||
- Common LISP
|
|
||||||
- Fortran
|
|
||||||
- Java
|
- Java
|
||||||
- Lua
|
|
||||||
- Perl
|
|
||||||
- Python
|
- Python
|
||||||
|
|
||||||
Building
|
Building
|
||||||
@ -19,7 +15,7 @@ There's a Makefile you can use to compile all of the sources or simply one of th
|
|||||||
|
|
||||||
Contributing
|
Contributing
|
||||||
------------
|
------------
|
||||||
Do you have another language? Found a bug? Make merge request or send me a patch at [nortega@themusicinnoise.net](mailto:nortega@themusicinnoise.net) and I'll see what I can do. Just make sure to specify a license and copyright statement at the top of the source file, only free software licenses are accepted.
|
Do you have another language? Found a bug? Make merge request or send me a patch at [deathsbreed@themusicinnoise.net](mailto:deathsbreed@themusicinnoise.net) and I'll see what I can do. Just make sure to specify a license and copyright statement at the top of the source file, only free software licenses are accepted.
|
||||||
|
|
||||||
License
|
License
|
||||||
-------
|
-------
|
||||||
|
@ -1,40 +0,0 @@
|
|||||||
#|
|
|
||||||
| Copyright (C) 2017 Ortega Froysa, Nicolás <deathsbreed@themusicinnoise.net> All rights reserved.
|
|
||||||
| Author: Ortega Froysa, Nicolás <deathsbreed@themusicinnoise.net>
|
|
||||||
|
|
|
||||||
| This software is provided 'as-is', without any express or implied
|
|
||||||
| warranty. In no event will the authors be held liable for any damages
|
|
||||||
| arising from the use of this software.
|
|
||||||
|
|
|
||||||
| Permission is granted to anyone to use this software for any purpose,
|
|
||||||
| including commercial applications, and to alter it and redistribute it
|
|
||||||
| freely, subject to the following restrictions:
|
|
||||||
|
|
|
||||||
| 1. The origin of this software must not be misrepresented; you must not
|
|
||||||
| claim that you wrote the original software. If you use this software
|
|
||||||
| in a product, an acknowledgment in the product documentation would be
|
|
||||||
| appreciated but is not required.
|
|
||||||
|
|
|
||||||
| 2. Altered source versions must be plainly marked as such, and must not be
|
|
||||||
| misrepresented as being the original software.
|
|
||||||
|
|
|
||||||
| 3. This notice may not be removed or altered from any source
|
|
||||||
| distribution.
|
|
||||||
|#
|
|
||||||
|
|
||||||
(print "Use Ctrl+C to exit.")
|
|
||||||
|
|
||||||
(let ((n 1))
|
|
||||||
(loop
|
|
||||||
(defvar a)
|
|
||||||
(format t "~%2^~a=" n)
|
|
||||||
(setq a (read))
|
|
||||||
(if (= a (expt 2 n))
|
|
||||||
(progn
|
|
||||||
(print "Correct!")
|
|
||||||
(incf n))
|
|
||||||
(if (= a 0)
|
|
||||||
(progn
|
|
||||||
(print "Goodbye!")
|
|
||||||
(return nil))
|
|
||||||
(print "Wrong answer, try again.")))))
|
|
@ -1,39 +0,0 @@
|
|||||||
-- Copyright (C) 2017 Ortega Froysa, Nicolás <deathsbreed@themusicinnoise.net> All rights reserved.
|
|
||||||
-- Author: Ortega Froysa, Nicolás <deathsbreed@themusicinnoise.net>
|
|
||||||
--
|
|
||||||
-- This software is provided 'as-is', without any express or implied
|
|
||||||
-- warranty. In no event will the authors be held liable for any damages
|
|
||||||
-- arising from the use of this software.
|
|
||||||
--
|
|
||||||
-- Permission is granted to anyone to use this software for any purpose,
|
|
||||||
-- including commercial applications, and to alter it and redistribute it
|
|
||||||
-- freely, subject to the following restrictions:
|
|
||||||
--
|
|
||||||
-- 1. The origin of this software must not be misrepresented; you must not
|
|
||||||
-- claim that you wrote the original software. If you use this software
|
|
||||||
-- in a product, an acknowledgment in the product documentation would be
|
|
||||||
-- appreciated but is not required.
|
|
||||||
--
|
|
||||||
-- 2. Altered source versions must be plainly marked as such, and must not be
|
|
||||||
-- misrepresented as being the original software.
|
|
||||||
--
|
|
||||||
-- 3. This notice may not be removed or altered from any source
|
|
||||||
-- distribution.
|
|
||||||
|
|
||||||
local n = 1
|
|
||||||
|
|
||||||
while(true) do
|
|
||||||
local a
|
|
||||||
io.write("2^", n, "=")
|
|
||||||
a = io.read("*number")
|
|
||||||
|
|
||||||
if(a == 0) then
|
|
||||||
print("Goodbye!")
|
|
||||||
break
|
|
||||||
elseif(a == 2 ^ n) then
|
|
||||||
print("Correct!")
|
|
||||||
n = n + 1
|
|
||||||
else
|
|
||||||
print("Wrong answer, try again.")
|
|
||||||
end
|
|
||||||
end
|
|
@ -1,40 +0,0 @@
|
|||||||
#!/usr/bin/perl
|
|
||||||
# Copyright (C) 2017 Ortega Froysa, Nicolás <deathsbreed@themusicinnoise.net> All rights reserved.
|
|
||||||
# Author: Ortega Froysa, Nicolás <deathsbreed@themusicinnoise.net>
|
|
||||||
#
|
|
||||||
# This software is provided 'as-is', without any express or implied
|
|
||||||
# warranty. In no event will the authors be held liable for any damages
|
|
||||||
# arising from the use of this software.
|
|
||||||
#
|
|
||||||
# Permission is granted to anyone to use this software for any purpose,
|
|
||||||
# including commercial applications, and to alter it and redistribute it
|
|
||||||
# freely, subject to the following restrictions:
|
|
||||||
#
|
|
||||||
# 1. The origin of this software must not be misrepresented; you must not
|
|
||||||
# claim that you wrote the original software. If you use this software
|
|
||||||
# in a product, an acknowledgment in the product documentation would be
|
|
||||||
# appreciated but is not required.
|
|
||||||
#
|
|
||||||
# 2. Altered source versions must be plainly marked as such, and must not be
|
|
||||||
# misrepresented as being the original software.
|
|
||||||
#
|
|
||||||
# 3. This notice may not be removed or altered from any source
|
|
||||||
# distribution.
|
|
||||||
|
|
||||||
$n = 1;
|
|
||||||
|
|
||||||
$run = 1;
|
|
||||||
|
|
||||||
while($run == 1) {
|
|
||||||
print "2^$n=";
|
|
||||||
$a = <>;
|
|
||||||
if($a == 0) {
|
|
||||||
print "Goodbye!\n";
|
|
||||||
$run = 0;
|
|
||||||
} elsif($a != 1 << $n) {
|
|
||||||
print "Wrong answer, try again.\n";
|
|
||||||
} else {
|
|
||||||
print "Correct!\n";
|
|
||||||
++$n;
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,74 +0,0 @@
|
|||||||
# Copyright (C) 2017 Ortega Froysa, Nicolás <deathsbreed@themusicinnoise.net> All rights reserved.
|
|
||||||
# Author: Ortega Froysa, Nicolás <deathsbreed@themusicinnoise.net>
|
|
||||||
#
|
|
||||||
# This software is provided 'as-is', without any express or implied
|
|
||||||
# warranty. In no event will the authors be held liable for any damages
|
|
||||||
# arising from the use of this software.
|
|
||||||
#
|
|
||||||
# Permission is granted to anyone to use this software for any purpose,
|
|
||||||
# including commercial applications, and to alter it and redistribute it
|
|
||||||
# freely, subject to the following restrictions:
|
|
||||||
#
|
|
||||||
# 1. The origin of this software must not be misrepresented; you must not
|
|
||||||
# claim that you wrote the original software. If you use this software
|
|
||||||
# in a product, an acknowledgment in the product documentation would be
|
|
||||||
# appreciated but is not required.
|
|
||||||
#
|
|
||||||
# 2. Altered source versions must be plainly marked as such, and must not be
|
|
||||||
# misrepresented as being the original software.
|
|
||||||
#
|
|
||||||
# 3. This notice may not be removed or altered from any source
|
|
||||||
# distribution.
|
|
||||||
#
|
|
||||||
.section .data
|
|
||||||
equation:
|
|
||||||
.ascii "2^%d=\0"
|
|
||||||
query:
|
|
||||||
.ascii "%d\0"
|
|
||||||
goodbye:
|
|
||||||
.ascii "Goodbye!\0"
|
|
||||||
tryagain:
|
|
||||||
.ascii "Wrong answer, try again.\0"
|
|
||||||
correct:
|
|
||||||
.ascii "Correct!\0"
|
|
||||||
number:
|
|
||||||
.int 1
|
|
||||||
answer:
|
|
||||||
.int 0
|
|
||||||
|
|
||||||
.section .text
|
|
||||||
.globl _start
|
|
||||||
|
|
||||||
_start:
|
|
||||||
mov number, %rsi
|
|
||||||
mov $equation, %rdi
|
|
||||||
call printf
|
|
||||||
|
|
||||||
mov $query, %rdi
|
|
||||||
mov $answer, %rsi
|
|
||||||
call scanf
|
|
||||||
cmp $0, answer
|
|
||||||
je quit
|
|
||||||
|
|
||||||
mov number, %rsi
|
|
||||||
shl $1, %rsi
|
|
||||||
cmp %rdi, answer
|
|
||||||
je next
|
|
||||||
|
|
||||||
mov $tryagain, %rdi
|
|
||||||
call puts
|
|
||||||
jmp _start
|
|
||||||
|
|
||||||
next:
|
|
||||||
mov $correct, %rdi
|
|
||||||
call puts
|
|
||||||
mov number, %rax
|
|
||||||
inc %rax
|
|
||||||
mov %rax, number
|
|
||||||
jmp _start
|
|
||||||
|
|
||||||
quit:
|
|
||||||
mov $goodbye, %rdi
|
|
||||||
call puts
|
|
||||||
mov $0, %rdi
|
|
||||||
call exit
|
|
@ -31,12 +31,12 @@ int main(void) {
|
|||||||
unsigned int a;
|
unsigned int a;
|
||||||
scanf("%u", &a);
|
scanf("%u", &a);
|
||||||
if(a == 0) {
|
if(a == 0) {
|
||||||
puts("Goodbye!");
|
printf("Goodbye!\n");
|
||||||
return 0;
|
return 0;
|
||||||
} else if(a != 1 << n) {
|
} else if(a != 1 << n) {
|
||||||
puts("Wrong answer, try again.");
|
printf("Wrong answer, try again.\n");
|
||||||
} else {
|
} else {
|
||||||
puts("Correct!");
|
printf("Correct!\n");
|
||||||
++n;
|
++n;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
40
src/main.f
40
src/main.f
@ -1,40 +0,0 @@
|
|||||||
C Copyright (C) 2017 Ortega Froysa, Nicolás <deathsbreed@themusicinnoise.net> All rights reserved.
|
|
||||||
C Author: Ortega Froysa, Nicolás <deathsbreed@themusicinnoise.net>
|
|
||||||
C
|
|
||||||
C This software is provided 'as-is', without any express or implied
|
|
||||||
C warranty. In no event will the authors be held liable for any damages
|
|
||||||
C arising from the use of this software.
|
|
||||||
C
|
|
||||||
C Permission is granted to anyone to use this software for any purpose,
|
|
||||||
C including commercial applications, and to alter it and redistribute it
|
|
||||||
C freely, subject to the following restrictions:
|
|
||||||
C
|
|
||||||
C 1. The origin of this software must not be misrepresented; you must not
|
|
||||||
C claim that you wrote the original software. If you use this software
|
|
||||||
C in a product, an acknowledgment in the product documentation would be
|
|
||||||
C appreciated but is not required.
|
|
||||||
C
|
|
||||||
C 2. Altered source versions must be plainly marked as such, and must not be
|
|
||||||
C misrepresented as being the original software.
|
|
||||||
C
|
|
||||||
C 3. This notice may not be removed or altered from any source
|
|
||||||
C distribution.
|
|
||||||
|
|
||||||
program doublesgame
|
|
||||||
integer :: a,n = 1
|
|
||||||
logical :: run = .TRUE.
|
|
||||||
|
|
||||||
do while(run)
|
|
||||||
write(*,*) '2^', n, '='
|
|
||||||
read(*,*) a
|
|
||||||
if(a .EQ. 0) then
|
|
||||||
write(*,*) "Goodbye!"
|
|
||||||
run = .FALSE.
|
|
||||||
elseif(a .NE. 2 ** n) then
|
|
||||||
write(*,*) "Wrong answer, try again."
|
|
||||||
else
|
|
||||||
write(*,*) "Correct!"
|
|
||||||
n = n + 1
|
|
||||||
endif
|
|
||||||
enddo
|
|
||||||
end program doublesgame
|
|
Loading…
Reference in New Issue
Block a user